[gnome-software/wip/ubuntu-changes] Only quit if we're not running as a GApplication service



commit c66c12e634c1c807bbcbb287a2b36e91009068a7
Author: William Hua <william hua canonical com>
Date:   Tue Mar 8 16:06:44 2016 -0500

    Only quit if we're not running as a GApplication service
    
    We were destroying the window explicitly even when the application was
    running as a service, causing subsequent activations to crash since the
    window was already destroyed.
    
    See also
    https://bugs.launchpad.net/ubuntu/+source/gnome-software/+bug/1552150.

 src/gs-shell.c |   19 +++++++++++++++++--
 1 files changed, 17 insertions(+), 2 deletions(-)
---
diff --git a/src/gs-shell.c b/src/gs-shell.c
index d5d8d5f..119405a 100644
--- a/src/gs-shell.c
+++ b/src/gs-shell.c
@@ -516,6 +516,13 @@ main_window_closed_cb (GtkWidget *dialog, GdkEvent *event, gpointer user_data)
        return TRUE;
 }
 
+static void
+main_window_destroyed_cb (GtkWidget *widget,
+                         GsShell   *shell)
+{
+       g_action_group_activate_action (G_ACTION_GROUP (g_application_get_default ()), "quit", NULL);
+}
+
 /**
  * gs_shell_updates_changed_cb:
  */
@@ -591,6 +598,7 @@ void
 gs_shell_setup (GsShell *shell, GsPluginLoader *plugin_loader, GCancellable *cancellable)
 {
        GsShellPrivate *priv = gs_shell_get_instance_private (shell);
+       GApplicationFlags flags;
        GtkWidget *widget;
 
        g_return_if_fail (GS_IS_SHELL (shell));
@@ -612,8 +620,15 @@ gs_shell_setup (GsShell *shell, GsPluginLoader *plugin_loader, GCancellable *can
        gtk_icon_theme_append_search_path (gtk_icon_theme_get_default (),
                                           GS_DATA G_DIR_SEPARATOR_S "icons");
 
-       g_signal_connect (priv->main_window, "delete-event",
-                         G_CALLBACK (main_window_closed_cb), shell);
+       flags = g_application_get_flags (g_application_get_default ());
+
+       if (flags & G_APPLICATION_IS_SERVICE) {
+               g_signal_connect (priv->main_window, "delete-event",
+                                 G_CALLBACK (main_window_closed_cb), shell);
+       } else {
+               g_signal_connect (priv->main_window, "destroy",
+                                 G_CALLBACK (main_window_destroyed_cb), shell);
+       }
 
        /* fix up the header bar */
        widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "header"));


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