Skip to content

Commit

Permalink
Only register sys.excepthook if the app actually started
Browse files Browse the repository at this point in the history
Without this patch, when running tests the crash message box may be displayed.
With those changes, it will be displayed only if the app was actually started.
  • Loading branch information
zas authored and phw committed Apr 24, 2024
1 parent d7bb9dc commit eec6513
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
12 changes: 6 additions & 6 deletions picard/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,10 @@ def crash_handler(exc: Exception = None):
app.quit()


def _global_exception_handler(exctype, value, traceback):
from picard import crash_handler
crash_handler(exc=value)
sys.__excepthook__(exctype, value, traceback)
def register_excepthook():
def _global_exception_handler(exctype, value, traceback):
from picard import crash_handler
crash_handler(exc=value)
sys.__excepthook__(exctype, value, traceback)


sys.excepthook = _global_exception_handler
sys.excepthook = _global_exception_handler
3 changes: 3 additions & 0 deletions picard/tagger.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
PICARD_ORG_NAME,
acoustid,
log,
register_excepthook,
)
from picard.acoustid.manager import AcoustIDManager
from picard.album import (
Expand Down Expand Up @@ -1505,6 +1506,8 @@ def process_picard_args():


def main(localedir=None, autoupdate=True):
register_excepthook()

# Some libs (ie. Phonon) require those to be set
QtWidgets.QApplication.setApplicationName(PICARD_APP_NAME)
QtWidgets.QApplication.setOrganizationName(PICARD_ORG_NAME)
Expand Down

0 comments on commit eec6513

Please sign in to comment.