[conduit/gsoc09_alexandre: 5/24] Fixed freezing when exception raised on exit.



commit 98e9588745a2d014ab86499eeadcf5467768c764
Author: Alexandre Rosenfeld <airmind gmail com>
Date:   Tue Jul 7 02:20:37 2009 -0300

    Fixed freezing when exception raised on exit.

 conduit/Main.py |   65 +++++++++++++++++++++++++++++-------------------------
 1 files changed, 35 insertions(+), 30 deletions(-)
---
diff --git a/conduit/Main.py b/conduit/Main.py
index 172287f..a87a224 100644
--- a/conduit/Main.py
+++ b/conduit/Main.py
@@ -4,6 +4,7 @@ import sys
 import dbus, dbus.service, dbus.mainloop.glib
 import gobject
 import logging
+import traceback
 
 dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
 dbus.mainloop.glib.threads_init()
@@ -271,36 +272,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 quiting, forcing close. %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]