Code

When closing a window and while asking whether to save, Inkscape should not be mislea...
authordvlierop2 <dvlierop2@users.sourceforge.net>
Sat, 6 Jun 2009 21:41:18 +0000 (21:41 +0000)
committerdvlierop2 <dvlierop2@users.sourceforge.net>
Sat, 6 Jun 2009 21:41:18 +0000 (21:41 +0000)
src/interface.cpp

index d628d964d3bc10bfc5e2e62546101d91de8fe7e4..a751608c582bc80c6f9b1741860e87414e107a92 100644 (file)
@@ -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;