[glib] gsignal: improve warning output
- From: Ryan Lortie <ryanl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] gsignal: improve warning output
- Date: Fri, 22 Feb 2013 00:54:56 +0000 (UTC)
commit f5d40bd8138991287bbdc2e249bd35cf82caf123
Author: Ryan Lortie <desrt desrt ca>
Date: Thu Feb 21 11:25:26 2013 +0000
gsignal: improve warning output
When looking up signals by name (to connect, for example) and the named
signal cannot be found on the given instance, report the type of the
instance.
This is quite a lot more useful as a diagnostic message than only a
memory address.
https://bugzilla.gnome.org/show_bug.cgi?id=694350
gobject/gsignal.c | 26 ++++++++++++++++++--------
1 files changed, 18 insertions(+), 8 deletions(-)
---
diff --git a/gobject/gsignal.c b/gobject/gsignal.c
index e2a8439..f5942ab 100644
--- a/gobject/gsignal.c
+++ b/gobject/gsignal.c
@@ -1157,7 +1157,8 @@ g_signal_stop_emission_by_name (gpointer instance,
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))
- g_warning ("%s: signal `%s' is invalid for instance `%p'", G_STRLOC, detailed_signal, instance);
+ g_warning ("%s: signal `%s' is invalid for instance `%p' of type `%s'",
+ G_STRLOC, detailed_signal, instance, g_type_name (itype));
else
{
Emission *emission_list = node->flags & G_SIGNAL_NO_RECURSE ? g_restart_emissions :
g_recursive_emissions;
@@ -1177,7 +1178,8 @@ g_signal_stop_emission_by_name (gpointer instance,
}
}
else
- g_warning ("%s: signal `%s' is invalid for instance `%p'", G_STRLOC, detailed_signal, instance);
+ g_warning ("%s: signal `%s' is invalid for instance `%p' of type `%s'",
+ G_STRLOC, detailed_signal, instance, g_type_name (itype));
SIGNAL_UNLOCK ();
}
@@ -2348,7 +2350,8 @@ g_signal_connect_closure (gpointer instance,
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))
- g_warning ("%s: signal `%s' is invalid for instance `%p'", G_STRLOC, detailed_signal, instance);
+ g_warning ("%s: signal `%s' is invalid for instance `%p' of type `%s'",
+ G_STRLOC, detailed_signal, instance, g_type_name (itype));
else
{
Handler *handler = handler_new (after);
@@ -2368,7 +2371,8 @@ g_signal_connect_closure (gpointer instance,
}
}
else
- g_warning ("%s: signal `%s' is invalid for instance `%p'", G_STRLOC, detailed_signal, instance);
+ g_warning ("%s: signal `%s' is invalid for instance `%p' of type `%s'",
+ G_STRLOC, detailed_signal, instance, g_type_name (itype));
SIGNAL_UNLOCK ();
return handler_seq_no;
@@ -2447,7 +2451,8 @@ g_signal_connect_data (gpointer instance,
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))
- g_warning ("%s: signal `%s' is invalid for instance `%p'", G_STRLOC, detailed_signal, instance);
+ g_warning ("%s: signal `%s' is invalid for instance `%p' of type `%s'",
+ G_STRLOC, detailed_signal, instance, g_type_name (itype));
else
{
Handler *handler = handler_new (after);
@@ -2466,7 +2471,8 @@ g_signal_connect_data (gpointer instance,
}
}
else
- g_warning ("%s: signal `%s' is invalid for instance `%p'", G_STRLOC, detailed_signal, instance);
+ g_warning ("%s: signal `%s' is invalid for instance `%p' of type `%s'",
+ G_STRLOC, detailed_signal, instance, g_type_name (itype));
SIGNAL_UNLOCK ();
return handler_seq_no;
@@ -3399,12 +3405,15 @@ g_signal_emit_by_name (gpointer instance,
{
GQuark detail = 0;
guint signal_id;
+ GType itype;
g_return_if_fail (G_TYPE_CHECK_INSTANCE (instance));
g_return_if_fail (detailed_signal != NULL);
+ itype = G_TYPE_FROM_INSTANCE (instance);
+
SIGNAL_LOCK ();
- signal_id = signal_parse_name (detailed_signal, G_TYPE_FROM_INSTANCE (instance), &detail, TRUE);
+ signal_id = signal_parse_name (detailed_signal, itype, &detail, TRUE);
SIGNAL_UNLOCK ();
if (signal_id)
@@ -3416,7 +3425,8 @@ g_signal_emit_by_name (gpointer instance,
va_end (var_args);
}
else
- g_warning ("%s: signal name `%s' is invalid for instance `%p'", G_STRLOC, detailed_signal, instance);
+ g_warning ("%s: signal name `%s' is invalid for instance `%p' of type `%s'",
+ G_STRLOC, detailed_signal, instance, g_type_name (itype));
}
static gboolean
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]