From ad3677f7ca55f9d459bbbc425674dd02b7469e19 Mon Sep 17 00:00:00 2001 From: Martin Rotter Date: Wed, 16 Apr 2014 08:44:16 +0200 Subject: [PATCH] Hmmmm --- src/updater/formupdater.cpp | 45 +++++++++++++++---------------------- src/updater/formupdater.h | 11 +++++++++ 2 files changed, 29 insertions(+), 27 deletions(-) diff --git a/src/updater/formupdater.cpp b/src/updater/formupdater.cpp index 7405e602c..f44ffb158 100644 --- a/src/updater/formupdater.cpp +++ b/src/updater/formupdater.cpp @@ -46,6 +46,9 @@ FormUpdater::FormUpdater(QWidget *parent) setWindowIcon(QIcon(APP_ICON_PATH)); moveToCenterAndResize(); + + connect(this, SIGNAL(debugMessageProduced(QtMsgType,QString)), + this, SLOT(consumeDebugMessage(QtMsgType,QString))); } FormUpdater::~FormUpdater() { @@ -108,14 +111,11 @@ void FormUpdater::executeMainApplication() { } } +void FormUpdater::triggerDebugMessageConsumption(QtMsgType type, const QString &message) { + emit debugMessageProduced(type, message); +} -#if QT_VERSION >= 0x050000 -void FormUpdater::debugHandler(QtMsgType type, - const QMessageLogContext &placement, - const QString &message) { -#ifndef QT_NO_DEBUG_OUTPUT - Q_UNUSED(placement) - +void FormUpdater::consumeDebugMessage(QtMsgType type, const QString &message) { switch (type) { case QtDebugMsg: s_instance->printText(QString("DEBUG: %1").arg(message)); @@ -136,6 +136,16 @@ void FormUpdater::debugHandler(QtMsgType type, default: break; } +} + +#if QT_VERSION >= 0x050000 +void FormUpdater::debugHandler(QtMsgType type, + const QMessageLogContext &placement, + const QString &message) { +#ifndef QT_NO_DEBUG_OUTPUT + Q_UNUSED(placement) + + s_instance->triggerDebugMessageConsumption(type, message); #else Q_UNUSED(type) Q_UNUSED(placement) @@ -145,26 +155,7 @@ void FormUpdater::debugHandler(QtMsgType type, #else void FormUpdater::debugHandler(QtMsgType type, const char *message) { #ifndef QT_NO_DEBUG_OUTPUT - switch (type) { - case QtDebugMsg: - s_instance->printText(QString("DEBUG: %1").arg(message)); - break; - - case QtWarningMsg: - s_instance->printText(QString("WARNING: %1").arg(message)); - break; - - case QtCriticalMsg: - s_instance->printText(QString("CRITICAL: %1").arg(message)); - break; - - case QtFatalMsg: - s_instance->printText(QString("FATAL: %1").arg(message)); - qApp->exit(EXIT_FAILURE); - - default: - break; - } + s_instance->triggerDebugMessageConsumption(type, QString(message)); #else Q_UNUSED(type) Q_UNUSED(message) diff --git a/src/updater/formupdater.h b/src/updater/formupdater.h index 9df7c15f4..500a09852 100644 --- a/src/updater/formupdater.h +++ b/src/updater/formupdater.h @@ -42,6 +42,9 @@ class FormUpdater : public QMainWindow { bool doFinalCleanup(); void executeMainApplication(); + // Used to trigger signal informaing about new debug message. + void triggerDebugMessageConsumption(QtMsgType type, const QString &message); + // Debug handlers for messages. #if QT_VERSION >= 0x050000 static void debugHandler(QtMsgType type, @@ -52,6 +55,14 @@ class FormUpdater : public QMainWindow { const char *message); #endif + public slots: + // Should be always called on GUI thread which is enforced + // by signal/slot auto connection. + void consumeDebugMessage(QtMsgType type, const QString &message); + + signals: + void debugMessageProduced(QtMsgType type, QString message); + protected: // Catch the "press any key event" to exit the updater. void keyPressEvent(QKeyEvent *event);