comparison ui/main.cpp @ 1072:1e429faf7c84

(issue46) Default to debug output on if RELEASE_BUILD is not defined
author Andre Heinecke <andre.heinecke@intevation.de>
date Wed, 10 Sep 2014 17:53:32 +0200
parents fe2c6666b462
children 8d811b030959
comparison
equal deleted inserted replaced
1071:fc4e1fe4e4d4 1072:1e429faf7c84
50 Q_IMPORT_PLUGIN(QWindowsIntegrationPlugin) 50 Q_IMPORT_PLUGIN(QWindowsIntegrationPlugin)
51 #else 51 #else
52 Q_IMPORT_PLUGIN(QXcbIntegrationPlugin) 52 Q_IMPORT_PLUGIN(QXcbIntegrationPlugin)
53 #endif 53 #endif
54 54
55 #ifdef DO_RELEASE_BUILD
55 bool g_debug = false; 56 bool g_debug = false;
57 #else
58 bool g_debug = true;
59 #endif
60
56 QtMessageHandler g_default_msg_handler = NULL; 61 QtMessageHandler g_default_msg_handler = NULL;
57 62
58 void noDebugOutput(QtMsgType type, const QMessageLogContext &context, const QString &msg) 63 void filterDebugOutput(QtMsgType type, const QMessageLogContext &context, const QString &msg)
59 { 64 {
60 if (type == QtDebugMsg) { 65 if (!g_debug && type == QtDebugMsg) {
61 return; 66 return;
62 } 67 }
63 68
64 if (g_default_msg_handler) { 69 if (g_default_msg_handler) {
65 (*g_default_msg_handler)(type, context, msg); 70 (*g_default_msg_handler)(type, context, msg);
94 QSettings::setDefaultFormat(QSettings::IniFormat); 99 QSettings::setDefaultFormat(QSettings::IniFormat);
95 QStringList arguments = QApplication::arguments(); 100 QStringList arguments = QApplication::arguments();
96 101
97 if (arguments.contains("--debug")) { 102 if (arguments.contains("--debug")) {
98 g_debug = true; 103 g_debug = true;
99 } else {
100 g_debug = false;
101 g_default_msg_handler = qInstallMessageHandler(noDebugOutput);
102 } 104 }
105 g_default_msg_handler = qInstallMessageHandler(filterDebugOutput);
103 106
104 qDebug() << "Application style is: " << app.style()->metaObject()->className(); 107 qDebug() << "Application style is: " << app.style()->metaObject()->className();
105 qDebug() << "Available styles: " << QStyleFactory::keys().join(", "); 108 qDebug() << "Available styles: " << QStyleFactory::keys().join(", ");
106 qDebug() << "Font is: " << app.font(); 109 qDebug() << "Font is: " << app.font();
107 110

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