From: Edward Hervey Date: Thu, 24 Sep 2009 08:16:48 +0000 (+0200) Subject: Pass the TypeNode to type_data_last_unref_Wm() X-Git-Tag: 2.23.1~39 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f8d24e849533e0e43cd7c9cf9a9692e4779c0472;p=platform%2Fupstream%2Fglib.git Pass the TypeNode to type_data_last_unref_Wm() Previously the GType was looked up just for calling the function Also moves the unref functions together in the code. https://bugzilla.gnome.org/show_bug.cgi?id=585375 --- diff --git a/gobject/gtype.c b/gobject/gtype.c index 5945d7f..cd33770 100644 --- a/gobject/gtype.c +++ b/gobject/gtype.c @@ -187,7 +187,7 @@ static void type_data_make_W (TypeNode *node, static inline void type_data_ref_Wm (TypeNode *node); static inline void type_data_unref_WmREC (TypeNode *node, gboolean uncached); -static void type_data_last_unref_Wm (GType type, +static void type_data_last_unref_Wm (TypeNode * node, gboolean uncached); static inline gpointer type_get_qdata_L (TypeNode *node, GQuark quark); @@ -1201,30 +1201,6 @@ type_data_ref_Wm (TypeNode *node) } } -static inline void -type_data_unref_WmREC (TypeNode *node, - gboolean uncached) -{ - g_assert (node->data && node->ref_count); - if (node->ref_count > 1) - node->ref_count -= 1; - else - { - GType node_type = NODE_TYPE (node); - if (!node->plugin) - { - g_warning ("static type `%s' unreferenced too often", - NODE_NAME (node)); - return; - } - G_WRITE_UNLOCK (&type_rw_lock); - g_static_rec_mutex_lock (&class_init_rec_mutex); /* required locking order: 1) class_init_rec_mutex, 2) type_rw_lock */ - G_WRITE_LOCK (&type_rw_lock); - type_data_last_unref_Wm (node_type, uncached); - g_static_rec_mutex_unlock (&class_init_rec_mutex); - } -} - static gboolean iface_node_has_available_offset_L (TypeNode *iface_node, int offset, @@ -2272,17 +2248,15 @@ type_data_finalize_class_U (TypeNode *node, } static void -type_data_last_unref_Wm (GType type, - gboolean uncached) +type_data_last_unref_Wm (TypeNode *node, + gboolean uncached) { - TypeNode *node = lookup_type_node_I (type); - g_return_if_fail (node != NULL && node->plugin != NULL); if (!node->data || node->ref_count == 0) { g_warning ("cannot drop last reference to unreferenced type `%s'", - type_descriptive_name_I (type)); + NODE_NAME (node)); return; } @@ -2370,6 +2344,29 @@ type_data_last_unref_Wm (GType type, } } +static inline void +type_data_unref_WmREC (TypeNode *node, + gboolean uncached) +{ + g_assert (node->data && node->ref_count); + if (node->ref_count > 1) + node->ref_count -= 1; + else + { + if (!node->plugin) + { + g_warning ("static type `%s' unreferenced too often", + NODE_NAME (node)); + return; + } + G_WRITE_UNLOCK (&type_rw_lock); + g_static_rec_mutex_lock (&class_init_rec_mutex); /* required locking order: 1) class_init_rec_mutex, 2) type_rw_lock */ + G_WRITE_LOCK (&type_rw_lock); + type_data_last_unref_Wm (node, uncached); + g_static_rec_mutex_unlock (&class_init_rec_mutex); + } +} + /** * g_type_add_class_cache_func: * @cache_data: data to be passed to @cache_func