Title: [96417] trunk
Revision
96417
Author
ves...@webkit.org
Date
2011-09-30 13:05:20 -0700 (Fri, 30 Sep 2011)

Log Message

[Qt] Prevent qDebug() output from DRT and WTR unless --verbose

For DRT we didn't install the message handler early enough to
catch output while constructing the QApplication. For WTR we
didn't even install a message handler.

Since the UI process will forward any output from the web process
we set an environment variable QT_WEBKIT_SUPPRESS_WEB_PROCESS_OUTPUT
in WTR before the web process is started. This is picked up by the
web process which installs its own message handler.

The environment variable can be overriden on the command line if you
want to see output from the web process, or you can pass --verbose to
WTR to see output from both processes.

https://bugs.webkit.org/show_bug.cgi?id=69132

Reviewed by Andreas Kling.

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (96416 => 96417)


--- trunk/Source/WebKit2/ChangeLog	2011-09-30 20:04:57 UTC (rev 96416)
+++ trunk/Source/WebKit2/ChangeLog	2011-09-30 20:05:20 UTC (rev 96417)
@@ -1,3 +1,26 @@
+2011-09-30  Tor Arne Vestbø  <tor.arne.ves...@nokia.com>
+
+        [Qt] Prevent qDebug() output from DRT and WTR unless --verbose
+
+        For DRT we didn't install the message handler early enough to
+        catch output while constructing the QApplication. For WTR we
+        didn't even install a message handler.
+
+        Since the UI process will forward any output from the web process
+        we set an environment variable QT_WEBKIT_SUPPRESS_WEB_PROCESS_OUTPUT
+        in WTR before the web process is started. This is picked up by the
+        web process which installs its own message handler.
+
+        The environment variable can be overriden on the command line if you
+        want to see output from the web process, or you can pass --verbose to
+        WTR to see output from both processes.
+
+        https://bugs.webkit.org/show_bug.cgi?id=69132
+
+        Reviewed by Andreas Kling.
+
+        * WebProcess/qt/WebProcessMainQt.cpp:
+
 2011-09-30  Anders Carlsson  <ander...@apple.com>
 
         Remove didCompleteRubberBandForMainFrame UIClient callback

Modified: trunk/Source/WebKit2/WebProcess/qt/WebProcessMainQt.cpp (96416 => 96417)


--- trunk/Source/WebKit2/WebProcess/qt/WebProcessMainQt.cpp	2011-09-30 20:04:57 UTC (rev 96416)
+++ trunk/Source/WebKit2/WebProcess/qt/WebProcessMainQt.cpp	2011-09-30 20:05:20 UTC (rev 96417)
@@ -130,8 +130,24 @@
     QNetworkProxyFactory::setUseSystemConfiguration(true);
 }
 
+void messageHandler(QtMsgType type, const char* message)
+{
+    if (type == QtCriticalMsg) {
+        fprintf(stderr, "%s\n", message);
+        return;
+    }
+
+    // Do nothing
+}
+
 Q_DECL_EXPORT int WebProcessMainQt(int argc, char** argv)
 {
+    // Has to be done before QApplication is constructed in case
+    // QApplication itself produces debug output.
+    QByteArray suppressOutput = qgetenv("QT_WEBKIT_SUPPRESS_WEB_PROCESS_OUTPUT");
+    if (!suppressOutput.isEmpty() && suppressOutput != "0")
+        qInstallMsgHandler(messageHandler);
+
     QApplication::setGraphicsSystem(QLatin1String("raster"));
     QApplication* app = new QApplication(argc, argv);
 #ifndef NDEBUG

Modified: trunk/Tools/ChangeLog (96416 => 96417)


--- trunk/Tools/ChangeLog	2011-09-30 20:04:57 UTC (rev 96416)
+++ trunk/Tools/ChangeLog	2011-09-30 20:05:20 UTC (rev 96417)
@@ -1,5 +1,29 @@
 2011-09-30  Tor Arne Vestbø  <tor.arne.ves...@nokia.com>
 
+        [Qt] Prevent qDebug() output from DRT and WTR unless --verbose
+
+        For DRT we didn't install the message handler early enough to
+        catch output while constructing the QApplication. For WTR we
+        didn't even install a message handler.
+
+        Since the UI process will forward any output from the web process
+        we set an environment variable QT_WEBKIT_SUPPRESS_WEB_PROCESS_OUTPUT
+        in WTR before the web process is started. This is picked up by the
+        web process which installs its own message handler.
+
+        The environment variable can be overriden on the command line if you
+        want to see output from the web process, or you can pass --verbose to
+        WTR to see output from both processes.
+
+        https://bugs.webkit.org/show_bug.cgi?id=69132
+
+        Reviewed by Andreas Kling.
+
+        * DumpRenderTree/qt/main.cpp:
+        * WebKitTestRunner/qt/main.cpp:
+
+2011-09-30  Tor Arne Vestbø  <tor.arne.ves...@nokia.com>
+
         [Qt] Make sure WTR sizes the window and item correctly
 
         Revision 96345 changed the logic for how the view and

Modified: trunk/Tools/DumpRenderTree/qt/main.cpp (96416 => 96417)


--- trunk/Tools/DumpRenderTree/qt/main.cpp	2011-09-30 20:04:57 UTC (rev 96416)
+++ trunk/Tools/DumpRenderTree/qt/main.cpp	2011-09-30 20:05:20 UTC (rev 96417)
@@ -136,6 +136,20 @@
     _setmode(2, _O_BINARY);
 #endif
 
+    // Suppress debug output from Qt if not started with -v
+    bool suppressQtDebugOutput = true;
+    for (int i = 1; i < argc; ++i) {
+        if (!qstrcmp(argv[i], "-v")) {
+            suppressQtDebugOutput = false;
+            break;
+        }
+    }
+
+    // Has to be done before QApplication is constructed in case
+    // QApplication itself produces debug output.
+    if (suppressQtDebugOutput)
+        qInstallMsgHandler(messageHandler);
+
 #ifdef Q_WS_X11
     FcInit();
     WebCore::DumpRenderTree::initializeFonts();
@@ -177,7 +191,7 @@
 #endif
 
     QStringList args = app.arguments();
-    if (args.count() < 2) {
+    if (args.count() < (!suppressQtDebugOutput ? 3 : 2)) {
         printUsage();
         exit(1);
     }
@@ -185,16 +199,9 @@
     // Remove the first arguments, it is application name itself
     args.removeAt(0);
 
-    // Suppress debug output from Qt if not started with -v
-    int index = args.indexOf(QLatin1String("-v"));
-    if (index == -1) 
-        qInstallMsgHandler(messageHandler);
-    else
-        args.removeAt(index);
-
     WebCore::DumpRenderTree dumper;
 
-    index = args.indexOf(QLatin1String("--pixel-tests"));
+    int index = args.indexOf(QLatin1String("--pixel-tests"));
     if (index != -1) {
         dumper.setDumpPixels(true);
         args.removeAt(index);

Modified: trunk/Tools/WebKitTestRunner/qt/main.cpp (96416 => 96417)


--- trunk/Tools/WebKitTestRunner/qt/main.cpp	2011-09-30 20:04:57 UTC (rev 96416)
+++ trunk/Tools/WebKitTestRunner/qt/main.cpp	2011-09-30 20:05:20 UTC (rev 96417)
@@ -60,8 +60,35 @@
     char** m_argv;
 };
 
+void messageHandler(QtMsgType type, const char* message)
+{
+    if (type == QtCriticalMsg) {
+        fprintf(stderr, "%s\n", message);
+        return;
+    }
+
+    // Do nothing
+}
+
 int main(int argc, char** argv)
 {
+    // Suppress debug output from Qt if not started with --verbose
+    bool suppressQtDebugOutput = true;
+    for (int i = 1; i < argc; ++i) {
+        if (!qstrcmp(argv[i], "--verbose")) {
+            suppressQtDebugOutput = false;
+            break;
+        }
+    }
+
+    // Has to be done before QApplication is constructed in case
+    // QApplication itself produces debug output.
+    if (suppressQtDebugOutput) {
+        qInstallMsgHandler(messageHandler);
+        if (qgetenv("QT_WEBKIT_SUPPRESS_WEB_PROCESS_OUTPUT").isEmpty())
+            qputenv("QT_WEBKIT_SUPPRESS_WEB_PROCESS_OUTPUT", "1");
+    }
+
     QApplication app(argc, argv);
     Launcher launcher(argc, argv);
     QTimer::singleShot(0, &launcher, SLOT(launch()));
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to