mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-11-09 19:06:15 +01:00
Add G_SIGNAL_DEPRECATED
Similar to G_PARAM_DEPRECATED. It will warn only for users of the signals, so a signal can still be emited without warning, for compatibility reasons. Apparently, there is no way user flags could have been used before, so that shouldn't break anyone. https://bugzilla.gnome.org/show_bug.cgi?id=663581
This commit is contained in:
parent
f09e71aff0
commit
fb95c20c96
@ -1171,7 +1171,7 @@ object_set_property (GObject *object,
|
||||
if (enable_diagnostic[0] == '1')
|
||||
{
|
||||
if (pspec->flags & G_PARAM_DEPRECATED)
|
||||
g_warning ("The property %s::%s is deprecated and shouldn't be used "
|
||||
g_warning ("The property %s:%s is deprecated and shouldn't be used "
|
||||
"anymore. It will be removed in a future version.",
|
||||
G_OBJECT_TYPE_NAME (object), pspec->name);
|
||||
}
|
||||
|
@ -180,6 +180,7 @@ static gboolean signal_emit_unlocked_R (SignalNode *node,
|
||||
GValue *return_value,
|
||||
const GValue *instance_and_params);
|
||||
static const gchar * type_debug_name (GType type);
|
||||
static void node_check_deprecated (const SignalNode *node);
|
||||
|
||||
|
||||
/* --- structures --- */
|
||||
@ -205,7 +206,7 @@ struct _SignalNode
|
||||
|
||||
/* reinitializable portion */
|
||||
guint test_class_offset : 12;
|
||||
guint flags : 8;
|
||||
guint flags : 9;
|
||||
guint n_params : 8;
|
||||
GType *param_types; /* mangled with G_SIGNAL_TYPE_STATIC_SCOPE flag */
|
||||
GType return_type; /* mangled with G_SIGNAL_TYPE_STATIC_SCOPE flag */
|
||||
@ -929,6 +930,9 @@ g_signal_add_emission_hook (guint signal_id,
|
||||
g_hook_list_init (node->emission_hooks, sizeof (SignalHook));
|
||||
node->emission_hooks->finalize_hook = signal_finalize_hook;
|
||||
}
|
||||
|
||||
node_check_deprecated (node);
|
||||
|
||||
hook = g_hook_alloc (node->emission_hooks);
|
||||
hook->data = hook_data;
|
||||
hook->func = (gpointer) hook_func;
|
||||
@ -1804,6 +1808,7 @@ g_signal_override_class_closure (guint signal_id,
|
||||
|
||||
SIGNAL_LOCK ();
|
||||
node = LOOKUP_SIGNAL_NODE (signal_id);
|
||||
node_check_deprecated (node);
|
||||
if (!g_type_is_a (instance_type, node->itype))
|
||||
g_warning ("%s: type `%s' cannot be overridden for signal id `%u'", G_STRLOC, type_debug_name (instance_type), signal_id);
|
||||
else
|
||||
@ -2229,6 +2234,29 @@ g_signal_connect_closure (gpointer instance,
|
||||
return handler_seq_no;
|
||||
}
|
||||
|
||||
static void
|
||||
node_check_deprecated (const SignalNode *node)
|
||||
{
|
||||
static const gchar * g_enable_diagnostic = NULL;
|
||||
|
||||
if (G_UNLIKELY (!g_enable_diagnostic))
|
||||
{
|
||||
g_enable_diagnostic = g_getenv ("G_ENABLE_DIAGNOSTIC");
|
||||
if (!g_enable_diagnostic)
|
||||
g_enable_diagnostic = "0";
|
||||
}
|
||||
|
||||
if (g_enable_diagnostic[0] == '1')
|
||||
{
|
||||
if (node->flags & G_SIGNAL_DEPRECATED)
|
||||
{
|
||||
g_warning ("The signal %s::%s is deprecated and shouldn't be used "
|
||||
"anymore. It will be removed in a future version.",
|
||||
type_debug_name (node->itype), node->name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* g_signal_connect_data:
|
||||
* @instance: the instance to connect to.
|
||||
@ -2274,6 +2302,8 @@ g_signal_connect_data (gpointer instance,
|
||||
{
|
||||
SignalNode *node = LOOKUP_SIGNAL_NODE (signal_id);
|
||||
|
||||
node_check_deprecated (node);
|
||||
|
||||
if (detail && !(node->flags & G_SIGNAL_DETAILED))
|
||||
g_warning ("%s: signal `%s' does not support details", G_STRLOC, detailed_signal);
|
||||
else if (!g_type_is_a (itype, node->itype))
|
||||
|
@ -110,6 +110,9 @@ typedef gboolean (*GSignalAccumulator) (GSignalInvocationHint *ihint,
|
||||
* @G_SIGNAL_NO_HOOKS: No emissions hooks are supported for this signal.
|
||||
* @G_SIGNAL_MUST_COLLECT: Varargs signal emission will always collect the
|
||||
* arguments, even if there are no signal handlers connected. Since 2.30.
|
||||
* @G_SIGNAL_DEPRECATED: The signal is deprecated and will be removed
|
||||
* in a future version. A warning will be generated if it is connected while
|
||||
* running with G_ENABLE_DIAGNOSTIC=1. Since 2.32.
|
||||
*
|
||||
* The signal flags are used to specify a signal's behaviour, the overall
|
||||
* signal description outlines how especially the RUN flags control the
|
||||
@ -124,14 +127,15 @@ typedef enum
|
||||
G_SIGNAL_DETAILED = 1 << 4,
|
||||
G_SIGNAL_ACTION = 1 << 5,
|
||||
G_SIGNAL_NO_HOOKS = 1 << 6,
|
||||
G_SIGNAL_MUST_COLLECT = 1 << 7
|
||||
G_SIGNAL_MUST_COLLECT = 1 << 7,
|
||||
G_SIGNAL_DEPRECATED = 1 << 8,
|
||||
} GSignalFlags;
|
||||
/**
|
||||
* G_SIGNAL_FLAGS_MASK:
|
||||
*
|
||||
* A mask for all #GSignalFlags bits.
|
||||
*/
|
||||
#define G_SIGNAL_FLAGS_MASK 0xff
|
||||
#define G_SIGNAL_FLAGS_MASK 0x1ff
|
||||
/**
|
||||
* GConnectFlags:
|
||||
* @G_CONNECT_AFTER: whether the handler should be called before or after the
|
||||
|
Loading…
Reference in New Issue
Block a user