[glib/wip/gcleanup: 67/106] gtype: Push registered GType onto the appropriate cleanup list
- From: Stefan Walter <stefw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib/wip/gcleanup: 67/106] gtype: Push registered GType onto the appropriate cleanup list
- Date: Mon, 11 Nov 2013 08:00:37 +0000 (UTC)
commit f0ff092ea078fb4274e6a030576536e2ed97eec3
Author: Stef Walter <stefw gnome org>
Date: Thu Nov 7 22:52:18 2013 +0100
gtype: Push registered GType onto the appropriate cleanup list
When G_CLEANUP_SCOPE is defined the G_DEFINE_TYPE and macros
properly push newly registered GTypes onto the cleanup list.
In addition push all the the basic types into the libgobject
cleanup list.
https://bugzilla.gnome.org/show_bug.cgi?id=711778
gobject/gbinding.c | 1 +
gobject/gboxed.c | 3 ++-
gobject/genums.c | 2 ++
gobject/gobject.c | 1 +
gobject/gparam.c | 1 +
gobject/gparamspecs.c | 12 ++++++++----
gobject/gsourceclosure.c | 1 +
gobject/gtype.c | 2 ++
gobject/gtype.h | 13 +++++++++++++
gobject/gtypemodule.c | 2 +-
gobject/gtypemodule.h | 3 +++
gobject/gtypeplugin.c | 1 +
gobject/gvaluetypes.c | 14 ++++++++++++++
gobject/tests/Makefile.am | 2 +-
gobject/tests/binding.c | 2 ++
gobject/tests/boxed.c | 2 ++
gobject/tests/dynamictests.c | 3 +++
gobject/tests/enums.c | 4 ++++
gobject/tests/ifaceproperties.c | 2 ++
gobject/tests/object.c | 2 ++
gobject/tests/param.c | 2 ++
gobject/tests/private.c | 2 ++
gobject/tests/properties.c | 2 ++
gobject/tests/reference.c | 2 ++
gobject/tests/signals.c | 6 ++++++
gobject/tests/testcommon.h | 2 ++
gobject/tests/threadtests.c | 2 ++
gobject/tests/type.c | 6 +++++-
tests/gobject/Makefile.am | 2 +-
tests/gobject/deftype.c | 2 ++
tests/gobject/dynamictype.c | 2 ++
tests/gobject/performance.c | 2 ++
tests/gobject/references.c | 2 ++
tests/gobject/singleton.c | 2 ++
34 files changed, 100 insertions(+), 9 deletions(-)
---
diff --git a/gobject/gbinding.c b/gobject/gbinding.c
index c8c8fa3..40ea70a 100644
--- a/gobject/gbinding.c
+++ b/gobject/gbinding.c
@@ -135,6 +135,7 @@ g_binding_flags_get_type (void)
};
GType g_define_type_id =
g_flags_register_static (g_intern_static_string ("GBindingFlags"), values);
+ g_type_cleanup_push (g_define_type_id, G_CLEANUP_SCOPE);
g_once_init_leave (&g_define_type_id__volatile, g_define_type_id);
}
diff --git a/gobject/gboxed.c b/gobject/gboxed.c
index 67d6351..0c370f4 100644
--- a/gobject/gboxed.c
+++ b/gobject/gboxed.c
@@ -108,6 +108,7 @@ _g_boxed_type_init (void)
*/
type = g_type_register_fundamental (G_TYPE_BOXED, g_intern_static_string ("GBoxed"), &info, &finfo,
G_TYPE_FLAG_ABSTRACT | G_TYPE_FLAG_VALUE_ABSTRACT);
+ g_type_cleanup_push (type, G_CLEANUP_SCOPE);
g_assert (type == G_TYPE_BOXED);
}
@@ -177,7 +178,7 @@ g_strv_get_type (void)
g_boxed_type_register_static (g_intern_static_string ("GStrv"),
(GBoxedCopyFunc) g_strdupv,
(GBoxedFreeFunc) g_strfreev);
-
+ g_type_cleanup_push (g_define_type_id, G_CLEANUP_SCOPE);
g_once_init_leave (&g_define_type_id__volatile, g_define_type_id);
}
diff --git a/gobject/genums.c b/gobject/genums.c
index 474e791..9442a80 100644
--- a/gobject/genums.c
+++ b/gobject/genums.c
@@ -113,6 +113,7 @@ _g_enum_types_init (void)
info.class_size = sizeof (GEnumClass);
type = g_type_register_fundamental (G_TYPE_ENUM, g_intern_static_string ("GEnum"), &info, &finfo,
G_TYPE_FLAG_ABSTRACT | G_TYPE_FLAG_VALUE_ABSTRACT);
+ g_type_cleanup_push (type, G_CLEANUP_SCOPE);
g_assert (type == G_TYPE_ENUM);
/* G_TYPE_FLAGS
@@ -120,6 +121,7 @@ _g_enum_types_init (void)
info.class_size = sizeof (GFlagsClass);
type = g_type_register_fundamental (G_TYPE_FLAGS, g_intern_static_string ("GFlags"), &info, &finfo,
G_TYPE_FLAG_ABSTRACT | G_TYPE_FLAG_VALUE_ABSTRACT);
+ g_type_cleanup_push (type, G_CLEANUP_SCOPE);
g_assert (type == G_TYPE_FLAGS);
}
diff --git a/gobject/gobject.c b/gobject/gobject.c
index 92023ae..4fb9439 100644
--- a/gobject/gobject.c
+++ b/gobject/gobject.c
@@ -389,6 +389,7 @@ _g_object_type_init (void)
*/
info.value_table = &value_table;
type = g_type_register_fundamental (G_TYPE_OBJECT, g_intern_static_string ("GObject"), &info, &finfo, 0);
+ g_type_cleanup_push (type, G_CLEANUP_SCOPE);
g_assert (type == G_TYPE_OBJECT);
g_value_register_transform_func (G_TYPE_OBJECT, G_TYPE_OBJECT, g_value_object_transform_value);
diff --git a/gobject/gparam.c b/gobject/gparam.c
index 301affb..10ee4dc 100644
--- a/gobject/gparam.c
+++ b/gobject/gparam.c
@@ -137,6 +137,7 @@ _g_param_type_init (void)
*/
type = g_type_register_fundamental (G_TYPE_PARAM, g_intern_static_string ("GParam"), ¶m_spec_info,
&finfo, G_TYPE_FLAG_ABSTRACT);
g_assert (type == G_TYPE_PARAM);
+ g_type_cleanup_push (type, G_CLEANUP_SCOPE);
g_param_private_offset = g_type_add_instance_private (type, sizeof (GParamSpecPrivate));
g_value_register_transform_func (G_TYPE_PARAM, G_TYPE_PARAM, value_param_transform_value);
}
diff --git a/gobject/gparamspecs.c b/gobject/gparamspecs.c
index 449ad85..e139713 100644
--- a/gobject/gparamspecs.c
+++ b/gobject/gparamspecs.c
@@ -1166,13 +1166,14 @@ GType *g_param_spec_types = NULL;
void
_g_param_spec_types_init (void)
{
- const guint n_types = 23;
+ static GType types[23];
GType type, *spec_types, *spec_types_bound;
+ guint i;
- g_param_spec_types = g_new0 (GType, n_types);
+ g_param_spec_types = types;
spec_types = g_param_spec_types;
- spec_types_bound = g_param_spec_types + n_types;
-
+ spec_types_bound = g_param_spec_types + G_N_ELEMENTS (types);
+
/* G_TYPE_PARAM_CHAR
*/
{
@@ -1590,6 +1591,9 @@ _g_param_spec_types_init (void)
}
g_assert (spec_types == spec_types_bound);
+
+ for (i = 0; i < G_N_ELEMENTS (types); i++)
+ g_type_cleanup_push (g_param_spec_types[i], G_CLEANUP_SCOPE);
}
/* --- GParamSpec initialization --- */
diff --git a/gobject/gsourceclosure.c b/gobject/gsourceclosure.c
index f6be8de..a9058b3 100644
--- a/gobject/gsourceclosure.c
+++ b/gobject/gsourceclosure.c
@@ -47,6 +47,7 @@ g_io_condition_get_type (void)
{ 0, NULL, NULL }
};
etype = g_flags_register_static ("GIOCondition", values);
+ g_type_cleanup_push (etype, G_CLEANUP_SCOPE);
}
return etype;
}
diff --git a/gobject/gtype.c b/gobject/gtype.c
index 52d1529..814cba4 100644
--- a/gobject/gtype.c
+++ b/gobject/gtype.c
@@ -4381,6 +4381,7 @@ gobject_init_ctor (void)
*/
node = type_node_fundamental_new_W (G_TYPE_NONE, g_intern_static_string ("void"), 0);
type = NODE_TYPE (node);
+ g_type_cleanup_push (type, G_CLEANUP_SCOPE);
g_assert (type == G_TYPE_NONE);
/* interface fundamental type G_TYPE_INTERFACE (!classed)
@@ -4389,6 +4390,7 @@ gobject_init_ctor (void)
node = type_node_fundamental_new_W (G_TYPE_INTERFACE, g_intern_static_string ("GInterface"),
G_TYPE_FLAG_DERIVABLE);
type = NODE_TYPE (node);
type_data_make_W (node, &info, NULL);
+ g_type_cleanup_push (type, G_CLEANUP_SCOPE);
g_assert (type == G_TYPE_INTERFACE);
G_WRITE_UNLOCK (&type_rw_lock);
diff --git a/gobject/gtype.h b/gobject/gtype.h
index d498c11..fbfc4a9 100644
--- a/gobject/gtype.h
+++ b/gobject/gtype.h
@@ -1454,6 +1454,7 @@ guint g_type_get_type_registration_serial (void);
* sizeof (GtkGadget),
* (GInstanceInitFunc) gtk_gadget_init,
* 0);
+ * g_type_cleanup_push (g_define_type_id, G_CLEANUP_SCOPE); \
* {
* const GInterfaceInfo g_implement_interface_info = {
* (GInterfaceInitFunc) gtk_gadget_gizmo_init
@@ -1672,6 +1673,13 @@ static void type_name##_class_intern_init (gpointer klass) \
}
#endif /* GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_38 */
+/* Cleanup the type in the module within which it was defined */
+#if GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_40
+#define _G_DEFINE_TYPE_CLEANUP() g_type_cleanup_push (g_define_type_id, G_CLEANUP_SCOPE)
+#else
+#define _G_DEFINE_TYPE_CLEANUP()
+#endif
+
#define _G_DEFINE_TYPE_EXTENDED_BEGIN(TypeName, type_name, TYPE_PARENT, flags) \
\
static void type_name##_init (TypeName *self); \
@@ -1701,6 +1709,7 @@ type_name##_get_type (void) \
sizeof (TypeName), \
(GInstanceInitFunc) type_name##_init, \
(GTypeFlags) flags); \
+ _G_DEFINE_TYPE_CLEANUP (); \
{ /* custom code follows */
#define _G_DEFINE_TYPE_EXTENDED_END() \
/* following custom code */ \
@@ -1728,6 +1737,7 @@ type_name##_get_type (void) \
0, \
(GInstanceInitFunc)NULL, \
(GTypeFlags) 0); \
+ _G_DEFINE_TYPE_CLEANUP (); \
if (TYPE_PREREQ) \
g_type_interface_add_prerequisite (g_define_type_id, TYPE_PREREQ); \
{ /* custom code follows */
@@ -1798,6 +1808,7 @@ type_name##_get_type (void) \
) = g_boxed_type_register_static; \
GType g_define_type_id = \
_g_register_boxed (g_intern_static_string (#TypeName), copy_func, free_func); \
+ _G_DEFINE_TYPE_CLEANUP (); \
{ /* custom code follows */
#else
#define _G_DEFINE_BOXED_TYPE_BEGIN(TypeName, type_name, copy_func, free_func) \
@@ -1811,6 +1822,7 @@ type_name##_get_type (void) \
g_boxed_type_register_static (g_intern_static_string (#TypeName), \
(GBoxedCopyFunc) copy_func, \
(GBoxedFreeFunc) free_func); \
+ _G_DEFINE_TYPE_CLEANUP (); \
{ /* custom code follows */
#endif /* __GNUC__ */
@@ -1850,6 +1862,7 @@ type_name##_get_type (void) \
{ \
GType g_define_type_id = \
g_pointer_type_register_static (g_intern_static_string (#TypeName)); \
+ _G_DEFINE_TYPE_CLEANUP (); \
{ /* custom code follows */
/* --- protected (for fundamental type implementations) --- */
diff --git a/gobject/gtypemodule.c b/gobject/gtypemodule.c
index b1a663d..25ec75d 100644
--- a/gobject/gtypemodule.c
+++ b/gobject/gtypemodule.c
@@ -171,8 +171,8 @@ g_type_module_get_type (void)
};
type_module_type = g_type_register_static (G_TYPE_OBJECT, g_intern_static_string ("GTypeModule"),
&type_module_info, G_TYPE_FLAG_ABSTRACT);
-
g_type_add_interface_static (type_module_type, G_TYPE_TYPE_PLUGIN, &iface_info);
+ g_type_cleanup_push (type_module_type, G_CLEANUP_SCOPE);
}
return type_module_type;
diff --git a/gobject/gtypemodule.h b/gobject/gtypemodule.h
index 2580e1b..751a975 100644
--- a/gobject/gtypemodule.h
+++ b/gobject/gtypemodule.h
@@ -211,12 +211,15 @@ type_name##_register_type (GTypeModule *type_module) \
(GInstanceInitFunc) type_name##_init, \
NULL /* value_table */ \
}; \
+ GType previous = g_type_from_name (#TypeName); \
type_name##_type_id = g_type_module_register_type (type_module, \
TYPE_PARENT, \
#TypeName, \
&g_define_type_info, \
(GTypeFlags) flags); \
g_define_type_id = type_name##_type_id; \
+ if (!previous) \
+ g_type_cleanup_push (g_define_type_id, G_CLEANUP_SCOPE); \
{ CODE ; } \
}
diff --git a/gobject/gtypeplugin.c b/gobject/gtypeplugin.c
index 192f6f9..73cc126 100644
--- a/gobject/gtypeplugin.c
+++ b/gobject/gtypeplugin.c
@@ -102,6 +102,7 @@ g_type_plugin_get_type (void)
};
type_plugin_type = g_type_register_static (G_TYPE_INTERFACE, g_intern_static_string ("GTypePlugin"),
&type_plugin_info, 0);
+ g_type_cleanup_push (type_plugin_type, G_CLEANUP_SCOPE);
}
return type_plugin_type;
diff --git a/gobject/gvaluetypes.c b/gobject/gvaluetypes.c
index b986415..b70c611 100644
--- a/gobject/gvaluetypes.c
+++ b/gobject/gvaluetypes.c
@@ -455,8 +455,10 @@ _g_value_types_init (void)
info.value_table = &value_table;
type = g_type_register_fundamental (G_TYPE_CHAR, g_intern_static_string ("gchar"), &info, &finfo, 0);
g_assert (type == G_TYPE_CHAR);
+ g_type_cleanup_push (type, G_CLEANUP_SCOPE);
type = g_type_register_fundamental (G_TYPE_UCHAR, g_intern_static_string ("guchar"), &info, &finfo, 0);
g_assert (type == G_TYPE_UCHAR);
+ g_type_cleanup_push (type, G_CLEANUP_SCOPE);
}
/* G_TYPE_BOOLEAN
@@ -475,6 +477,7 @@ _g_value_types_init (void)
info.value_table = &value_table;
type = g_type_register_fundamental (G_TYPE_BOOLEAN, g_intern_static_string ("gboolean"), &info, &finfo,
0);
g_assert (type == G_TYPE_BOOLEAN);
+ g_type_cleanup_push (type, G_CLEANUP_SCOPE);
}
/* G_TYPE_INT / G_TYPE_UINT
@@ -493,8 +496,10 @@ _g_value_types_init (void)
info.value_table = &value_table;
type = g_type_register_fundamental (G_TYPE_INT, g_intern_static_string ("gint"), &info, &finfo, 0);
g_assert (type == G_TYPE_INT);
+ g_type_cleanup_push (type, G_CLEANUP_SCOPE);
type = g_type_register_fundamental (G_TYPE_UINT, g_intern_static_string ("guint"), &info, &finfo, 0);
g_assert (type == G_TYPE_UINT);
+ g_type_cleanup_push (type, G_CLEANUP_SCOPE);
}
/* G_TYPE_LONG / G_TYPE_ULONG
@@ -513,8 +518,10 @@ _g_value_types_init (void)
info.value_table = &value_table;
type = g_type_register_fundamental (G_TYPE_LONG, g_intern_static_string ("glong"), &info, &finfo, 0);
g_assert (type == G_TYPE_LONG);
+ g_type_cleanup_push (type, G_CLEANUP_SCOPE);
type = g_type_register_fundamental (G_TYPE_ULONG, g_intern_static_string ("gulong"), &info, &finfo, 0);
g_assert (type == G_TYPE_ULONG);
+ g_type_cleanup_push (type, G_CLEANUP_SCOPE);
}
/* G_TYPE_INT64 / G_TYPE_UINT64
@@ -533,8 +540,10 @@ _g_value_types_init (void)
info.value_table = &value_table;
type = g_type_register_fundamental (G_TYPE_INT64, g_intern_static_string ("gint64"), &info, &finfo, 0);
g_assert (type == G_TYPE_INT64);
+ g_type_cleanup_push (type, G_CLEANUP_SCOPE);
type = g_type_register_fundamental (G_TYPE_UINT64, g_intern_static_string ("guint64"), &info, &finfo, 0);
g_assert (type == G_TYPE_UINT64);
+ g_type_cleanup_push (type, G_CLEANUP_SCOPE);
}
/* G_TYPE_FLOAT
@@ -553,6 +562,7 @@ _g_value_types_init (void)
info.value_table = &value_table;
type = g_type_register_fundamental (G_TYPE_FLOAT, g_intern_static_string ("gfloat"), &info, &finfo, 0);
g_assert (type == G_TYPE_FLOAT);
+ g_type_cleanup_push (type, G_CLEANUP_SCOPE);
}
/* G_TYPE_DOUBLE
@@ -571,6 +581,7 @@ _g_value_types_init (void)
info.value_table = &value_table;
type = g_type_register_fundamental (G_TYPE_DOUBLE, g_intern_static_string ("gdouble"), &info, &finfo, 0);
g_assert (type == G_TYPE_DOUBLE);
+ g_type_cleanup_push (type, G_CLEANUP_SCOPE);
}
/* G_TYPE_STRING
@@ -589,6 +600,7 @@ _g_value_types_init (void)
info.value_table = &value_table;
type = g_type_register_fundamental (G_TYPE_STRING, g_intern_static_string ("gchararray"), &info, &finfo,
0);
g_assert (type == G_TYPE_STRING);
+ g_type_cleanup_push (type, G_CLEANUP_SCOPE);
}
/* G_TYPE_POINTER
@@ -607,6 +619,7 @@ _g_value_types_init (void)
info.value_table = &value_table;
type = g_type_register_fundamental (G_TYPE_POINTER, g_intern_static_string ("gpointer"), &info, &finfo,
0);
g_assert (type == G_TYPE_POINTER);
+ g_type_cleanup_push (type, G_CLEANUP_SCOPE);
}
/* G_TYPE_VARIANT
@@ -625,6 +638,7 @@ _g_value_types_init (void)
info.value_table = &value_table;
type = g_type_register_fundamental (G_TYPE_VARIANT, g_intern_static_string ("GVariant"), &info, &finfo,
0);
g_assert (type == G_TYPE_VARIANT);
+ g_type_cleanup_push (type, G_CLEANUP_SCOPE);
}
}
diff --git a/gobject/tests/Makefile.am b/gobject/tests/Makefile.am
index 2c5cc1a..bf1884d 100644
--- a/gobject/tests/Makefile.am
+++ b/gobject/tests/Makefile.am
@@ -2,7 +2,7 @@ include $(top_srcdir)/glib-tap.mk
LDADD = ../libgobject-2.0.la $(top_builddir)/glib/libglib-2.0.la
AM_CPPFLAGS = -g $(gobject_INCLUDES) $(GLIB_DEBUG_FLAGS)
-DEFS = -DG_LOG_DOMAIN=\"GLib-GObject\"
+DEFS = -DG_LOG_DOMAIN=\"GLib-GObject\" -DG_CLEANUP_SCOPE=gobject_tests_cleanup
AM_CFLAGS = $(GLIB_WARN_CFLAGS)
# -----------------------------------------------------------------------------
diff --git a/gobject/tests/binding.c b/gobject/tests/binding.c
index 5f87e84..0086703 100644
--- a/gobject/tests/binding.c
+++ b/gobject/tests/binding.c
@@ -2,6 +2,8 @@
#include <gstdio.h>
#include <glib-object.h>
+G_CLEANUP_DEFINE;
+
typedef struct _BindingSource
{
GObject parent_instance;
diff --git a/gobject/tests/boxed.c b/gobject/tests/boxed.c
index 70e3ea7..9c9c46d 100644
--- a/gobject/tests/boxed.c
+++ b/gobject/tests/boxed.c
@@ -2,6 +2,8 @@
#include <glib-object.h>
+G_CLEANUP_DEFINE;
+
typedef struct _MyBoxed MyBoxed;
struct _MyBoxed
diff --git a/gobject/tests/dynamictests.c b/gobject/tests/dynamictests.c
index a052e1a..86dcdf3 100644
--- a/gobject/tests/dynamictests.c
+++ b/gobject/tests/dynamictests.c
@@ -25,6 +25,8 @@
/* This test tests the macros for defining dynamic types.
*/
+G_CLEANUP_DEFINE;
+
static GMutex sync_mutex;
static gboolean loaded = FALSE;
@@ -96,6 +98,7 @@ static GType test_module_get_type (void)
(GInstanceInitFunc)NULL
};
object_type = g_type_register_static (G_TYPE_TYPE_MODULE, "TestModule", &object_info, 0);
+ g_type_cleanup_push (object_type, G_CLEANUP_SCOPE);
}
return object_type;
}
diff --git a/gobject/tests/enums.c b/gobject/tests/enums.c
index 84ffed7..f8ae42c 100644
--- a/gobject/tests/enums.c
+++ b/gobject/tests/enums.c
@@ -1,5 +1,7 @@
#include <glib-object.h>
+G_CLEANUP_DEFINE;
+
static const GEnumValue my_enum_values[] =
{
{ 1, "the first value", "one" },
@@ -17,6 +19,7 @@ test_enum_basic (void)
GValue value = G_VALUE_INIT;
type = g_enum_register_static ("MyEnum", my_enum_values);
+ g_type_cleanup_push (type, G_CLEANUP_SCOPE);
g_value_init (&value, type);
g_assert (G_VALUE_HOLDS_ENUM (&value));
@@ -80,6 +83,7 @@ test_flags_basic (void)
GValue value = G_VALUE_INIT;
type = g_flags_register_static ("MyFlags", my_flag_values);
+ g_type_cleanup_push (type, G_CLEANUP_SCOPE);
g_value_init (&value, type);
g_assert (G_VALUE_HOLDS_FLAGS (&value));
diff --git a/gobject/tests/ifaceproperties.c b/gobject/tests/ifaceproperties.c
index 1fba57e..97dcfd6 100644
--- a/gobject/tests/ifaceproperties.c
+++ b/gobject/tests/ifaceproperties.c
@@ -35,6 +35,8 @@
* prop4: Defined in BaseObject, Overridden in DerivedObject
*/
+G_CLEANUP_DEFINE;
+
static GType base_object_get_type (void);
static GType derived_object_get_type (void);
diff --git a/gobject/tests/object.c b/gobject/tests/object.c
index 63c85a8..9e05df4 100644
--- a/gobject/tests/object.c
+++ b/gobject/tests/object.c
@@ -1,5 +1,7 @@
#include <glib-object.h>
+G_CLEANUP_DEFINE;
+
/* --------------------------------- */
/* test_object_constructor_singleton */
diff --git a/gobject/tests/param.c b/gobject/tests/param.c
index 0215dc0..5e11962 100644
--- a/gobject/tests/param.c
+++ b/gobject/tests/param.c
@@ -2,6 +2,8 @@
#include <glib-object.h>
#include <stdlib.h>
+G_CLEANUP_DEFINE;
+
static void
test_param_value (void)
{
diff --git a/gobject/tests/private.c b/gobject/tests/private.c
index 80ef9fc..edf4314 100644
--- a/gobject/tests/private.c
+++ b/gobject/tests/private.c
@@ -1,5 +1,7 @@
#include <glib-object.h>
+G_CLEANUP_DEFINE;
+
typedef struct {
GObject parent_instance;
} TestObject;
diff --git a/gobject/tests/properties.c b/gobject/tests/properties.c
index 7140f90..59415fe 100644
--- a/gobject/tests/properties.c
+++ b/gobject/tests/properties.c
@@ -2,6 +2,8 @@
#include <gstdio.h>
#include <glib-object.h>
+G_CLEANUP_DEFINE;
+
typedef struct _TestObject {
GObject parent_instance;
gint foo;
diff --git a/gobject/tests/reference.c b/gobject/tests/reference.c
index 0742339..5965e4b 100644
--- a/gobject/tests/reference.c
+++ b/gobject/tests/reference.c
@@ -1,5 +1,7 @@
#include <glib-object.h>
+G_CLEANUP_DEFINE;
+
static void
test_fundamentals (void)
{
diff --git a/gobject/tests/signals.c b/gobject/tests/signals.c
index a8ff35b..e0363e0 100644
--- a/gobject/tests/signals.c
+++ b/gobject/tests/signals.c
@@ -1,6 +1,8 @@
#include <glib-object.h>
#include "marshalers.h"
+G_CLEANUP_DEFINE;
+
typedef enum {
TEST_ENUM_NEGATIVE = -30,
TEST_ENUM_NONE = 0,
@@ -32,6 +34,7 @@ test_enum_get_type (void)
};
GType g_define_type_id =
g_enum_register_static (g_intern_static_string ("TestEnum"), values);
+ g_type_cleanup_push (g_define_type_id, G_CLEANUP_SCOPE);
g_once_init_leave (&g_define_type_id__volatile, g_define_type_id);
}
@@ -52,6 +55,7 @@ test_unsigned_enum_get_type (void)
};
GType g_define_type_id =
g_enum_register_static (g_intern_static_string ("TestUnsignedEnum"), values);
+ g_type_cleanup_push (g_define_type_id, G_CLEANUP_SCOPE);
g_once_init_leave (&g_define_type_id__volatile, g_define_type_id);
}
@@ -109,7 +113,9 @@ test_class_init (TestClass *klass)
guint s;
enum_type = g_enum_register_static ("MyEnum", my_enum_values);
+ g_type_cleanup_push (enum_type, G_CLEANUP_SCOPE);
flags_type = g_flags_register_static ("MyFlag", my_flag_values);
+ g_type_cleanup_push (flags_type, G_CLEANUP_SCOPE);
klass->all_types = all_types_handler;
diff --git a/gobject/tests/testcommon.h b/gobject/tests/testcommon.h
index 7bfef05..ea35422 100644
--- a/gobject/tests/testcommon.h
+++ b/gobject/tests/testcommon.h
@@ -48,6 +48,7 @@ prefix ## _get_type (void) \
object_type = g_type_register_static (parent_type, \
# name, \
&object_info, 0); \
+ g_type_cleanup_push (object_type, G_CLEANUP_SCOPE); \
interface_decl \
} \
\
@@ -79,6 +80,7 @@ prefix ## _get_type (void) \
iface_type = g_type_register_static (G_TYPE_INTERFACE, \
# name, \
&iface_info, 0); \
+ g_type_cleanup_push (iface_type, G_CLEANUP_SCOPE); \
} \
return iface_type; \
}
diff --git a/gobject/tests/threadtests.c b/gobject/tests/threadtests.c
index e075c57..30ae183 100644
--- a/gobject/tests/threadtests.c
+++ b/gobject/tests/threadtests.c
@@ -23,6 +23,8 @@
#include <glib.h>
#include <glib-object.h>
+G_CLEANUP_DEFINE;
+
static volatile int mtsafe_call_counter = 0; /* multi thread safe call counter */
static int unsafe_call_counter = 0; /* single-threaded call counter */
static GCond sync_cond;
diff --git a/gobject/tests/type.c b/gobject/tests/type.c
index 1abe482..f12af11 100644
--- a/gobject/tests/type.c
+++ b/gobject/tests/type.c
@@ -1,12 +1,16 @@
#include <glib-object.h>
+G_CLEANUP_DEFINE;
+
static void
test_registration_serial (void)
{
gint serial1, serial2, serial3;
+ GType type;
serial1 = g_type_get_type_registration_serial ();
- g_pointer_type_register_static ("my+pointer");
+ type = g_pointer_type_register_static ("my+pointer");
+ g_type_cleanup_push (type, G_CLEANUP_SCOPE);
serial2 = g_type_get_type_registration_serial ();
g_assert (serial1 != serial2);
serial3 = g_type_get_type_registration_serial ();
diff --git a/tests/gobject/Makefile.am b/tests/gobject/Makefile.am
index 84f7410..af2f0b5 100644
--- a/tests/gobject/Makefile.am
+++ b/tests/gobject/Makefile.am
@@ -2,7 +2,7 @@ include $(top_srcdir)/glib.mk
LDADD = $(top_builddir)/glib/libglib-2.0.la $(top_builddir)/gobject/libgobject-2.0.la
AM_CPPFLAGS = $(gmodule_INCLUDES) $(GLIB_DEBUG_FLAGS)
-DEFS = -DGLIB_DISABLE_DEPRECATION_WARNINGS -DG_LOG_DOMAIN=\"GLib\"
+DEFS = -DGLIB_DISABLE_DEPRECATION_WARNINGS -DG_LOG_DOMAIN=\"GLib\" -DG_CLEANUP_SCOPE=gobject_tests_cleanup
AM_CFLAGS = -g
# So far, only two gtester-ified cases
diff --git a/tests/gobject/deftype.c b/tests/gobject/deftype.c
index 232feff..32f7acf 100644
--- a/tests/gobject/deftype.c
+++ b/tests/gobject/deftype.c
@@ -20,6 +20,8 @@
/* see http://bugzilla.gnome.org/show_bug.cgi?id=337128 for the purpose of this test */
+G_CLEANUP_DEFINE;
+
#define MY_G_IMPLEMENT_INTERFACE(TYPE_IFACE, iface_init) { \
const GInterfaceInfo g_implement_interface_info = { \
(GInterfaceInitFunc) iface_init, \
diff --git a/tests/gobject/dynamictype.c b/tests/gobject/dynamictype.c
index b527608..bc003a1 100644
--- a/tests/gobject/dynamictype.c
+++ b/tests/gobject/dynamictype.c
@@ -32,6 +32,8 @@
/* This test tests the macros for defining dynamic types.
*/
+G_CLEANUP_DEFINE;
+
static gboolean loaded = FALSE;
struct _TestIfaceClass
diff --git a/tests/gobject/performance.c b/tests/gobject/performance.c
index fdc51da..d96c01b 100644
--- a/tests/gobject/performance.c
+++ b/tests/gobject/performance.c
@@ -22,6 +22,8 @@
#include <glib-object.h>
#include "testcommon.h"
+G_CLEANUP_DEFINE;
+
#define WARM_UP_N_RUNS 50
#define ESTIMATE_ROUND_TIME_N_RUNS 5
#define DEFAULT_TEST_TIME 15 /* seconds */
diff --git a/tests/gobject/references.c b/tests/gobject/references.c
index cfedfa9..398bf1c 100644
--- a/tests/gobject/references.c
+++ b/tests/gobject/references.c
@@ -29,6 +29,8 @@
/* This test tests weak and toggle references
*/
+G_CLEANUP_DEFINE;
+
static GObject *global_object;
static gboolean object_destroyed;
diff --git a/tests/gobject/singleton.c b/tests/gobject/singleton.c
index abf1a0b..ac53031 100644
--- a/tests/gobject/singleton.c
+++ b/tests/gobject/singleton.c
@@ -21,6 +21,8 @@
#include <glib-object.h>
#include <string.h>
+G_CLEANUP_DEFINE;
+
/* --- MySingleton class --- */
typedef struct {
GObject parent_instance;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]