mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-07 10:14:46 -04:00
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:
parent
a2a111da8c
commit
a74e6eda06
@ -1040,6 +1040,12 @@ class Application(QApplication):
|
||||
if colors != self.color_prefs.get('custom_colors_for_color_dialog', None):
|
||||
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
|
||||
|
||||
class SanitizeLibraryPath(object):
|
||||
|
@ -199,7 +199,8 @@ class GuiRunner(QObject):
|
||||
|
||||
def hide_splash_screen(self):
|
||||
if self.splash_screen is not None:
|
||||
self.splash_screen.hide()
|
||||
with self.app:
|
||||
self.splash_screen.hide()
|
||||
self.splash_screen = None
|
||||
|
||||
def choose_dir(self, initial_dir):
|
||||
@ -210,7 +211,8 @@ class GuiRunner(QObject):
|
||||
|
||||
def show_error(self, title, msg, det_msg=''):
|
||||
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):
|
||||
print 'Catastrophic failure initializing GUI, bailing out...'
|
||||
@ -254,14 +256,15 @@ class GuiRunner(QObject):
|
||||
db = LibraryDatabase(self.library_path)
|
||||
except apsw.Error:
|
||||
self.hide_splash_screen()
|
||||
repair = question_dialog(None, _('Corrupted database'),
|
||||
_('The library database at %s appears to be corrupted. Do '
|
||||
'you want calibre to try and rebuild it automatically? '
|
||||
'The rebuild may not be completely successful. '
|
||||
'If you say No, a new empty calibre library will be created.')
|
||||
% force_unicode(self.library_path, filesystem_encoding),
|
||||
det_msg=traceback.format_exc()
|
||||
)
|
||||
with self.app:
|
||||
repair = question_dialog(None, _('Corrupted database'),
|
||||
_('The library database at %s appears to be corrupted. Do '
|
||||
'you want calibre to try and rebuild it automatically? '
|
||||
'The rebuild may not be completely successful. '
|
||||
'If you say No, a new empty calibre library will be created.')
|
||||
% force_unicode(self.library_path, filesystem_encoding),
|
||||
det_msg=traceback.format_exc()
|
||||
)
|
||||
if repair:
|
||||
if repair_library(self.library_path):
|
||||
db = LibraryDatabase(self.library_path)
|
||||
|
Loading…
x
Reference in New Issue
Block a user