[nautilus/gnome-3-10] application: Ignore windows that are not NautilusWindow when using gtk_application_get_windows () to
- From: Robert Ancell <rancell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus/gnome-3-10] application: Ignore windows that are not NautilusWindow when using gtk_application_get_windows () to
- Date: Wed, 23 Apr 2014 21:22:43 +0000 (UTC)
commit ee3c41b37ce3d724593299a664700bc49100bd64
Author: Robert Ancell <robert ancell canonical com>
Date: Wed Apr 23 11:57:12 2014 +1200
application: Ignore windows that are not NautilusWindow when using gtk_application_get_windows () to
avoid crashes when accessing things like GtkDialog.
Nautilus crashes on startup if the "required directories missing" dialog
appears. This is because the code is mistakenly assuming that
gtk_application_get_windows() only contains objects of type NautilusWindow. The
dialog is an object of type GtkDialog.
https://bugzilla.gnome.org/show_bug.cgi?id=728765
src/nautilus-application.c | 32 +++++++++++++++-----------------
1 files changed, 15 insertions(+), 17 deletions(-)
---
diff --git a/src/nautilus-application.c b/src/nautilus-application.c
index 21b22cf..1900e90 100644
--- a/src/nautilus-application.c
+++ b/src/nautilus-application.c
@@ -492,11 +492,10 @@ static gboolean
another_navigation_window_already_showing (NautilusApplication *application,
NautilusWindow *the_window)
{
- GList *list, *item;
+ GList *l;
- list = gtk_application_get_windows (GTK_APPLICATION (application));
- for (item = list; item != NULL; item = item->next) {
- if (item->data != the_window) {
+ for (l = gtk_application_get_windows (GTK_APPLICATION (application)); l; l = l->next) {
+ if (NAUTILUS_IS_WINDOW (l->data) && l->data != the_window) {
return TRUE;
}
}
@@ -563,12 +562,10 @@ get_window_slot_for_location (NautilusApplication *application, GFile *location)
}
for (l = gtk_application_get_windows (GTK_APPLICATION (application)); l; l = l->next) {
- NautilusWindow *win = NAUTILUS_WINDOW (l->data);
-
- if (NAUTILUS_IS_DESKTOP_WINDOW (win))
+ if (!NAUTILUS_IS_WINDOW (l->data) || NAUTILUS_IS_DESKTOP_WINDOW (l->data))
continue;
- for (sl = nautilus_window_get_slots (win); sl; sl = sl->next) {
+ for (sl = nautilus_window_get_slots (NAUTILUS_WINDOW (l->data)); sl; sl = sl->next) {
NautilusWindowSlot *current = NAUTILUS_WINDOW_SLOT (sl->data);
GFile *slot_location = nautilus_window_slot_get_location (current);
@@ -942,11 +939,13 @@ action_quit (GSimpleAction *action,
gpointer user_data)
{
GtkApplication *application = user_data;
- GList *windows;
+ GList *l;
/* nautilus_window_close() doesn't do anything for desktop windows */
- windows = gtk_application_get_windows (application);
- g_list_foreach (windows, (GFunc) nautilus_window_close, NULL);
+ for (l = gtk_application_get_windows (GTK_APPLICATION (application)); l; l = l->next) {
+ if (NAUTILUS_IS_WINDOW (l->data))
+ nautilus_window_close (NAUTILUS_WINDOW (l->data));
+ }
}
static void
@@ -1650,13 +1649,10 @@ update_dbus_opened_locations (NautilusApplication *app)
g_return_if_fail (NAUTILUS_IS_APPLICATION (app));
for (l = gtk_application_get_windows (GTK_APPLICATION (app)); l; l = l->next) {
- NautilusWindow *win = NAUTILUS_WINDOW (l->data);
-
- if (NAUTILUS_IS_DESKTOP_WINDOW (win)) {
+ if (!NAUTILUS_IS_WINDOW (l->data) || NAUTILUS_IS_DESKTOP_WINDOW (l->data))
continue;
- }
- for (sl = nautilus_window_get_slots (win); sl; sl = sl->next) {
+ for (sl = nautilus_window_get_slots (NAUTILUS_WINDOW (l->data)); sl; sl = sl->next) {
NautilusWindowSlot *slot = NAUTILUS_WINDOW_SLOT (sl->data);
gchar *uri = nautilus_window_slot_get_location_uri (slot);
@@ -1736,12 +1732,14 @@ nautilus_application_window_removed (GtkApplication *app,
GtkWindow *window)
{
NautilusPreviewer *previewer;
+ GList *l;
/* chain to parent */
GTK_APPLICATION_CLASS (nautilus_application_parent_class)->window_removed (app, window);
/* if this was the last window, close the previewer */
- if (g_list_length (gtk_application_get_windows (app)) == 0) {
+ for (l = gtk_application_get_windows (GTK_APPLICATION (app)); l && !NAUTILUS_IS_WINDOW (l->data); l =
l->next);
+ if (!l) {
previewer = nautilus_previewer_get_singleton ();
nautilus_previewer_call_close (previewer);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]