node-gtk 0.12.1 → 0.14.0

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-gtk",
3
- "version": "0.12.1",
3
+ "version": "0.14.0",
4
4
  "description": "GNOME Gtk+ bindings for NodeJS",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {
package/scripts/ci.sh CHANGED
@@ -47,7 +47,7 @@ function npm_test() {
47
47
  --skip=error \
48
48
  tests/__run__.js
49
49
  else
50
- xvfb-run -a npm test;
50
+ xvfb-run -a npm test -- --skip=callback;
51
51
  fi;
52
52
  }
53
53
 
package/src/callback.cc CHANGED
@@ -32,13 +32,21 @@ static Local<Object> GetSelfInstance(GIArgument **args) {
32
32
  Callback::Callback(Local<Function> fn, GICallableInfo* callback_info, GIScopeType scope_type_) {
33
33
  persistent.Reset(fn);
34
34
  info = g_base_info_ref (callback_info);
35
+ #ifdef GI_AVAILABLE_IN_1_72
35
36
  closure = g_callable_info_create_closure(info, &cif, Callback::Call, this);
37
+ #else
38
+ closure = g_callable_info_prepare_closure(info, &cif, Callback::Call, this);
39
+ #endif
36
40
  scope_type = scope_type_;
37
41
  }
38
42
 
39
43
  Callback::~Callback() {
40
44
  persistent.Reset();
45
+ #ifdef GI_AVAILABLE_IN_1_72
41
46
  g_callable_info_destroy_closure (this->info, this->closure);
47
+ #else
48
+ g_callable_info_free_closure (this->info, this->closure);
49
+ #endif
42
50
  g_base_info_unref (this->info);
43
51
  }
44
52
 
package/src/gobject.cc CHANGED
@@ -120,11 +120,15 @@ static void AssociateGObject(Local<Object> object, GObject *gobject, GType gtype
120
120
 
121
121
  SET_OBJECT_GTYPE(object, gtype);
122
122
 
123
- g_object_ref_sink (gobject);
124
- g_object_add_toggle_ref (gobject, ToggleNotify, NULL);
125
-
126
123
  Persistent<Object> *persistent = new Persistent<Object>(object);
127
124
  g_object_set_qdata (gobject, GNodeJS::object_quark(), persistent);
125
+
126
+ // Because we can't sink floating ref and add toggle ref at the same time,
127
+ // first sink the floating ref, add the toggle ref, and then release the
128
+ // ref we've just sunken. At the end, we must carry only the toggle ref.
129
+ g_object_ref_sink (gobject);
130
+ g_object_add_toggle_ref (gobject, ToggleNotify, NULL);
131
+ g_object_unref (gobject);
128
132
  }
129
133
 
130
134
  static void GObjectConstructor(const FunctionCallbackInfo<Value> &info) {
@@ -168,6 +172,12 @@ static void GObjectConstructor(const FunctionCallbackInfo<Value> &info) {
168
172
  }
169
173
 
170
174
  AssociateGObject(self, gobject, gtype);
175
+ if (G_IS_INITIALLY_UNOWNED(gobject)) {
176
+ // AssociateGObject() has sunken the floating ref.
177
+ } else {
178
+ // AssociateGObject() has added its own ref.
179
+ g_object_unref(gobject);
180
+ }
171
181
  }
172
182
 
173
183
  static void GObjectDestroyed(const Nan::WeakCallbackInfo<GObject> &data) {
@@ -181,7 +191,7 @@ static void GObjectDestroyed(const Nan::WeakCallbackInfo<GObject> &data) {
181
191
  * the qdata that points back to us. */
182
192
  g_object_set_qdata (gobject, GNodeJS::object_quark(), NULL);
183
193
 
184
- g_object_unref (gobject);
194
+ g_object_remove_toggle_ref (gobject, &ToggleNotify, NULL);
185
195
  }
186
196
 
187
197
  static void GObjectClassDestroyed(const Nan::WeakCallbackInfo<GType> &info) {
package/src/value.cc CHANGED
@@ -1169,8 +1169,16 @@ void FreeGIArgument(GITypeInfo *type_info, GIArgument *arg, GITransfer transfer,
1169
1169
  GIInfoType i_type = g_base_info_get_type(i_info);
1170
1170
  switch (i_type) {
1171
1171
  case GI_INFO_TYPE_OBJECT:
1172
- case GI_INFO_TYPE_INTERFACE: // TODO(validate interface are handled)
1173
- // handled by gobject.cc/boxed.cc
1172
+ case GI_INFO_TYPE_INTERFACE:
1173
+ if (is_out) {
1174
+ // WrapperFromGObject() have either created a new wrapper
1175
+ // taking it's own ref in process, or given an existing
1176
+ // wrapper with existing ref.
1177
+ g_object_unref(arg->v_pointer);
1178
+ } else {
1179
+ // GObjectFromWrapper() haven't given an additional ref.
1180
+ // Thus, do nothing.
1181
+ }
1174
1182
  break;
1175
1183
  case GI_INFO_TYPE_BOXED:
1176
1184
  case GI_INFO_TYPE_STRUCT: