mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-04-22 15:19:16 +02:00
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
This commit is contained in:
parent
718b476c44
commit
f8d24e8495
@ -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_ref_Wm (TypeNode *node);
|
||||||
static inline void type_data_unref_WmREC (TypeNode *node,
|
static inline void type_data_unref_WmREC (TypeNode *node,
|
||||||
gboolean uncached);
|
gboolean uncached);
|
||||||
static void type_data_last_unref_Wm (GType type,
|
static void type_data_last_unref_Wm (TypeNode * node,
|
||||||
gboolean uncached);
|
gboolean uncached);
|
||||||
static inline gpointer type_get_qdata_L (TypeNode *node,
|
static inline gpointer type_get_qdata_L (TypeNode *node,
|
||||||
GQuark quark);
|
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
|
static gboolean
|
||||||
iface_node_has_available_offset_L (TypeNode *iface_node,
|
iface_node_has_available_offset_L (TypeNode *iface_node,
|
||||||
int offset,
|
int offset,
|
||||||
@ -2272,17 +2248,15 @@ type_data_finalize_class_U (TypeNode *node,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
type_data_last_unref_Wm (GType type,
|
type_data_last_unref_Wm (TypeNode *node,
|
||||||
gboolean uncached)
|
gboolean uncached)
|
||||||
{
|
{
|
||||||
TypeNode *node = lookup_type_node_I (type);
|
|
||||||
|
|
||||||
g_return_if_fail (node != NULL && node->plugin != NULL);
|
g_return_if_fail (node != NULL && node->plugin != NULL);
|
||||||
|
|
||||||
if (!node->data || node->ref_count == 0)
|
if (!node->data || node->ref_count == 0)
|
||||||
{
|
{
|
||||||
g_warning ("cannot drop last reference to unreferenced type `%s'",
|
g_warning ("cannot drop last reference to unreferenced type `%s'",
|
||||||
type_descriptive_name_I (type));
|
NODE_NAME (node));
|
||||||
return;
|
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:
|
* g_type_add_class_cache_func:
|
||||||
* @cache_data: data to be passed to @cache_func
|
* @cache_data: data to be passed to @cache_func
|
||||||
|
Loading…
x
Reference in New Issue
Block a user