[PATCH v2] Fix saving of multiple modified files on quit

Previously, file modifications could be lost when quitting meld
when multiple diff panes were open and more than 1 of the panes
had file modifications.  Quitting would prompt the user to
Discard/Cancel/Save the changes in one of the modified panes.  Pressing
"Discard Changes" would result in Meld quitting immediately without
prompting the user if they wanted to save the other modified files.

This issue only occurred if multiple files were open, eg when using
Meld to diff/modify multiple files in a version-controlled directory.

Signed-off-by: Peter Tyser <ptyser gmail com>
Changes since v1:
- Changed functionality to match Kai's description at http://mail.gnome.org/archives/meld-list/2010-April/msg00011.html

 meld/meldapp.py |   16 ++++++++++------
 1 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/meld/meldapp.py b/meld/meldapp.py
index 7de8ab3..b55afe4 100644
--- a/meld/meldapp.py
+++ b/meld/meldapp.py
@@ -642,12 +642,14 @@ class MeldApp(gnomeglade.Component):
     def on_menu_quit_activate(self, *extra):
-        for c in self.notebook.get_children():
-            response = c.get_data("pyobject").on_delete_event(appquit=1)
+        # Delete pages from right-to-left.  This ensures that if a version
+        # control page is open in the far left page, it will be closed last.
+        for c in reversed(self.notebook.get_children()):
+            page = c.get_data("pyobject")
+            self.notebook.set_current_page(self.notebook.page_num(page.widget))
+            response = self.try_remove_page(page, appquit=1)
             if response == gtk.RESPONSE_CANCEL:
                 return gtk.RESPONSE_CANCEL
-            elif response == gtk.RESPONSE_CLOSE:
-                break
         for c in self.notebook.get_children():
@@ -746,9 +748,10 @@ class MeldApp(gnomeglade.Component):
     def on_toolbar_stop_clicked(self, *args):
-    def try_remove_page(self, page):
+    def try_remove_page(self, page, appquit=0):
         "See if a page will allow itself to be removed"
-        if page.on_delete_event() != gtk.RESPONSE_CANCEL:
+        response = page.on_delete_event(appquit)
+        if response != gtk.RESPONSE_CANCEL:
             self.scheduler.remove_scheduler( page.scheduler )
             i = self.notebook.page_num( page.widget )
@@ -758,6 +761,7 @@ class MeldApp(gnomeglade.Component):
             if self.notebook.get_n_pages() == 0:
+        return response
     def on_file_changed(self, srcpage, filename):
         for c in self.notebook.get_children():

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