Workaround for Qt 5 behavior change on OS X which prevented error handling during startup on OS X to not work

This commit is contained in:
Kovid Goyal 2014-09-02 12:44:15 +05:30
parent a2a111da8c
commit a74e6eda06
2 changed files with 19 additions and 10 deletions

View File

@ -1040,6 +1040,12 @@ class Application(QApplication):
if colors != self.color_prefs.get('custom_colors_for_color_dialog', None): if colors != self.color_prefs.get('custom_colors_for_color_dialog', None):
self.color_prefs.set('custom_colors_for_color_dialog', colors) self.color_prefs.set('custom_colors_for_color_dialog', colors)
def __enter__(self):
self.setQuitOnLastWindowClosed(False)
def __exit__(self, *args):
self.setQuitOnLastWindowClosed(True)
_store_app = None _store_app = None
class SanitizeLibraryPath(object): class SanitizeLibraryPath(object):

View File

@ -199,7 +199,8 @@ class GuiRunner(QObject):
def hide_splash_screen(self): def hide_splash_screen(self):
if self.splash_screen is not None: if self.splash_screen is not None:
self.splash_screen.hide() with self.app:
self.splash_screen.hide()
self.splash_screen = None self.splash_screen = None
def choose_dir(self, initial_dir): def choose_dir(self, initial_dir):
@ -210,7 +211,8 @@ class GuiRunner(QObject):
def show_error(self, title, msg, det_msg=''): def show_error(self, title, msg, det_msg=''):
self.hide_splash_screen() self.hide_splash_screen()
error_dialog(self.main, title, msg, det_msg=det_msg, show=True) with self.app:
error_dialog(self.main, title, msg, det_msg=det_msg, show=True)
def initialization_failed(self): def initialization_failed(self):
print 'Catastrophic failure initializing GUI, bailing out...' print 'Catastrophic failure initializing GUI, bailing out...'
@ -254,14 +256,15 @@ class GuiRunner(QObject):
db = LibraryDatabase(self.library_path) db = LibraryDatabase(self.library_path)
except apsw.Error: except apsw.Error:
self.hide_splash_screen() self.hide_splash_screen()
repair = question_dialog(None, _('Corrupted database'), with self.app:
_('The library database at %s appears to be corrupted. Do ' repair = question_dialog(None, _('Corrupted database'),
'you want calibre to try and rebuild it automatically? ' _('The library database at %s appears to be corrupted. Do '
'The rebuild may not be completely successful. ' 'you want calibre to try and rebuild it automatically? '
'If you say No, a new empty calibre library will be created.') 'The rebuild may not be completely successful. '
% force_unicode(self.library_path, filesystem_encoding), 'If you say No, a new empty calibre library will be created.')
det_msg=traceback.format_exc() % force_unicode(self.library_path, filesystem_encoding),
) det_msg=traceback.format_exc()
)
if repair: if repair:
if repair_library(self.library_path): if repair_library(self.library_path):
db = LibraryDatabase(self.library_path) db = LibraryDatabase(self.library_path)