Make argument to QQmlDebuggingEnabler::startTcpServer an enum
authorUlf Hermann <ulf.hermann@theqtcompany.com>
Mon, 8 Jun 2015 14:43:23 +0000 (16:43 +0200)
committerJani Heikkinen <jani.heikkinen@theqtcompany.com>
Wed, 10 Jun 2015 09:52:09 +0000 (09:52 +0000)
The bool argument is less intuitive as you don't know if e.g. true
means "Yes, run the QML" or "Yes, block the QML engine".

Task-number: QTBUG-46565
Change-Id: I6d268e1354cebeb794b065e118bc0c353d7dd59a
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
src/qml/debugger/qqmldebug.h
src/qml/qml/qqmlengine.cpp
tests/auto/qml/debugger/qqmldebuggingenabler/qqmldebuggingenablerserver/qqmldebuggingenablerserver.cpp

index bb90c4f1b80260345b68b79ea730cc1238ec518f..559c492dfd5c2d8c7e5055426b9f3bd5200c4cbf 100644 (file)
@@ -42,8 +42,13 @@ QT_BEGIN_NAMESPACE
 
 struct Q_QML_EXPORT QQmlDebuggingEnabler
 {
+    enum StartMode {
+        DoNotWaitForClient,
+        WaitForClient
+    };
+
     QQmlDebuggingEnabler(bool printWarning = true);
-    static bool startTcpDebugServer(int port, bool block = false,
+    static bool startTcpDebugServer(int port, StartMode mode = DoNotWaitForClient,
                                     const QString &hostName = QString());
 };
 
index 8a7e4b84e7afba96b11e8bc42e05c999b55ad110..8cf3d2064d482d14490f74f1cce8c2cc1876ef6c 100644 (file)
@@ -1490,19 +1490,30 @@ QQmlDebuggingEnabler::QQmlDebuggingEnabler(bool printWarning)
 #endif
 }
 
+/*!
+ * \enum QQmlDebuggingEnabler::StartMode
+ *
+ * Defines the debug server's start behavior. You can interrupt QML engines starting while a debug
+ * client is connecting, in order to set breakpoints in or profile startup code.
+ *
+ * \value DoNotWaitForClient Run any QML engines as usual while the debug services are connecting.
+ * \value WaitForClient      If a QML engine starts while the debug services are connecting,
+ *                           interrupt it until they are done.
+ */
+
 /*!
  * Enables debugging for QML engines created after calling this function. The debug server will
  * listen on \a port at \a hostName and block the QML engine until it receives a connection if
- * \a block is true. If \a block is not specified it won't block and if \a hostName isn't specified
- * it will listen on all available interfaces. You can only start one debug server at a time. A
- * debug server may have already been started if the -qmljsdebugger= command line argument was
- * given. This method returns \c true if a new debug server was successfully started, or \c false
- * otherwise.
+ * \a mode is \c WaitForClient. If \a mode is not specified it won't block and if \a hostName is not
+ * specified it will listen on all available interfaces. You can only start one debug server at a
+ * time. A debug server may have already been started if the -qmljsdebugger= command line argument
+ * was given. This method returns \c true if a new debug server was successfully started, or
+ * \c false otherwise.
  */
-bool QQmlDebuggingEnabler::startTcpDebugServer(int port, bool block, const QString &hostName)
+bool QQmlDebuggingEnabler::startTcpDebugServer(int port, StartMode mode, const QString &hostName)
 {
 #ifndef QQML_NO_DEBUG_PROTOCOL
-    return QQmlDebugServer::enable(port, port, block, hostName);
+    return QQmlDebugServer::enable(port, port, mode == WaitForClient, hostName);
 #else
     Q_UNUSED(port);
     Q_UNUSED(block);
index 68279413e086469614aec28cd11b7a7ece658603..bddece64523c1b819aa77b38198f4707d655986f 100644 (file)
@@ -36,7 +36,7 @@
 
 int main(int argc, char *argv[])
 {
-      bool block = false;
+      QQmlDebuggingEnabler::StartMode block = QQmlDebuggingEnabler::DoNotWaitForClient;
       int portFrom = 0;
       int portTo = 0;
 
@@ -45,7 +45,7 @@ int main(int argc, char *argv[])
       arguments.removeFirst();
 
       if (arguments.size() && arguments.first() == QLatin1String("-block")) {
-          block = true;
+          block = QQmlDebuggingEnabler::WaitForClient;
           arguments.removeFirst();
       }