diff options
-rw-r--r-- | src/errordialoghandler.cpp | 15 | ||||
-rw-r--r-- | src/errordialoghandler.h | 2 | ||||
-rw-r--r-- | src/test/main.cpp | 4 |
3 files changed, 20 insertions, 1 deletions
diff --git a/src/errordialoghandler.cpp b/src/errordialoghandler.cpp index 640e238c5d..c0888fbfab 100644 --- a/src/errordialoghandler.cpp +++ b/src/errordialoghandler.cpp @@ -67,6 +67,12 @@ void ErrorDialogProperties::addButton(QMessageBox::StandardButton button) { // ---------- ErrorDialogHandler begins here ---------- ErrorDialogHandler* ErrorDialogHandler::s_pInstance = NULL; +bool ErrorDialogHandler::s_bEnabled = true; + +// static +void ErrorDialogHandler::setEnabled(bool enabled) { + s_bEnabled = enabled; +} ErrorDialogHandler::ErrorDialogHandler() : m_signalMapper(this) { @@ -88,6 +94,9 @@ ErrorDialogProperties* ErrorDialogHandler::newDialogProperties() { bool ErrorDialogHandler::requestErrorDialog(DialogType type, QString message, bool shouldQuit) { + if (!s_bEnabled) { + return false; + } ErrorDialogProperties* props = newDialogProperties(); props->setType(type); props->setText(message); @@ -109,9 +118,15 @@ bool ErrorDialogHandler::requestErrorDialog(DialogType type, QString message, } bool ErrorDialogHandler::requestErrorDialog(ErrorDialogProperties* props) { + if (!s_bEnabled) { + delete props; + return false; + } + // Make sure the minimum items are set QString text = props->getText(); DEBUG_ASSERT_AND_HANDLE(!text.isEmpty()) { + delete props; return false; } diff --git a/src/errordialoghandler.h b/src/errordialoghandler.h index 1e2ee96588..6e2cd34adf 100644 --- a/src/errordialoghandler.h +++ b/src/errordialoghandler.h @@ -140,6 +140,7 @@ class ErrorDialogHandler : public QObject { s_pInstance = new ErrorDialogHandler(); return s_pInstance; } + static void setEnabled(bool enabled); virtual ~ErrorDialogHandler(); // Call this to get a new instance of ErrorDialogProperties to populate with @@ -172,6 +173,7 @@ class ErrorDialogHandler : public QObject { ErrorDialogHandler(); static ErrorDialogHandler *s_pInstance; + static bool s_bEnabled; bool m_errorCondition; QList<QString> m_dialogKeys; diff --git a/src/test/main.cpp b/src/test/main.cpp index 105050d97b..0645ab6dcc 100644 --- a/src/test/main.cpp +++ b/src/test/main.cpp @@ -1,9 +1,11 @@ #include <gtest/gtest.h> #include "util/console.h" - +#include "errordialoghandler.h" int main(int argc, char **argv) { Console console(); + // We never want to popup error dialogs when running tests. + ErrorDialogHandler::setEnabled(false); testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); } |