qml 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ab6994a5395ab183bdec0c003033822ea4b2ef99
4
- data.tar.gz: dbd518f8f5dc09bd4441b82e518c8e086c89e7d3
3
+ metadata.gz: aeac6eba39f94bf9bd1fdad9ce8d143962b2f0d9
4
+ data.tar.gz: a213b3aa19785890dce3884961861141c35d1776
5
5
  SHA512:
6
- metadata.gz: dbaf73bddc72313761f9b2520edc82e2a309cb8e75fc12d8504d396460045773448cd81e060107d3c8935b566996eb6aff1a8a27cf2352fad71e6aac75e12dad
7
- data.tar.gz: c36f4bb9facdfa0b85998d12983314d0ab37acfd2a7a4f36b763d45eccdfc44d4a0b9802d5b6e318bacc0037d5daca6070655abe8a2260a5c242292ce1295e57
6
+ metadata.gz: 1f6242e2dd5f1d9579512235554ea4675dcff7b381e34d3aaecc0e8bf89c627c8bb85defddee8543420ad13109059a57d069a16347971a0bc504317998a01fac
7
+ data.tar.gz: 2f0a517c2381f2461cf4404acb15d6f123a200f307e9656518c4ea698a306294eca0a8d8fcd02dedaddf6a8386c82dd7f6d6cf38cdfe1e1cea7caeec5b7d52c9
data/README.md CHANGED
@@ -30,7 +30,7 @@ It provides bindings between QML and Ruby and enables you to use Qt Quick-based
30
30
 
31
31
  * **Ruby 2.1 or later**
32
32
  * **OS X or Linux**
33
- * Qt 5.2 or later
33
+ * Qt 5.4 or later
34
34
 
35
35
  ### OS X with Homebrew
36
36
 
data/changes.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 1.0.2 (2015-07-11)
2
+
3
+ * Fixes error when calling `next_tick` from Ruby threads (#24)
4
+
1
5
  ## 1.0.1 (2015-06-20)
2
6
 
3
7
  * Fixes 100% CPU usage (#21)
@@ -5,6 +5,7 @@
5
5
  #include <QSharedPointer>
6
6
  #include <QTimer>
7
7
  #include <QVector>
8
+ #include <functional>
8
9
 
9
10
  using namespace QmlBind;
10
11
 
@@ -40,6 +41,44 @@ private:
40
41
  QVector<char *> mArgv;
41
42
  };
42
43
 
44
+ class NextTickProcessor : public QObject
45
+ {
46
+ public:
47
+ class Event : public QEvent
48
+ {
49
+ public:
50
+ enum Type {
51
+ Type = QEvent::User
52
+ };
53
+
54
+ Event(const std::function<void ()> func) : QEvent((QEvent::Type)Type),
55
+ mFunc(func)
56
+ {
57
+ }
58
+
59
+ void call() const
60
+ {
61
+ mFunc();
62
+ }
63
+
64
+ private:
65
+ std::function<void ()> mFunc;
66
+ };
67
+
68
+ bool event(QEvent *event) Q_DECL_OVERRIDE
69
+ {
70
+ if (event->type() == Event::User) {
71
+ static_cast<Event *>(event)->call();
72
+ return true;
73
+ }
74
+ else {
75
+ return QObject::event(event);
76
+ }
77
+ }
78
+ };
79
+
80
+ static auto nextTickProcessor = new NextTickProcessor();
81
+
43
82
  }
44
83
 
45
84
  extern "C" {
@@ -70,9 +109,9 @@ void qmlbind_process_events()
70
109
 
71
110
  void qmlbind_next_tick(void (*callback)(void *), void *data)
72
111
  {
73
- QTimer::singleShot(0, QCoreApplication::instance(), [=] {
112
+ QCoreApplication::postEvent(nextTickProcessor, new NextTickProcessor::Event([=] {
74
113
  callback(data);
75
- });
114
+ }));
76
115
  }
77
116
 
78
117
  }
@@ -68,11 +68,17 @@ static VALUE qml_engine(VALUE module) {
68
68
  return rbqml_engine;
69
69
  }
70
70
 
71
- static void nextTickCallback(void *data)
71
+ static void *nextTickCallbackImpl(void *data)
72
72
  {
73
73
  VALUE block = (VALUE)data;
74
74
  rb_proc_call(block, rb_ary_new());
75
75
  rb_hash_delete(rbqml_referenced_objects, block);
76
+ return NULL;
77
+ }
78
+
79
+ static void nextTickCallback(void *data)
80
+ {
81
+ rb_thread_call_with_gvl(nextTickCallbackImpl, data);
76
82
  }
77
83
 
78
84
  static VALUE qml_next_tick(int argc, VALUE *argv, VALUE module) {
@@ -1,3 +1,3 @@
1
1
  module QML
2
- VERSION = '1.0.1'
2
+ VERSION = '1.0.2'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: qml
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryohei Ikegami
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-20 00:00:00.000000000 Z
11
+ date: 2015-07-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler