From 2ac91abd306215d44d52c70ee6bff4366e16f921 Mon Sep 17 00:00:00 2001 From: Kai Koehne <kai.koehne@nokia.com> Date: Wed, 3 Nov 2010 10:44:40 +0100 Subject: [PATCH] QmlApp template: Use new 4.7.1 API to enable qml debugging Qml debugging is now disabled by default, and has to be enabled explicitly (b2016bbfc9). This has to be done before the QDView/QDEngine is instantiated ... The patch introduces a static create method to QmlApplicationViewer, so that the setup can be hidden from the users main file. Reviewed-by: Alessandro Portale --- .../qt_private/qdeclarativedebughelper_p.h | 4 ++++ share/qtcreator/templates/qmlapp/app.pro | 2 +- .../qmlapplicationviewer.cpp | 20 +++++++++++++++++++ .../wizards/qmlstandaloneapp.cpp | 2 +- 4 files changed, 26 insertions(+), 2 deletions(-) diff --git a/share/qtcreator/qml/qmljsdebugger/include/qt_private/qdeclarativedebughelper_p.h b/share/qtcreator/qml/qmljsdebugger/include/qt_private/qdeclarativedebughelper_p.h index d676ebce4d1..4f57be9a5a4 100644 --- a/share/qtcreator/qml/qmljsdebugger/include/qt_private/qdeclarativedebughelper_p.h +++ b/share/qtcreator/qml/qmljsdebugger/include/qt_private/qdeclarativedebughelper_p.h @@ -59,6 +59,10 @@ class QMLJSDEBUGGER_EXTERN QDeclarativeDebugHelper public: static QScriptEngine *getScriptEngine(QDeclarativeEngine *engine); static void setAnimationSlowDownFactor(qreal factor); + + // Enables remote debugging functionality + // Only use this for debugging in a safe environment! + static void enableDebugging(); }; QT_END_NAMESPACE diff --git a/share/qtcreator/templates/qmlapp/app.pro b/share/qtcreator/templates/qmlapp/app.pro index 73a99b843e8..5dcaeb3f68b 100644 --- a/share/qtcreator/templates/qmlapp/app.pro +++ b/share/qtcreator/templates/qmlapp/app.pro @@ -20,7 +20,7 @@ DEFINES += NETWORKACCESS # TARGETUID3 # symbian:TARGET.UID3 = 0xE1111234 -# Define QMLJSDEBUGGER to allow debugging of QML +# Define QMLJSDEBUGGER to allow debugging of QML in debug builds # (This might significantly increase build time) # DEFINES += QMLJSDEBUGGER diff --git a/share/qtcreator/templates/qmlapp/qmlapplicationviewer/qmlapplicationviewer.cpp b/share/qtcreator/templates/qmlapp/qmlapplicationviewer/qmlapplicationviewer.cpp index 5fdc94c8cd8..59d9750edd6 100644 --- a/share/qtcreator/templates/qmlapp/qmlapplicationviewer/qmlapplicationviewer.cpp +++ b/share/qtcreator/templates/qmlapp/qmlapplicationviewer/qmlapplicationviewer.cpp @@ -16,6 +16,10 @@ #include <QtDeclarative/QDeclarativeEngine> #include <QtDeclarative/QDeclarativeContext> +#if defined(QMLJSDEBUGGER) +#include <qt_private/qdeclarativedebughelper_p.h> +#endif + #if defined(QMLJSDEBUGGER) && !defined(NO_JSDEBUGGER) #include <jsdebuggeragent.h> #endif @@ -30,6 +34,22 @@ #include <aknappui.h> #endif // Q_OS_SYMBIAN && ORIENTATIONLOCK +#if defined(QMLJSDEBUGGER) + +// Enable debugging before any QDeclarativeEngine is created +struct QmlJsDebuggingEnabler +{ + QmlJsDebuggingEnabler() + { + QDeclarativeDebugHelper::enableDebugging(); + } +}; + +// Execute code in constructor before first QDeclarativeEngine is instantiated +static QmlJsDebuggingEnabler enableDebuggingHelper; + +#endif // QMLJSDEBUGGER + class QmlApplicationViewerPrivate { QString mainQmlFile; diff --git a/src/plugins/qt4projectmanager/wizards/qmlstandaloneapp.cpp b/src/plugins/qt4projectmanager/wizards/qmlstandaloneapp.cpp index 807f4274923..3a3586229ab 100644 --- a/src/plugins/qt4projectmanager/wizards/qmlstandaloneapp.cpp +++ b/src/plugins/qt4projectmanager/wizards/qmlstandaloneapp.cpp @@ -477,7 +477,7 @@ bool QmlStandaloneApp::updateFiles(const QList<QmlAppGeneratedFileInfo> &list, Q return true; } -const int QmlStandaloneApp::StubVersion = 9; +const int QmlStandaloneApp::StubVersion = 10; } // namespace Internal } // namespace Qt4ProjectManager -- GitLab