[conduit/gsoc09_alexandre: 18/24] Terminate Conduit when an exception occurs when exiting (this works from the GUI too).



commit 0bd9695f090acf627c514a3abf9892946ff9f796
Author: Alexandre Rosenfeld <airmind gmail com>
Date:   Sat Aug 1 02:06:56 2009 -0300

    Terminate Conduit when an exception occurs when exiting (this works from the GUI too).

 conduit/Main.py |   64 +++++++++++++++++++++++++++++-------------------------
 1 files changed, 34 insertions(+), 30 deletions(-)
---
diff --git a/conduit/Main.py b/conduit/Main.py
index 89b78b9..beaaee1 100644
--- a/conduit/Main.py
+++ b/conduit/Main.py
@@ -274,36 +274,40 @@ class Application(dbus.service.Object):
 
     @dbus.service.method(APPLICATION_DBUS_IFACE, in_signature='', out_signature='')
     def Quit(self):
-        #Hide the GUI first, so we feel responsive    
-        log.info("Closing application")
-        if self.gui != None:
-            self.gui.mainWindow.hide()
-            if conduit.GLOBALS.settings.get("save_on_exit") == True:
-                self.gui.save_settings(None)
-
-        #Cancel all syncs
-        self.Cancel()
-
-        #give the dataprovider factories time to shut down
-        log.info("Closing dataprovider factories")
-        conduit.GLOBALS.moduleManager.quit()
-        
-        #unitialize all dataproviders
-        log.info("Unitializing dataproviders")
-        self.guiSyncSet.quit()
-        log.info("GUI Quit")
-        self.dbusSyncSet.quit()
-        log.info("DBus Quit")
-
-        #Save the mapping DB
-        conduit.GLOBALS.mappingDB.save()
-        conduit.GLOBALS.mappingDB.close()
-
-        #Save the application settings
-        conduit.GLOBALS.settings.save()
-        
-        log.info("Main Loop Quitting")
-        conduit.GLOBALS.mainloop.quit()
+        try:
+            #Hide the GUI first, so we feel responsive    
+            log.info("Closing application")
+            if self.gui != None:
+                self.gui.mainWindow.hide()
+                if conduit.GLOBALS.settings.get("save_on_exit") == True:
+                    self.gui.save_settings(None)
+
+            #Cancel all syncs
+            self.Cancel()
+
+            #give the dataprovider factories time to shut down
+            log.info("Closing dataprovider factories")
+            conduit.GLOBALS.moduleManager.quit()
+            
+            #unitialize all dataproviders
+            log.info("Unitializing dataproviders")
+            self.guiSyncSet.quit()
+            log.info("GUI Quit")
+            self.dbusSyncSet.quit()
+            log.info("DBus Quit")
+
+            #Save the mapping DB
+            conduit.GLOBALS.mappingDB.save()
+            conduit.GLOBALS.mappingDB.close()
+
+            #Save the application settings
+            conduit.GLOBALS.settings.save()
+            
+            log.info("Main Loop Quitting")
+            conduit.GLOBALS.mainloop.quit()
+        except:
+            log.error("Error exiting. Terminating application. %s" % traceback.format_exc())
+            sys.exit(-1)
 
     @dbus.service.method(APPLICATION_DBUS_IFACE, in_signature='', out_signature='')
     def Synchronize(self):



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