glib2 3.2.4 → 3.2.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3e7c46f4eb5a10e1649d2b490cb2b833edae8e9ae5da9356b12e74989866f0a7
4
- data.tar.gz: 14ed50ef75a95a8e7ecf5a68642ebfb42cb9a1d8099698c7e1c6f59652a5d9d3
3
+ metadata.gz: 77534c50691b8b994542848ef827853636695fbe6a2f28fc433566b41512bd5f
4
+ data.tar.gz: a08ac20b032e5a8e49fb508b260ca0c64a0e59a16eaa6af23d6eb0cc64bbfd23
5
5
  SHA512:
6
- metadata.gz: 84c26c394a51846e36ecf67819123f025aff24f441e1866fb1468b33052b9971ff0fcdb1c318efca33d5fd4593eb1beb52d8c5ad8ad394b6ad30b3aa4c547ed6
7
- data.tar.gz: 852ea6e2aeda7c5bb6ed596bf71bbb05de650e09391823f40451b6c8a66b64f1dd5edaebb681c151bdc3ec54d5c55cf63d1f18294446e4b44170f0e2911d74a7
6
+ metadata.gz: 82839b7d5c5178786b062a4e20acfaacc8099bd5f5bd12eb7bddb84f531064501117cc9400ab52c9aefd414afd094558152d11c55853424fc0ac618e3ba2145e
7
+ data.tar.gz: 54051be5590430b10aca4763ef9c0f663ca8abed7f006c68e48b8ff669187f00b527a2008fd794e7a387759c98859d300cd560b94d6e2caca61db3a1f508b85d
@@ -61,6 +61,9 @@ EXPORTS
61
61
  rbgobj_class_init_func
62
62
  rbgobj_register_type
63
63
  rbgobj_object_alloc_func
64
+ rbgobj_object_add_relative
65
+ rbgobj_object_remove_relative
66
+ rbgobj_object_remove_relatives
64
67
  rbgobj_set_signal_func
65
68
  rbgobj_get_signal_func
66
69
  rbgobj_set_signal_call_func
@@ -36,7 +36,7 @@ extern "C" {
36
36
 
37
37
  #define RBGLIB_MAJOR_VERSION 3
38
38
  #define RBGLIB_MINOR_VERSION 2
39
- #define RBGLIB_MICRO_VERSION 4
39
+ #define RBGLIB_MICRO_VERSION 5
40
40
 
41
41
  #ifndef RB_ZALLOC
42
42
  # ifdef ZALLOC
@@ -46,6 +46,10 @@ extern "C" {
46
46
  # endif
47
47
  #endif
48
48
 
49
+ #ifndef RB_ALLOC
50
+ # define RB_ALLOC(type) ALLOC(type)
51
+ #endif
52
+
49
53
  #ifndef RB_ALLOC_N
50
54
  # define RB_ALLOC_N(type, n) ALLOC_N(type, n)
51
55
  #endif
@@ -28,7 +28,15 @@
28
28
  static VALUE
29
29
  rg_unbind(VALUE self)
30
30
  {
31
- g_binding_unbind(_SELF(self));
31
+ GBinding *binding = _SELF(self);
32
+ GObject *source;
33
+ VALUE rb_source;
34
+
35
+ source = g_binding_get_source(binding);
36
+ rb_source = GOBJ2RVAL(source);
37
+ rbgobj_object_remove_relative(rb_source, self);
38
+ g_binding_unbind(binding);
39
+
32
40
  return self;
33
41
  }
34
42
  #endif
@@ -1,6 +1,6 @@
1
1
  /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
2
  /*
3
- * Copyright (C) 2011-2016 Ruby-GNOME2 Project Team
3
+ * Copyright (C) 2011-2018 Ruby-GNOME2 Project Team
4
4
  * Copyright (C) 2002-2006 Ruby-GNOME2 Project
5
5
  * Copyright (C) 2002,2003 Masahiro Sakai
6
6
  *
@@ -191,8 +191,9 @@ rclosure_invalidate(G_GNUC_UNUSED gpointer data, GClosure *closure)
191
191
  for (next = rclosure->objects; next; next = next->next) {
192
192
  GObject *object = G_OBJECT(next->data);
193
193
  VALUE obj = rbgobj_ruby_object_from_instance2(object, FALSE);
194
- if (!NIL_P(rclosure->rb_holder) && !NIL_P(obj))
195
- G_REMOVE_RELATIVE(obj, id_closures, rclosure->rb_holder);
194
+ if (!NIL_P(rclosure->rb_holder) && !NIL_P(obj)) {
195
+ rbgobj_object_remove_relative(obj, rclosure->rb_holder);
196
+ }
196
197
  }
197
198
 
198
199
  rclosure_unref(rclosure);
@@ -286,16 +287,15 @@ rclosure_weak_notify(gpointer data, GObject* where_the_object_was)
286
287
  void
287
288
  g_rclosure_attach(GClosure *closure, VALUE object)
288
289
  {
289
- static VALUE mGLibObject = (VALUE)NULL;
290
+ static VALUE cGLibObject = Qnil;
290
291
  GRClosure *rclosure = (GRClosure *)closure;
291
292
 
292
- G_RELATIVE2(object, Qnil, id_closures, rclosure->rb_holder);
293
-
294
- if (!mGLibObject) {
295
- mGLibObject = rb_const_get(mGLib, rb_intern("Object"));
293
+ if (NIL_P(cGLibObject)) {
294
+ cGLibObject = rb_const_get(mGLib, rb_intern("Object"));
296
295
  }
297
- if (rb_obj_is_kind_of(object, mGLibObject)) {
296
+ if (rb_obj_is_kind_of(object, cGLibObject)) {
298
297
  GObject *gobject;
298
+ rbgobj_object_add_relative(object, rclosure->rb_holder);
299
299
  gobject = RVAL2GOBJ(object);
300
300
  rclosure->count++;
301
301
  g_object_weak_ref(gobject, rclosure_weak_notify, rclosure);
@@ -43,19 +43,33 @@ weak_notify(gpointer data, G_GNUC_UNUSED GObject *where_the_object_was)
43
43
  gobj_holder *holder = data;
44
44
 
45
45
  rbgobj_instance_call_cinfo_free(holder->gobj);
46
- rbgobj_invalidate_relatives(holder->self);
46
+ g_hash_table_unref(holder->rb_relatives);
47
+ holder->rb_relatives = NULL;
47
48
  holder->destroyed = TRUE;
48
49
 
49
50
  g_object_unref(holder->gobj);
50
51
  holder->gobj = NULL;
51
52
  }
52
53
 
54
+ static void
55
+ holder_relatives_mark(gpointer key, gpointer value, gpointer user_data)
56
+ {
57
+ VALUE rb_relative = (VALUE)value;
58
+ rb_gc_mark(rb_relative);
59
+ }
60
+
53
61
  static void
54
62
  holder_mark(void *data)
55
63
  {
56
64
  gobj_holder *holder = data;
57
- if (holder->gobj && !holder->destroyed)
58
- rbgobj_instance_call_cinfo_mark(holder->gobj);
65
+
66
+ if (!holder->gobj)
67
+ return;
68
+ if (holder->destroyed)
69
+ return;
70
+
71
+ rbgobj_instance_call_cinfo_mark(holder->gobj);
72
+ g_hash_table_foreach(holder->rb_relatives, holder_relatives_mark, NULL);
59
73
  }
60
74
 
61
75
  static void
@@ -91,6 +105,59 @@ static const rb_data_type_t rg_glib_object_type = {
91
105
  RUBY_TYPED_FREE_IMMEDIATELY,
92
106
  };
93
107
 
108
+ void
109
+ rbgobj_object_add_relative(VALUE rb_gobject, VALUE rb_relative)
110
+ {
111
+ gobj_holder *holder;
112
+ TypedData_Get_Struct(rb_gobject,
113
+ gobj_holder,
114
+ &rg_glib_object_type,
115
+ holder);
116
+ if (holder->rb_relatives) {
117
+ g_hash_table_insert(holder->rb_relatives,
118
+ (gpointer)(rb_relative),
119
+ (gpointer)(rb_relative));
120
+ }
121
+ }
122
+
123
+ void
124
+ rbgobj_object_remove_relative(VALUE rb_gobject, VALUE rb_relative)
125
+ {
126
+ gobj_holder *holder;
127
+ TypedData_Get_Struct(rb_gobject,
128
+ gobj_holder,
129
+ &rg_glib_object_type,
130
+ holder);
131
+ if (holder->rb_relatives) {
132
+ g_hash_table_remove(holder->rb_relatives,
133
+ (gpointer)(rb_relative));
134
+ }
135
+ }
136
+
137
+ static gboolean
138
+ rbgobj_object_remove_relatives_body(gpointer key,
139
+ gpointer value,
140
+ gpointer user_data)
141
+ {
142
+ VALUE rb_relative = (VALUE)value;
143
+ VALUE rb_relative_class = (VALUE)user_data;
144
+
145
+ return RVAL2CBOOL(rb_obj_is_kind_of(rb_relative, rb_relative_class));
146
+ }
147
+
148
+ void
149
+ rbgobj_object_remove_relatives(VALUE rb_gobject, VALUE rb_relative_class)
150
+ {
151
+ gobj_holder *holder;
152
+ TypedData_Get_Struct(rb_gobject,
153
+ gobj_holder,
154
+ &rg_glib_object_type,
155
+ holder);
156
+ g_hash_table_foreach_remove(holder->rb_relatives,
157
+ rbgobj_object_remove_relatives_body,
158
+ (gpointer)(rb_relative_class));
159
+ }
160
+
94
161
  VALUE
95
162
  rbgobj_object_alloc_func(VALUE klass)
96
163
  {
@@ -105,6 +172,7 @@ rbgobj_object_alloc_func(VALUE klass)
105
172
  holder->gobj = NULL;
106
173
  holder->cinfo = NULL;
107
174
  holder->destroyed = FALSE;
175
+ holder->rb_relatives = g_hash_table_new(g_direct_hash, g_direct_equal);
108
176
 
109
177
  return result;
110
178
  }
@@ -686,13 +754,6 @@ static void
686
754
  rg_destroy_bind_property_full_data(gpointer user_data)
687
755
  {
688
756
  RGBindPropertyCallbackData *data = (RGBindPropertyCallbackData *)user_data;
689
-
690
- if (!NIL_P(data->transform_to_callback))
691
- G_CHILD_REMOVE(data->self, data->transform_to_callback);
692
-
693
- if (!NIL_P(data->transform_from_callback))
694
- G_CHILD_REMOVE(data->self, data->transform_from_callback);
695
-
696
757
  xfree(data);
697
758
  }
698
759
 
@@ -715,6 +776,7 @@ rg_bind_property(gint argc, VALUE *argv, VALUE self)
715
776
  GBinding *binding;
716
777
  GBindingTransformFunc transform_to = NULL;
717
778
  GBindingTransformFunc transform_from = NULL;
779
+ VALUE rb_binding;
718
780
 
719
781
  rb_scan_args(argc, argv, "41", &rb_source_property, &rb_target,
720
782
  &rb_target_property, &rb_flags, &rb_options);
@@ -731,18 +793,16 @@ rg_bind_property(gint argc, VALUE *argv, VALUE self)
731
793
  flags = RVAL2GBINDINGFLAGS(rb_flags);
732
794
 
733
795
  if (!NIL_P(rb_transform_to)) {
734
- G_CHILD_ADD(self, rb_transform_to);
735
796
  transform_to = rg_bind_property_transform_to_callback;
736
797
  }
737
798
 
738
799
  if (!NIL_P(rb_transform_from)) {
739
- G_CHILD_ADD(self, rb_transform_from);
740
800
  transform_from = rg_bind_property_transform_from_callback;
741
801
  }
742
802
 
743
803
  if (transform_to || transform_from) {
744
804
  RGBindPropertyCallbackData *data;
745
- data = (RGBindPropertyCallbackData *)xmalloc(sizeof(RGBindPropertyCallbackData));
805
+ data = RB_ALLOC(RGBindPropertyCallbackData);
746
806
  data->self = self;
747
807
  data->transform_to_callback = rb_transform_to;
748
808
  data->transform_from_callback = rb_transform_from;
@@ -752,13 +812,21 @@ rg_bind_property(gint argc, VALUE *argv, VALUE self)
752
812
  transform_from,
753
813
  (gpointer)data,
754
814
  rg_destroy_bind_property_full_data);
815
+ rb_binding = GOBJ2RVAL(binding);
816
+ if (!NIL_P(rb_transform_to)) {
817
+ rbgobj_object_add_relative(rb_binding, rb_transform_to);
818
+ }
819
+ if (!NIL_P(rb_transform_from)) {
820
+ rbgobj_object_add_relative(rb_binding, rb_transform_from);
821
+ }
755
822
  } else {
756
823
  binding = g_object_bind_property(source, source_property,
757
824
  target, target_property,
758
825
  flags);
826
+ rb_binding = GOBJ2RVAL(binding);
759
827
  }
760
828
 
761
- return GOBJ2RVAL(binding);
829
+ return rb_binding;
762
830
  }
763
831
  #endif
764
832
 
@@ -1,6 +1,6 @@
1
1
  /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
2
  /*
3
- * Copyright (C) 2011 Ruby-GNOME2 Project Team
3
+ * Copyright (C) 2011-2018 Ruby-GNOME2 Project Team
4
4
  * Copyright (C) 2003-2006 Ruby-GNOME2 Project Team
5
5
  * Copyright (C) 2002,2003 Masahiro Sakai
6
6
  * Copyright (C) 1998-2000 Yukihiro Matsumoto,
@@ -183,16 +183,25 @@ rbgobj_ruby_object_from_instance_with_unref(gpointer instance)
183
183
  void
184
184
  rbgobj_add_relative(VALUE obj, VALUE relative)
185
185
  {
186
- VALUE hash = Qnil;
186
+ static VALUE mGLibObject = Qnil;
187
+ if (NIL_P(mGLibObject)) {
188
+ mGLibObject = rb_const_get(mGLib, rb_intern("Object"));
189
+ }
187
190
 
188
- if (RVAL2CBOOL(rb_ivar_defined(obj, id_relatives)))
189
- hash = rb_ivar_get(obj, id_relatives);
191
+ if (rb_obj_is_kind_of(obj, mGLibObject)) {
192
+ rbgobj_object_add_relative(obj, relative);
193
+ } else {
194
+ VALUE hash = Qnil;
190
195
 
191
- if (NIL_P(hash) || TYPE(hash) != RUBY_T_HASH) {
192
- hash = rb_hash_new();
193
- rb_ivar_set(obj, id_relatives, hash);
196
+ if (RVAL2CBOOL(rb_ivar_defined(obj, id_relatives)))
197
+ hash = rb_ivar_get(obj, id_relatives);
198
+
199
+ if (NIL_P(hash) || TYPE(hash) != RUBY_T_HASH) {
200
+ hash = rb_hash_new();
201
+ rb_ivar_set(obj, id_relatives, hash);
202
+ }
203
+ rb_hash_aset(hash, relative, Qnil);
194
204
  }
195
- rb_hash_aset(hash, relative, Qnil);
196
205
  }
197
206
 
198
207
  void
@@ -207,16 +216,26 @@ rbgobj_invalidate_relatives(VALUE obj)
207
216
  void
208
217
  rbgobj_add_relative_removable(VALUE obj, VALUE relative, ID obj_ivar_id, VALUE hash_key)
209
218
  {
210
- VALUE hash = Qnil;
219
+ static VALUE cGLibObject = Qnil;
220
+ if (NIL_P(cGLibObject)) {
221
+ cGLibObject = rb_const_get(mGLib, rb_intern("Object"));
222
+ }
211
223
 
212
- if (RVAL2CBOOL(rb_ivar_defined(obj, obj_ivar_id)))
213
- hash = rb_ivar_get(obj, obj_ivar_id);
224
+ if (obj_ivar_id == rbgobj_id_children &&
225
+ rb_obj_is_kind_of(obj, cGLibObject)) {
226
+ rbgobj_object_add_relative(obj, hash_key);
227
+ } else {
228
+ VALUE hash = Qnil;
214
229
 
215
- if (NIL_P(hash) || TYPE(hash) != RUBY_T_HASH) {
216
- hash = rb_hash_new();
217
- rb_ivar_set(obj, obj_ivar_id, hash);
230
+ if (RVAL2CBOOL(rb_ivar_defined(obj, obj_ivar_id)))
231
+ hash = rb_ivar_get(obj, obj_ivar_id);
232
+
233
+ if (NIL_P(hash) || TYPE(hash) != RUBY_T_HASH) {
234
+ hash = rb_hash_new();
235
+ rb_ivar_set(obj, obj_ivar_id, hash);
236
+ }
237
+ rb_hash_aset(hash, hash_key, relative);
218
238
  }
219
- rb_hash_aset(hash, hash_key, relative);
220
239
  }
221
240
 
222
241
  VALUE
@@ -236,15 +255,25 @@ rbgobj_get_relative_removable(VALUE obj, ID obj_ivar_id, VALUE hash_key)
236
255
  void
237
256
  rbgobj_remove_relative(VALUE obj, ID obj_ivar_id, VALUE hash_key)
238
257
  {
239
- VALUE hash = Qnil;
240
-
241
- if (RVAL2CBOOL(rb_ivar_defined(obj, obj_ivar_id)))
242
- hash = rb_ivar_get(obj, obj_ivar_id);
258
+ static VALUE cGLibObject = Qnil;
259
+ if (NIL_P(cGLibObject)) {
260
+ cGLibObject = rb_const_get(mGLib, rb_intern("Object"));
261
+ }
243
262
 
244
- if (NIL_P(hash) || TYPE(hash) != RUBY_T_HASH) {
245
- /* should not happen. */
263
+ if ((obj_ivar_id == id_relatives || obj_ivar_id == rbgobj_id_children) &&
264
+ rb_obj_is_kind_of(obj, cGLibObject)) {
265
+ rbgobj_object_remove_relative(obj, hash_key);
246
266
  } else {
247
- rb_funcall(hash, id_delete, 1, hash_key);
267
+ VALUE hash = Qnil;
268
+
269
+ if (RVAL2CBOOL(rb_ivar_defined(obj, obj_ivar_id)))
270
+ hash = rb_ivar_get(obj, obj_ivar_id);
271
+
272
+ if (NIL_P(hash) || TYPE(hash) != RUBY_T_HASH) {
273
+ /* should not happen. */
274
+ } else {
275
+ rb_funcall(hash, id_delete, 1, hash_key);
276
+ }
248
277
  }
249
278
  }
250
279
 
@@ -79,6 +79,7 @@ RUBY_GLIB2_VAR ID rbgobj_id_children;
79
79
  (rbgobj_add_relative_removable(self, Qnil, rbgobj_id_children, child))
80
80
  #define G_CHILD_REMOVE(self, child) \
81
81
  (rbgobj_remove_relative(self, rbgobj_id_children, child))
82
+ /* Deprecated since 3.2.5. Use rbobj_object_remove_relatives() instead. */
82
83
  #define G_CHILD_REMOVE_ALL(self) \
83
84
  (rbgobj_remove_relative_all(self, rbgobj_id_children))
84
85
 
@@ -147,6 +148,13 @@ extern VALUE rbgobj_ruby_object_from_instance2(gpointer instance, gboolean alloc
147
148
  extern VALUE rbgobj_ruby_object_from_instance_with_unref(gpointer instance);
148
149
  extern void rbgobj_instance_unref(gpointer instance);
149
150
 
151
+ extern void rbgobj_object_add_relative(VALUE rb_gobject,
152
+ VALUE rb_relative);
153
+ extern void rbgobj_object_remove_relative(VALUE rb_gobject,
154
+ VALUE rb_relative);
155
+ extern void rbgobj_object_remove_relatives(VALUE rb_gobject,
156
+ VALUE rb_relative_class);
157
+
150
158
  extern void rbgobj_add_relative(VALUE obj, VALUE relative);
151
159
  extern void rbgobj_invalidate_relatives(VALUE obj);
152
160
  extern void rbgobj_add_relative_removable(VALUE obj, VALUE relative,
@@ -1,6 +1,6 @@
1
1
  /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
2
  /*
3
- * Copyright (C) 2007-2017 Ruby-GNOME2 Project Team
3
+ * Copyright (C) 2007-2018 Ruby-GNOME2 Project Team
4
4
  *
5
5
  * This library is free software; you can redistribute it and/or
6
6
  * modify it under the terms of the GNU Lesser General Public
@@ -42,6 +42,7 @@ typedef struct {
42
42
  GObject* gobj;
43
43
  const RGObjClassInfo* cinfo;
44
44
  gboolean destroyed;
45
+ GHashTable *rb_relatives;
45
46
  } gobj_holder;
46
47
 
47
48
  typedef struct {
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glib2
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.4
4
+ version: 3.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - The Ruby-GNOME2 Project Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-04-09 00:00:00.000000000 Z
11
+ date: 2018-05-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pkg-config