X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;f=src%2Fcommon%2Fquassel.h;h=77f7b870b40eeb380b4e45321fedadfdfaed9c0c;hb=d438145b28f34b7fdbc7e290aa001e5f3f922207;hp=17e252c13d3cf28050d4eb77f73657156435c172;hpb=493043890c74e4679bb3fdaf512a0e1e52c426d3;p=quassel.git diff --git a/src/common/quassel.h b/src/common/quassel.h index 17e252c1..77f7b870 100644 --- a/src/common/quassel.h +++ b/src/common/quassel.h @@ -32,6 +32,7 @@ #include #include "abstractcliparser.h" +#include "abstractsignalwatcher.h" #include "singleton.h" class QFile; @@ -198,10 +199,26 @@ public: using QuitHandler = std::function; + /** + * Registers a handler that is called when the application is supposed to quit. + * + * @note If multiple handlers are registered, they are processed in order of registration. + * @note If any handler is registered, quit() will not call QCoreApplication::quit(). It relies + * on one of the handlers doing so, instead. + * @param quitHandler Handler to register + */ static void registerQuitHandler(QuitHandler quitHandler); const QString &coreDumpFileName(); +public slots: + /** + * Requests to quit the application. + * + * Calls any registered quit handlers. If no handlers are registered, calls QCoreApplication::quit(). + */ + void quit(); + signals: void messageLogged(const QDateTime &timeStamp, const QString &msg); @@ -212,7 +229,6 @@ protected: static void setDataDirPaths(const QStringList &paths); static QStringList findDataDirPaths(); - static void disableCrashHandler(); friend class CoreApplication; friend class QtUiApplication; @@ -221,6 +237,7 @@ protected: private: void setupEnvironment(); void registerMetaTypes(); + void setupSignalHandling(); /** * Requests a reload of relevant runtime configuration. @@ -232,22 +249,16 @@ private: */ bool reloadConfig(); - /** - * Requests to quit the application. - * - * Calls any registered quit handlers. If no handlers are registered, calls QCoreApplication::quit(). - */ - void quit(); - void logBacktrace(const QString &filename); - static void handleSignal(int signal); +private slots: + void handleSignal(AbstractSignalWatcher::Action action); private: BuildInfo _buildInfo; RunMode _runMode; bool _initialized{false}; - bool _handleCrashes{true}; + bool _quitting{false}; QString _coreDumpFileName; QString _configDirPath; @@ -257,6 +268,7 @@ private: std::shared_ptr _cliParser; Logger *_logger; + AbstractSignalWatcher *_signalWatcher{nullptr}; std::vector _reloadHandlers; std::vector _quitHandlers;