[glib/glib-2-28] GApplication: Check more before warning about a missing signal handler.



commit a01af94c35f52b69870e83f9212e04e65f7ef169
Author: Murray Cumming <murrayc murrayc com>
Date:   Mon Feb 28 11:15:13 2011 +0100

    GApplication: Check more before warning about a missing signal handler.
    
    * gio/application.c (g_application_real_command_line): Check that the
    default signal handler is not the current one before complaining, because
    it is not unusual for overloads to call the base class implementation as
    a matter of habit.
    g_application_real_open() and g_application_real_activate() already do this
    extra check.

 gio/gapplication.c |   22 ++++++++++++++--------
 1 files changed, 14 insertions(+), 8 deletions(-)
---
diff --git a/gio/gapplication.c b/gio/gapplication.c
index 6cacb1e..c21cd9e 100644
--- a/gio/gapplication.c
+++ b/gio/gapplication.c
@@ -255,18 +255,24 @@ static int
 g_application_real_command_line (GApplication            *application,
                                  GApplicationCommandLine *cmdline)
 {
-  static gboolean warned;
+  if (!g_signal_has_handler_pending (application,
+                                     g_application_signals[SIGNAL_COMMAND_LINE],
+                                     0, TRUE) &&
+      G_APPLICATION_GET_CLASS (application)->command_line == g_application_real_command_line)
+    {
+      static gboolean warned;
 
-  if (warned) 
-    return 1;
+      if (warned) 
+        return 1;
 
-  g_warning ("Your application claims to support custom command line "
-             "handling but does not implement g_application_command_line() "
-             "and has no handlers connected to the 'command-line' signal.");
+      g_warning ("Your application claims to support custom command line "
+                 "handling but does not implement g_application_command_line() "
+                 "and has no handlers connected to the 'command-line' signal.");
 
-  warned = TRUE;
+      warned = TRUE;
+    }
 
-  return 1;
+    return 1;
 }
 
 static gboolean



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]