[evolution/gnome-3-18] Address crashes related to second instance execution



commit 8178105e48a28bbfbf91f563925cc8e7ac3f3639
Author: Milan Crha <mcrha redhat com>
Date:   Fri Jan 15 15:40:24 2016 +0100

    Address crashes related to second instance execution
    
    This is related to bug 755743 (Cannot open new window from overview),
    but without the chunk to fix the evolution.desktop file, thus it doesn't
    fully fix the bug report. It's still good to have it, due to the crash
    fixes.

 shell/e-shell.c |   64 ++++++++++++++++++++++++++++++-------------------------
 shell/main.c    |   12 +++++++--
 2 files changed, 44 insertions(+), 32 deletions(-)
---
diff --git a/shell/e-shell.c b/shell/e-shell.c
index c367f76..5e73f01 100644
--- a/shell/e-shell.c
+++ b/shell/e-shell.c
@@ -179,30 +179,47 @@ shell_action_new_window_cb (GSimpleAction *action,
                             EShell *shell)
 {
        GtkApplication *application;
-       GList *list;
        const gchar *view_name;
 
        application = GTK_APPLICATION (shell);
-       list = gtk_application_get_windows (application);
 
-       view_name = g_variant_get_string (parameter, NULL);
+       view_name = parameter ? g_variant_get_string (parameter, NULL) : NULL;
+       if (view_name && !*view_name)
+               view_name = NULL;
 
-       /* Present the first EShellWindow showing 'view_name'. */
-       while (list != NULL) {
-               GtkWindow *window = GTK_WINDOW (list->data);
+       if (view_name) {
+               GList *list;
+               gboolean get_current = g_strcmp0 (view_name, "current") == 0;
 
-               if (E_IS_SHELL_WINDOW (window)) {
-                       const gchar *active_view;
+               list = gtk_application_get_windows (application);
 
-                       active_view = e_shell_window_get_active_view (
-                               E_SHELL_WINDOW (window));
-                       if (g_strcmp0 (active_view, view_name) == 0) {
-                               gtk_window_present (window);
-                               return;
+               /* Present the first EShellWindow showing 'view_name'. */
+               while (list != NULL) {
+                       GtkWindow *window = GTK_WINDOW (list->data);
+
+                       if (E_IS_SHELL_WINDOW (window)) {
+                               const gchar *active_view;
+
+                               active_view = e_shell_window_get_active_view (
+                                       E_SHELL_WINDOW (window));
+                               if (g_strcmp0 (active_view, view_name) == 0) {
+                                       gtk_window_present (window);
+                                       return;
+                               } else if (get_current && active_view) {
+                                       view_name = active_view;
+                                       break;
+                               }
                        }
+
+                       list = g_list_next (list);
                }
+       } else {
+               GtkWindow *window;
 
-               list = g_list_next (list);
+               window = e_shell_get_active_window (shell);
+
+               if (E_IS_SHELL_WINDOW (window))
+                       view_name = e_shell_window_get_active_view (E_SHELL_WINDOW (window));
        }
 
        /* No suitable EShellWindow found, so create one. */
@@ -262,7 +279,7 @@ shell_add_actions (GApplication *application)
 
        /* Add actions that remote instances can invoke. */
 
-       action = g_simple_action_new ("new-window", G_VARIANT_TYPE_STRING);
+       action = g_simple_action_new ("create-from-remote", G_VARIANT_TYPE_STRING);
        g_signal_connect (
                action, "activate",
                G_CALLBACK (shell_action_new_window_cb), application);
@@ -1159,15 +1176,7 @@ shell_app_menu_activate_cb (GSimpleAction *action,
        g_return_if_fail (name != NULL);
 
        if (g_str_equal (name, "new-window")) {
-               GtkWindow *window;
-
-               window = e_shell_get_active_window (shell);
-
-               if (E_IS_SHELL_WINDOW (window))
-                       e_shell_create_shell_window (shell,
-                               e_shell_window_get_active_view (E_SHELL_WINDOW (window)));
-               else
-                       e_shell_create_shell_window (shell, NULL);
+               shell_action_new_window_cb (action, parameter, shell);
        } else if (g_str_equal (name, "preferences")) {
                e_shell_utils_run_preferences (shell);
        } else if (g_str_equal (name, "quick-reference")) {
@@ -1176,8 +1185,6 @@ shell_app_menu_activate_cb (GSimpleAction *action,
                e_shell_utils_run_help_contents (shell);
        } else if (g_str_equal (name, "about")) {
                e_shell_utils_run_help_about (shell);
-       } else if (g_str_equal (name, "quit")) {
-               e_shell_quit (shell, E_SHELL_QUIT_ACTION);
        } else {
                g_warning ("%s: Unknown app-menu action '%s'", G_STRFUNC, name);
        }
@@ -1191,8 +1198,7 @@ shell_create_app_menu (GtkApplication *application)
                { "preferences", shell_app_menu_activate_cb, NULL, NULL, NULL },
                { "quick-reference", shell_app_menu_activate_cb, NULL, NULL, NULL },
                { "help", shell_app_menu_activate_cb, NULL, NULL, NULL },
-               { "about", shell_app_menu_activate_cb, NULL, NULL, NULL },
-               { "quit", shell_app_menu_activate_cb, NULL, NULL, NULL }
+               { "about", shell_app_menu_activate_cb, NULL, NULL, NULL }
        };
        GMenu *app_menu, *section;
 
@@ -2262,7 +2268,7 @@ remote:  /* Send a message to the other Evolution process. */
 
        if (view_name != NULL) {
                g_action_group_activate_action (
-                       G_ACTION_GROUP (shell), "new-window",
+                       G_ACTION_GROUP (shell), "create-from-remote",
                        g_variant_new_string (view_name));
        } else
                g_application_activate (G_APPLICATION (shell));
diff --git a/shell/main.c b/shell/main.c
index eded077..b96cb8b 100644
--- a/shell/main.c
+++ b/shell/main.c
@@ -605,9 +605,15 @@ main (gint argc,
                goto exit;
        }
 
-       if (g_application_get_is_remote (G_APPLICATION (shell)) &&
-           remaining_args && *remaining_args) {
-               e_shell_handle_uris (shell, (const gchar * const *) remaining_args, import_uris);
+       if (g_application_get_is_remote (G_APPLICATION (shell))) {
+               if (remaining_args && *remaining_args)
+                       e_shell_handle_uris (shell, (const gchar * const *) remaining_args, import_uris);
+
+               /* This will be redirected to the previously run instance,
+                  because this instance is remote. */
+               if (requested_view && *requested_view)
+                       e_shell_create_shell_window (shell, requested_view);
+
                goto exit;
        }
 


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