From 748b743cdcd60581065cc1feef415a7a48cac261 Mon Sep 17 00:00:00 2001 From: dvlierop2 Date: Sat, 6 Jun 2009 21:41:18 +0000 Subject: [PATCH] When closing a window and while asking whether to save, Inkscape should not be mislead by changing focus to another document (fixes bug #381357) --- src/interface.cpp | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/src/interface.cpp b/src/interface.cpp index d628d964d..a751608c5 100644 --- a/src/interface.cpp +++ b/src/interface.cpp @@ -308,13 +308,19 @@ sp_ui_new_view_preview() void sp_ui_close_view(GtkWidget */*widget*/) { - if (SP_ACTIVE_DESKTOP == NULL) { + SPDesktop *dt = SP_ACTIVE_DESKTOP; + + if (dt == NULL) { return; } - if ((SP_ACTIVE_DESKTOP)->shutdown()) { - return; + + if (dt->shutdown()) { + return; // Shutdown operation has been canceled, so do nothing } - SP_ACTIVE_DESKTOP->destroyWidget(); + + // Shutdown can proceed; use the stored reference to the desktop here instead of the current SP_ACTIVE_DESKTOP, + // because the user might have changed the focus in the meantime (see bug #381357 on Launchpad) + dt->destroyWidget(); } @@ -335,11 +341,14 @@ sp_ui_close_all(void) /* Iterate through all the windows, destroying each in the order they become active */ while (SP_ACTIVE_DESKTOP) { - if ((SP_ACTIVE_DESKTOP)->shutdown()) { - /* The user cancelled the operation, so end doing the close */ + SPDesktop *dt = SP_ACTIVE_DESKTOP; + if (dt->shutdown()) { + /* The user canceled the operation, so end doing the close */ return FALSE; } - SP_ACTIVE_DESKTOP->destroyWidget(); + // Shutdown can proceed; use the stored reference to the desktop here instead of the current SP_ACTIVE_DESKTOP, + // because the user might have changed the focus in the meantime (see bug #381357 on Launchpad) + dt->destroyWidget(); } return TRUE; -- 2.30.2