diff ui/administrator.cpp @ 1059:f638eb1f3b0f

(issue46) Add debug option for trustbridge-admin
author Andre Heinecke <andre.heinecke@intevation.de>
date Tue, 09 Sep 2014 18:00:37 +0200
parents 0051cb07da28
children 1e429faf7c84
line wrap: on
line diff
--- a/ui/administrator.cpp	Tue Sep 09 17:58:55 2014 +0200
+++ b/ui/administrator.cpp	Tue Sep 09 18:00:37 2014 +0200
@@ -40,6 +40,20 @@
  Q_IMPORT_PLUGIN(QXcbIntegrationPlugin)
 #endif
 
+bool g_debug = false;
+QtMessageHandler g_default_msg_handler = NULL;
+
+void noDebugOutput(QtMsgType type, const QMessageLogContext &context, const QString &msg)
+{
+    if (type == QtDebugMsg) {
+        return;
+    }
+
+    if (g_default_msg_handler) {
+        (*g_default_msg_handler)(type, context, msg);
+    }
+}
+
 int main(int argc, char **argv)
 {
     QApplication app (argc, argv);
@@ -58,6 +72,13 @@
         return 0;
     }
 
+    if (arguments.contains("--debug")) {
+        g_debug = true;
+    } else {
+        g_debug = false;
+        g_default_msg_handler = qInstallMessageHandler(noDebugOutput);
+    }
+
     QTranslator translator;
     if (QLocale::system().name() == "C") {
         /* Useful for testing / development as the primary target is german */

http://wald.intevation.org/projects/trustbridge/