PICARD-2869: Run register_excepthook early

Don't separately catch exceptions around main but rely on the new excepthook.

This prevents the crash dialog to be shown twice for exceptions which
are catched by the exception handler already.
This commit is contained in:
Philipp Wolfer
2024-04-29 08:18:04 +02:00
parent ff2f899c7e
commit 9393da348c
3 changed files with 10 additions and 21 deletions

View File

@@ -73,7 +73,6 @@ from picard import (
PICARD_ORG_NAME, PICARD_ORG_NAME,
acoustid, acoustid,
log, log,
register_excepthook,
) )
from picard.acoustid.manager import AcoustIDManager from picard.acoustid.manager import AcoustIDManager
from picard.album import ( from picard.album import (
@@ -1508,8 +1507,6 @@ If a new instance will not be spawned files/directories will be passed to the ex
def main(localedir=None, autoupdate=True): def main(localedir=None, autoupdate=True):
register_excepthook()
# Some libs (ie. Phonon) require those to be set # Some libs (ie. Phonon) require those to be set
QtWidgets.QApplication.setApplicationName(PICARD_APP_NAME) QtWidgets.QApplication.setApplicationName(PICARD_APP_NAME)
QtWidgets.QApplication.setOrganizationName(PICARD_ORG_NAME) QtWidgets.QApplication.setOrganizationName(PICARD_ORG_NAME)

View File

@@ -1,11 +1,7 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
try: from picard import register_excepthook
from picard.tagger import main register_excepthook()
main('%(localedir)s', %(autoupdate)s)
except SystemExit: from picard.tagger import main
raise # Just continue with a normal application exit main('%(localedir)s', %(autoupdate)s)
except: # noqa: E722,F722 # pylint: disable=bare-except
from picard import crash_handler
crash_handler()
raise

View File

@@ -12,12 +12,8 @@ if getattr(sys, 'frozen', False) and hasattr(sys, '_MEIPASS'):
else: else:
basedir = os.path.dirname(os.path.abspath(__file__)) basedir = os.path.dirname(os.path.abspath(__file__))
try: from picard import register_excepthook
from picard.tagger import main register_excepthook()
main(os.path.join(basedir, 'locale'), %(autoupdate)s)
except SystemExit: from picard.tagger import main
raise # Just continue with a normal application exit main(os.path.join(basedir, 'locale'), %(autoupdate)s)
except: # noqa: E722,F722 # pylint: disable=bare-except
from picard import crash_handler
crash_handler()
raise