summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Soriano <csoriano@gnome.org>2016-04-26 10:32:34 +0200
committerCarlos Soriano <csoriano@gnome.org>2016-04-26 10:38:39 +0200
commit6ffaf5ea66da7772cba6a091b26b41dc9c0e5e70 (patch)
treeb6779025bfbf1caceaff9711d51c68635fa95efa
parent020e405414eea963524c4347767430d46481f9b7 (diff)
downloadnautilus-6ffaf5ea66da7772cba6a091b26b41dc9c0e5e70.tar.gz
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
-rw-r--r--src/nautilus-application.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/nautilus-application.c b/src/nautilus-application.c
index de136cb61..2a0d402d3 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)");