From 7b8136a36e5bc4b005708470a47a1805cf74314f Mon Sep 17 00:00:00 2001 From: Leo Franchi Date: Sun, 17 Jun 2012 15:29:47 +0200 Subject: [PATCH] Reimplement QApplication::notify() to print out something about the exception if we can --- src/TomahawkApp.cpp | 21 +++++++++++++++++++++ src/TomahawkApp.h | 3 +++ 2 files changed, 24 insertions(+) diff --git a/src/TomahawkApp.cpp b/src/TomahawkApp.cpp index f3ac2a95c..ec7dc8ea3 100644 --- a/src/TomahawkApp.cpp +++ b/src/TomahawkApp.cpp @@ -707,6 +707,27 @@ TomahawkApp::loadUrl( const QString& url ) } +bool +TomahawkApp::notify( QObject *receiver, QEvent *e ) +{ + try + { + return TOMAHAWK_APPLICATION::notify( receiver, e ); + } + catch ( const std::exception& e ) + { + qWarning( "TomahawkApp::notify caught a std exception in a Qt event handler: " ); + qFatal( e.what() ); + } + catch ( ... ) + { + qFatal( "TomahawkApp::notify caught a non-std-exception from a Qt event handler. Aborting." ); + } + + return false; +} + + void TomahawkApp::instanceStarted( KDSingleApplicationGuard::Instance instance ) { diff --git a/src/TomahawkApp.h b/src/TomahawkApp.h index 417bc3094..74cfffc11 100644 --- a/src/TomahawkApp.h +++ b/src/TomahawkApp.h @@ -99,6 +99,9 @@ public: bool isTomahawkLoaded() const { return m_loaded; } + // reimplemented from QApplication/QCoreApplication + virtual bool notify( QObject* receiver, QEvent* e ); + signals: void tomahawkLoaded();