[nautilus] application: protect against having no window



commit 6ffaf5ea66da7772cba6a091b26b41dc9c0e5e70
Author: Carlos Soriano <csoriano gnome org>
Date:   Tue Apr 26 10:32:34 2016 +0200

    application: protect against having no window
    
    If nautilus is run with --gapplication-service it has no active window
    active.
    
    We were assuming there is always a window active, and therefore nautilus
    was crashing if the active window was null.
    
    To fix it add some safe guards.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=765045

 src/nautilus-application.c |   15 ++++++++++-----
 1 files changed, 10 insertions(+), 5 deletions(-)
---
diff --git a/src/nautilus-application.c b/src/nautilus-application.c
index de136cb..2a0d402 100644
--- a/src/nautilus-application.c
+++ b/src/nautilus-application.c
@@ -341,9 +341,9 @@ real_open_location_full (NautilusApplication     *self,
                          NautilusWindow          *target_window,
                          NautilusWindowSlot      *target_slot)
 {
-        NautilusWindowSlot *active_slot;
+        NautilusWindowSlot *active_slot = NULL;
         NautilusWindow *active_window;
-        GFile *old_location;
+        GFile *old_location = NULL;
        char *old_uri, *new_uri;
        gboolean use_same;
 
@@ -353,11 +353,16 @@ real_open_location_full (NautilusApplication     *self,
          * so what we do is never rely on this on the callers, but would be cool to
         * make it work withouth explicitly setting the active window on the callers. */
         active_window = NAUTILUS_WINDOW (gtk_application_get_active_window (GTK_APPLICATION (self)));
-        active_slot = nautilus_window_get_active_slot (active_window);
+        /* There is no active window if the application is run with
+         * --gapplication-service
+         */
+        if (active_window) {
+                active_slot = nautilus_window_get_active_slot (active_window);
+                /* Just for debug.*/
+                old_location = nautilus_window_slot_get_location (active_slot);
+        }
 
-       /* Just for debug.*/
 
-       old_location = nautilus_window_slot_get_location (active_slot);
         /* this happens at startup */
         if (old_location == NULL)
                old_uri = g_strdup ("(none)");


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