Shutdown correctly if config is not initialized yet

This commit is contained in:
Florian Bruhin 2014-07-30 18:13:36 +02:00
parent 276315483d
commit 8c78806e1c

View File

@ -674,8 +674,9 @@ class Application(QApplication):
return return
self._shutting_down = True self._shutting_down = True
log.destroy.debug("Shutting down with status {}...".format(status)) log.destroy.debug("Shutting down with status {}...".format(status))
to_save = []
# Save everything # Save everything
if self.config is not None:
to_save = []
if self.config.get('general', 'auto-save-config'): if self.config.get('general', 'auto-save-config'):
to_save.append(("config", self.config.save)) to_save.append(("config", self.config.save))
to_save += [("command history", self.cmd_history.save), to_save += [("command history", self.cmd_history.save),
@ -691,11 +692,15 @@ class Application(QApplication):
except AttributeError as e: except AttributeError as e:
log.destroy.warning("Could not save {}.".format(what)) log.destroy.warning("Could not save {}.".format(what))
log.destroy.debug(e) log.destroy.debug(e)
else:
log.destroy.debug("Config not initialized yet, so not saving "
"anything.")
# Re-enable faulthandler to stdout, then remove crash log # Re-enable faulthandler to stdout, then remove crash log
log.destroy.debug("Deactiving crash log...") log.destroy.debug("Deactiving crash log...")
self._destroy_crashlogfile() self._destroy_crashlogfile()
# If we don't kill our custom handler here we might get segfaults # If we don't kill our custom handler here we might get segfaults
log.destroy.debug("Deactiving message handler...") log.destroy.debug("Deactiving message handler...")
qInstallMessageHandler(None) qInstallMessageHandler(None)
# Now we can hopefully quit without segfaults
log.destroy.info("Good bye!") log.destroy.info("Good bye!")
self.exit(status) self.exit(status)