[gtk+] GtkApplication: Do not assert sm_proxy != NULL in inhibit functions



commit 0e350eeea6d962f9edb4a381b7388166d99e2763
Author: Matt Barnes <mbarnes redhat com>
Date:   Sun Jul 28 16:09:58 2013 -0400

    GtkApplication: Do not assert sm_proxy != NULL in inhibit functions
    
    Applications have no way of finding out if a session manager proxy was
    successfully created in gtk_application_startup_session_dbus(), so it's not
    appropriate for certain public GtkApplication functions to be asserting the
    presence of a session manager proxy as if it were a programmer error.
    
    This affects:
    
       gtk_application_inhibit()
       gtk_application_is_inhibited()
    
    If sm_proxy is NULL, the function should just return silently.
    
    In the case of gtk_application_uninhibit(), the application should only be
    calling this if it obtained a valid cookie, which implies the presence of a
    session manager proxy.  I noted that with a comment.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=701365

 gtk/gtkapplication.c |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)
---
diff --git a/gtk/gtkapplication.c b/gtk/gtkapplication.c
index ed638a7..2727ece 100644
--- a/gtk/gtkapplication.c
+++ b/gtk/gtkapplication.c
@@ -1418,7 +1418,9 @@ gtk_application_inhibit (GtkApplication             *application,
 
   g_return_val_if_fail (GTK_IS_APPLICATION (application), 0);
   g_return_val_if_fail (!g_application_get_is_remote (G_APPLICATION (application)), 0);
-  g_return_val_if_fail (application->priv->sm_proxy != NULL, 0);
+
+  if (application->priv->sm_proxy == NULL)
+    return 0;
 
   if (window != NULL)
     {
@@ -1473,6 +1475,10 @@ gtk_application_uninhibit (GtkApplication *application,
 {
   g_return_if_fail (GTK_IS_APPLICATION (application));
   g_return_if_fail (!g_application_get_is_remote (G_APPLICATION (application)));
+  g_return_if_fail (cookie > 0);
+
+  /* Application could only obtain a cookie through a session
+   * manager proxy, so it's valid to assert its presence here. */
   g_return_if_fail (application->priv->sm_proxy != NULL);
 
   g_dbus_proxy_call (application->priv->sm_proxy,
@@ -1505,7 +1511,9 @@ gtk_application_is_inhibited (GtkApplication             *application,
 
   g_return_val_if_fail (GTK_IS_APPLICATION (application), FALSE);
   g_return_val_if_fail (!g_application_get_is_remote (G_APPLICATION (application)), FALSE);
-  g_return_val_if_fail (application->priv->sm_proxy != NULL, FALSE);
+
+  if (application->priv->sm_proxy == NULL)
+    return FALSE;
 
   res = g_dbus_proxy_call_sync (application->priv->sm_proxy,
                                 "IsInhibited",


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