From 0e8c33a0b1b1e9bd95b597d76dc3b1f980124357 Mon Sep 17 00:00:00 2001 From: Nicola Fontana Date: Fri, 23 Mar 2012 15:02:44 +0100 Subject: [PATCH] AdgEntity: added "destroy" signal g_object_unref() is not enough to destroy a composite entity because its children still hold references to itself. This is why the "destroy" signal is needed for: it will be propagated to the children (or to its internal entities) so at the end all the references will be released and the entity will likely be destroyed. Anyway the entity will be still alive after a destroy process if the caller owns a reference to it. --- src/adg/adg-container.c | 11 ++++++++++ src/adg/adg-entity.c | 43 ++++++++++++++++++++++++++++++++++++++++ src/adg/adg-entity.h | 2 ++ src/adg/adg-table.c | 11 ++++++++++ src/adg/tests/test-adim.c | 8 ++++---- src/adg/tests/test-arrow.c | 2 +- src/adg/tests/test-canvas.c | 32 +++++++++++++++--------------- src/adg/tests/test-container.c | 10 +++++----- src/adg/tests/test-dim-style.c | 20 +++++++++---------- src/adg/tests/test-dim.c | 20 +++++++++---------- src/adg/tests/test-entity.c | 14 ++++++------- src/adg/tests/test-gtk-area.c | 14 ++++++------- src/adg/tests/test-gtk-layout.c | 4 ++-- src/adg/tests/test-hatch.c | 2 +- src/adg/tests/test-ldim.c | 6 +++--- src/adg/tests/test-logo.c | 6 +++--- src/adg/tests/test-marker.c | 10 +++++----- src/adg/tests/test-model.c | 2 +- src/adg/tests/test-projection.c | 6 +++--- src/adg/tests/test-stroke.c | 4 ++-- src/adg/tests/test-table.c | 4 ++-- src/adg/tests/test-text.c | 4 ++-- src/adg/tests/test-title-block.c | 28 +++++++++++++------------- src/adg/tests/test-toy-text.c | 4 ++-- 24 files changed, 167 insertions(+), 100 deletions(-) diff --git a/src/adg/adg-container.c b/src/adg/adg-container.c index c71fcd31..d9d36101 100644 --- a/src/adg/adg-container.c +++ b/src/adg/adg-container.c @@ -74,6 +74,7 @@ static void _adg_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec); +static void _adg_destroy (AdgEntity *entity); static void _adg_global_changed (AdgEntity *entity); static void _adg_local_changed (AdgEntity *entity); static void _adg_invalidate (AdgEntity *entity); @@ -108,6 +109,7 @@ adg_container_class_init(AdgContainerClass *klass) gobject_class->dispose = _adg_dispose; gobject_class->set_property = _adg_set_property; + entity_class->destroy = _adg_destroy; entity_class->global_changed = _adg_global_changed; entity_class->local_changed = _adg_local_changed; entity_class->invalidate = _adg_invalidate; @@ -446,6 +448,15 @@ adg_container_propagate_valist(AdgContainer *container, static void +_adg_destroy(AdgEntity *entity) +{ + adg_container_propagate_by_name((AdgContainer *) entity, "destroy"); + + if (_ADG_PARENT_ENTITY_CLASS->destroy) + _ADG_PARENT_ENTITY_CLASS->destroy(entity); +} + +static void _adg_global_changed(AdgEntity *entity) { if (_ADG_PARENT_ENTITY_CLASS->global_changed) diff --git a/src/adg/adg-entity.c b/src/adg/adg-entity.c index 420fcd74..7be13d03 100644 --- a/src/adg/adg-entity.c +++ b/src/adg/adg-entity.c @@ -43,6 +43,7 @@ /** * AdgEntityClass: + * @destroy: when a destroy request has been explicitely requested * @parent_set: called whenever the parent of an entity has changed * @global_changed: the global matrix has been invalidated * @local_changed: the local matrix has been invalidated @@ -101,6 +102,7 @@ enum { }; enum { + DESTROY, PARENT_SET, GLOBAL_CHANGED, LOCAL_CHANGED, @@ -148,6 +150,7 @@ adg_entity_class_init(AdgEntityClass *klass) gobject_class->get_property = _adg_get_property; gobject_class->set_property = _adg_set_property; + klass->destroy = (void (*)(AdgEntity *)) g_object_unref; klass->parent_set = NULL; klass->global_changed = _adg_global_changed; klass->local_changed = _adg_local_changed; @@ -184,6 +187,29 @@ adg_entity_class_init(AdgEntityClass *klass) g_object_class_install_property(gobject_class, PROP_LOCAL_METHOD, param); /** + * AdgEntity::destroy: + * @entity: an #AdgEntity + * + * Emitted to explicitely destroy @entity. It unreferences + * @entity so that will be destroyed, unless the caller owns + * an additional references added with g_object_ref(). + * + * In the usual case, this is equivalent of calling + * g_object_unref() on @entity but, for composite entities or + * containers, the destroy signal is propagated to the children. + * + * Since: 1.0 + **/ + _adg_signals[DESTROY] = + g_signal_new("destroy", + G_OBJECT_CLASS_TYPE(gobject_class), + G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET(AdgEntityClass, destroy), + NULL, NULL, + adg_marshal_VOID__VOID, + G_TYPE_NONE, 0); + + /** * AdgEntity::parent-set: * @entity: an #AdgEntity * @old_parent: the old parent @@ -413,6 +439,23 @@ adg_switch_extents(gboolean state) } /** + * adg_entity_destroy: + * @entity: an #AdgEntity + * + * Emits the #AdgEntity::destroy signal on @entity and on all of + * its children, if any. + * + * Since: 1.0 + **/ +void +adg_entity_destroy(AdgEntity *entity) +{ + g_return_if_fail(ADG_IS_ENTITY(entity)); + + g_signal_emit(entity, _adg_signals[DESTROY], 0); +} + +/** * adg_entity_get_canvas: * @entity: an #AdgEntity * diff --git a/src/adg/adg-entity.h b/src/adg/adg-entity.h index b6b3120e..de734752 100644 --- a/src/adg/adg-entity.h +++ b/src/adg/adg-entity.h @@ -64,6 +64,7 @@ struct _AdgEntityClass { GInitiallyUnownedClass parent_class; /*< public >*/ /* Signals */ + void (*destroy) (AdgEntity *entity); void (*parent_set) (AdgEntity *entity, AdgEntity *old_parent); void (*global_changed) (AdgEntity *entity); @@ -78,6 +79,7 @@ struct _AdgEntityClass { void adg_switch_extents (gboolean state); GType adg_entity_get_type (void) G_GNUC_CONST; +void adg_entity_destroy (AdgEntity *entity); AdgCanvas * adg_entity_get_canvas (AdgEntity *entity); void adg_entity_set_parent (AdgEntity *entity, AdgEntity *parent); diff --git a/src/adg/adg-table.c b/src/adg/adg-table.c index 8f7fa9a2..baa0a86e 100644 --- a/src/adg/adg-table.c +++ b/src/adg/adg-table.c @@ -83,6 +83,7 @@ static void _adg_set_property (GObject *object, guint param_id, const GValue *value, GParamSpec *pspec); +static void _adg_destroy (AdgEntity *entity); static void _adg_global_changed (AdgEntity *entity); static void _adg_local_changed (AdgEntity *entity); static void _adg_invalidate (AdgEntity *entity); @@ -123,6 +124,7 @@ adg_table_class_init(AdgTableClass *klass) gobject_class->get_property = _adg_get_property; gobject_class->set_property = _adg_set_property; + entity_class->destroy = _adg_destroy; entity_class->global_changed = _adg_global_changed; entity_class->local_changed = _adg_local_changed; entity_class->invalidate = _adg_invalidate; @@ -588,6 +590,15 @@ adg_table_invalidate_grid(AdgTable *table) static void +_adg_destroy(AdgEntity *entity) +{ + _adg_propagate((AdgTable *) entity, "destroy"); + + if (_ADG_OLD_ENTITY_CLASS->destroy) + _ADG_OLD_ENTITY_CLASS->destroy(entity); +} + +static void _adg_global_changed(AdgEntity *entity) { if (_ADG_OLD_ENTITY_CLASS->global_changed) diff --git a/src/adg/tests/test-adim.c b/src/adg/tests/test-adim.c index 4511d1f8..be9a3f87 100644 --- a/src/adg/tests/test-adim.c +++ b/src/adg/tests/test-adim.c @@ -101,7 +101,7 @@ _adg_test_org1(void) adg_point_destroy(origin); adg_point_destroy(explicit_point); adg_point_destroy(model_point); - g_object_unref(adim); + adg_entity_destroy(ADG_ENTITY(adim)); g_object_unref(model); } @@ -185,7 +185,7 @@ _adg_test_org2(void) adg_point_destroy(origin); adg_point_destroy(explicit_point); adg_point_destroy(model_point); - g_object_unref(adim); + adg_entity_destroy(ADG_ENTITY(adim)); g_object_unref(model); } @@ -225,7 +225,7 @@ _adg_test_has_extension1(void) g_object_get(adim, "has-extension1", &has_extension1, NULL); g_assert(has_extension1); - g_object_unref(adim); + adg_entity_destroy(ADG_ENTITY(adim)); } static void @@ -264,7 +264,7 @@ _adg_test_has_extension2(void) g_object_get(adim, "has-extension2", &has_extension2, NULL); g_assert(has_extension2); - g_object_unref(adim); + adg_entity_destroy(ADG_ENTITY(adim)); } diff --git a/src/adg/tests/test-arrow.c b/src/adg/tests/test-arrow.c index 05ee4690..f84bee92 100644 --- a/src/adg/tests/test-arrow.c +++ b/src/adg/tests/test-arrow.c @@ -58,7 +58,7 @@ _adg_test_angle(void) g_object_get(arrow, "angle", &angle, NULL); g_assert_cmpfloat(angle, !=, invalid_value); - g_object_unref(arrow); + adg_entity_destroy(ADG_ENTITY(arrow)); } diff --git a/src/adg/tests/test-canvas.c b/src/adg/tests/test-canvas.c index 359ac6a4..5c8a0400 100644 --- a/src/adg/tests/test-canvas.c +++ b/src/adg/tests/test-canvas.c @@ -59,7 +59,7 @@ _adg_test_background_dress(void) g_object_get(canvas, "background-dress", &background_dress, NULL); g_assert_cmpint(background_dress, ==, valid_dress_2); - g_object_unref(canvas); + adg_entity_destroy(ADG_ENTITY(canvas)); } static void @@ -100,7 +100,7 @@ _adg_test_frame_dress(void) g_object_get(canvas, "frame-dress", &frame_dress, NULL); g_assert_cmpint(frame_dress, ==, valid_dress_2); - g_object_unref(canvas); + adg_entity_destroy(ADG_ENTITY(canvas)); } static void @@ -140,19 +140,19 @@ _adg_test_title_block(void) g_object_set(canvas, "title-block", valid_title_block, NULL); g_object_get(canvas, "title-block", &title_block, NULL); g_assert(title_block == valid_title_block); - g_object_unref(title_block); + adg_entity_destroy(ADG_ENTITY(title_block)); g_object_set(canvas, "title-block", invalid_title_block, NULL); g_object_get(canvas, "title-block", &title_block, NULL); g_assert(title_block == valid_title_block); - g_object_unref(title_block); + adg_entity_destroy(ADG_ENTITY(title_block)); g_object_set(canvas, "title-block", NULL, NULL); g_object_get(canvas, "title-block", &title_block, NULL); g_assert(title_block == NULL); - g_object_unref(canvas); - g_object_unref(valid_title_block); + adg_entity_destroy(ADG_ENTITY(canvas)); + adg_entity_destroy(ADG_ENTITY(valid_title_block)); } static void @@ -198,7 +198,7 @@ _adg_test_size(void) g_assert(cpml_pair_equal(size_dup, &null_size)); g_free(size_dup); - g_object_unref(canvas); + adg_entity_destroy(ADG_ENTITY(canvas)); } static void @@ -230,7 +230,7 @@ _adg_test_top_margin(void) g_object_get(canvas, "top-margin", &top_margin, NULL); g_assert_cmpfloat(top_margin, ==, valid_value_2); - g_object_unref(canvas); + adg_entity_destroy(ADG_ENTITY(canvas)); } static void @@ -262,7 +262,7 @@ _adg_test_right_margin(void) g_object_get(canvas, "right-margin", &right_margin, NULL); g_assert_cmpfloat(right_margin, ==, valid_value_2); - g_object_unref(canvas); + adg_entity_destroy(ADG_ENTITY(canvas)); } static void @@ -294,7 +294,7 @@ _adg_test_bottom_margin(void) g_object_get(canvas, "bottom-margin", &bottom_margin, NULL); g_assert_cmpfloat(bottom_margin, ==, valid_value_2); - g_object_unref(canvas); + adg_entity_destroy(ADG_ENTITY(canvas)); } static void @@ -326,7 +326,7 @@ _adg_test_left_margin(void) g_object_get(canvas, "left-margin", &left_margin, NULL); g_assert_cmpfloat(left_margin, ==, valid_value_2); - g_object_unref(canvas); + adg_entity_destroy(ADG_ENTITY(canvas)); } static void @@ -365,7 +365,7 @@ _adg_test_has_frame(void) g_object_get(canvas, "has-frame", &has_frame, NULL); g_assert(has_frame); - g_object_unref(canvas); + adg_entity_destroy(ADG_ENTITY(canvas)); } static void @@ -397,7 +397,7 @@ _adg_test_top_padding(void) g_object_get(canvas, "top-padding", &top_padding, NULL); g_assert_cmpfloat(top_padding, ==, valid_value_2); - g_object_unref(canvas); + adg_entity_destroy(ADG_ENTITY(canvas)); } static void @@ -429,7 +429,7 @@ _adg_test_right_padding(void) g_object_get(canvas, "right-padding", &right_padding, NULL); g_assert_cmpfloat(right_padding, ==, valid_value_2); - g_object_unref(canvas); + adg_entity_destroy(ADG_ENTITY(canvas)); } static void @@ -461,7 +461,7 @@ _adg_test_bottom_padding(void) g_object_get(canvas, "bottom-padding", &bottom_padding, NULL); g_assert_cmpfloat(bottom_padding, ==, valid_value_2); - g_object_unref(canvas); + adg_entity_destroy(ADG_ENTITY(canvas)); } static void @@ -493,7 +493,7 @@ _adg_test_left_padding(void) g_object_get(canvas, "left-padding", &left_padding, NULL); g_assert_cmpfloat(left_padding, ==, valid_value_2); - g_object_unref(canvas); + adg_entity_destroy(ADG_ENTITY(canvas)); } diff --git a/src/adg/tests/test-container.c b/src/adg/tests/test-container.c index 0865c73b..167f6d7e 100644 --- a/src/adg/tests/test-container.c +++ b/src/adg/tests/test-container.c @@ -79,8 +79,8 @@ _adg_property_child(void) children = adg_container_children(container); g_assert(children == NULL); - g_object_unref(container); - g_object_unref(valid_entity); + adg_entity_destroy(ADG_ENTITY(container)); + adg_entity_destroy(valid_entity); } static void @@ -109,17 +109,17 @@ _adg_misc(void) g_assert_cmpint(g_slist_length(children), ==, 2); g_slist_free(children); - g_object_unref(entity1); + adg_entity_destroy(entity1); children = adg_container_children(container); g_assert(children != NULL); g_assert_cmpint(g_slist_length(children), ==, 1); g_slist_free(children); - g_object_unref(entity2); + adg_entity_destroy(entity2); children = adg_container_children(container); g_assert(children == NULL); - g_object_unref(container); + adg_entity_destroy(ADG_ENTITY(container)); } diff --git a/src/adg/tests/test-dim-style.c b/src/adg/tests/test-dim-style.c index 3e559d2a..774eb06c 100644 --- a/src/adg/tests/test-dim-style.c +++ b/src/adg/tests/test-dim-style.c @@ -327,12 +327,12 @@ _adg_marker1(void) adg_dim_style_set_marker1(dim_style, valid_marker); marker = adg_dim_style_marker1_new(dim_style); g_assert(marker != NULL); - g_object_unref(marker); + adg_entity_destroy(ADG_ENTITY(marker)); adg_dim_style_set_marker1(dim_style, invalid_marker); marker = adg_dim_style_marker1_new(dim_style); g_assert(marker != NULL); - g_object_unref(marker); + adg_entity_destroy(ADG_ENTITY(marker)); adg_dim_style_set_marker1(dim_style, NULL); marker = adg_dim_style_marker1_new(dim_style); @@ -342,19 +342,19 @@ _adg_marker1(void) g_object_set(dim_style, "marker1", valid_marker, NULL); marker = adg_dim_style_marker1_new(dim_style); g_assert(marker != NULL); - g_object_unref(marker); + adg_entity_destroy(ADG_ENTITY(marker)); g_object_set(dim_style, "marker1", invalid_marker, NULL); marker = adg_dim_style_marker1_new(dim_style); g_assert(marker != NULL); - g_object_unref(marker); + adg_entity_destroy(ADG_ENTITY(marker)); g_object_set(dim_style, "marker1", NULL, NULL); marker = adg_dim_style_marker1_new(dim_style); g_assert(marker == NULL); g_object_unref(dim_style); - g_object_unref(valid_marker); + adg_entity_destroy(ADG_ENTITY(valid_marker)); } static void @@ -371,12 +371,12 @@ _adg_marker2(void) adg_dim_style_set_marker2(dim_style, valid_marker); marker = adg_dim_style_marker2_new(dim_style); g_assert(marker != NULL); - g_object_unref(marker); + adg_entity_destroy(ADG_ENTITY(marker)); adg_dim_style_set_marker2(dim_style, invalid_marker); marker = adg_dim_style_marker2_new(dim_style); g_assert(marker != NULL); - g_object_unref(marker); + adg_entity_destroy(ADG_ENTITY(marker)); adg_dim_style_set_marker2(dim_style, NULL); marker = adg_dim_style_marker2_new(dim_style); @@ -386,19 +386,19 @@ _adg_marker2(void) g_object_set(dim_style, "marker2", valid_marker, NULL); marker = adg_dim_style_marker2_new(dim_style); g_assert(marker != NULL); - g_object_unref(marker); + adg_entity_destroy(ADG_ENTITY(marker)); g_object_set(dim_style, "marker2", invalid_marker, NULL); marker = adg_dim_style_marker2_new(dim_style); g_assert(marker != NULL); - g_object_unref(marker); + adg_entity_destroy(ADG_ENTITY(marker)); g_object_set(dim_style, "marker2", NULL, NULL); marker = adg_dim_style_marker2_new(dim_style); g_assert(marker == NULL); g_object_unref(dim_style); - g_object_unref(valid_marker); + adg_entity_destroy(ADG_ENTITY(valid_marker)); } static void diff --git a/src/adg/tests/test-dim.c b/src/adg/tests/test-dim.c index 80abf476..b2bfbb5c 100644 --- a/src/adg/tests/test-dim.c +++ b/src/adg/tests/test-dim.c @@ -59,7 +59,7 @@ _adg_test_detached(void) g_object_get(dim, "detached", &detached, NULL); g_assert_cmpint(detached, ==, valid_three_state_2); - g_object_unref(dim); + adg_entity_destroy(ADG_ENTITY(dim)); } static void @@ -91,7 +91,7 @@ _adg_test_dim_dress(void) g_object_get(dim, "dim-dress", &dim_dress, NULL); g_assert_cmpint(dim_dress, ==, valid_dress); - g_object_unref(dim); + adg_entity_destroy(ADG_ENTITY(dim)); } static void @@ -123,7 +123,7 @@ _adg_test_level(void) g_object_get(dim, "level", &level, NULL); g_assert_cmpfloat(level, ==, valid_value_2); - g_object_unref(dim); + adg_entity_destroy(ADG_ENTITY(dim)); } static void @@ -166,7 +166,7 @@ _adg_test_max(void) g_object_get(dim, "max", &max_dup, NULL); g_assert(max_dup == NULL); - g_object_unref(dim); + adg_entity_destroy(ADG_ENTITY(dim)); } static void @@ -209,7 +209,7 @@ _adg_test_min(void) g_object_get(dim, "min", &min_dup, NULL); g_assert(min_dup == NULL); - g_object_unref(dim); + adg_entity_destroy(ADG_ENTITY(dim)); } static void @@ -250,7 +250,7 @@ _adg_test_outside(void) g_object_get(dim, "outside", &outside, NULL); g_assert_cmpint(outside, ==, valid_three_state_2); - g_object_unref(dim); + adg_entity_destroy(ADG_ENTITY(dim)); } static void @@ -333,7 +333,7 @@ _adg_test_pos(void) adg_point_destroy(origin); adg_point_destroy(explicit_point); adg_point_destroy(model_point); - g_object_unref(dim); + adg_entity_destroy(ADG_ENTITY(dim)); g_object_unref(model); } @@ -417,7 +417,7 @@ _adg_test_ref1(void) adg_point_destroy(origin); adg_point_destroy(explicit_point); adg_point_destroy(model_point); - g_object_unref(dim); + adg_entity_destroy(ADG_ENTITY(dim)); g_object_unref(model); } @@ -501,7 +501,7 @@ _adg_test_ref2(void) adg_point_destroy(origin); adg_point_destroy(explicit_point); adg_point_destroy(model_point); - g_object_unref(dim); + adg_entity_destroy(ADG_ENTITY(dim)); g_object_unref(model); } @@ -545,7 +545,7 @@ _adg_test_value(void) g_object_get(dim, "value", &value_dup, NULL); g_assert(value_dup == NULL); - g_object_unref(dim); + adg_entity_destroy(ADG_ENTITY(dim)); } diff --git a/src/adg/tests/test-entity.c b/src/adg/tests/test-entity.c index faefdb04..ef1eb471 100644 --- a/src/adg/tests/test-entity.c +++ b/src/adg/tests/test-entity.c @@ -49,19 +49,19 @@ _adg_test_parent(void) g_object_set(entity, "parent", valid_container, NULL); g_object_get(entity, "parent", &parent, NULL); g_assert(parent == valid_container); - g_object_unref(parent); + adg_entity_destroy(parent); g_object_set(entity, "parent", invalid_container, NULL); g_object_get(entity, "parent", &parent, NULL); g_assert(parent == valid_container); - g_object_unref(parent); + adg_entity_destroy(parent); g_object_set(entity, "parent", NULL, NULL); g_object_get(entity, "parent", &parent, NULL); g_assert(parent == NULL); - g_object_unref(entity); - g_object_unref(valid_container); + adg_entity_destroy(entity); + adg_entity_destroy(valid_container); } static void @@ -119,7 +119,7 @@ _adg_test_global_map(void) g_assert(adg_matrix_equal(global_map_dup, identity_map)); g_free(global_map_dup); - g_object_unref(entity); + adg_entity_destroy(entity); } static void @@ -177,7 +177,7 @@ _adg_test_local_map(void) g_assert(adg_matrix_equal(local_map_dup, identity_map)); g_free(local_map_dup); - g_object_unref(entity); + adg_entity_destroy(entity); } static void @@ -218,7 +218,7 @@ _adg_test_local_method(void) g_object_get(entity, "local-method", &local_method, NULL); g_assert_cmpint(local_method, ==, valid_method2); - g_object_unref(entity); + adg_entity_destroy(entity); } diff --git a/src/adg/tests/test-gtk-area.c b/src/adg/tests/test-gtk-area.c index c4d4553e..0f9d6ceb 100644 --- a/src/adg/tests/test-gtk-area.c +++ b/src/adg/tests/test-gtk-area.c @@ -58,19 +58,19 @@ _adg_test_canvas(void) g_object_set(area, "canvas", valid_canvas, NULL); g_object_get(area, "canvas", &canvas, NULL); g_assert(canvas == valid_canvas); - g_object_unref(canvas); + adg_entity_destroy(ADG_ENTITY(canvas)); g_object_set(area, "canvas", invalid_canvas, NULL); g_object_get(area, "canvas", &canvas, NULL); g_assert(canvas == valid_canvas); - g_object_unref(canvas); + adg_entity_destroy(ADG_ENTITY(canvas)); g_object_set(area, "canvas", NULL, NULL); g_object_get(area, "canvas", &canvas, NULL); g_assert(canvas == NULL); - g_object_unref(area); - g_object_unref(valid_canvas); + gtk_widget_destroy(GTK_WIDGET(area)); + adg_entity_destroy(ADG_ENTITY(valid_canvas)); } static void @@ -110,7 +110,7 @@ _adg_test_factor(void) g_object_get(area, "factor", &factor, NULL); g_assert_cmpfloat(factor, ==, valid_factor2); - g_object_unref(area); + gtk_widget_destroy(GTK_WIDGET(area)); } static void @@ -149,7 +149,7 @@ _adg_test_autozoom(void) g_object_get(area, "autozoom", &has_autozoom, NULL); g_assert(has_autozoom); - g_object_unref(area); + gtk_widget_destroy(GTK_WIDGET(area)); } static void @@ -207,7 +207,7 @@ _adg_test_render_map(void) g_assert(adg_matrix_equal(render_map_dup, identity_map)); g_free(render_map_dup); - g_object_unref(area); + gtk_widget_destroy(GTK_WIDGET(area)); } diff --git a/src/adg/tests/test-gtk-layout.c b/src/adg/tests/test-gtk-layout.c index 061a6a74..f48dfc54 100644 --- a/src/adg/tests/test-gtk-layout.c +++ b/src/adg/tests/test-gtk-layout.c @@ -75,7 +75,7 @@ _adg_test_hadjustment(void) g_assert(hadjustment != valid_adjustment && GTK_IS_ADJUSTMENT(hadjustment)); g_object_unref(hadjustment); - g_object_unref(layout); + gtk_widget_destroy(GTK_WIDGET(layout)); g_object_unref(valid_adjustment); } @@ -133,7 +133,7 @@ _adg_test_vadjustment(void) g_assert(vadjustment != valid_adjustment && GTK_IS_ADJUSTMENT(vadjustment)); g_object_unref(vadjustment); - g_object_unref(layout); + gtk_widget_destroy(GTK_WIDGET(layout)); g_object_unref(valid_adjustment); } diff --git a/src/adg/tests/test-hatch.c b/src/adg/tests/test-hatch.c index 777f1b45..52b865b0 100644 --- a/src/adg/tests/test-hatch.c +++ b/src/adg/tests/test-hatch.c @@ -59,7 +59,7 @@ _adg_test_fill_dress(void) g_object_get(hatch, "fill-dress", &fill_dress, NULL); g_assert_cmpint(fill_dress, ==, valid_dress_2); - g_object_unref(hatch); + adg_entity_destroy(ADG_ENTITY(hatch)); } diff --git a/src/adg/tests/test-ldim.c b/src/adg/tests/test-ldim.c index 7587c518..3b393089 100644 --- a/src/adg/tests/test-ldim.c +++ b/src/adg/tests/test-ldim.c @@ -58,7 +58,7 @@ _adg_test_direction(void) g_object_get(ldim, "direction", &direction, NULL); g_assert_cmpfloat(direction, !=, invalid_value); - g_object_unref(ldim); + adg_entity_destroy(ADG_ENTITY(ldim)); } static void @@ -97,7 +97,7 @@ _adg_test_has_extension1(void) g_object_get(ldim, "has-extension1", &has_extension1, NULL); g_assert(has_extension1); - g_object_unref(ldim); + adg_entity_destroy(ADG_ENTITY(ldim)); } static void @@ -136,7 +136,7 @@ _adg_test_has_extension2(void) g_object_get(ldim, "has-extension2", &has_extension2, NULL); g_assert(has_extension2); - g_object_unref(ldim); + adg_entity_destroy(ADG_ENTITY(ldim)); } diff --git a/src/adg/tests/test-logo.c b/src/adg/tests/test-logo.c index 00225003..d83f6794 100644 --- a/src/adg/tests/test-logo.c +++ b/src/adg/tests/test-logo.c @@ -59,7 +59,7 @@ _adg_test_frame_dress(void) g_object_get(logo, "frame-dress", &frame_dress, NULL); g_assert_cmpint(frame_dress, ==, valid_dress_2); - g_object_unref(logo); + adg_entity_destroy(ADG_ENTITY(logo)); } static void @@ -100,7 +100,7 @@ _adg_test_screen_dress(void) g_object_get(logo, "screen-dress", &screen_dress, NULL); g_assert_cmpint(screen_dress, ==, valid_dress_2); - g_object_unref(logo); + adg_entity_destroy(ADG_ENTITY(logo)); } static void @@ -141,7 +141,7 @@ _adg_test_symbol_dress(void) g_object_get(logo, "symbol-dress", &symbol_dress, NULL); g_assert_cmpint(symbol_dress, ==, valid_dress_2); - g_object_unref(logo); + adg_entity_destroy(ADG_ENTITY(logo)); } diff --git a/src/adg/tests/test-marker.c b/src/adg/tests/test-marker.c index 954eea9b..a672b491 100644 --- a/src/adg/tests/test-marker.c +++ b/src/adg/tests/test-marker.c @@ -69,7 +69,7 @@ _adg_test_model(void) g_object_get(marker, "model", &model, NULL); g_assert(model == NULL); - g_object_unref(marker); + adg_entity_destroy(ADG_ENTITY(marker)); g_object_unref(valid_model); } @@ -114,7 +114,7 @@ _adg_test_n_segment(void) g_object_get(marker, "n-segment", &n_segment, NULL); g_assert_cmpint(n_segment, ==, valid_n_segment); - g_object_unref(marker); + adg_entity_destroy(ADG_ENTITY(marker)); g_object_unref(trail); } @@ -155,7 +155,7 @@ _adg_test_pos(void) g_object_get(marker, "pos", &pos, NULL); g_assert_cmpfloat(pos, ==, valid_pos2); - g_object_unref(marker); + adg_entity_destroy(ADG_ENTITY(marker)); } static void @@ -214,7 +214,7 @@ _adg_test_trail(void) g_object_get(marker, "trail", &trail, NULL); g_assert(trail == NULL); - g_object_unref(marker); + adg_entity_destroy(ADG_ENTITY(marker)); g_object_unref(valid_trail); } @@ -255,7 +255,7 @@ _adg_test_size(void) g_object_get(marker, "size", &size, NULL); g_assert_cmpfloat(size, ==, valid_size2); - g_object_unref(marker); + adg_entity_destroy(ADG_ENTITY(marker)); } diff --git a/src/adg/tests/test-model.c b/src/adg/tests/test-model.c index 9979364c..9c5e3b60 100644 --- a/src/adg/tests/test-model.c +++ b/src/adg/tests/test-model.c @@ -98,7 +98,7 @@ _adg_test_dependency(void) g_assert(dependencies == NULL); g_object_unref(model); - g_object_unref(valid_entity); + adg_entity_destroy(valid_entity); } diff --git a/src/adg/tests/test-projection.c b/src/adg/tests/test-projection.c index 166c1576..a91a6f3f 100644 --- a/src/adg/tests/test-projection.c +++ b/src/adg/tests/test-projection.c @@ -59,7 +59,7 @@ _adg_test_axis_dress(void) g_object_get(projection, "axis-dress", &axis_dress, NULL); g_assert_cmpint(axis_dress, ==, valid_dress_2); - g_object_unref(projection); + adg_entity_destroy(ADG_ENTITY(projection)); } static void @@ -100,7 +100,7 @@ _adg_test_scheme(void) g_object_get(projection, "scheme", &scheme, NULL); g_assert_cmpint(scheme, ==, valid_scheme_2); - g_object_unref(projection); + adg_entity_destroy(ADG_ENTITY(projection)); } static void @@ -141,7 +141,7 @@ _adg_test_symbol_dress(void) g_object_get(projection, "symbol-dress", &symbol_dress, NULL); g_assert_cmpint(symbol_dress, ==, valid_dress_2); - g_object_unref(projection); + adg_entity_destroy(ADG_ENTITY(projection)); } diff --git a/src/adg/tests/test-stroke.c b/src/adg/tests/test-stroke.c index a29306a4..cd6d0757 100644 --- a/src/adg/tests/test-stroke.c +++ b/src/adg/tests/test-stroke.c @@ -59,7 +59,7 @@ _adg_test_line_dress(void) g_object_get(stroke, "line-dress", &line_dress, NULL); g_assert_cmpint(line_dress, ==, valid_dress_2); - g_object_unref(stroke); + adg_entity_destroy(ADG_ENTITY(stroke)); } static void @@ -110,7 +110,7 @@ _adg_test_trail(void) g_object_get(stroke, "trail", &trail, NULL); g_assert(trail == NULL); - g_object_unref(stroke); + adg_entity_destroy(ADG_ENTITY(stroke)); g_object_unref(valid_trail); } diff --git a/src/adg/tests/test-table.c b/src/adg/tests/test-table.c index a736c9c3..05da379c 100644 --- a/src/adg/tests/test-table.c +++ b/src/adg/tests/test-table.c @@ -50,7 +50,7 @@ _adg_test_table_dress(void) g_object_get(table, "table-dress", &table_dress, NULL); g_assert_cmpint(table_dress, ==, valid_dress); - g_object_unref(table); + adg_entity_destroy(ADG_ENTITY(table)); } static void @@ -89,7 +89,7 @@ _adg_test_has_frame(void) g_object_get(table, "has-frame", &has_frame, NULL); g_assert(has_frame); - g_object_unref(table); + adg_entity_destroy(ADG_ENTITY(table)); } diff --git a/src/adg/tests/test-text.c b/src/adg/tests/test-text.c index ff25c063..e0509cfc 100644 --- a/src/adg/tests/test-text.c +++ b/src/adg/tests/test-text.c @@ -61,7 +61,7 @@ _adg_test_font_dress(void) g_object_get(toy_text, "font-dress", &font_dress, NULL); g_assert_cmpint(font_dress, ==, valid_dress_2); - g_object_unref(toy_text); + adg_entity_destroy(ADG_ENTITY(toy_text)); } static void @@ -108,7 +108,7 @@ _adg_test_text(void) g_object_get(toy_text, "text", &text, NULL); g_assert(text == NULL); - g_object_unref(toy_text); + adg_entity_destroy(ADG_ENTITY(toy_text)); } diff --git a/src/adg/tests/test-title-block.c b/src/adg/tests/test-title-block.c index 30aec098..7ca49d7c 100644 --- a/src/adg/tests/test-title-block.c +++ b/src/adg/tests/test-title-block.c @@ -61,7 +61,7 @@ _adg_test_author(void) g_object_get(title_block, "author", &author_dup, NULL); g_assert(author_dup == NULL); - g_object_unref(title_block); + adg_entity_destroy(ADG_ENTITY(title_block)); } static void @@ -105,7 +105,7 @@ _adg_test_date(void) g_assert(date_dup != NULL); g_free(date_dup); - g_object_unref(title_block); + adg_entity_destroy(ADG_ENTITY(title_block)); } static void @@ -148,7 +148,7 @@ _adg_test_drawing(void) g_object_get(title_block, "drawing", &drawing_dup, NULL); g_assert(drawing_dup == NULL); - g_object_unref(title_block); + adg_entity_destroy(ADG_ENTITY(title_block)); } static void @@ -178,19 +178,19 @@ _adg_test_logo(void) g_object_set(title_block, "logo", valid_entity, NULL); g_object_get(title_block, "logo", &logo, NULL); g_assert(logo == valid_entity); - g_object_unref(logo); + adg_entity_destroy(logo); g_object_set(title_block, "logo", invalid_entity, NULL); g_object_get(title_block, "logo", &logo, NULL); g_assert(logo == valid_entity); - g_object_unref(logo); + adg_entity_destroy(logo); g_object_set(title_block, "logo", NULL, NULL); g_object_get(title_block, "logo", &logo, NULL); g_assert(logo == NULL); - g_object_unref(title_block); - g_object_unref(valid_entity); + adg_entity_destroy(ADG_ENTITY(title_block)); + adg_entity_destroy(valid_entity); } static void @@ -220,19 +220,19 @@ _adg_test_projection(void) g_object_set(title_block, "projection", valid_entity, NULL); g_object_get(title_block, "projection", &projection, NULL); g_assert(projection == valid_entity); - g_object_unref(projection); + adg_entity_destroy(projection); g_object_set(title_block, "projection", invalid_entity, NULL); g_object_get(title_block, "projection", &projection, NULL); g_assert(projection == valid_entity); - g_object_unref(projection); + adg_entity_destroy(projection); g_object_set(title_block, "projection", NULL, NULL); g_object_get(title_block, "projection", &projection, NULL); g_assert(projection == NULL); - g_object_unref(title_block); - g_object_unref(valid_entity); + adg_entity_destroy(ADG_ENTITY(title_block)); + adg_entity_destroy(valid_entity); } static void @@ -275,7 +275,7 @@ _adg_test_scale(void) g_object_get(title_block, "scale", &scale_dup, NULL); g_assert(scale_dup == NULL); - g_object_unref(title_block); + adg_entity_destroy(ADG_ENTITY(title_block)); } static void @@ -318,7 +318,7 @@ _adg_test_size(void) g_object_get(title_block, "size", &size_dup, NULL); g_assert(size_dup == NULL); - g_object_unref(title_block); + adg_entity_destroy(ADG_ENTITY(title_block)); } static void @@ -361,7 +361,7 @@ _adg_test_title(void) g_object_get(title_block, "title", &title_dup, NULL); g_assert(title_dup == NULL); - g_object_unref(title_block); + adg_entity_destroy(ADG_ENTITY(title_block)); } diff --git a/src/adg/tests/test-toy-text.c b/src/adg/tests/test-toy-text.c index 10f80c1d..a3dac476 100644 --- a/src/adg/tests/test-toy-text.c +++ b/src/adg/tests/test-toy-text.c @@ -61,7 +61,7 @@ _adg_test_font_dress(void) g_object_get(toy_text, "font-dress", &font_dress, NULL); g_assert_cmpint(font_dress, ==, valid_dress_2); - g_object_unref(toy_text); + adg_entity_destroy(ADG_ENTITY(toy_text)); } static void @@ -108,7 +108,7 @@ _adg_test_text(void) g_object_get(toy_text, "text", &text, NULL); g_assert(text == NULL); - g_object_unref(toy_text); + adg_entity_destroy(ADG_ENTITY(toy_text)); } -- 2.11.4.GIT