From 4739a241722c20a4dade8f02b18a809fda94e942 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Wed, 24 Aug 2011 15:51:04 +0200 Subject: tests: Use CONFIG option instead of QDeclarativeDebugHelper class Change-Id: I84119a3164018a4179f8a7187348865a30b3237a --- tests/auto/declarative/qdeclarativedebug/qdeclarativedebug.pro | 2 +- tests/auto/declarative/qdeclarativedebug/tst_qdeclarativedebug.cpp | 4 ---- .../declarative/qdeclarativedebugclient/qdeclarativedebugclient.pro | 2 ++ .../qdeclarativedebugclient/tst_qdeclarativedebugclient.cpp | 4 ---- tests/auto/declarative/qdeclarativedebugjs/app/app.pro | 1 + tests/auto/declarative/qdeclarativedebugjs/app/main.cpp | 3 --- .../declarative/qdeclarativedebugservice/qdeclarativedebugservice.pro | 2 +- .../qdeclarativedebugservice/tst_qdeclarativedebugservice.cpp | 4 ---- 8 files changed, 5 insertions(+), 17 deletions(-) diff --git a/tests/auto/declarative/qdeclarativedebug/qdeclarativedebug.pro b/tests/auto/declarative/qdeclarativedebug/qdeclarativedebug.pro index 1214fcf..d488b53 100644 --- a/tests/auto/declarative/qdeclarativedebug/qdeclarativedebug.pro +++ b/tests/auto/declarative/qdeclarativedebug/qdeclarativedebug.pro @@ -6,5 +6,5 @@ HEADERS += ../shared/debugutil_p.h SOURCES += tst_qdeclarativedebug.cpp \ ../shared/debugutil.cpp -CONFIG += parallel_test +CONFIG += parallel_test declarative_debug diff --git a/tests/auto/declarative/qdeclarativedebug/tst_qdeclarativedebug.cpp b/tests/auto/declarative/qdeclarativedebug/tst_qdeclarativedebug.cpp index 9c20bd6..d5ae040 100644 --- a/tests/auto/declarative/qdeclarativedebug/tst_qdeclarativedebug.cpp +++ b/tests/auto/declarative/qdeclarativedebug/tst_qdeclarativedebug.cpp @@ -59,7 +59,6 @@ #include #include #include -#include #include "../../../shared/util.h" #include "../shared/debugutil_p.h" @@ -296,9 +295,6 @@ void tst_QDeclarativeDebug::initTestCase() qRegisterMetaType(); qmlRegisterType("Test", 1, 0, "NonScriptPropertyElement"); - QTest::ignoreMessage(QtWarningMsg, "Qml debugging is enabled. Only use this in a safe environment!"); - QDeclarativeDebugHelper::enableDebugging(); - QTest::ignoreMessage(QtWarningMsg, "QDeclarativeDebugServer: Waiting for connection on port 3768..."); m_engine = new QDeclarativeEngine(this); diff --git a/tests/auto/declarative/qdeclarativedebugclient/qdeclarativedebugclient.pro b/tests/auto/declarative/qdeclarativedebugclient/qdeclarativedebugclient.pro index a3afd99..8fa87d2 100644 --- a/tests/auto/declarative/qdeclarativedebugclient/qdeclarativedebugclient.pro +++ b/tests/auto/declarative/qdeclarativedebugclient/qdeclarativedebugclient.pro @@ -5,3 +5,5 @@ macx:CONFIG -= app_bundle HEADERS += ../shared/debugutil_p.h SOURCES += tst_qdeclarativedebugclient.cpp \ ../shared/debugutil.cpp + +CONFIG += declarative_debug diff --git a/tests/auto/declarative/qdeclarativedebugclient/tst_qdeclarativedebugclient.cpp b/tests/auto/declarative/qdeclarativedebugclient/tst_qdeclarativedebugclient.cpp index d41cfa3..1599cab 100644 --- a/tests/auto/declarative/qdeclarativedebugclient/tst_qdeclarativedebugclient.cpp +++ b/tests/auto/declarative/qdeclarativedebugclient/tst_qdeclarativedebugclient.cpp @@ -51,7 +51,6 @@ #include #include #include -#include #include "../../../shared/util.h" #include "../shared/debugutil_p.h" @@ -73,9 +72,6 @@ private slots: void tst_QDeclarativeDebugClient::initTestCase() { - QTest::ignoreMessage(QtWarningMsg, "Qml debugging is enabled. Only use this in a safe environment!"); - QDeclarativeDebugHelper::enableDebugging(); - QTest::ignoreMessage(QtWarningMsg, "QDeclarativeDebugServer: Waiting for connection on port 13770..."); new QDeclarativeEngine(this); diff --git a/tests/auto/declarative/qdeclarativedebugjs/app/app.pro b/tests/auto/declarative/qdeclarativedebugjs/app/app.pro index 800c033..d1c0cdd 100644 --- a/tests/auto/declarative/qdeclarativedebugjs/app/app.pro +++ b/tests/auto/declarative/qdeclarativedebugjs/app/app.pro @@ -1,6 +1,7 @@ TEMPLATE = app QT += declarative +CONFIG += declarative_debug CONFIG += console CONFIG -= app_bundle diff --git a/tests/auto/declarative/qdeclarativedebugjs/app/main.cpp b/tests/auto/declarative/qdeclarativedebugjs/app/main.cpp index f5b830e..fe58502 100644 --- a/tests/auto/declarative/qdeclarativedebugjs/app/main.cpp +++ b/tests/auto/declarative/qdeclarativedebugjs/app/main.cpp @@ -44,13 +44,10 @@ #include #include #include -#include #include int main(int argc, char *argv[]) { - QDeclarativeDebugHelper::enableDebugging(); - QApplication app(argc, argv); const QUrl path = QUrl::fromLocalFile(app.arguments().last()); diff --git a/tests/auto/declarative/qdeclarativedebugservice/qdeclarativedebugservice.pro b/tests/auto/declarative/qdeclarativedebugservice/qdeclarativedebugservice.pro index a62e148..ca5a398 100644 --- a/tests/auto/declarative/qdeclarativedebugservice/qdeclarativedebugservice.pro +++ b/tests/auto/declarative/qdeclarativedebugservice/qdeclarativedebugservice.pro @@ -6,5 +6,5 @@ HEADERS += ../shared/debugutil_p.h SOURCES += tst_qdeclarativedebugservice.cpp \ ../shared/debugutil.cpp -CONFIG += parallel_test +CONFIG += parallel_test declarative_debug diff --git a/tests/auto/declarative/qdeclarativedebugservice/tst_qdeclarativedebugservice.cpp b/tests/auto/declarative/qdeclarativedebugservice/tst_qdeclarativedebugservice.cpp index 3fa8bba..74f549c 100644 --- a/tests/auto/declarative/qdeclarativedebugservice/tst_qdeclarativedebugservice.cpp +++ b/tests/auto/declarative/qdeclarativedebugservice/tst_qdeclarativedebugservice.cpp @@ -46,7 +46,6 @@ #include #include -#include #include #include @@ -76,9 +75,6 @@ private slots: void tst_QDeclarativeDebugService::initTestCase() { - QTest::ignoreMessage(QtWarningMsg, "Qml debugging is enabled. Only use this in a safe environment!"); - QDeclarativeDebugHelper::enableDebugging(); - QTest::ignoreMessage(QtWarningMsg, "QDeclarativeDebugServer: Waiting for connection on port 13769..."); new QDeclarativeEngine(this); -- cgit v0.12 From 4b52d866748c848184c3d5f314ba6d84fd8f8d5c Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Wed, 24 Aug 2011 15:53:12 +0200 Subject: Add qdeclarativedebugjs autotests to declarative.pro We forgot about this in the original commit. Change-Id: Ic88c6155e0f95bb8d93629489ab6c95b1844bca7 Reviewed-by: TrustMe --- tests/auto/declarative/declarative.pro | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/auto/declarative/declarative.pro b/tests/auto/declarative/declarative.pro index 72c32cb..08d59d3 100644 --- a/tests/auto/declarative/declarative.pro +++ b/tests/auto/declarative/declarative.pro @@ -39,6 +39,7 @@ contains(QT_CONFIG, private_tests) { qdeclarativedebug \ qdeclarativedebugclient \ qdeclarativedebugservice \ + qdeclarativedebugjs \ qdeclarativedom \ qdeclarativeecmascript \ qdeclarativeflickable \ -- cgit v0.12 From 3074b010734f8bc3e982c42473e6c39a63e4cce0 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Thu, 25 Aug 2011 15:37:05 +0200 Subject: QDeclarativeDebugJs: Disable unstable autotest The application might get the COVERAGE false message before anything is executed. Change-Id: Iafa26e527757a76a1e8502c362ba767acfe87e75 Reviewed-by: Aurindam Jana --- .../declarative/qdeclarativedebugjs/tst_qdeclarativedebugjs.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/auto/declarative/qdeclarativedebugjs/tst_qdeclarativedebugjs.cpp b/tests/auto/declarative/qdeclarativedebugjs/tst_qdeclarativedebugjs.cpp index 1990c0d..f841272 100644 --- a/tests/auto/declarative/qdeclarativedebugjs/tst_qdeclarativedebugjs.cpp +++ b/tests/auto/declarative/qdeclarativedebugjs/tst_qdeclarativedebugjs.cpp @@ -1431,8 +1431,10 @@ void tst_QDeclarativeDebugJS::testCoverageRun() client.startCoverageRun(); client.startCoverageCompleted(); - QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(coverageScriptLoaded()))); - QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(coveragePosChanged()))); + + // The app might get "COVERAGE false" before anything is actually executed + //QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(coverageScriptLoaded()))); + //QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(coveragePosChanged()))); //QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(coverageFuncEntered()))); //QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(coverageFuncExited()))); } -- cgit v0.12 From 01f09542782ce87483979d9e817b95d55a3b28d3 Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Mon, 15 Aug 2011 13:44:44 +1000 Subject: FocusScope's focusItem must always be a descendent Task-number: QTBUG-20699 Reviewed-by: Michael Brasser --- src/gui/graphicsview/qgraphicsitem.cpp | 34 ++++++++++++++------------ tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp | 32 ++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 16 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index 2ac2bdf..0c218fc 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -1171,24 +1171,26 @@ void QGraphicsItemPrivate::setParentItemHelper(QGraphicsItem *newParent, const Q // Update focus scope item ptr in new scope. QGraphicsItem *newFocusScopeItem = subFocusItem ? subFocusItem : parentFocusScopeItem; if (newFocusScopeItem && newParent) { - if (subFocusItem) { - // Find the subFocusItem's topmost focus scope. - QGraphicsItem *ancestorScope = 0; - QGraphicsItem *p = subFocusItem->d_ptr->parent; - while (p) { - if (p->d_ptr->flags & QGraphicsItem::ItemIsFocusScope) - ancestorScope = p; - if (p->d_ptr->flags & QGraphicsItem::ItemIsPanel) - break; - p = p->d_ptr->parent; - } - if (ancestorScope) - newFocusScopeItem = ancestorScope; - } - QGraphicsItem *p = newParent; while (p) { if (p->d_ptr->flags & QGraphicsItem::ItemIsFocusScope) { + if (subFocusItem && subFocusItem != q_ptr) { + // Find the subFocusItem's topmost focus scope within the new parent's focusscope + QGraphicsItem *ancestorScope = 0; + QGraphicsItem *p2 = subFocusItem->d_ptr->parent; + while (p2 && p2 != p) { + if (p2->d_ptr->flags & QGraphicsItem::ItemIsFocusScope) + ancestorScope = p2; + if (p2->d_ptr->flags & QGraphicsItem::ItemIsPanel) + break; + if (p2 == q_ptr) + break; + p2 = p2->d_ptr->parent; + } + if (ancestorScope) + newFocusScopeItem = ancestorScope; + } + p->d_ptr->focusScopeItem = newFocusScopeItem; newFocusScopeItem->d_ptr->focusScopeItemChange(true); // Ensure the new item is no longer the subFocusItem. The @@ -3297,7 +3299,7 @@ void QGraphicsItemPrivate::setFocusHelper(Qt::FocusReason focusReason, bool clim } if (climb) { - while (f->d_ptr->focusScopeItem && f->d_ptr->focusScopeItem->isVisible() && f->d_ptr->focusScopeItem != f) + while (f->d_ptr->focusScopeItem && f->d_ptr->focusScopeItem->isVisible()) f = f->d_ptr->focusScopeItem; } diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp index 3665b10..9b834d5 100644 --- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp @@ -475,6 +475,7 @@ private slots: void QTBUG_12112_focusItem(); void QTBUG_13473_sceneposchange(); void QTBUG_16374_crashInDestructor(); + void QTBUG_20699_focusScopeCrash(); private: QList paintedItems; @@ -11265,5 +11266,36 @@ void tst_QGraphicsItem::QTBUG_16374_crashInDestructor() QTest::qWaitForWindowShown(&view); } +void tst_QGraphicsItem::QTBUG_20699_focusScopeCrash() +{ + QGraphicsScene scene; + QGraphicsView view(&scene); + QGraphicsPixmapItem fs; + fs.setFlags(QGraphicsItem::ItemIsFocusScope | QGraphicsItem::ItemIsFocusable); + scene.addItem(&fs); + QGraphicsPixmapItem* fs2 = new QGraphicsPixmapItem(&fs); + fs2->setFlags(QGraphicsItem::ItemIsFocusScope | QGraphicsItem::ItemIsFocusable); + QGraphicsPixmapItem* fi2 = new QGraphicsPixmapItem(&fs); + fi2->setFlags(QGraphicsItem::ItemIsFocusable); + QGraphicsPixmapItem* fi = new QGraphicsPixmapItem(fs2); + fi->setFlags(QGraphicsItem::ItemIsFocusable); + fs.setFocus(); + fi->setFocus(); + + view.show(); + QTest::qWaitForWindowShown(&view); + + fi->setParentItem(fi2); + fi->setFocus(); + fs.setFocus(); + fi->setParentItem(fs2); + fi->setFocus(); + fs2->setFocus(); + fs.setFocus(); + fi->setParentItem(fi2); + fi->setFocus(); + fs.setFocus(); +} + QTEST_MAIN(tst_QGraphicsItem) #include "tst_qgraphicsitem.moc" -- cgit v0.12 From 71bcd941d577097ca99900554386c9f12d4353e3 Mon Sep 17 00:00:00 2001 From: Jocelyn Turcotte Date: Tue, 13 Sep 2011 15:33:31 +0200 Subject: Add missing checks for httpReply in QNetworkHttpBackend. httpReply is not guaranteed to be non-null. Adding missing checks for methods that can be called from outside the class. Reviewed-By: Peter Hartmann --- src/network/access/qnetworkaccesshttpbackend.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/network/access/qnetworkaccesshttpbackend.cpp b/src/network/access/qnetworkaccesshttpbackend.cpp index abef8ab..aa477fb 100644 --- a/src/network/access/qnetworkaccesshttpbackend.cpp +++ b/src/network/access/qnetworkaccesshttpbackend.cpp @@ -737,7 +737,7 @@ void QNetworkAccessHttpBackend::readFromHttp() void QNetworkAccessHttpBackend::replyFinished() { - if (httpReply->bytesAvailable()) + if (!httpReply || httpReply->bytesAvailable()) // we haven't read everything yet. Wait some more. return; @@ -788,6 +788,9 @@ void QNetworkAccessHttpBackend::checkForRedirect(const int statusCode) void QNetworkAccessHttpBackend::replyHeaderChanged() { + if (!httpReply) + return; + setAttribute(QNetworkRequest::HttpPipeliningWasUsedAttribute, httpReply->isPipeliningUsed()); // reconstruct the HTTP header @@ -1128,7 +1131,7 @@ bool QNetworkAccessHttpBackend::canResume() const return false; // Can only resume if server/resource supports Range header. - if (httpReply->headerField("Accept-Ranges", "none") == "none") + if (!httpReply || httpReply->headerField("Accept-Ranges", "none") == "none") return false; // We only support resuming for byte ranges. -- cgit v0.12 From c4cab7199590cc6b1901334e8ff604cd876fccee Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Wed, 14 Sep 2011 14:07:06 +0100 Subject: Prevent crash when cache is changed on the fly Calling QNetworkAccessManager::setCache while there were requests being processed using the existing cache caused crashes due to deleting the old cache invalidating pointers to the cache data streams (QTemporaryFile in case of QNetworkDiskCache). Using pointer to deleted data caused a crash in some cases. It has undefined behaviour because the memory may have been overwritten or decommitted. To fix this, use the deleted signal to notify QNetworkReplyImpl that the cache has been destroyed. It then clears the pointer to the data stream and disables caching. This avoids the crash that previously happened when trying to write to the cache file. Task-number: QT-5252 Reviewed-by: Peter Hartmann --- src/network/access/qnetworkreplyimpl.cpp | 23 +++++++++++++++++++---- src/network/access/qnetworkreplyimpl_p.h | 2 ++ 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/src/network/access/qnetworkreplyimpl.cpp b/src/network/access/qnetworkreplyimpl.cpp index 8a0a944..81cd548 100644 --- a/src/network/access/qnetworkreplyimpl.cpp +++ b/src/network/access/qnetworkreplyimpl.cpp @@ -446,6 +446,7 @@ bool QNetworkReplyImplPrivate::isCachingEnabled() const void QNetworkReplyImplPrivate::setCachingEnabled(bool enable) { + Q_Q(QNetworkReplyImpl); if (!enable && !cacheEnabled) return; // nothing to do if (enable && cacheEnabled) @@ -468,15 +469,27 @@ void QNetworkReplyImplPrivate::setCachingEnabled(bool enable) networkCache()->remove(url); cacheSaveDevice = 0; cacheEnabled = false; + QObject::disconnect(networkCache(), SIGNAL(destroyed()), q, SLOT(_q_cacheDestroyed())); } } +void QNetworkReplyImplPrivate::_q_cacheDestroyed() +{ + //destruction of cache invalidates cacheSaveDevice + cacheSaveDevice = 0; + cacheEnabled = false; +} + void QNetworkReplyImplPrivate::completeCacheSave() { - if (cacheEnabled && errorCode != QNetworkReplyImpl::NoError) { - networkCache()->remove(url); - } else if (cacheEnabled && cacheSaveDevice) { - networkCache()->insert(cacheSaveDevice); + Q_Q(QNetworkReplyImpl); + if (cacheEnabled) { + if (errorCode != QNetworkReplyImpl::NoError) { + networkCache()->remove(url); + } else if (cacheSaveDevice) { + networkCache()->insert(cacheSaveDevice); + } + QObject::disconnect(networkCache(), SIGNAL(destroyed()), q, SLOT(_q_cacheDestroyed())); } cacheSaveDevice = 0; cacheEnabled = false; @@ -536,6 +549,8 @@ void QNetworkReplyImplPrivate::initCacheSaveDevice() networkCache()->remove(url); cacheSaveDevice = 0; cacheEnabled = false; + } else { + q->connect(networkCache(), SIGNAL(destroyed()), SLOT(_q_cacheDestroyed())); } } diff --git a/src/network/access/qnetworkreplyimpl_p.h b/src/network/access/qnetworkreplyimpl_p.h index 31da297..0e4ff8f 100644 --- a/src/network/access/qnetworkreplyimpl_p.h +++ b/src/network/access/qnetworkreplyimpl_p.h @@ -103,6 +103,7 @@ public: Q_PRIVATE_SLOT(d_func(), void _q_networkSessionConnected()) Q_PRIVATE_SLOT(d_func(), void _q_networkSessionFailed()) #endif + Q_PRIVATE_SLOT(d_func(), void _q_cacheDestroyed()) }; class QNetworkReplyImplPrivate: public QNetworkReplyPrivate @@ -139,6 +140,7 @@ public: void _q_networkSessionConnected(); void _q_networkSessionFailed(); #endif + void _q_cacheDestroyed(); void setup(QNetworkAccessManager::Operation op, const QNetworkRequest &request, QIODevice *outgoingData); -- cgit v0.12 From 5571dbea919d1f122e7331cb0214e584c89efcb9 Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Fri, 18 Feb 2011 16:47:39 +0000 Subject: Fix RConnection handle leak in symbian bearer plugin The implementation was opening RConnection handles on top of previous instances, and not closing RConnection handles. Both of these cause a resource leak in the socket server which cannot clean up the connection until the Qt process has exited. After a lot of this (which could be triggered by the QNetworkReply auto test), the socket server may run out of memory resulting in all socket operations failing. Reviewed-by: Markus Goetz (cherry picked from commit f5e7b6c64caa67bf11fa9754114d686da73b22d6) --- .../bearer/symbian/qnetworksession_impl.cpp | 97 +++++++++------------- src/plugins/bearer/symbian/qnetworksession_impl.h | 1 + 2 files changed, 41 insertions(+), 57 deletions(-) diff --git a/src/plugins/bearer/symbian/qnetworksession_impl.cpp b/src/plugins/bearer/symbian/qnetworksession_impl.cpp index 5639c4f..fc6e141 100644 --- a/src/plugins/bearer/symbian/qnetworksession_impl.cpp +++ b/src/plugins/bearer/symbian/qnetworksession_impl.cpp @@ -89,33 +89,43 @@ QNetworkSessionPrivateImpl::QNetworkSessionPrivateImpl(SymbianEngine *engine) TRAP_IGNORE(iConnectionMonitor.ConnectL()); } -QNetworkSessionPrivateImpl::~QNetworkSessionPrivateImpl() +void QNetworkSessionPrivateImpl::closeHandles() { - isOpen = false; - isOpening = false; - // Cancel Connection Progress Notifications first. - // Note: ConnectionNotifier must be destroyed before Canceling RConnection::Start() + // Note: ConnectionNotifier must be destroyed before RConnection::Close() // => deleting ipConnectionNotifier results RConnection::CancelProgressNotification() delete ipConnectionNotifier; ipConnectionNotifier = NULL; #ifdef SNAP_FUNCTIONALITY_AVAILABLE - if (iMobility) { - delete iMobility; - iMobility = NULL; - } + // mobility monitor must be deleted before RConnection is closed + delete iMobility; + iMobility = NULL; #endif - // Cancel possible RConnection::Start() + // Cancel possible RConnection::Start() - may call RConnection::Close if Start was in progress Cancel(); - iSocketServ.Close(); + //close any open connection (note Close twice is safe in case Cancel did it above) + iConnection.Close(); // Close global 'Open C' RConnection // Clears also possible unsetdefaultif() flags. setdefaultif(0); iConnectionMonitor.Close(); +#ifdef QT_BEARERMGMT_SYMBIAN_DEBUG + qDebug() << "QNS this : " << QString::number((uint)this) + << " - handles closed"; +#endif + iSocketServ.Close(); +} + +QNetworkSessionPrivateImpl::~QNetworkSessionPrivateImpl() +{ + isOpen = false; + isOpening = false; + + closeHandles(); iOpenCLibrary.Close(); #ifdef QT_BEARERMGMT_SYMBIAN_DEBUG qDebug() << "QNS this : " << QString::number((uint)this) @@ -166,7 +176,7 @@ void QNetworkSessionPrivateImpl::configurationAdded(QNetworkConfigurationPrivate #ifdef QT_BEARERMGMT_SYMBIAN_DEBUG qDebug() << "QNS this : " << QString::number((uint)this) << " - " << "configurationAdded IAP: " - << toSymbianConfig(privateConfiguration(config))->numericIdentifier(); + << toSymbianConfig(config)->numericIdentifier(); #endif syncStateWithInterface(); @@ -372,7 +382,8 @@ void QNetworkSessionPrivateImpl::open() syncStateWithInterface(); return; } - + + Q_ASSERT(!iConnection.SubSessionHandle()); error = iConnection.Open(iSocketServ); if (error != KErrNone) { // Could not open RConnection @@ -414,8 +425,8 @@ void QNetworkSessionPrivateImpl::open() pref.SetIapId(symbianConfig->numericIdentifier()); #endif - iConnection.Start(pref, iStatus); if (!IsActive()) { + iConnection.Start(pref, iStatus); SetActive(); } // Avoid flip flop of states if the configuration is already @@ -442,8 +453,8 @@ void QNetworkSessionPrivateImpl::open() #else TConnSnapPref snapPref(symbianConfig->numericIdentifier()); #endif - iConnection.Start(snapPref, iStatus); if (!IsActive()) { + iConnection.Start(snapPref, iStatus); SetActive(); } // Avoid flip flop of states if the configuration is already @@ -453,8 +464,8 @@ void QNetworkSessionPrivateImpl::open() } } else if (publicConfig.type() == QNetworkConfiguration::UserChoice) { iKnownConfigsBeforeConnectionStart = engine->accessPointConfigurationIdentifiers(); - iConnection.Start(iStatus); if (!IsActive()) { + iConnection.Start(iStatus); SetActive(); } newState(QNetworkSession::Connecting); @@ -465,9 +476,7 @@ void QNetworkSessionPrivateImpl::open() isOpening = false; iError = QNetworkSession::UnknownSessionError; emit QNetworkSessionPrivate::error(iError); - if (ipConnectionNotifier) { - ipConnectionNotifier->StopNotifications(); - } + closeHandles(); syncStateWithInterface(); } } @@ -521,21 +530,10 @@ void QNetworkSessionPrivateImpl::close(bool allowSignals) serviceConfig = QNetworkConfiguration(); -#ifdef SNAP_FUNCTIONALITY_AVAILABLE - if (iMobility) { - delete iMobility; - iMobility = NULL; - } -#endif + closeHandles(); - if (ipConnectionNotifier && !iHandleStateNotificationsFromManager) { - ipConnectionNotifier->StopNotifications(); - // Start handling IAP state change signals from QNetworkConfigurationManagerPrivate - iHandleStateNotificationsFromManager = true; - } - - Cancel(); // closes iConnection - iSocketServ.Close(); + // Start handling IAP state change signals from QNetworkConfigurationManagerPrivate + iHandleStateNotificationsFromManager = true; // Close global 'Open C' RConnection. If OpenC supports, // close the defaultif for good to avoid difficult timing @@ -759,12 +757,14 @@ void QNetworkSessionPrivateImpl::NewCarrierActive(TAccessPointInfo /*aNewAPInfo* } } -void QNetworkSessionPrivateImpl::Error(TInt /*aError*/) +void QNetworkSessionPrivateImpl::Error(TInt aError) { #ifdef QT_BEARERMGMT_SYMBIAN_DEBUG qDebug() << "QNS this : " << QString::number((uint)this) << " - " - << "roaming Error() occurred, isOpen is: " << isOpen; + << "roaming Error() occurred" << aError << ", isOpen is: " << isOpen; #endif + if (aError == KErrCancel) + return; //avoid recursive deletion if (isOpen) { isOpen = false; isOpening = false; @@ -772,10 +772,7 @@ void QNetworkSessionPrivateImpl::Error(TInt /*aError*/) serviceConfig = QNetworkConfiguration(); iError = QNetworkSession::RoamingError; emit QNetworkSessionPrivate::error(iError); - Cancel(); - if (ipConnectionNotifier) { - ipConnectionNotifier->StopNotifications(); - } + closeHandles(); QT_TRY { syncStateWithInterface(); // In some cases IAP is still in Connected state when @@ -1102,18 +1099,13 @@ void QNetworkSessionPrivateImpl::RunL() isOpening = false; iError = QNetworkSession::UnknownSessionError; QT_TRYCATCH_LEAVING(emit QNetworkSessionPrivate::error(iError)); - if (ipConnectionNotifier) { - ipConnectionNotifier->StopNotifications(); - } + closeHandles(); if (!newActiveConfig.isValid()) { // No valid configuration, bail out. // Status updates from QNCM won't be received correctly // because there is no configuration to associate them with so transit here. - iConnection.Close(); newState(QNetworkSession::Closing); newState(QNetworkSession::Disconnected); - } else { - Cancel(); } QT_TRYCATCH_LEAVING(syncStateWithInterface()); return; @@ -1156,10 +1148,7 @@ void QNetworkSessionPrivateImpl::RunL() serviceConfig = QNetworkConfiguration(); iError = QNetworkSession::InvalidConfigurationError; QT_TRYCATCH_LEAVING(emit QNetworkSessionPrivate::error(iError)); - if (ipConnectionNotifier) { - ipConnectionNotifier->StopNotifications(); - } - Cancel(); + closeHandles(); QT_TRYCATCH_LEAVING(syncStateWithInterface()); break; case KErrCancel: // Connection attempt cancelled @@ -1178,10 +1167,7 @@ void QNetworkSessionPrivateImpl::RunL() iError = QNetworkSession::UnknownSessionError; } QT_TRYCATCH_LEAVING(emit QNetworkSessionPrivate::error(iError)); - if (ipConnectionNotifier) { - ipConnectionNotifier->StopNotifications(); - } - Cancel(); + closeHandles(); QT_TRYCATCH_LEAVING(syncStateWithInterface()); break; } @@ -1273,10 +1259,7 @@ bool QNetworkSessionPrivateImpl::newState(QNetworkSession::State newState, TUint serviceConfig = QNetworkConfiguration(); iError = QNetworkSession::SessionAbortedError; emit QNetworkSessionPrivate::error(iError); - if (ipConnectionNotifier) { - ipConnectionNotifier->StopNotifications(); - } - Cancel(); + closeHandles(); // Start handling IAP state change signals from QNetworkConfigurationManagerPrivate iHandleStateNotificationsFromManager = true; emitSessionClosed = true; // Emit SessionClosed after state change has been reported diff --git a/src/plugins/bearer/symbian/qnetworksession_impl.h b/src/plugins/bearer/symbian/qnetworksession_impl.h index 774b988..a597812 100644 --- a/src/plugins/bearer/symbian/qnetworksession_impl.h +++ b/src/plugins/bearer/symbian/qnetworksession_impl.h @@ -149,6 +149,7 @@ private: bool easyWlanTrueIapId(TUint32 &trueIapId) const; #endif + void closeHandles(); private: // data SymbianEngine *engine; -- cgit v0.12 From ada33b11092f278ae4f1280a6da07ffd151a31b6 Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Fri, 18 Feb 2011 17:22:32 +0000 Subject: Refactor dangerous multiple inheritance QObject and CBase both expect to be the root class of the object hierarchy so it can cause problems if they are used in multiple inheritance. Refactored the CActive used for starting RConnection into a helper class. Reviewed-by: Markus Goetz (cherry picked from commit 5a6365f14006ab50854e41a5927645c7e9966756) --- .../bearer/symbian/qnetworksession_impl.cpp | 82 ++++++++++++++++------ src/plugins/bearer/symbian/qnetworksession_impl.h | 29 ++++++-- 2 files changed, 86 insertions(+), 25 deletions(-) diff --git a/src/plugins/bearer/symbian/qnetworksession_impl.cpp b/src/plugins/bearer/symbian/qnetworksession_impl.cpp index fc6e141..5514511 100644 --- a/src/plugins/bearer/symbian/qnetworksession_impl.cpp +++ b/src/plugins/bearer/symbian/qnetworksession_impl.cpp @@ -61,13 +61,12 @@ QT_BEGIN_NAMESPACE QNetworkSessionPrivateImpl::QNetworkSessionPrivateImpl(SymbianEngine *engine) -: CActive(CActive::EPriorityUserInput), engine(engine), - iDynamicUnSetdefaultif(0), ipConnectionNotifier(0), +: engine(engine), + ipConnectionNotifier(0), ipConnectionStarter(0), iHandleStateNotificationsFromManager(false), iFirstSync(true), iStoppedByUser(false), iClosedByUser(false), iError(QNetworkSession::UnknownSessionError), iALREnabled(0), iConnectInBackground(false), isOpening(false) { - CActiveScheduler::Add(this); #ifdef SNAP_FUNCTIONALITY_AVAILABLE iMobility = NULL; @@ -104,7 +103,8 @@ void QNetworkSessionPrivateImpl::closeHandles() #endif // Cancel possible RConnection::Start() - may call RConnection::Close if Start was in progress - Cancel(); + delete ipConnectionStarter; + ipConnectionStarter = 0; //close any open connection (note Close twice is safe in case Cancel did it above) iConnection.Close(); @@ -425,9 +425,9 @@ void QNetworkSessionPrivateImpl::open() pref.SetIapId(symbianConfig->numericIdentifier()); #endif - if (!IsActive()) { - iConnection.Start(pref, iStatus); - SetActive(); + if (!ipConnectionStarter) { + ipConnectionStarter = new ConnectionStarter(*this, iConnection); + ipConnectionStarter->Start(pref); } // Avoid flip flop of states if the configuration is already // active. IsOpen/opened() will indicate when ready. @@ -453,9 +453,9 @@ void QNetworkSessionPrivateImpl::open() #else TConnSnapPref snapPref(symbianConfig->numericIdentifier()); #endif - if (!IsActive()) { - iConnection.Start(snapPref, iStatus); - SetActive(); + if (!ipConnectionStarter) { + ipConnectionStarter = new ConnectionStarter(*this, iConnection); + ipConnectionStarter->Start(snapPref); } // Avoid flip flop of states if the configuration is already // active. IsOpen/opened() will indicate when ready. @@ -464,9 +464,9 @@ void QNetworkSessionPrivateImpl::open() } } else if (publicConfig.type() == QNetworkConfiguration::UserChoice) { iKnownConfigsBeforeConnectionStart = engine->accessPointConfigurationIdentifiers(); - if (!IsActive()) { - iConnection.Start(iStatus); - SetActive(); + if (!ipConnectionStarter) { + ipConnectionStarter = new ConnectionStarter(*this, iConnection); + ipConnectionStarter->Start(); } newState(QNetworkSession::Connecting); } @@ -1066,13 +1066,14 @@ QNetworkConfiguration QNetworkSessionPrivateImpl::activeConfiguration(TUint32 ia return publicConfig; } -void QNetworkSessionPrivateImpl::RunL() +void QNetworkSessionPrivateImpl::ConnectionStartComplete(TInt statusCode) { #ifdef QT_BEARERMGMT_SYMBIAN_DEBUG qDebug() << "QNS this : " << QString::number((uint)this) << " - " - << "RConnection::RunL with status code: " << iStatus.Int(); + << "RConnection::Start completed with status code: " << statusCode; #endif - TInt statusCode = iStatus.Int(); + delete ipConnectionStarter; + ipConnectionStarter = 0; switch (statusCode) { case KErrNone: // Connection created successfully @@ -1173,11 +1174,6 @@ void QNetworkSessionPrivateImpl::RunL() } } -void QNetworkSessionPrivateImpl::DoCancel() -{ - iConnection.Close(); -} - // Enters newState if feasible according to current state. // AccessPointId may be given as parameter. If it is zero, state-change is assumed to // concern this session's configuration. If non-zero, the configuration is looked up @@ -1566,6 +1562,50 @@ void ConnectionProgressNotifier::RunL() } } +ConnectionStarter::ConnectionStarter(QNetworkSessionPrivateImpl &owner, RConnection &connection) + : CActive(CActive::EPriorityUserInput), iOwner(owner), iConnection(connection) +{ + CActiveScheduler::Add(this); +} + +ConnectionStarter::~ConnectionStarter() +{ + Cancel(); +} + +void ConnectionStarter::Start() +{ + if (!IsActive()) { + iConnection.Start(iStatus); + SetActive(); + } +} + +void ConnectionStarter::Start(TConnPref &pref) +{ + if (!IsActive()) { + iConnection.Start(pref, iStatus); + SetActive(); + } +} + +void ConnectionStarter::RunL() +{ + iOwner.ConnectionStartComplete(iStatus.Int()); + //note owner deletes on callback +} + +TInt ConnectionStarter::RunError(TInt err) +{ + qWarning() << "ConnectionStarter::RunError" << err; + return KErrNone; +} + +void ConnectionStarter::DoCancel() +{ + iConnection.Close(); +} + QT_END_NAMESPACE #endif //QT_NO_BEARERMANAGEMENT diff --git a/src/plugins/bearer/symbian/qnetworksession_impl.h b/src/plugins/bearer/symbian/qnetworksession_impl.h index a597812..a5a4f87 100644 --- a/src/plugins/bearer/symbian/qnetworksession_impl.h +++ b/src/plugins/bearer/symbian/qnetworksession_impl.h @@ -68,11 +68,12 @@ QT_BEGIN_NAMESPACE class ConnectionProgressNotifier; +class ConnectionStarter; class SymbianEngine; typedef void (*TOpenCUnSetdefaultifFunction)(); -class QNetworkSessionPrivateImpl : public QNetworkSessionPrivate, public CActive +class QNetworkSessionPrivateImpl : public QNetworkSessionPrivate #ifdef SNAP_FUNCTIONALITY_AVAILABLE , public MMobilityProtocolResp #endif @@ -125,7 +126,7 @@ public: // From MMobilityProtocolResp #endif protected: // From CActive - void RunL(); + void ConnectionStartComplete(TInt statusCode); void DoCancel(); private Q_SLOTS: @@ -167,12 +168,13 @@ private: // data mutable RConnection iConnection; mutable RConnectionMonitor iConnectionMonitor; ConnectionProgressNotifier* ipConnectionNotifier; - + ConnectionStarter* ipConnectionStarter; + bool iHandleStateNotificationsFromManager; bool iFirstSync; bool iStoppedByUser; bool iClosedByUser; - + #ifdef SNAP_FUNCTIONALITY_AVAILABLE CActiveCommsMobilityApiExt* iMobility; #endif @@ -190,6 +192,7 @@ private: // data bool isOpening; friend class ConnectionProgressNotifier; + friend class ConnectionStarter; }; class ConnectionProgressNotifier : public CActive @@ -212,6 +215,24 @@ private: // Data }; +class ConnectionStarter : public CActive +{ +public: + ConnectionStarter(QNetworkSessionPrivateImpl &owner, RConnection &connection); + ~ConnectionStarter(); + + void Start(); + void Start(TConnPref &pref); +protected: + void RunL(); + TInt RunError(TInt err); + void DoCancel(); + +private: // Data + QNetworkSessionPrivateImpl &iOwner; + RConnection& iConnection; +}; + QT_END_NAMESPACE #endif //QNETWORKSESSION_IMPL_H -- cgit v0.12 From 22ef6f15102cd287bd3cdbc9fe723d22b35560ca Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Wed, 31 Aug 2011 10:01:19 +0200 Subject: Debugger: Move QT_DECLARATIVE_DEBUG handling out of qdeclarative.h Apps don't have to (directly or indirectly) include qdeclarative.h. Instead, move the static instance to qdeclarativeengine.h, and qdeclarativeview.h (which instantiates it's own engine). Change-Id: I8b3e63ad4f134969734a2cc712395145d90e0dfa Reviewed-on: http://codereview.qt.nokia.com/3941 Reviewed-by: Qt Sanity Bot Reviewed-by: Aurindam Jana Reviewed-by: Martin Jones (cherrypicked from commit 6cb39fb829b78b5f6e9751283c7cd50400821e2a) --- src/declarative/debugger/debugger.pri | 3 +- src/declarative/debugger/qdeclarativedebug.h | 67 ++++++++++++++++++++++++++++ src/declarative/qml/qdeclarative.h | 11 ----- src/declarative/qml/qdeclarativeengine.h | 1 + src/declarative/util/qdeclarativeview.h | 1 + 5 files changed, 71 insertions(+), 12 deletions(-) create mode 100644 src/declarative/debugger/qdeclarativedebug.h diff --git a/src/declarative/debugger/debugger.pri b/src/declarative/debugger/debugger.pri index 3134c79..a904f6f 100644 --- a/src/declarative/debugger/debugger.pri +++ b/src/declarative/debugger/debugger.pri @@ -27,4 +27,5 @@ HEADERS += \ $$PWD/qdeclarativeinspectorservice_p.h \ $$PWD/qdeclarativeinspectorinterface_p.h \ $$PWD/qjsdebuggeragent_p.h \ - $$PWD/qjsdebugservice_p.h + $$PWD/qjsdebugservice_p.h \ + $$PWD/qdeclarativedebug.h diff --git a/src/declarative/debugger/qdeclarativedebug.h b/src/declarative/debugger/qdeclarativedebug.h new file mode 100644 index 0000000..b7930b2 --- /dev/null +++ b/src/declarative/debugger/qdeclarativedebug.h @@ -0,0 +1,67 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QDECLARATIVEDEBUG_H +#define QDECLARATIVEDEBUG_H + +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Declarative) + +struct Q_DECLARATIVE_EXPORT QDeclarativeDebuggingEnabler +{ + QDeclarativeDebuggingEnabler(); +}; + +// Execute code in constructor before first QDeclarativeEngine is instantiated +#if defined(QT_DECLARATIVE_DEBUG) +static QDeclarativeDebuggingEnabler qmlEnableDebuggingHelper; +#endif + +QT_END_NAMESPACE + +QT_END_HEADER + +#endif // QDECLARATIVEDEBUG_H diff --git a/src/declarative/qml/qdeclarative.h b/src/declarative/qml/qdeclarative.h index 5e8d0f4..399c207 100644 --- a/src/declarative/qml/qdeclarative.h +++ b/src/declarative/qml/qdeclarative.h @@ -405,17 +405,6 @@ QObject *qmlAttachedPropertiesObject(const QObject *obj, bool create = true) return qmlAttachedPropertiesObject(&idx, obj, &T::staticMetaObject, create); } -// Enable debugging before any QDeclarativeEngine is created -struct Q_DECLARATIVE_EXPORT QDeclarativeDebuggingEnabler -{ - QDeclarativeDebuggingEnabler(); -}; - -// Execute code in constructor before first QDeclarativeEngine is instantiated -#if defined(QT_DECLARATIVE_DEBUG) -static QDeclarativeDebuggingEnabler qmlEnableDebuggingHelper; -#endif - QT_END_NAMESPACE QML_DECLARE_TYPE(QObject) diff --git a/src/declarative/qml/qdeclarativeengine.h b/src/declarative/qml/qdeclarativeengine.h index 61ab2b2..4d6887f 100644 --- a/src/declarative/qml/qdeclarativeengine.h +++ b/src/declarative/qml/qdeclarativeengine.h @@ -47,6 +47,7 @@ #include #include #include +#include QT_BEGIN_HEADER diff --git a/src/declarative/util/qdeclarativeview.h b/src/declarative/util/qdeclarativeview.h index b3854fc..ef51934 100644 --- a/src/declarative/util/qdeclarativeview.h +++ b/src/declarative/util/qdeclarativeview.h @@ -47,6 +47,7 @@ #include #include #include +#include QT_BEGIN_HEADER -- cgit v0.12 From 83d3085841b2caadb15c2534b1a2e329949f748d Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Thu, 15 Sep 2011 18:19:28 +1000 Subject: Fix aliasing bug when compiled with gcc 4.6 Task-number: QTBUG-21265 --- src/declarative/qml/qdeclarativenotifier_p.h | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/src/declarative/qml/qdeclarativenotifier_p.h b/src/declarative/qml/qdeclarativenotifier_p.h index 5f70f7d..e46b843 100644 --- a/src/declarative/qml/qdeclarativenotifier_p.h +++ b/src/declarative/qml/qdeclarativenotifier_p.h @@ -99,8 +99,15 @@ private: enum { InvalidType, SignalType, NotifierType } type; union { - char signalData[sizeof(Signal)]; - char notifierData[sizeof(Notifier)]; + struct { + Signal *signal; + union { + char signalData[sizeof(Signal)]; + qint64 q_for_alignment_1; + double q_for_alignment_2; + }; + }; + Notifier notifier; }; inline Notifier *toNotifier(); @@ -194,7 +201,7 @@ void QDeclarativeNotifierEndpoint::connect(QDeclarativeNotifier *notifier) void QDeclarativeNotifierEndpoint::disconnect() { if (type == SignalType) { - Signal *s = (Signal *)&signalData; + Signal *s = asSignal(); if (s->source) { QMetaObject::disconnectOne(s->source, s->sourceSignal, target, targetMethod); s->source = 0; @@ -234,7 +241,8 @@ QDeclarativeNotifierEndpoint::Notifier *QDeclarativeNotifierEndpoint::toNotifier QDeclarativeNotifierEndpoint::Notifier *QDeclarativeNotifierEndpoint::asNotifier() { - return (Notifier *)(¬ifierData); + Q_ASSERT(type == NotifierType); + return ¬ifier; } QDeclarativeNotifierEndpoint::Signal *QDeclarativeNotifierEndpoint::toSignal() @@ -243,16 +251,15 @@ QDeclarativeNotifierEndpoint::Signal *QDeclarativeNotifierEndpoint::toSignal() return asSignal(); disconnect(); - Signal *s = asSignal(); - new (s) Signal; + signal = new (&signalData) Signal; type = SignalType; - - return s; + return signal; } QDeclarativeNotifierEndpoint::Signal *QDeclarativeNotifierEndpoint::asSignal() { - return (Signal *)(&signalData); + Q_ASSERT(type == SignalType); + return signal; } QT_END_NAMESPACE -- cgit v0.12 From 6aebdf7a224ea976adc74bf47bd49fa6a1606ee2 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Tue, 30 Aug 2011 17:21:30 +0200 Subject: Rename QDeclarativeEngineDebugServer to ~Service And fix the file names/location, too Change-Id: If2d5ec0896332896ad11af748ec8f75c39e1555c Reviewed-on: http://codereview.qt.nokia.com/3890 Reviewed-by: Qt Sanity Bot Reviewed-by: Kai Koehne (cherrypicked from 8804ec49bda8672c5700ab843f2958c3d2bd8e41) --- src/declarative/debugger/debugger.pri | 6 +- src/declarative/debugger/qdeclarativedebug.cpp | 16 +- .../debugger/qdeclarativeenginedebugservice.cpp | 747 +++++++++++++++++++++ .../debugger/qdeclarativeenginedebugservice_p.h | 134 ++++ src/declarative/qml/qdeclarativecomponent.cpp | 4 +- src/declarative/qml/qdeclarativeengine.cpp | 8 +- src/declarative/qml/qdeclarativeenginedebug.cpp | 747 --------------------- src/declarative/qml/qdeclarativeenginedebug_p.h | 134 ---- src/declarative/qml/qml.pri | 2 - .../qdeclarativedebug/tst_qdeclarativedebug.cpp | 1 - .../tst_qdeclarativedebugclient.cpp | 1 - .../tst_qdeclarativedebugservice.cpp | 1 - 12 files changed, 899 insertions(+), 902 deletions(-) create mode 100644 src/declarative/debugger/qdeclarativeenginedebugservice.cpp create mode 100644 src/declarative/debugger/qdeclarativeenginedebugservice_p.h delete mode 100644 src/declarative/qml/qdeclarativeenginedebug.cpp delete mode 100644 src/declarative/qml/qdeclarativeenginedebug_p.h diff --git a/src/declarative/debugger/debugger.pri b/src/declarative/debugger/debugger.pri index a904f6f..0810872 100644 --- a/src/declarative/debugger/debugger.pri +++ b/src/declarative/debugger/debugger.pri @@ -11,7 +11,8 @@ SOURCES += \ $$PWD/qdeclarativedebugserver.cpp \ $$PWD/qdeclarativeinspectorservice.cpp \ $$PWD/qjsdebuggeragent.cpp \ - $$PWD/qjsdebugservice.cpp + $$PWD/qjsdebugservice.cpp \ + $$PWD/qdeclarativeenginedebugservice.cpp HEADERS += \ $$PWD/qdeclarativedebuggerstatus_p.h \ @@ -28,4 +29,5 @@ HEADERS += \ $$PWD/qdeclarativeinspectorinterface_p.h \ $$PWD/qjsdebuggeragent_p.h \ $$PWD/qjsdebugservice_p.h \ - $$PWD/qdeclarativedebug.h + $$PWD/qdeclarativedebug.h \ + $$PWD/qdeclarativeenginedebugservice_p.h diff --git a/src/declarative/debugger/qdeclarativedebug.cpp b/src/declarative/debugger/qdeclarativedebug.cpp index 620ee1d..17bd553 100644 --- a/src/declarative/debugger/qdeclarativedebug.cpp +++ b/src/declarative/debugger/qdeclarativedebug.cpp @@ -43,7 +43,7 @@ #include "private/qdeclarativedebugclient_p.h" -#include +#include #include @@ -207,7 +207,7 @@ void QDeclarativeEngineDebugPrivate::remove(QDeclarativeEngineDebug *c, QDeclara void QDeclarativeEngineDebugPrivate::decode(QDataStream &ds, QDeclarativeDebugObjectReference &o, bool simple) { - QDeclarativeEngineDebugServer::QDeclarativeObjectData data; + QDeclarativeEngineDebugService::QDeclarativeObjectData data; ds >> data; o.m_debugId = data.objectId; o.m_class = data.objectType; @@ -234,7 +234,7 @@ void QDeclarativeEngineDebugPrivate::decode(QDataStream &ds, QDeclarativeDebugOb ds >> propCount; for (int ii = 0; ii < propCount; ++ii) { - QDeclarativeEngineDebugServer::QDeclarativeObjectProperty data; + QDeclarativeEngineDebugService::QDeclarativeObjectProperty data; ds >> data; QDeclarativeDebugPropertyReference prop; prop.m_objectDebugId = o.m_debugId; @@ -243,21 +243,21 @@ void QDeclarativeEngineDebugPrivate::decode(QDataStream &ds, QDeclarativeDebugOb prop.m_hasNotifySignal = data.hasNotifySignal; prop.m_valueTypeName = data.valueTypeName; switch (data.type) { - case QDeclarativeEngineDebugServer::QDeclarativeObjectProperty::Basic: - case QDeclarativeEngineDebugServer::QDeclarativeObjectProperty::List: - case QDeclarativeEngineDebugServer::QDeclarativeObjectProperty::SignalProperty: + case QDeclarativeEngineDebugService::QDeclarativeObjectProperty::Basic: + case QDeclarativeEngineDebugService::QDeclarativeObjectProperty::List: + case QDeclarativeEngineDebugService::QDeclarativeObjectProperty::SignalProperty: { prop.m_value = data.value; break; } - case QDeclarativeEngineDebugServer::QDeclarativeObjectProperty::Object: + case QDeclarativeEngineDebugService::QDeclarativeObjectProperty::Object: { QDeclarativeDebugObjectReference obj; obj.m_debugId = prop.m_value.toInt(); prop.m_value = QVariant::fromValue(obj); break; } - case QDeclarativeEngineDebugServer::QDeclarativeObjectProperty::Unknown: + case QDeclarativeEngineDebugService::QDeclarativeObjectProperty::Unknown: break; } o.m_properties << prop; diff --git a/src/declarative/debugger/qdeclarativeenginedebugservice.cpp b/src/declarative/debugger/qdeclarativeenginedebugservice.cpp new file mode 100644 index 0000000..7683733 --- /dev/null +++ b/src/declarative/debugger/qdeclarativeenginedebugservice.cpp @@ -0,0 +1,747 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "private/qdeclarativeenginedebugservice_p.h" + +#include "private/qdeclarativeboundsignal_p.h" +#include "qdeclarativeengine.h" +#include "private/qdeclarativemetatype_p.h" +#include "qdeclarativeproperty.h" +#include "private/qdeclarativeproperty_p.h" +#include "private/qdeclarativebinding_p.h" +#include "private/qdeclarativecontext_p.h" +#include "private/qdeclarativewatcher_p.h" +#include "private/qdeclarativevaluetype_p.h" +#include "private/qdeclarativevmemetaobject_p.h" +#include "private/qdeclarativeexpression_p.h" +#include "private/qdeclarativepropertychanges_p.h" + +#include +#include + +QT_BEGIN_NAMESPACE + +Q_GLOBAL_STATIC(QDeclarativeEngineDebugService, qmlEngineDebugService); + +QDeclarativeEngineDebugService *QDeclarativeEngineDebugService::instance() +{ + return qmlEngineDebugService(); +} + +QDeclarativeEngineDebugService::QDeclarativeEngineDebugService(QObject *parent) +: QDeclarativeDebugService(QLatin1String("QDeclarativeEngine"), parent), + m_watch(new QDeclarativeWatcher(this)) +{ + QObject::connect(m_watch, SIGNAL(propertyChanged(int,int,QMetaProperty,QVariant)), + this, SLOT(propertyChanged(int,int,QMetaProperty,QVariant))); +} + +QDataStream &operator<<(QDataStream &ds, + const QDeclarativeEngineDebugService::QDeclarativeObjectData &data) +{ + ds << data.url << data.lineNumber << data.columnNumber << data.idString + << data.objectName << data.objectType << data.objectId << data.contextId; + return ds; +} + +QDataStream &operator>>(QDataStream &ds, + QDeclarativeEngineDebugService::QDeclarativeObjectData &data) +{ + ds >> data.url >> data.lineNumber >> data.columnNumber >> data.idString + >> data.objectName >> data.objectType >> data.objectId >> data.contextId; + return ds; +} + +QDataStream &operator<<(QDataStream &ds, + const QDeclarativeEngineDebugService::QDeclarativeObjectProperty &data) +{ + ds << (int)data.type << data.name << data.value << data.valueTypeName + << data.binding << data.hasNotifySignal; + return ds; +} + +QDataStream &operator>>(QDataStream &ds, + QDeclarativeEngineDebugService::QDeclarativeObjectProperty &data) +{ + int type; + ds >> type >> data.name >> data.value >> data.valueTypeName + >> data.binding >> data.hasNotifySignal; + data.type = (QDeclarativeEngineDebugService::QDeclarativeObjectProperty::Type)type; + return ds; +} + +static inline bool isSignalPropertyName(const QString &signalName) +{ + // see QmlCompiler::isSignalPropertyName + return signalName.length() >= 3 && signalName.startsWith(QLatin1String("on")) && + signalName.at(2).isLetter() && signalName.at(2).isUpper(); +} + +static bool hasValidSignal(QObject *object, const QString &propertyName) +{ + if (!isSignalPropertyName(propertyName)) + return false; + + QString signalName = propertyName.mid(2); + signalName[0] = signalName.at(0).toLower(); + + int sigIdx = QDeclarativePropertyPrivate::findSignalByName(object->metaObject(), signalName.toLatin1()).methodIndex(); + + if (sigIdx == -1) + return false; + + return true; +} + +QDeclarativeEngineDebugService::QDeclarativeObjectProperty +QDeclarativeEngineDebugService::propertyData(QObject *obj, int propIdx) +{ + QDeclarativeObjectProperty rv; + + QMetaProperty prop = obj->metaObject()->property(propIdx); + + rv.type = QDeclarativeObjectProperty::Unknown; + rv.valueTypeName = QString::fromUtf8(prop.typeName()); + rv.name = QString::fromUtf8(prop.name()); + rv.hasNotifySignal = prop.hasNotifySignal(); + QDeclarativeAbstractBinding *binding = + QDeclarativePropertyPrivate::binding(QDeclarativeProperty(obj, rv.name)); + if (binding) + rv.binding = binding->expression(); + + if (QDeclarativeValueTypeFactory::isValueType(prop.userType())) { + rv.type = QDeclarativeObjectProperty::Basic; + } else if (QDeclarativeMetaType::isQObject(prop.userType())) { + rv.type = QDeclarativeObjectProperty::Object; + } else if (QDeclarativeMetaType::isList(prop.userType())) { + rv.type = QDeclarativeObjectProperty::List; + } + + QVariant value; + if (rv.type != QDeclarativeObjectProperty::Unknown && prop.userType() != 0) { + value = prop.read(obj); + } + rv.value = valueContents(value); + + return rv; +} + +QVariant QDeclarativeEngineDebugService::valueContents(const QVariant &value) const +{ + int userType = value.userType(); + + if (value.type() == QVariant::List) { + QVariantList contents; + QVariantList list = value.toList(); + int count = list.size(); + for (int i = 0; i < count; i++) + contents << valueContents(list.at(i)); + return contents; + } + + if (QDeclarativeValueTypeFactory::isValueType(userType)) + return value; + + if (QDeclarativeMetaType::isQObject(userType)) { + QObject *o = QDeclarativeMetaType::toQObject(value); + if (o) { + QString name = o->objectName(); + if (name.isEmpty()) + name = QLatin1String(""); + return name; + } + } + + return QLatin1String(""); +} + +void QDeclarativeEngineDebugService::buildObjectDump(QDataStream &message, + QObject *object, bool recur, bool dumpProperties) +{ + message << objectData(object); + + QObjectList children = object->children(); + + int childrenCount = children.count(); + for (int ii = 0; ii < children.count(); ++ii) { + if (qobject_cast(children[ii]) || QDeclarativeBoundSignal::cast(children[ii])) + --childrenCount; + } + + message << childrenCount << recur; + + QList fakeProperties; + + for (int ii = 0; ii < children.count(); ++ii) { + QObject *child = children.at(ii); + if (qobject_cast(child)) + continue; + QDeclarativeBoundSignal *signal = QDeclarativeBoundSignal::cast(child); + if (signal) { + if (!dumpProperties) + continue; + QDeclarativeObjectProperty prop; + prop.type = QDeclarativeObjectProperty::SignalProperty; + prop.hasNotifySignal = false; + QDeclarativeExpression *expr = signal->expression(); + if (expr) { + prop.value = expr->expression(); + QObject *scope = expr->scopeObject(); + if (scope) { + QString sig = QLatin1String(scope->metaObject()->method(signal->index()).signature()); + int lparen = sig.indexOf(QLatin1Char('(')); + if (lparen >= 0) { + QString methodName = sig.mid(0, lparen); + prop.name = QLatin1String("on") + methodName[0].toUpper() + + methodName.mid(1); + } + } + } + fakeProperties << prop; + } else { + if (recur) + buildObjectDump(message, child, recur, dumpProperties); + else + message << objectData(child); + } + } + + if (!dumpProperties) { + message << 0; + return; + } + + QList propertyIndexes; + for (int ii = 0; ii < object->metaObject()->propertyCount(); ++ii) { + if (object->metaObject()->property(ii).isScriptable()) + propertyIndexes << ii; + } + + message << propertyIndexes.size() + fakeProperties.count(); + + for (int ii = 0; ii < propertyIndexes.size(); ++ii) + message << propertyData(object, propertyIndexes.at(ii)); + + for (int ii = 0; ii < fakeProperties.count(); ++ii) + message << fakeProperties[ii]; +} + +void QDeclarativeEngineDebugService::prepareDeferredObjects(QObject *obj) +{ + qmlExecuteDeferred(obj); + + QObjectList children = obj->children(); + for (int ii = 0; ii < children.count(); ++ii) { + QObject *child = children.at(ii); + prepareDeferredObjects(child); + } + +} + +void QDeclarativeEngineDebugService::buildObjectList(QDataStream &message, QDeclarativeContext *ctxt) +{ + QDeclarativeContextData *p = QDeclarativeContextData::get(ctxt); + + QString ctxtName = ctxt->objectName(); + int ctxtId = QDeclarativeDebugService::idForObject(ctxt); + + message << ctxtName << ctxtId; + + int count = 0; + + QDeclarativeContextData *child = p->childContexts; + while (child) { + ++count; + child = child->nextChild; + } + + message << count; + + child = p->childContexts; + while (child) { + buildObjectList(message, child->asQDeclarativeContext()); + child = child->nextChild; + } + + // Clean deleted objects + QDeclarativeContextPrivate *ctxtPriv = QDeclarativeContextPrivate::get(ctxt); + for (int ii = 0; ii < ctxtPriv->instances.count(); ++ii) { + if (!ctxtPriv->instances.at(ii)) { + ctxtPriv->instances.removeAt(ii); + --ii; + } + } + + message << ctxtPriv->instances.count(); + for (int ii = 0; ii < ctxtPriv->instances.count(); ++ii) { + message << objectData(ctxtPriv->instances.at(ii)); + } +} + +void QDeclarativeEngineDebugService::buildStatesList(QDeclarativeContext *ctxt, bool cleanList=false) +{ + if (cleanList) + m_allStates.clear(); + + QDeclarativeContextPrivate *ctxtPriv = QDeclarativeContextPrivate::get(ctxt); + for (int ii = 0; ii < ctxtPriv->instances.count(); ++ii) { + buildStatesList(ctxtPriv->instances.at(ii)); + } + + QDeclarativeContextData *child = QDeclarativeContextData::get(ctxt)->childContexts; + while (child) { + buildStatesList(child->asQDeclarativeContext()); + child = child->nextChild; + } +} + +void QDeclarativeEngineDebugService::buildStatesList(QObject *obj) +{ + if (QDeclarativeState *state = qobject_cast(obj)) { + m_allStates.append(state); + } + + QObjectList children = obj->children(); + for (int ii = 0; ii < children.count(); ++ii) { + buildStatesList(children.at(ii)); + } +} + +QDeclarativeEngineDebugService::QDeclarativeObjectData +QDeclarativeEngineDebugService::objectData(QObject *object) +{ + QDeclarativeData *ddata = QDeclarativeData::get(object); + QDeclarativeObjectData rv; + if (ddata && ddata->outerContext) { + rv.url = ddata->outerContext->url; + rv.lineNumber = ddata->lineNumber; + rv.columnNumber = ddata->columnNumber; + } else { + rv.lineNumber = -1; + rv.columnNumber = -1; + } + + QDeclarativeContext *context = qmlContext(object); + if (context) { + QDeclarativeContextData *cdata = QDeclarativeContextData::get(context); + if (cdata) + rv.idString = cdata->findObjectId(object); + } + + rv.objectName = object->objectName(); + rv.objectId = QDeclarativeDebugService::idForObject(object); + rv.contextId = QDeclarativeDebugService::idForObject(qmlContext(object)); + + QDeclarativeType *type = QDeclarativeMetaType::qmlType(object->metaObject()); + if (type) { + QString typeName = QLatin1String(type->qmlTypeName()); + int lastSlash = typeName.lastIndexOf(QLatin1Char('/')); + rv.objectType = lastSlash < 0 ? typeName : typeName.mid(lastSlash+1); + } else { + rv.objectType = QString::fromUtf8(object->metaObject()->className()); + int marker = rv.objectType.indexOf(QLatin1String("_QMLTYPE_")); + if (marker != -1) + rv.objectType = rv.objectType.left(marker); + } + + return rv; +} + +void QDeclarativeEngineDebugService::messageReceived(const QByteArray &message) +{ + QDataStream ds(message); + + QByteArray type; + ds >> type; + + if (type == "LIST_ENGINES") { + int queryId; + ds >> queryId; + + QByteArray reply; + QDataStream rs(&reply, QIODevice::WriteOnly); + rs << QByteArray("LIST_ENGINES_R"); + rs << queryId << m_engines.count(); + + for (int ii = 0; ii < m_engines.count(); ++ii) { + QDeclarativeEngine *engine = m_engines.at(ii); + + QString engineName = engine->objectName(); + int engineId = QDeclarativeDebugService::idForObject(engine); + + rs << engineName << engineId; + } + + sendMessage(reply); + } else if (type == "LIST_OBJECTS") { + int queryId; + int engineId = -1; + ds >> queryId >> engineId; + + QDeclarativeEngine *engine = + qobject_cast(QDeclarativeDebugService::objectForId(engineId)); + + QByteArray reply; + QDataStream rs(&reply, QIODevice::WriteOnly); + rs << QByteArray("LIST_OBJECTS_R") << queryId; + + if (engine) { + buildObjectList(rs, engine->rootContext()); + buildStatesList(engine->rootContext(), true); + } + + sendMessage(reply); + } else if (type == "FETCH_OBJECT") { + int queryId; + int objectId; + bool recurse; + bool dumpProperties = true; + + ds >> queryId >> objectId >> recurse >> dumpProperties; + + QObject *object = QDeclarativeDebugService::objectForId(objectId); + + QByteArray reply; + QDataStream rs(&reply, QIODevice::WriteOnly); + rs << QByteArray("FETCH_OBJECT_R") << queryId; + + if (object) { + if (recurse) + prepareDeferredObjects(object); + buildObjectDump(rs, object, recurse, dumpProperties); + } + + sendMessage(reply); + } else if (type == "WATCH_OBJECT") { + int queryId; + int objectId; + + ds >> queryId >> objectId; + bool ok = m_watch->addWatch(queryId, objectId); + + QByteArray reply; + QDataStream rs(&reply, QIODevice::WriteOnly); + rs << QByteArray("WATCH_OBJECT_R") << queryId << ok; + + sendMessage(reply); + } else if (type == "WATCH_PROPERTY") { + int queryId; + int objectId; + QByteArray property; + + ds >> queryId >> objectId >> property; + bool ok = m_watch->addWatch(queryId, objectId, property); + + QByteArray reply; + QDataStream rs(&reply, QIODevice::WriteOnly); + rs << QByteArray("WATCH_PROPERTY_R") << queryId << ok; + + sendMessage(reply); + } else if (type == "WATCH_EXPR_OBJECT") { + int queryId; + int debugId; + QString expr; + + ds >> queryId >> debugId >> expr; + bool ok = m_watch->addWatch(queryId, debugId, expr); + + QByteArray reply; + QDataStream rs(&reply, QIODevice::WriteOnly); + rs << QByteArray("WATCH_EXPR_OBJECT_R") << queryId << ok; + sendMessage(reply); + } else if (type == "NO_WATCH") { + int queryId; + + ds >> queryId; + m_watch->removeWatch(queryId); + } else if (type == "EVAL_EXPRESSION") { + int queryId; + int objectId; + QString expr; + + ds >> queryId >> objectId >> expr; + + QObject *object = QDeclarativeDebugService::objectForId(objectId); + QDeclarativeContext *context = qmlContext(object); + QVariant result; + if (object && context) { + QDeclarativeExpression exprObj(context, object, expr); + bool undefined = false; + QVariant value = exprObj.evaluate(&undefined); + if (undefined) + result = QLatin1String(""); + else + result = valueContents(value); + } else { + result = QLatin1String(""); + } + + QByteArray reply; + QDataStream rs(&reply, QIODevice::WriteOnly); + rs << QByteArray("EVAL_EXPRESSION_R") << queryId << result; + + sendMessage(reply); + } else if (type == "SET_BINDING") { + int objectId; + QString propertyName; + QVariant expr; + bool isLiteralValue; + QString filename; + int line; + ds >> objectId >> propertyName >> expr >> isLiteralValue; + if (!ds.atEnd()) { // backward compatibility from 2.1, 2.2 + ds >> filename >> line; + } + setBinding(objectId, propertyName, expr, isLiteralValue, filename, line); + } else if (type == "RESET_BINDING") { + int objectId; + QString propertyName; + ds >> objectId >> propertyName; + resetBinding(objectId, propertyName); + } else if (type == "SET_METHOD_BODY") { + int objectId; + QString methodName; + QString methodBody; + ds >> objectId >> methodName >> methodBody; + setMethodBody(objectId, methodName, methodBody); + } +} + +void QDeclarativeEngineDebugService::setBinding(int objectId, + const QString &propertyName, + const QVariant &expression, + bool isLiteralValue, + QString filename, + int line) +{ + QObject *object = objectForId(objectId); + QDeclarativeContext *context = qmlContext(object); + + if (object && context) { + QDeclarativeProperty property(object, propertyName, context); + if (property.isValid()) { + + bool inBaseState = true; + + foreach(QWeakPointer statePointer, m_allStates) { + if (QDeclarativeState *state = statePointer.data()) { + // here we assume that the revert list on itself defines the base state + if (state->isStateActive() && state->containsPropertyInRevertList(object, propertyName)) { + inBaseState = false; + + QDeclarativeBinding *newBinding = 0; + if (!isLiteralValue) { + newBinding = new QDeclarativeBinding(expression.toString(), object, context); + newBinding->setTarget(property); + newBinding->setNotifyOnValueChanged(true); + newBinding->setSourceLocation(filename, line); + } + + state->changeBindingInRevertList(object, propertyName, newBinding); + + if (isLiteralValue) + state->changeValueInRevertList(object, propertyName, expression); + } + } + } + + if (inBaseState) { + if (isLiteralValue) { + property.write(expression); + } else if (hasValidSignal(object, propertyName)) { + QDeclarativeExpression *declarativeExpression = new QDeclarativeExpression(context, object, expression.toString()); + QDeclarativePropertyPrivate::setSignalExpression(property, declarativeExpression); + declarativeExpression->setSourceLocation(filename, line); + } else if (property.isProperty()) { + QDeclarativeBinding *binding = new QDeclarativeBinding(expression.toString(), object, context); + binding->setTarget(property); + binding->setSourceLocation(filename, line); + binding->setNotifyOnValueChanged(true); + QDeclarativeAbstractBinding *oldBinding = QDeclarativePropertyPrivate::setBinding(property, binding); + if (oldBinding) + oldBinding->destroy(); + binding->update(); + } else { + qWarning() << "QDeclarativeEngineDebugService::setBinding: unable to set property" << propertyName << "on object" << object; + } + } + + } else { + // not a valid property + if (QDeclarativePropertyChanges *propertyChanges = qobject_cast(object)) { + if (isLiteralValue) { + propertyChanges->changeValue(propertyName, expression); + } else { + propertyChanges->changeExpression(propertyName, expression.toString()); + } + } else { + qWarning() << "QDeclarativeEngineDebugService::setBinding: unable to set property" << propertyName << "on object" << object; + } + } + } +} + +void QDeclarativeEngineDebugService::resetBinding(int objectId, const QString &propertyName) +{ + QObject *object = objectForId(objectId); + QDeclarativeContext *context = qmlContext(object); + + if (object && context) { + if (object->property(propertyName.toLatin1()).isValid()) { + QDeclarativeProperty property(object, propertyName); + QDeclarativeAbstractBinding *oldBinding = QDeclarativePropertyPrivate::binding(property); + if (oldBinding) { + QDeclarativeAbstractBinding *oldBinding = QDeclarativePropertyPrivate::setBinding(property, 0); + if (oldBinding) + oldBinding->destroy(); + } + if (property.isResettable()) { + // Note: this will reset the property in any case, without regard to states + // Right now almost no QDeclarativeItem has reset methods for its properties (with the + // notable exception of QDeclarativeAnchors), so this is not a big issue + // later on, setBinding does take states into account + property.reset(); + } else { + // overwrite with default value + if (QDeclarativeType *objType = QDeclarativeMetaType::qmlType(object->metaObject())) { + if (QObject *emptyObject = objType->create()) { + if (emptyObject->property(propertyName.toLatin1()).isValid()) { + QVariant defaultValue = QDeclarativeProperty(emptyObject, propertyName).read(); + if (defaultValue.isValid()) { + setBinding(objectId, propertyName, defaultValue, true); + } + } + delete emptyObject; + } + } + } + } else if (hasValidSignal(object, propertyName)) { + QDeclarativeProperty property(object, propertyName, context); + QDeclarativePropertyPrivate::setSignalExpression(property, 0); + } else { + if (QDeclarativePropertyChanges *propertyChanges = qobject_cast(object)) { + propertyChanges->removeProperty(propertyName); + } + } + } +} + +void QDeclarativeEngineDebugService::setMethodBody(int objectId, const QString &method, const QString &body) +{ + QObject *object = objectForId(objectId); + QDeclarativeContext *context = qmlContext(object); + if (!object || !context || !context->engine()) + return; + QDeclarativeContextData *contextData = QDeclarativeContextData::get(context); + if (!contextData) + return; + + QDeclarativePropertyCache::Data dummy; + QDeclarativePropertyCache::Data *prop = + QDeclarativePropertyCache::property(context->engine(), object, method, dummy); + + if (!prop || !(prop->flags & QDeclarativePropertyCache::Data::IsVMEFunction)) + return; + + QMetaMethod metaMethod = object->metaObject()->method(prop->coreIndex); + QList paramNames = metaMethod.parameterNames(); + + QString paramStr; + for (int ii = 0; ii < paramNames.count(); ++ii) { + if (ii != 0) paramStr.append(QLatin1String(",")); + paramStr.append(QString::fromUtf8(paramNames.at(ii))); + } + + QString jsfunction = QLatin1String("(function ") + method + QLatin1String("(") + paramStr + + QLatin1String(") {"); + jsfunction += body; + jsfunction += QLatin1String("\n})"); + + QDeclarativeVMEMetaObject *vmeMetaObject = + static_cast(QObjectPrivate::get(object)->metaObject); + Q_ASSERT(vmeMetaObject); // the fact we found the property above should guarentee this + + int lineNumber = vmeMetaObject->vmeMethodLineNumber(prop->coreIndex); + vmeMetaObject->setVmeMethod(prop->coreIndex, QDeclarativeExpressionPrivate::evalInObjectScope(contextData, object, jsfunction, contextData->url.toString(), lineNumber, 0)); +} + +void QDeclarativeEngineDebugService::propertyChanged(int id, int objectId, const QMetaProperty &property, const QVariant &value) +{ + QByteArray reply; + QDataStream rs(&reply, QIODevice::WriteOnly); + + rs << QByteArray("UPDATE_WATCH") << id << objectId << QByteArray(property.name()) << valueContents(value); + + sendMessage(reply); +} + +void QDeclarativeEngineDebugService::addEngine(QDeclarativeEngine *engine) +{ + Q_ASSERT(engine); + Q_ASSERT(!m_engines.contains(engine)); + + m_engines.append(engine); +} + +void QDeclarativeEngineDebugService::remEngine(QDeclarativeEngine *engine) +{ + Q_ASSERT(engine); + Q_ASSERT(m_engines.contains(engine)); + + m_engines.removeAll(engine); +} + +void QDeclarativeEngineDebugService::objectCreated(QDeclarativeEngine *engine, QObject *object) +{ + Q_ASSERT(engine); + Q_ASSERT(m_engines.contains(engine)); + + int engineId = QDeclarativeDebugService::idForObject(engine); + int objectId = QDeclarativeDebugService::idForObject(object); + + QByteArray reply; + QDataStream rs(&reply, QIODevice::WriteOnly); + + rs << QByteArray("OBJECT_CREATED") << engineId << objectId; + sendMessage(reply); +} + +QT_END_NAMESPACE diff --git a/src/declarative/debugger/qdeclarativeenginedebugservice_p.h b/src/declarative/debugger/qdeclarativeenginedebugservice_p.h new file mode 100644 index 0000000..3674b83 --- /dev/null +++ b/src/declarative/debugger/qdeclarativeenginedebugservice_p.h @@ -0,0 +1,134 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QDECLARATIVEENGINEDEBUGSERVICE_P_H +#define QDECLARATIVEENGINEDEBUGSERVICE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include + +#include +#include +#include + +QT_BEGIN_NAMESPACE + +class QDeclarativeEngine; +class QDeclarativeContext; +class QDeclarativeWatcher; +class QDataStream; +class QDeclarativeState; + +class QDeclarativeEngineDebugService : public QDeclarativeDebugService +{ + Q_OBJECT +public: + QDeclarativeEngineDebugService(QObject * = 0); + + struct QDeclarativeObjectData { + QUrl url; + int lineNumber; + int columnNumber; + QString idString; + QString objectName; + QString objectType; + int objectId; + int contextId; + }; + + struct QDeclarativeObjectProperty { + enum Type { Unknown, Basic, Object, List, SignalProperty }; + Type type; + QString name; + QVariant value; + QString valueTypeName; + QString binding; + bool hasNotifySignal; + }; + + void addEngine(QDeclarativeEngine *); + void remEngine(QDeclarativeEngine *); + void objectCreated(QDeclarativeEngine *, QObject *); + + static QDeclarativeEngineDebugService *instance(); + +protected: + virtual void messageReceived(const QByteArray &); + +private Q_SLOTS: + void propertyChanged(int id, int objectId, const QMetaProperty &property, const QVariant &value); + +private: + void prepareDeferredObjects(QObject *); + void buildObjectList(QDataStream &, QDeclarativeContext *); + void buildObjectDump(QDataStream &, QObject *, bool, bool); + void buildStatesList(QDeclarativeContext *, bool); + void buildStatesList(QObject *obj); + QDeclarativeObjectData objectData(QObject *); + QDeclarativeObjectProperty propertyData(QObject *, int); + QVariant valueContents(const QVariant &defaultValue) const; + void setBinding(int objectId, const QString &propertyName, const QVariant &expression, bool isLiteralValue, QString filename = QString(), int line = -1); + void resetBinding(int objectId, const QString &propertyName); + void setMethodBody(int objectId, const QString &method, const QString &body); + + QList m_engines; + QDeclarativeWatcher *m_watch; + QList > m_allStates; +}; +Q_DECLARATIVE_PRIVATE_EXPORT QDataStream &operator<<(QDataStream &, const QDeclarativeEngineDebugService::QDeclarativeObjectData &); +Q_DECLARATIVE_PRIVATE_EXPORT QDataStream &operator>>(QDataStream &, QDeclarativeEngineDebugService::QDeclarativeObjectData &); +Q_DECLARATIVE_PRIVATE_EXPORT QDataStream &operator<<(QDataStream &, const QDeclarativeEngineDebugService::QDeclarativeObjectProperty &); +Q_DECLARATIVE_PRIVATE_EXPORT QDataStream &operator>>(QDataStream &, QDeclarativeEngineDebugService::QDeclarativeObjectProperty &); + +QT_END_NAMESPACE + +#endif // QDECLARATIVEENGINEDEBUGSERVICE_P_H + diff --git a/src/declarative/qml/qdeclarativecomponent.cpp b/src/declarative/qml/qdeclarativecomponent.cpp index d9f291b..f423f50 100644 --- a/src/declarative/qml/qdeclarativecomponent.cpp +++ b/src/declarative/qml/qdeclarativecomponent.cpp @@ -53,7 +53,7 @@ #include "private/qdeclarativeglobal_p.h" #include "private/qdeclarativescriptparser_p.h" #include "private/qdeclarativedebugtrace_p.h" -#include "private/qdeclarativeenginedebug_p.h" +#include "private/qdeclarativeenginedebugservice_p.h" #include #include @@ -896,7 +896,7 @@ QObject * QDeclarativeComponentPrivate::begin(QDeclarativeContextData *parentCon if (enginePriv->isDebugging && rv) { if (!parentContext->isInternal) parentContext->asQDeclarativeContextPrivate()->instances.append(rv); - QDeclarativeEngineDebugServer::instance()->objectCreated(parentContext->engine, rv); + QDeclarativeEngineDebugService::instance()->objectCreated(parentContext->engine, rv); } return rv; diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp index 34014f7..1417b78 100644 --- a/src/declarative/qml/qdeclarativeengine.cpp +++ b/src/declarative/qml/qdeclarativeengine.cpp @@ -51,7 +51,7 @@ #include "qdeclarativecomponent.h" #include "private/qdeclarativebinding_p_p.h" #include "private/qdeclarativevme_p.h" -#include "private/qdeclarativeenginedebug_p.h" +#include "private/qdeclarativeenginedebugservice_p.h" #include "private/qdeclarativestringconverters_p.h" #include "private/qdeclarativexmlhttprequest_p.h" #include "private/qdeclarativesqldatabase_p.h" @@ -581,9 +581,9 @@ void QDeclarativeEnginePrivate::init() scriptEngine.globalObject().property(QLatin1String("Qt")).setProperty(QLatin1String("application"), applicationObject); if (QCoreApplication::instance()->thread() == q->thread() && - QDeclarativeEngineDebugServer::isDebuggingEnabled()) { + QDeclarativeEngineDebugService::isDebuggingEnabled()) { isDebugging = true; - QDeclarativeEngineDebugServer::instance()->addEngine(q); + QDeclarativeEngineDebugService::instance()->addEngine(q); QJSDebugService::instance()->addEngine(q); } } @@ -648,7 +648,7 @@ QDeclarativeEngine::~QDeclarativeEngine() { Q_D(QDeclarativeEngine); if (d->isDebugging) { - QDeclarativeEngineDebugServer::instance()->remEngine(this); + QDeclarativeEngineDebugService::instance()->remEngine(this); QJSDebugService::instance()->removeEngine(this); } } diff --git a/src/declarative/qml/qdeclarativeenginedebug.cpp b/src/declarative/qml/qdeclarativeenginedebug.cpp deleted file mode 100644 index 8707a7f..0000000 --- a/src/declarative/qml/qdeclarativeenginedebug.cpp +++ /dev/null @@ -1,747 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "private/qdeclarativeenginedebug_p.h" - -#include "private/qdeclarativeboundsignal_p.h" -#include "qdeclarativeengine.h" -#include "private/qdeclarativemetatype_p.h" -#include "qdeclarativeproperty.h" -#include "private/qdeclarativeproperty_p.h" -#include "private/qdeclarativebinding_p.h" -#include "private/qdeclarativecontext_p.h" -#include "private/qdeclarativewatcher_p.h" -#include "private/qdeclarativevaluetype_p.h" -#include "private/qdeclarativevmemetaobject_p.h" -#include "private/qdeclarativeexpression_p.h" -#include "private/qdeclarativepropertychanges_p.h" - -#include -#include - -QT_BEGIN_NAMESPACE - -Q_GLOBAL_STATIC(QDeclarativeEngineDebugServer, qmlEngineDebugServer); - -QDeclarativeEngineDebugServer *QDeclarativeEngineDebugServer::instance() -{ - return qmlEngineDebugServer(); -} - -QDeclarativeEngineDebugServer::QDeclarativeEngineDebugServer(QObject *parent) -: QDeclarativeDebugService(QLatin1String("QDeclarativeEngine"), parent), - m_watch(new QDeclarativeWatcher(this)) -{ - QObject::connect(m_watch, SIGNAL(propertyChanged(int,int,QMetaProperty,QVariant)), - this, SLOT(propertyChanged(int,int,QMetaProperty,QVariant))); -} - -QDataStream &operator<<(QDataStream &ds, - const QDeclarativeEngineDebugServer::QDeclarativeObjectData &data) -{ - ds << data.url << data.lineNumber << data.columnNumber << data.idString - << data.objectName << data.objectType << data.objectId << data.contextId; - return ds; -} - -QDataStream &operator>>(QDataStream &ds, - QDeclarativeEngineDebugServer::QDeclarativeObjectData &data) -{ - ds >> data.url >> data.lineNumber >> data.columnNumber >> data.idString - >> data.objectName >> data.objectType >> data.objectId >> data.contextId; - return ds; -} - -QDataStream &operator<<(QDataStream &ds, - const QDeclarativeEngineDebugServer::QDeclarativeObjectProperty &data) -{ - ds << (int)data.type << data.name << data.value << data.valueTypeName - << data.binding << data.hasNotifySignal; - return ds; -} - -QDataStream &operator>>(QDataStream &ds, - QDeclarativeEngineDebugServer::QDeclarativeObjectProperty &data) -{ - int type; - ds >> type >> data.name >> data.value >> data.valueTypeName - >> data.binding >> data.hasNotifySignal; - data.type = (QDeclarativeEngineDebugServer::QDeclarativeObjectProperty::Type)type; - return ds; -} - -static inline bool isSignalPropertyName(const QString &signalName) -{ - // see QmlCompiler::isSignalPropertyName - return signalName.length() >= 3 && signalName.startsWith(QLatin1String("on")) && - signalName.at(2).isLetter() && signalName.at(2).isUpper(); -} - -static bool hasValidSignal(QObject *object, const QString &propertyName) -{ - if (!isSignalPropertyName(propertyName)) - return false; - - QString signalName = propertyName.mid(2); - signalName[0] = signalName.at(0).toLower(); - - int sigIdx = QDeclarativePropertyPrivate::findSignalByName(object->metaObject(), signalName.toLatin1()).methodIndex(); - - if (sigIdx == -1) - return false; - - return true; -} - -QDeclarativeEngineDebugServer::QDeclarativeObjectProperty -QDeclarativeEngineDebugServer::propertyData(QObject *obj, int propIdx) -{ - QDeclarativeObjectProperty rv; - - QMetaProperty prop = obj->metaObject()->property(propIdx); - - rv.type = QDeclarativeObjectProperty::Unknown; - rv.valueTypeName = QString::fromUtf8(prop.typeName()); - rv.name = QString::fromUtf8(prop.name()); - rv.hasNotifySignal = prop.hasNotifySignal(); - QDeclarativeAbstractBinding *binding = - QDeclarativePropertyPrivate::binding(QDeclarativeProperty(obj, rv.name)); - if (binding) - rv.binding = binding->expression(); - - if (QDeclarativeValueTypeFactory::isValueType(prop.userType())) { - rv.type = QDeclarativeObjectProperty::Basic; - } else if (QDeclarativeMetaType::isQObject(prop.userType())) { - rv.type = QDeclarativeObjectProperty::Object; - } else if (QDeclarativeMetaType::isList(prop.userType())) { - rv.type = QDeclarativeObjectProperty::List; - } - - QVariant value; - if (rv.type != QDeclarativeObjectProperty::Unknown && prop.userType() != 0) { - value = prop.read(obj); - } - rv.value = valueContents(value); - - return rv; -} - -QVariant QDeclarativeEngineDebugServer::valueContents(const QVariant &value) const -{ - int userType = value.userType(); - - if (value.type() == QVariant::List) { - QVariantList contents; - QVariantList list = value.toList(); - int count = list.size(); - for (int i = 0; i < count; i++) - contents << valueContents(list.at(i)); - return contents; - } - - if (QDeclarativeValueTypeFactory::isValueType(userType)) - return value; - - if (QDeclarativeMetaType::isQObject(userType)) { - QObject *o = QDeclarativeMetaType::toQObject(value); - if (o) { - QString name = o->objectName(); - if (name.isEmpty()) - name = QLatin1String(""); - return name; - } - } - - return QLatin1String(""); -} - -void QDeclarativeEngineDebugServer::buildObjectDump(QDataStream &message, - QObject *object, bool recur, bool dumpProperties) -{ - message << objectData(object); - - QObjectList children = object->children(); - - int childrenCount = children.count(); - for (int ii = 0; ii < children.count(); ++ii) { - if (qobject_cast(children[ii]) || QDeclarativeBoundSignal::cast(children[ii])) - --childrenCount; - } - - message << childrenCount << recur; - - QList fakeProperties; - - for (int ii = 0; ii < children.count(); ++ii) { - QObject *child = children.at(ii); - if (qobject_cast(child)) - continue; - QDeclarativeBoundSignal *signal = QDeclarativeBoundSignal::cast(child); - if (signal) { - if (!dumpProperties) - continue; - QDeclarativeObjectProperty prop; - prop.type = QDeclarativeObjectProperty::SignalProperty; - prop.hasNotifySignal = false; - QDeclarativeExpression *expr = signal->expression(); - if (expr) { - prop.value = expr->expression(); - QObject *scope = expr->scopeObject(); - if (scope) { - QString sig = QLatin1String(scope->metaObject()->method(signal->index()).signature()); - int lparen = sig.indexOf(QLatin1Char('(')); - if (lparen >= 0) { - QString methodName = sig.mid(0, lparen); - prop.name = QLatin1String("on") + methodName[0].toUpper() - + methodName.mid(1); - } - } - } - fakeProperties << prop; - } else { - if (recur) - buildObjectDump(message, child, recur, dumpProperties); - else - message << objectData(child); - } - } - - if (!dumpProperties) { - message << 0; - return; - } - - QList propertyIndexes; - for (int ii = 0; ii < object->metaObject()->propertyCount(); ++ii) { - if (object->metaObject()->property(ii).isScriptable()) - propertyIndexes << ii; - } - - message << propertyIndexes.size() + fakeProperties.count(); - - for (int ii = 0; ii < propertyIndexes.size(); ++ii) - message << propertyData(object, propertyIndexes.at(ii)); - - for (int ii = 0; ii < fakeProperties.count(); ++ii) - message << fakeProperties[ii]; -} - -void QDeclarativeEngineDebugServer::prepareDeferredObjects(QObject *obj) -{ - qmlExecuteDeferred(obj); - - QObjectList children = obj->children(); - for (int ii = 0; ii < children.count(); ++ii) { - QObject *child = children.at(ii); - prepareDeferredObjects(child); - } - -} - -void QDeclarativeEngineDebugServer::buildObjectList(QDataStream &message, QDeclarativeContext *ctxt) -{ - QDeclarativeContextData *p = QDeclarativeContextData::get(ctxt); - - QString ctxtName = ctxt->objectName(); - int ctxtId = QDeclarativeDebugService::idForObject(ctxt); - - message << ctxtName << ctxtId; - - int count = 0; - - QDeclarativeContextData *child = p->childContexts; - while (child) { - ++count; - child = child->nextChild; - } - - message << count; - - child = p->childContexts; - while (child) { - buildObjectList(message, child->asQDeclarativeContext()); - child = child->nextChild; - } - - // Clean deleted objects - QDeclarativeContextPrivate *ctxtPriv = QDeclarativeContextPrivate::get(ctxt); - for (int ii = 0; ii < ctxtPriv->instances.count(); ++ii) { - if (!ctxtPriv->instances.at(ii)) { - ctxtPriv->instances.removeAt(ii); - --ii; - } - } - - message << ctxtPriv->instances.count(); - for (int ii = 0; ii < ctxtPriv->instances.count(); ++ii) { - message << objectData(ctxtPriv->instances.at(ii)); - } -} - -void QDeclarativeEngineDebugServer::buildStatesList(QDeclarativeContext *ctxt, bool cleanList=false) -{ - if (cleanList) - m_allStates.clear(); - - QDeclarativeContextPrivate *ctxtPriv = QDeclarativeContextPrivate::get(ctxt); - for (int ii = 0; ii < ctxtPriv->instances.count(); ++ii) { - buildStatesList(ctxtPriv->instances.at(ii)); - } - - QDeclarativeContextData *child = QDeclarativeContextData::get(ctxt)->childContexts; - while (child) { - buildStatesList(child->asQDeclarativeContext()); - child = child->nextChild; - } -} - -void QDeclarativeEngineDebugServer::buildStatesList(QObject *obj) -{ - if (QDeclarativeState *state = qobject_cast(obj)) { - m_allStates.append(state); - } - - QObjectList children = obj->children(); - for (int ii = 0; ii < children.count(); ++ii) { - buildStatesList(children.at(ii)); - } -} - -QDeclarativeEngineDebugServer::QDeclarativeObjectData -QDeclarativeEngineDebugServer::objectData(QObject *object) -{ - QDeclarativeData *ddata = QDeclarativeData::get(object); - QDeclarativeObjectData rv; - if (ddata && ddata->outerContext) { - rv.url = ddata->outerContext->url; - rv.lineNumber = ddata->lineNumber; - rv.columnNumber = ddata->columnNumber; - } else { - rv.lineNumber = -1; - rv.columnNumber = -1; - } - - QDeclarativeContext *context = qmlContext(object); - if (context) { - QDeclarativeContextData *cdata = QDeclarativeContextData::get(context); - if (cdata) - rv.idString = cdata->findObjectId(object); - } - - rv.objectName = object->objectName(); - rv.objectId = QDeclarativeDebugService::idForObject(object); - rv.contextId = QDeclarativeDebugService::idForObject(qmlContext(object)); - - QDeclarativeType *type = QDeclarativeMetaType::qmlType(object->metaObject()); - if (type) { - QString typeName = QLatin1String(type->qmlTypeName()); - int lastSlash = typeName.lastIndexOf(QLatin1Char('/')); - rv.objectType = lastSlash < 0 ? typeName : typeName.mid(lastSlash+1); - } else { - rv.objectType = QString::fromUtf8(object->metaObject()->className()); - int marker = rv.objectType.indexOf(QLatin1String("_QMLTYPE_")); - if (marker != -1) - rv.objectType = rv.objectType.left(marker); - } - - return rv; -} - -void QDeclarativeEngineDebugServer::messageReceived(const QByteArray &message) -{ - QDataStream ds(message); - - QByteArray type; - ds >> type; - - if (type == "LIST_ENGINES") { - int queryId; - ds >> queryId; - - QByteArray reply; - QDataStream rs(&reply, QIODevice::WriteOnly); - rs << QByteArray("LIST_ENGINES_R"); - rs << queryId << m_engines.count(); - - for (int ii = 0; ii < m_engines.count(); ++ii) { - QDeclarativeEngine *engine = m_engines.at(ii); - - QString engineName = engine->objectName(); - int engineId = QDeclarativeDebugService::idForObject(engine); - - rs << engineName << engineId; - } - - sendMessage(reply); - } else if (type == "LIST_OBJECTS") { - int queryId; - int engineId = -1; - ds >> queryId >> engineId; - - QDeclarativeEngine *engine = - qobject_cast(QDeclarativeDebugService::objectForId(engineId)); - - QByteArray reply; - QDataStream rs(&reply, QIODevice::WriteOnly); - rs << QByteArray("LIST_OBJECTS_R") << queryId; - - if (engine) { - buildObjectList(rs, engine->rootContext()); - buildStatesList(engine->rootContext(), true); - } - - sendMessage(reply); - } else if (type == "FETCH_OBJECT") { - int queryId; - int objectId; - bool recurse; - bool dumpProperties = true; - - ds >> queryId >> objectId >> recurse >> dumpProperties; - - QObject *object = QDeclarativeDebugService::objectForId(objectId); - - QByteArray reply; - QDataStream rs(&reply, QIODevice::WriteOnly); - rs << QByteArray("FETCH_OBJECT_R") << queryId; - - if (object) { - if (recurse) - prepareDeferredObjects(object); - buildObjectDump(rs, object, recurse, dumpProperties); - } - - sendMessage(reply); - } else if (type == "WATCH_OBJECT") { - int queryId; - int objectId; - - ds >> queryId >> objectId; - bool ok = m_watch->addWatch(queryId, objectId); - - QByteArray reply; - QDataStream rs(&reply, QIODevice::WriteOnly); - rs << QByteArray("WATCH_OBJECT_R") << queryId << ok; - - sendMessage(reply); - } else if (type == "WATCH_PROPERTY") { - int queryId; - int objectId; - QByteArray property; - - ds >> queryId >> objectId >> property; - bool ok = m_watch->addWatch(queryId, objectId, property); - - QByteArray reply; - QDataStream rs(&reply, QIODevice::WriteOnly); - rs << QByteArray("WATCH_PROPERTY_R") << queryId << ok; - - sendMessage(reply); - } else if (type == "WATCH_EXPR_OBJECT") { - int queryId; - int debugId; - QString expr; - - ds >> queryId >> debugId >> expr; - bool ok = m_watch->addWatch(queryId, debugId, expr); - - QByteArray reply; - QDataStream rs(&reply, QIODevice::WriteOnly); - rs << QByteArray("WATCH_EXPR_OBJECT_R") << queryId << ok; - sendMessage(reply); - } else if (type == "NO_WATCH") { - int queryId; - - ds >> queryId; - m_watch->removeWatch(queryId); - } else if (type == "EVAL_EXPRESSION") { - int queryId; - int objectId; - QString expr; - - ds >> queryId >> objectId >> expr; - - QObject *object = QDeclarativeDebugService::objectForId(objectId); - QDeclarativeContext *context = qmlContext(object); - QVariant result; - if (object && context) { - QDeclarativeExpression exprObj(context, object, expr); - bool undefined = false; - QVariant value = exprObj.evaluate(&undefined); - if (undefined) - result = QLatin1String(""); - else - result = valueContents(value); - } else { - result = QLatin1String(""); - } - - QByteArray reply; - QDataStream rs(&reply, QIODevice::WriteOnly); - rs << QByteArray("EVAL_EXPRESSION_R") << queryId << result; - - sendMessage(reply); - } else if (type == "SET_BINDING") { - int objectId; - QString propertyName; - QVariant expr; - bool isLiteralValue; - QString filename; - int line; - ds >> objectId >> propertyName >> expr >> isLiteralValue; - if (!ds.atEnd()) { // backward compatibility from 2.1, 2.2 - ds >> filename >> line; - } - setBinding(objectId, propertyName, expr, isLiteralValue, filename, line); - } else if (type == "RESET_BINDING") { - int objectId; - QString propertyName; - ds >> objectId >> propertyName; - resetBinding(objectId, propertyName); - } else if (type == "SET_METHOD_BODY") { - int objectId; - QString methodName; - QString methodBody; - ds >> objectId >> methodName >> methodBody; - setMethodBody(objectId, methodName, methodBody); - } -} - -void QDeclarativeEngineDebugServer::setBinding(int objectId, - const QString &propertyName, - const QVariant &expression, - bool isLiteralValue, - QString filename, - int line) -{ - QObject *object = objectForId(objectId); - QDeclarativeContext *context = qmlContext(object); - - if (object && context) { - QDeclarativeProperty property(object, propertyName, context); - if (property.isValid()) { - - bool inBaseState = true; - - foreach(QWeakPointer statePointer, m_allStates) { - if (QDeclarativeState *state = statePointer.data()) { - // here we assume that the revert list on itself defines the base state - if (state->isStateActive() && state->containsPropertyInRevertList(object, propertyName)) { - inBaseState = false; - - QDeclarativeBinding *newBinding = 0; - if (!isLiteralValue) { - newBinding = new QDeclarativeBinding(expression.toString(), object, context); - newBinding->setTarget(property); - newBinding->setNotifyOnValueChanged(true); - newBinding->setSourceLocation(filename, line); - } - - state->changeBindingInRevertList(object, propertyName, newBinding); - - if (isLiteralValue) - state->changeValueInRevertList(object, propertyName, expression); - } - } - } - - if (inBaseState) { - if (isLiteralValue) { - property.write(expression); - } else if (hasValidSignal(object, propertyName)) { - QDeclarativeExpression *declarativeExpression = new QDeclarativeExpression(context, object, expression.toString()); - QDeclarativePropertyPrivate::setSignalExpression(property, declarativeExpression); - declarativeExpression->setSourceLocation(filename, line); - } else if (property.isProperty()) { - QDeclarativeBinding *binding = new QDeclarativeBinding(expression.toString(), object, context); - binding->setTarget(property); - binding->setSourceLocation(filename, line); - binding->setNotifyOnValueChanged(true); - QDeclarativeAbstractBinding *oldBinding = QDeclarativePropertyPrivate::setBinding(property, binding); - if (oldBinding) - oldBinding->destroy(); - binding->update(); - } else { - qWarning() << "QDeclarativeEngineDebugServer::setBinding: unable to set property" << propertyName << "on object" << object; - } - } - - } else { - // not a valid property - if (QDeclarativePropertyChanges *propertyChanges = qobject_cast(object)) { - if (isLiteralValue) { - propertyChanges->changeValue(propertyName, expression); - } else { - propertyChanges->changeExpression(propertyName, expression.toString()); - } - } else { - qWarning() << "QDeclarativeEngineDebugServer::setBinding: unable to set property" << propertyName << "on object" << object; - } - } - } -} - -void QDeclarativeEngineDebugServer::resetBinding(int objectId, const QString &propertyName) -{ - QObject *object = objectForId(objectId); - QDeclarativeContext *context = qmlContext(object); - - if (object && context) { - if (object->property(propertyName.toLatin1()).isValid()) { - QDeclarativeProperty property(object, propertyName); - QDeclarativeAbstractBinding *oldBinding = QDeclarativePropertyPrivate::binding(property); - if (oldBinding) { - QDeclarativeAbstractBinding *oldBinding = QDeclarativePropertyPrivate::setBinding(property, 0); - if (oldBinding) - oldBinding->destroy(); - } - if (property.isResettable()) { - // Note: this will reset the property in any case, without regard to states - // Right now almost no QDeclarativeItem has reset methods for its properties (with the - // notable exception of QDeclarativeAnchors), so this is not a big issue - // later on, setBinding does take states into account - property.reset(); - } else { - // overwrite with default value - if (QDeclarativeType *objType = QDeclarativeMetaType::qmlType(object->metaObject())) { - if (QObject *emptyObject = objType->create()) { - if (emptyObject->property(propertyName.toLatin1()).isValid()) { - QVariant defaultValue = QDeclarativeProperty(emptyObject, propertyName).read(); - if (defaultValue.isValid()) { - setBinding(objectId, propertyName, defaultValue, true); - } - } - delete emptyObject; - } - } - } - } else if (hasValidSignal(object, propertyName)) { - QDeclarativeProperty property(object, propertyName, context); - QDeclarativePropertyPrivate::setSignalExpression(property, 0); - } else { - if (QDeclarativePropertyChanges *propertyChanges = qobject_cast(object)) { - propertyChanges->removeProperty(propertyName); - } - } - } -} - -void QDeclarativeEngineDebugServer::setMethodBody(int objectId, const QString &method, const QString &body) -{ - QObject *object = objectForId(objectId); - QDeclarativeContext *context = qmlContext(object); - if (!object || !context || !context->engine()) - return; - QDeclarativeContextData *contextData = QDeclarativeContextData::get(context); - if (!contextData) - return; - - QDeclarativePropertyCache::Data dummy; - QDeclarativePropertyCache::Data *prop = - QDeclarativePropertyCache::property(context->engine(), object, method, dummy); - - if (!prop || !(prop->flags & QDeclarativePropertyCache::Data::IsVMEFunction)) - return; - - QMetaMethod metaMethod = object->metaObject()->method(prop->coreIndex); - QList paramNames = metaMethod.parameterNames(); - - QString paramStr; - for (int ii = 0; ii < paramNames.count(); ++ii) { - if (ii != 0) paramStr.append(QLatin1String(",")); - paramStr.append(QString::fromUtf8(paramNames.at(ii))); - } - - QString jsfunction = QLatin1String("(function ") + method + QLatin1String("(") + paramStr + - QLatin1String(") {"); - jsfunction += body; - jsfunction += QLatin1String("\n})"); - - QDeclarativeVMEMetaObject *vmeMetaObject = - static_cast(QObjectPrivate::get(object)->metaObject); - Q_ASSERT(vmeMetaObject); // the fact we found the property above should guarentee this - - int lineNumber = vmeMetaObject->vmeMethodLineNumber(prop->coreIndex); - vmeMetaObject->setVmeMethod(prop->coreIndex, QDeclarativeExpressionPrivate::evalInObjectScope(contextData, object, jsfunction, contextData->url.toString(), lineNumber, 0)); -} - -void QDeclarativeEngineDebugServer::propertyChanged(int id, int objectId, const QMetaProperty &property, const QVariant &value) -{ - QByteArray reply; - QDataStream rs(&reply, QIODevice::WriteOnly); - - rs << QByteArray("UPDATE_WATCH") << id << objectId << QByteArray(property.name()) << valueContents(value); - - sendMessage(reply); -} - -void QDeclarativeEngineDebugServer::addEngine(QDeclarativeEngine *engine) -{ - Q_ASSERT(engine); - Q_ASSERT(!m_engines.contains(engine)); - - m_engines.append(engine); -} - -void QDeclarativeEngineDebugServer::remEngine(QDeclarativeEngine *engine) -{ - Q_ASSERT(engine); - Q_ASSERT(m_engines.contains(engine)); - - m_engines.removeAll(engine); -} - -void QDeclarativeEngineDebugServer::objectCreated(QDeclarativeEngine *engine, QObject *object) -{ - Q_ASSERT(engine); - Q_ASSERT(m_engines.contains(engine)); - - int engineId = QDeclarativeDebugService::idForObject(engine); - int objectId = QDeclarativeDebugService::idForObject(object); - - QByteArray reply; - QDataStream rs(&reply, QIODevice::WriteOnly); - - rs << QByteArray("OBJECT_CREATED") << engineId << objectId; - sendMessage(reply); -} - -QT_END_NAMESPACE diff --git a/src/declarative/qml/qdeclarativeenginedebug_p.h b/src/declarative/qml/qdeclarativeenginedebug_p.h deleted file mode 100644 index 804a043..0000000 --- a/src/declarative/qml/qdeclarativeenginedebug_p.h +++ /dev/null @@ -1,134 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVEENGINEDEBUG_P_H -#define QDECLARATIVEENGINEDEBUG_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include - -#include -#include -#include - -QT_BEGIN_NAMESPACE - -class QDeclarativeEngine; -class QDeclarativeContext; -class QDeclarativeWatcher; -class QDataStream; -class QDeclarativeState; - -class QDeclarativeEngineDebugServer : public QDeclarativeDebugService -{ - Q_OBJECT -public: - QDeclarativeEngineDebugServer(QObject * = 0); - - struct QDeclarativeObjectData { - QUrl url; - int lineNumber; - int columnNumber; - QString idString; - QString objectName; - QString objectType; - int objectId; - int contextId; - }; - - struct QDeclarativeObjectProperty { - enum Type { Unknown, Basic, Object, List, SignalProperty }; - Type type; - QString name; - QVariant value; - QString valueTypeName; - QString binding; - bool hasNotifySignal; - }; - - void addEngine(QDeclarativeEngine *); - void remEngine(QDeclarativeEngine *); - void objectCreated(QDeclarativeEngine *, QObject *); - - static QDeclarativeEngineDebugServer *instance(); - -protected: - virtual void messageReceived(const QByteArray &); - -private Q_SLOTS: - void propertyChanged(int id, int objectId, const QMetaProperty &property, const QVariant &value); - -private: - void prepareDeferredObjects(QObject *); - void buildObjectList(QDataStream &, QDeclarativeContext *); - void buildObjectDump(QDataStream &, QObject *, bool, bool); - void buildStatesList(QDeclarativeContext *, bool); - void buildStatesList(QObject *obj); - QDeclarativeObjectData objectData(QObject *); - QDeclarativeObjectProperty propertyData(QObject *, int); - QVariant valueContents(const QVariant &defaultValue) const; - void setBinding(int objectId, const QString &propertyName, const QVariant &expression, bool isLiteralValue, QString filename = QString(), int line = -1); - void resetBinding(int objectId, const QString &propertyName); - void setMethodBody(int objectId, const QString &method, const QString &body); - - QList m_engines; - QDeclarativeWatcher *m_watch; - QList > m_allStates; -}; -Q_DECLARATIVE_PRIVATE_EXPORT QDataStream &operator<<(QDataStream &, const QDeclarativeEngineDebugServer::QDeclarativeObjectData &); -Q_DECLARATIVE_PRIVATE_EXPORT QDataStream &operator>>(QDataStream &, QDeclarativeEngineDebugServer::QDeclarativeObjectData &); -Q_DECLARATIVE_PRIVATE_EXPORT QDataStream &operator<<(QDataStream &, const QDeclarativeEngineDebugServer::QDeclarativeObjectProperty &); -Q_DECLARATIVE_PRIVATE_EXPORT QDataStream &operator>>(QDataStream &, QDeclarativeEngineDebugServer::QDeclarativeObjectProperty &); - -QT_END_NAMESPACE - -#endif // QDECLARATIVEENGINEDEBUG_P_H - diff --git a/src/declarative/qml/qml.pri b/src/declarative/qml/qml.pri index bf9e54a..5d171bf 100644 --- a/src/declarative/qml/qml.pri +++ b/src/declarative/qml/qml.pri @@ -27,7 +27,6 @@ SOURCES += \ $$PWD/qdeclarativeinfo.cpp \ $$PWD/qdeclarativeerror.cpp \ $$PWD/qdeclarativescriptparser.cpp \ - $$PWD/qdeclarativeenginedebug.cpp \ $$PWD/qdeclarativerewrite.cpp \ $$PWD/qdeclarativevaluetype.cpp \ $$PWD/qdeclarativecompiledbindings.cpp \ @@ -99,7 +98,6 @@ HEADERS += \ $$PWD/qdeclarativedata_p.h \ $$PWD/qdeclarativeerror.h \ $$PWD/qdeclarativescriptparser_p.h \ - $$PWD/qdeclarativeenginedebug_p.h \ $$PWD/qdeclarativerewrite_p.h \ $$PWD/qpodvector_p.h \ $$PWD/qbitfield_p.h \ diff --git a/tests/auto/declarative/qdeclarativedebug/tst_qdeclarativedebug.cpp b/tests/auto/declarative/qdeclarativedebug/tst_qdeclarativedebug.cpp index d5ae040..0821245 100644 --- a/tests/auto/declarative/qdeclarativedebug/tst_qdeclarativedebug.cpp +++ b/tests/auto/declarative/qdeclarativedebug/tst_qdeclarativedebug.cpp @@ -53,7 +53,6 @@ #include #include -#include #include #include #include diff --git a/tests/auto/declarative/qdeclarativedebugclient/tst_qdeclarativedebugclient.cpp b/tests/auto/declarative/qdeclarativedebugclient/tst_qdeclarativedebugclient.cpp index 1599cab..0d371d0 100644 --- a/tests/auto/declarative/qdeclarativedebugclient/tst_qdeclarativedebugclient.cpp +++ b/tests/auto/declarative/qdeclarativedebugclient/tst_qdeclarativedebugclient.cpp @@ -48,7 +48,6 @@ #include #include -#include #include #include diff --git a/tests/auto/declarative/qdeclarativedebugservice/tst_qdeclarativedebugservice.cpp b/tests/auto/declarative/qdeclarativedebugservice/tst_qdeclarativedebugservice.cpp index 74f549c..1ca3b8f 100644 --- a/tests/auto/declarative/qdeclarativedebugservice/tst_qdeclarativedebugservice.cpp +++ b/tests/auto/declarative/qdeclarativedebugservice/tst_qdeclarativedebugservice.cpp @@ -48,7 +48,6 @@ #include #include -#include #include #include -- cgit v0.12 From 160e1eed007f43a68ee03a6e8c0bfd2602a64ee0 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Wed, 31 Aug 2011 09:12:39 +0200 Subject: Debugger: Rename qdeclarativedebug* to qdeclarativeenginedebug* Change-Id: I0c289bdf555aa317dc12c5dbcff0168ebcc7bd50 Reviewed-on: http://codereview.qt.nokia.com/3935 Reviewed-by: Qt Sanity Bot Reviewed-by: Aurindam Jana (cherrypicked from a07f68eff5ac4696a551f083d186a685f7ef043d) --- src/declarative/debugger/debugger.pri | 4 +- src/declarative/debugger/qdeclarativedebug.cpp | 1068 -------------------- src/declarative/debugger/qdeclarativedebug_p.h | 387 ------- .../debugger/qdeclarativeenginedebug.cpp | 1068 ++++++++++++++++++++ .../debugger/qdeclarativeenginedebug_p.h | 387 +++++++ .../qdeclarativedebug/tst_qdeclarativedebug.cpp | 2 +- .../tst_qdeclarativedebugclient.cpp | 2 - .../tst_qdeclarativedebugservice.cpp | 1 - 8 files changed, 1458 insertions(+), 1461 deletions(-) delete mode 100644 src/declarative/debugger/qdeclarativedebug.cpp delete mode 100644 src/declarative/debugger/qdeclarativedebug_p.h create mode 100644 src/declarative/debugger/qdeclarativeenginedebug.cpp create mode 100644 src/declarative/debugger/qdeclarativeenginedebug_p.h diff --git a/src/declarative/debugger/debugger.pri b/src/declarative/debugger/debugger.pri index 0810872..c81968e 100644 --- a/src/declarative/debugger/debugger.pri +++ b/src/declarative/debugger/debugger.pri @@ -5,7 +5,7 @@ SOURCES += \ $$PWD/qpacketprotocol.cpp \ $$PWD/qdeclarativedebugservice.cpp \ $$PWD/qdeclarativedebugclient.cpp \ - $$PWD/qdeclarativedebug.cpp \ + $$PWD/qdeclarativeenginedebug.cpp \ $$PWD/qdeclarativedebugtrace.cpp \ $$PWD/qdeclarativedebughelper.cpp \ $$PWD/qdeclarativedebugserver.cpp \ @@ -20,7 +20,7 @@ HEADERS += \ $$PWD/qdeclarativedebugservice_p.h \ $$PWD/qdeclarativedebugservice_p_p.h \ $$PWD/qdeclarativedebugclient_p.h \ - $$PWD/qdeclarativedebug_p.h \ + $$PWD/qdeclarativeenginedebug_p.h \ $$PWD/qdeclarativedebugtrace_p.h \ $$PWD/qdeclarativedebughelper_p.h \ $$PWD/qdeclarativedebugserver_p.h \ diff --git a/src/declarative/debugger/qdeclarativedebug.cpp b/src/declarative/debugger/qdeclarativedebug.cpp deleted file mode 100644 index 17bd553..0000000 --- a/src/declarative/debugger/qdeclarativedebug.cpp +++ /dev/null @@ -1,1068 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "private/qdeclarativedebug_p.h" - -#include "private/qdeclarativedebugclient_p.h" - -#include - -#include - -QT_BEGIN_NAMESPACE - -class QDeclarativeEngineDebugClient : public QDeclarativeDebugClient -{ -public: - QDeclarativeEngineDebugClient(QDeclarativeDebugConnection *client, QDeclarativeEngineDebugPrivate *p); - -protected: - virtual void statusChanged(Status status); - virtual void messageReceived(const QByteArray &); - -private: - QDeclarativeEngineDebugPrivate *priv; - friend class QDeclarativeEngineDebugPrivate; -}; - -class QDeclarativeEngineDebugPrivate : public QObjectPrivate -{ - Q_DECLARE_PUBLIC(QDeclarativeEngineDebug) -public: - QDeclarativeEngineDebugPrivate(QDeclarativeDebugConnection *); - ~QDeclarativeEngineDebugPrivate(); - - void statusChanged(QDeclarativeEngineDebug::Status status); - void message(const QByteArray &); - - QDeclarativeEngineDebugClient *client; - int nextId; - int getId(); - - void decode(QDataStream &, QDeclarativeDebugContextReference &); - void decode(QDataStream &, QDeclarativeDebugObjectReference &, bool simple); - - static void remove(QDeclarativeEngineDebug *, QDeclarativeDebugEnginesQuery *); - static void remove(QDeclarativeEngineDebug *, QDeclarativeDebugRootContextQuery *); - static void remove(QDeclarativeEngineDebug *, QDeclarativeDebugObjectQuery *); - static void remove(QDeclarativeEngineDebug *, QDeclarativeDebugExpressionQuery *); - static void remove(QDeclarativeEngineDebug *, QDeclarativeDebugWatch *); - - QHash enginesQuery; - QHash rootContextQuery; - QHash objectQuery; - QHash expressionQuery; - - QHash watched; -}; - -QDeclarativeEngineDebugClient::QDeclarativeEngineDebugClient(QDeclarativeDebugConnection *client, - QDeclarativeEngineDebugPrivate *p) -: QDeclarativeDebugClient(QLatin1String("QDeclarativeEngine"), client), priv(p) -{ -} - -void QDeclarativeEngineDebugClient::statusChanged(Status status) -{ - if (priv) - priv->statusChanged(static_cast(status)); -} - -void QDeclarativeEngineDebugClient::messageReceived(const QByteArray &data) -{ - if (priv) - priv->message(data); -} - -QDeclarativeEngineDebugPrivate::QDeclarativeEngineDebugPrivate(QDeclarativeDebugConnection *c) -: client(new QDeclarativeEngineDebugClient(c, this)), nextId(0) -{ -} - -QDeclarativeEngineDebugPrivate::~QDeclarativeEngineDebugPrivate() -{ - if (client) - client->priv = 0; - delete client; - - QHash::iterator enginesIter = enginesQuery.begin(); - for (; enginesIter != enginesQuery.end(); ++enginesIter) { - enginesIter.value()->m_client = 0; - if (enginesIter.value()->state() == QDeclarativeDebugQuery::Waiting) - enginesIter.value()->setState(QDeclarativeDebugQuery::Error); - } - - QHash::iterator rootContextIter = rootContextQuery.begin(); - for (; rootContextIter != rootContextQuery.end(); ++rootContextIter) { - rootContextIter.value()->m_client = 0; - if (rootContextIter.value()->state() == QDeclarativeDebugQuery::Waiting) - rootContextIter.value()->setState(QDeclarativeDebugQuery::Error); - } - - QHash::iterator objectIter = objectQuery.begin(); - for (; objectIter != objectQuery.end(); ++objectIter) { - objectIter.value()->m_client = 0; - if (objectIter.value()->state() == QDeclarativeDebugQuery::Waiting) - objectIter.value()->setState(QDeclarativeDebugQuery::Error); - } - - QHash::iterator exprIter = expressionQuery.begin(); - for (; exprIter != expressionQuery.end(); ++exprIter) { - exprIter.value()->m_client = 0; - if (exprIter.value()->state() == QDeclarativeDebugQuery::Waiting) - exprIter.value()->setState(QDeclarativeDebugQuery::Error); - } - - QHash::iterator watchIter = watched.begin(); - for (; watchIter != watched.end(); ++watchIter) { - watchIter.value()->m_client = 0; - watchIter.value()->setState(QDeclarativeDebugWatch::Dead); - } -} - -int QDeclarativeEngineDebugPrivate::getId() -{ - return nextId++; -} - -void QDeclarativeEngineDebugPrivate::remove(QDeclarativeEngineDebug *c, QDeclarativeDebugEnginesQuery *q) -{ - if (c && q) { - QDeclarativeEngineDebugPrivate *p = (QDeclarativeEngineDebugPrivate *)QObjectPrivate::get(c); - p->enginesQuery.remove(q->m_queryId); - } -} - -void QDeclarativeEngineDebugPrivate::remove(QDeclarativeEngineDebug *c, - QDeclarativeDebugRootContextQuery *q) -{ - if (c && q) { - QDeclarativeEngineDebugPrivate *p = (QDeclarativeEngineDebugPrivate *)QObjectPrivate::get(c); - p->rootContextQuery.remove(q->m_queryId); - } -} - -void QDeclarativeEngineDebugPrivate::remove(QDeclarativeEngineDebug *c, QDeclarativeDebugObjectQuery *q) -{ - if (c && q) { - QDeclarativeEngineDebugPrivate *p = (QDeclarativeEngineDebugPrivate *)QObjectPrivate::get(c); - p->objectQuery.remove(q->m_queryId); - } -} - -void QDeclarativeEngineDebugPrivate::remove(QDeclarativeEngineDebug *c, QDeclarativeDebugExpressionQuery *q) -{ - if (c && q) { - QDeclarativeEngineDebugPrivate *p = (QDeclarativeEngineDebugPrivate *)QObjectPrivate::get(c); - p->expressionQuery.remove(q->m_queryId); - } -} - -void QDeclarativeEngineDebugPrivate::remove(QDeclarativeEngineDebug *c, QDeclarativeDebugWatch *w) -{ - if (c && w) { - QDeclarativeEngineDebugPrivate *p = (QDeclarativeEngineDebugPrivate *)QObjectPrivate::get(c); - p->watched.remove(w->m_queryId); - } -} - -void QDeclarativeEngineDebugPrivate::decode(QDataStream &ds, QDeclarativeDebugObjectReference &o, - bool simple) -{ - QDeclarativeEngineDebugService::QDeclarativeObjectData data; - ds >> data; - o.m_debugId = data.objectId; - o.m_class = data.objectType; - o.m_idString = data.idString; - o.m_name = data.objectName; - o.m_source.m_url = data.url; - o.m_source.m_lineNumber = data.lineNumber; - o.m_source.m_columnNumber = data.columnNumber; - o.m_contextDebugId = data.contextId; - - if (simple) - return; - - int childCount; - bool recur; - ds >> childCount >> recur; - - for (int ii = 0; ii < childCount; ++ii) { - o.m_children.append(QDeclarativeDebugObjectReference()); - decode(ds, o.m_children.last(), !recur); - } - - int propCount; - ds >> propCount; - - for (int ii = 0; ii < propCount; ++ii) { - QDeclarativeEngineDebugService::QDeclarativeObjectProperty data; - ds >> data; - QDeclarativeDebugPropertyReference prop; - prop.m_objectDebugId = o.m_debugId; - prop.m_name = data.name; - prop.m_binding = data.binding; - prop.m_hasNotifySignal = data.hasNotifySignal; - prop.m_valueTypeName = data.valueTypeName; - switch (data.type) { - case QDeclarativeEngineDebugService::QDeclarativeObjectProperty::Basic: - case QDeclarativeEngineDebugService::QDeclarativeObjectProperty::List: - case QDeclarativeEngineDebugService::QDeclarativeObjectProperty::SignalProperty: - { - prop.m_value = data.value; - break; - } - case QDeclarativeEngineDebugService::QDeclarativeObjectProperty::Object: - { - QDeclarativeDebugObjectReference obj; - obj.m_debugId = prop.m_value.toInt(); - prop.m_value = QVariant::fromValue(obj); - break; - } - case QDeclarativeEngineDebugService::QDeclarativeObjectProperty::Unknown: - break; - } - o.m_properties << prop; - } -} - -void QDeclarativeEngineDebugPrivate::decode(QDataStream &ds, QDeclarativeDebugContextReference &c) -{ - ds >> c.m_name >> c.m_debugId; - - int contextCount; - ds >> contextCount; - - for (int ii = 0; ii < contextCount; ++ii) { - c.m_contexts.append(QDeclarativeDebugContextReference()); - decode(ds, c.m_contexts.last()); - } - - int objectCount; - ds >> objectCount; - - for (int ii = 0; ii < objectCount; ++ii) { - QDeclarativeDebugObjectReference obj; - decode(ds, obj, true); - - obj.m_contextDebugId = c.m_debugId; - c.m_objects << obj; - } -} - -void QDeclarativeEngineDebugPrivate::statusChanged(QDeclarativeEngineDebug::Status status) -{ - emit q_func()->statusChanged(status); -} - -void QDeclarativeEngineDebugPrivate::message(const QByteArray &data) -{ - QDataStream ds(data); - - QByteArray type; - ds >> type; - - //qDebug() << "QDeclarativeEngineDebugPrivate::message()" << type; - - if (type == "LIST_ENGINES_R") { - int queryId; - ds >> queryId; - - QDeclarativeDebugEnginesQuery *query = enginesQuery.value(queryId); - if (!query) - return; - enginesQuery.remove(queryId); - - int count; - ds >> count; - - for (int ii = 0; ii < count; ++ii) { - QDeclarativeDebugEngineReference ref; - ds >> ref.m_name; - ds >> ref.m_debugId; - query->m_engines << ref; - } - - query->m_client = 0; - query->setState(QDeclarativeDebugQuery::Completed); - } else if (type == "LIST_OBJECTS_R") { - int queryId; - ds >> queryId; - - QDeclarativeDebugRootContextQuery *query = rootContextQuery.value(queryId); - if (!query) - return; - rootContextQuery.remove(queryId); - - if (!ds.atEnd()) - decode(ds, query->m_context); - - query->m_client = 0; - query->setState(QDeclarativeDebugQuery::Completed); - } else if (type == "FETCH_OBJECT_R") { - int queryId; - ds >> queryId; - - QDeclarativeDebugObjectQuery *query = objectQuery.value(queryId); - if (!query) - return; - objectQuery.remove(queryId); - - if (!ds.atEnd()) - decode(ds, query->m_object, false); - - query->m_client = 0; - query->setState(QDeclarativeDebugQuery::Completed); - } else if (type == "EVAL_EXPRESSION_R") { - int queryId; - QVariant result; - ds >> queryId >> result; - - QDeclarativeDebugExpressionQuery *query = expressionQuery.value(queryId); - if (!query) - return; - expressionQuery.remove(queryId); - - query->m_result = result; - query->m_client = 0; - query->setState(QDeclarativeDebugQuery::Completed); - } else if (type == "WATCH_PROPERTY_R") { - int queryId; - bool ok; - ds >> queryId >> ok; - - QDeclarativeDebugWatch *watch = watched.value(queryId); - if (!watch) - return; - - watch->setState(ok ? QDeclarativeDebugWatch::Active : QDeclarativeDebugWatch::Inactive); - } else if (type == "WATCH_OBJECT_R") { - int queryId; - bool ok; - ds >> queryId >> ok; - - QDeclarativeDebugWatch *watch = watched.value(queryId); - if (!watch) - return; - - watch->setState(ok ? QDeclarativeDebugWatch::Active : QDeclarativeDebugWatch::Inactive); - } else if (type == "WATCH_EXPR_OBJECT_R") { - int queryId; - bool ok; - ds >> queryId >> ok; - - QDeclarativeDebugWatch *watch = watched.value(queryId); - if (!watch) - return; - - watch->setState(ok ? QDeclarativeDebugWatch::Active : QDeclarativeDebugWatch::Inactive); - } else if (type == "UPDATE_WATCH") { - int queryId; - int debugId; - QByteArray name; - QVariant value; - ds >> queryId >> debugId >> name >> value; - - QDeclarativeDebugWatch *watch = watched.value(queryId, 0); - if (!watch) - return; - emit watch->valueChanged(name, value); - } else if (type == "OBJECT_CREATED") { - emit q_func()->newObjects(); - } -} - -QDeclarativeEngineDebug::QDeclarativeEngineDebug(QDeclarativeDebugConnection *client, QObject *parent) -: QObject(*(new QDeclarativeEngineDebugPrivate(client)), parent) -{ -} - -QDeclarativeEngineDebug::Status QDeclarativeEngineDebug::status() const -{ - Q_D(const QDeclarativeEngineDebug); - - return static_cast(d->client->status()); -} - -QDeclarativeDebugPropertyWatch *QDeclarativeEngineDebug::addWatch(const QDeclarativeDebugPropertyReference &property, QObject *parent) -{ - Q_D(QDeclarativeEngineDebug); - - QDeclarativeDebugPropertyWatch *watch = new QDeclarativeDebugPropertyWatch(parent); - if (d->client->status() == QDeclarativeDebugClient::Enabled) { - int queryId = d->getId(); - watch->m_queryId = queryId; - watch->m_client = this; - watch->m_objectDebugId = property.objectDebugId(); - watch->m_name = property.name(); - d->watched.insert(queryId, watch); - - QByteArray message; - QDataStream ds(&message, QIODevice::WriteOnly); - ds << QByteArray("WATCH_PROPERTY") << queryId << property.objectDebugId() << property.name().toUtf8(); - d->client->sendMessage(message); - } else { - watch->m_state = QDeclarativeDebugWatch::Dead; - } - - return watch; -} - -QDeclarativeDebugWatch *QDeclarativeEngineDebug::addWatch(const QDeclarativeDebugContextReference &, const QString &, QObject *) -{ - qWarning("QDeclarativeEngineDebug::addWatch(): Not implemented"); - return 0; -} - -QDeclarativeDebugObjectExpressionWatch *QDeclarativeEngineDebug::addWatch(const QDeclarativeDebugObjectReference &object, const QString &expr, QObject *parent) -{ - Q_D(QDeclarativeEngineDebug); - QDeclarativeDebugObjectExpressionWatch *watch = new QDeclarativeDebugObjectExpressionWatch(parent); - if (d->client->status() == QDeclarativeDebugClient::Enabled) { - int queryId = d->getId(); - watch->m_queryId = queryId; - watch->m_client = this; - watch->m_objectDebugId = object.debugId(); - watch->m_expr = expr; - d->watched.insert(queryId, watch); - - QByteArray message; - QDataStream ds(&message, QIODevice::WriteOnly); - ds << QByteArray("WATCH_EXPR_OBJECT") << queryId << object.debugId() << expr; - d->client->sendMessage(message); - } else { - watch->m_state = QDeclarativeDebugWatch::Dead; - } - return watch; -} - -QDeclarativeDebugWatch *QDeclarativeEngineDebug::addWatch(const QDeclarativeDebugObjectReference &object, QObject *parent) -{ - Q_D(QDeclarativeEngineDebug); - - QDeclarativeDebugWatch *watch = new QDeclarativeDebugWatch(parent); - if (d->client->status() == QDeclarativeDebugClient::Enabled) { - int queryId = d->getId(); - watch->m_queryId = queryId; - watch->m_client = this; - watch->m_objectDebugId = object.debugId(); - d->watched.insert(queryId, watch); - - QByteArray message; - QDataStream ds(&message, QIODevice::WriteOnly); - ds << QByteArray("WATCH_OBJECT") << queryId << object.debugId(); - d->client->sendMessage(message); - } else { - watch->m_state = QDeclarativeDebugWatch::Dead; - } - - return watch; -} - -QDeclarativeDebugWatch *QDeclarativeEngineDebug::addWatch(const QDeclarativeDebugFileReference &, QObject *) -{ - qWarning("QDeclarativeEngineDebug::addWatch(): Not implemented"); - return 0; -} - -void QDeclarativeEngineDebug::removeWatch(QDeclarativeDebugWatch *watch) -{ - Q_D(QDeclarativeEngineDebug); - - if (!watch || !watch->m_client) - return; - - watch->m_client = 0; - watch->setState(QDeclarativeDebugWatch::Inactive); - - d->watched.remove(watch->queryId()); - - if (d->client && d->client->status() == QDeclarativeDebugClient::Enabled) { - QByteArray message; - QDataStream ds(&message, QIODevice::WriteOnly); - ds << QByteArray("NO_WATCH") << watch->queryId(); - d->client->sendMessage(message); - } -} - -QDeclarativeDebugEnginesQuery *QDeclarativeEngineDebug::queryAvailableEngines(QObject *parent) -{ - Q_D(QDeclarativeEngineDebug); - - QDeclarativeDebugEnginesQuery *query = new QDeclarativeDebugEnginesQuery(parent); - if (d->client->status() == QDeclarativeDebugClient::Enabled) { - query->m_client = this; - int queryId = d->getId(); - query->m_queryId = queryId; - d->enginesQuery.insert(queryId, query); - - QByteArray message; - QDataStream ds(&message, QIODevice::WriteOnly); - ds << QByteArray("LIST_ENGINES") << queryId; - d->client->sendMessage(message); - } else { - query->m_state = QDeclarativeDebugQuery::Error; - } - - return query; -} - -QDeclarativeDebugRootContextQuery *QDeclarativeEngineDebug::queryRootContexts(const QDeclarativeDebugEngineReference &engine, QObject *parent) -{ - Q_D(QDeclarativeEngineDebug); - - QDeclarativeDebugRootContextQuery *query = new QDeclarativeDebugRootContextQuery(parent); - if (d->client->status() == QDeclarativeDebugClient::Enabled && engine.debugId() != -1) { - query->m_client = this; - int queryId = d->getId(); - query->m_queryId = queryId; - d->rootContextQuery.insert(queryId, query); - - QByteArray message; - QDataStream ds(&message, QIODevice::WriteOnly); - ds << QByteArray("LIST_OBJECTS") << queryId << engine.debugId(); - d->client->sendMessage(message); - } else { - query->m_state = QDeclarativeDebugQuery::Error; - } - - return query; -} - -QDeclarativeDebugObjectQuery *QDeclarativeEngineDebug::queryObject(const QDeclarativeDebugObjectReference &object, QObject *parent) -{ - Q_D(QDeclarativeEngineDebug); - - QDeclarativeDebugObjectQuery *query = new QDeclarativeDebugObjectQuery(parent); - if (d->client->status() == QDeclarativeDebugClient::Enabled && object.debugId() != -1) { - query->m_client = this; - int queryId = d->getId(); - query->m_queryId = queryId; - d->objectQuery.insert(queryId, query); - - QByteArray message; - QDataStream ds(&message, QIODevice::WriteOnly); - ds << QByteArray("FETCH_OBJECT") << queryId << object.debugId() - << false << true; - d->client->sendMessage(message); - } else { - query->m_state = QDeclarativeDebugQuery::Error; - } - - return query; -} - -QDeclarativeDebugObjectQuery *QDeclarativeEngineDebug::queryObjectRecursive(const QDeclarativeDebugObjectReference &object, QObject *parent) -{ - Q_D(QDeclarativeEngineDebug); - - QDeclarativeDebugObjectQuery *query = new QDeclarativeDebugObjectQuery(parent); - if (d->client->status() == QDeclarativeDebugClient::Enabled && object.debugId() != -1) { - query->m_client = this; - int queryId = d->getId(); - query->m_queryId = queryId; - d->objectQuery.insert(queryId, query); - - QByteArray message; - QDataStream ds(&message, QIODevice::WriteOnly); - ds << QByteArray("FETCH_OBJECT") << queryId << object.debugId() - << true << true; - d->client->sendMessage(message); - } else { - query->m_state = QDeclarativeDebugQuery::Error; - } - - return query; -} - -QDeclarativeDebugExpressionQuery *QDeclarativeEngineDebug::queryExpressionResult(int objectDebugId, const QString &expr, QObject *parent) -{ - Q_D(QDeclarativeEngineDebug); - - QDeclarativeDebugExpressionQuery *query = new QDeclarativeDebugExpressionQuery(parent); - if (d->client->status() == QDeclarativeDebugClient::Enabled && objectDebugId != -1) { - query->m_client = this; - query->m_expr = expr; - int queryId = d->getId(); - query->m_queryId = queryId; - d->expressionQuery.insert(queryId, query); - - QByteArray message; - QDataStream ds(&message, QIODevice::WriteOnly); - ds << QByteArray("EVAL_EXPRESSION") << queryId << objectDebugId << expr; - d->client->sendMessage(message); - } else { - query->m_state = QDeclarativeDebugQuery::Error; - } - - return query; -} - -bool QDeclarativeEngineDebug::setBindingForObject(int objectDebugId, const QString &propertyName, - const QVariant &bindingExpression, - bool isLiteralValue, - QString source, int line) -{ - Q_D(QDeclarativeEngineDebug); - - if (d->client->status() == QDeclarativeDebugClient::Enabled && objectDebugId != -1) { - QByteArray message; - QDataStream ds(&message, QIODevice::WriteOnly); - ds << QByteArray("SET_BINDING") << objectDebugId << propertyName << bindingExpression << isLiteralValue << source << line; - d->client->sendMessage(message); - return true; - } else { - return false; - } -} - -bool QDeclarativeEngineDebug::resetBindingForObject(int objectDebugId, const QString &propertyName) -{ - Q_D(QDeclarativeEngineDebug); - - if (d->client->status() == QDeclarativeDebugClient::Enabled && objectDebugId != -1) { - QByteArray message; - QDataStream ds(&message, QIODevice::WriteOnly); - ds << QByteArray("RESET_BINDING") << objectDebugId << propertyName; - d->client->sendMessage(message); - return true; - } else { - return false; - } -} - -bool QDeclarativeEngineDebug::setMethodBody(int objectDebugId, const QString &methodName, - const QString &methodBody) -{ - Q_D(QDeclarativeEngineDebug); - - if (d->client->status() == QDeclarativeDebugClient::Enabled && objectDebugId != -1) { - QByteArray message; - QDataStream ds(&message, QIODevice::WriteOnly); - ds << QByteArray("SET_METHOD_BODY") << objectDebugId << methodName << methodBody; - d->client->sendMessage(message); - return true; - } else { - return false; - } -} - -QDeclarativeDebugWatch::QDeclarativeDebugWatch(QObject *parent) -: QObject(parent), m_state(Waiting), m_queryId(-1), m_client(0), m_objectDebugId(-1) -{ -} - -QDeclarativeDebugWatch::~QDeclarativeDebugWatch() -{ - if (m_client && m_queryId != -1) - QDeclarativeEngineDebugPrivate::remove(m_client, this); -} - -int QDeclarativeDebugWatch::queryId() const -{ - return m_queryId; -} - -int QDeclarativeDebugWatch::objectDebugId() const -{ - return m_objectDebugId; -} - -QDeclarativeDebugWatch::State QDeclarativeDebugWatch::state() const -{ - return m_state; -} - -void QDeclarativeDebugWatch::setState(State s) -{ - if (m_state == s) - return; - m_state = s; - emit stateChanged(m_state); -} - -QDeclarativeDebugPropertyWatch::QDeclarativeDebugPropertyWatch(QObject *parent) - : QDeclarativeDebugWatch(parent) -{ -} - -QString QDeclarativeDebugPropertyWatch::name() const -{ - return m_name; -} - - -QDeclarativeDebugObjectExpressionWatch::QDeclarativeDebugObjectExpressionWatch(QObject *parent) - : QDeclarativeDebugWatch(parent) -{ -} - -QString QDeclarativeDebugObjectExpressionWatch::expression() const -{ - return m_expr; -} - - -QDeclarativeDebugQuery::QDeclarativeDebugQuery(QObject *parent) -: QObject(parent), m_state(Waiting) -{ -} - -QDeclarativeDebugQuery::State QDeclarativeDebugQuery::state() const -{ - return m_state; -} - -bool QDeclarativeDebugQuery::isWaiting() const -{ - return m_state == Waiting; -} - -void QDeclarativeDebugQuery::setState(State s) -{ - if (m_state == s) - return; - m_state = s; - emit stateChanged(m_state); -} - -QDeclarativeDebugEnginesQuery::QDeclarativeDebugEnginesQuery(QObject *parent) -: QDeclarativeDebugQuery(parent), m_client(0), m_queryId(-1) -{ -} - -QDeclarativeDebugEnginesQuery::~QDeclarativeDebugEnginesQuery() -{ - if (m_client && m_queryId != -1) - QDeclarativeEngineDebugPrivate::remove(m_client, this); -} - -QList QDeclarativeDebugEnginesQuery::engines() const -{ - return m_engines; -} - -QDeclarativeDebugRootContextQuery::QDeclarativeDebugRootContextQuery(QObject *parent) -: QDeclarativeDebugQuery(parent), m_client(0), m_queryId(-1) -{ -} - -QDeclarativeDebugRootContextQuery::~QDeclarativeDebugRootContextQuery() -{ - if (m_client && m_queryId != -1) - QDeclarativeEngineDebugPrivate::remove(m_client, this); -} - -QDeclarativeDebugContextReference QDeclarativeDebugRootContextQuery::rootContext() const -{ - return m_context; -} - -QDeclarativeDebugObjectQuery::QDeclarativeDebugObjectQuery(QObject *parent) -: QDeclarativeDebugQuery(parent), m_client(0), m_queryId(-1) -{ -} - -QDeclarativeDebugObjectQuery::~QDeclarativeDebugObjectQuery() -{ - if (m_client && m_queryId != -1) - QDeclarativeEngineDebugPrivate::remove(m_client, this); -} - -QDeclarativeDebugObjectReference QDeclarativeDebugObjectQuery::object() const -{ - return m_object; -} - -QDeclarativeDebugExpressionQuery::QDeclarativeDebugExpressionQuery(QObject *parent) -: QDeclarativeDebugQuery(parent), m_client(0), m_queryId(-1) -{ -} - -QDeclarativeDebugExpressionQuery::~QDeclarativeDebugExpressionQuery() -{ - if (m_client && m_queryId != -1) - QDeclarativeEngineDebugPrivate::remove(m_client, this); -} - -QVariant QDeclarativeDebugExpressionQuery::expression() const -{ - return m_expr; -} - -QVariant QDeclarativeDebugExpressionQuery::result() const -{ - return m_result; -} - -QDeclarativeDebugEngineReference::QDeclarativeDebugEngineReference() -: m_debugId(-1) -{ -} - -QDeclarativeDebugEngineReference::QDeclarativeDebugEngineReference(int debugId) -: m_debugId(debugId) -{ -} - -QDeclarativeDebugEngineReference::QDeclarativeDebugEngineReference(const QDeclarativeDebugEngineReference &o) -: m_debugId(o.m_debugId), m_name(o.m_name) -{ -} - -QDeclarativeDebugEngineReference & -QDeclarativeDebugEngineReference::operator=(const QDeclarativeDebugEngineReference &o) -{ - m_debugId = o.m_debugId; m_name = o.m_name; - return *this; -} - -int QDeclarativeDebugEngineReference::debugId() const -{ - return m_debugId; -} - -QString QDeclarativeDebugEngineReference::name() const -{ - return m_name; -} - -QDeclarativeDebugObjectReference::QDeclarativeDebugObjectReference() -: m_debugId(-1), m_contextDebugId(-1) -{ -} - -QDeclarativeDebugObjectReference::QDeclarativeDebugObjectReference(int debugId) -: m_debugId(debugId), m_contextDebugId(-1) -{ -} - -QDeclarativeDebugObjectReference::QDeclarativeDebugObjectReference(const QDeclarativeDebugObjectReference &o) -: m_debugId(o.m_debugId), m_class(o.m_class), m_idString(o.m_idString), - m_name(o.m_name), m_source(o.m_source), m_contextDebugId(o.m_contextDebugId), - m_properties(o.m_properties), m_children(o.m_children) -{ -} - -QDeclarativeDebugObjectReference & -QDeclarativeDebugObjectReference::operator=(const QDeclarativeDebugObjectReference &o) -{ - m_debugId = o.m_debugId; m_class = o.m_class; m_idString = o.m_idString; - m_name = o.m_name; m_source = o.m_source; m_contextDebugId = o.m_contextDebugId; - m_properties = o.m_properties; m_children = o.m_children; - return *this; -} - -int QDeclarativeDebugObjectReference::debugId() const -{ - return m_debugId; -} - -QString QDeclarativeDebugObjectReference::className() const -{ - return m_class; -} - -QString QDeclarativeDebugObjectReference::idString() const -{ - return m_idString; -} - -QString QDeclarativeDebugObjectReference::name() const -{ - return m_name; -} - -QDeclarativeDebugFileReference QDeclarativeDebugObjectReference::source() const -{ - return m_source; -} - -int QDeclarativeDebugObjectReference::contextDebugId() const -{ - return m_contextDebugId; -} - -QList QDeclarativeDebugObjectReference::properties() const -{ - return m_properties; -} - -QList QDeclarativeDebugObjectReference::children() const -{ - return m_children; -} - -QDeclarativeDebugContextReference::QDeclarativeDebugContextReference() -: m_debugId(-1) -{ -} - -QDeclarativeDebugContextReference::QDeclarativeDebugContextReference(const QDeclarativeDebugContextReference &o) -: m_debugId(o.m_debugId), m_name(o.m_name), m_objects(o.m_objects), m_contexts(o.m_contexts) -{ -} - -QDeclarativeDebugContextReference &QDeclarativeDebugContextReference::operator=(const QDeclarativeDebugContextReference &o) -{ - m_debugId = o.m_debugId; m_name = o.m_name; m_objects = o.m_objects; - m_contexts = o.m_contexts; - return *this; -} - -int QDeclarativeDebugContextReference::debugId() const -{ - return m_debugId; -} - -QString QDeclarativeDebugContextReference::name() const -{ - return m_name; -} - -QList QDeclarativeDebugContextReference::objects() const -{ - return m_objects; -} - -QList QDeclarativeDebugContextReference::contexts() const -{ - return m_contexts; -} - -QDeclarativeDebugFileReference::QDeclarativeDebugFileReference() -: m_lineNumber(-1), m_columnNumber(-1) -{ -} - -QDeclarativeDebugFileReference::QDeclarativeDebugFileReference(const QDeclarativeDebugFileReference &o) -: m_url(o.m_url), m_lineNumber(o.m_lineNumber), m_columnNumber(o.m_columnNumber) -{ -} - -QDeclarativeDebugFileReference &QDeclarativeDebugFileReference::operator=(const QDeclarativeDebugFileReference &o) -{ - m_url = o.m_url; m_lineNumber = o.m_lineNumber; m_columnNumber = o.m_columnNumber; - return *this; -} - -QUrl QDeclarativeDebugFileReference::url() const -{ - return m_url; -} - -void QDeclarativeDebugFileReference::setUrl(const QUrl &u) -{ - m_url = u; -} - -int QDeclarativeDebugFileReference::lineNumber() const -{ - return m_lineNumber; -} - -void QDeclarativeDebugFileReference::setLineNumber(int l) -{ - m_lineNumber = l; -} - -int QDeclarativeDebugFileReference::columnNumber() const -{ - return m_columnNumber; -} - -void QDeclarativeDebugFileReference::setColumnNumber(int c) -{ - m_columnNumber = c; -} - -QDeclarativeDebugPropertyReference::QDeclarativeDebugPropertyReference() -: m_objectDebugId(-1), m_hasNotifySignal(false) -{ -} - -QDeclarativeDebugPropertyReference::QDeclarativeDebugPropertyReference(const QDeclarativeDebugPropertyReference &o) -: m_objectDebugId(o.m_objectDebugId), m_name(o.m_name), m_value(o.m_value), - m_valueTypeName(o.m_valueTypeName), m_binding(o.m_binding), - m_hasNotifySignal(o.m_hasNotifySignal) -{ -} - -QDeclarativeDebugPropertyReference &QDeclarativeDebugPropertyReference::operator=(const QDeclarativeDebugPropertyReference &o) -{ - m_objectDebugId = o.m_objectDebugId; m_name = o.m_name; m_value = o.m_value; - m_valueTypeName = o.m_valueTypeName; m_binding = o.m_binding; - m_hasNotifySignal = o.m_hasNotifySignal; - return *this; -} - -int QDeclarativeDebugPropertyReference::objectDebugId() const -{ - return m_objectDebugId; -} - -QString QDeclarativeDebugPropertyReference::name() const -{ - return m_name; -} - -QString QDeclarativeDebugPropertyReference::valueTypeName() const -{ - return m_valueTypeName; -} - -QVariant QDeclarativeDebugPropertyReference::value() const -{ - return m_value; -} - -QString QDeclarativeDebugPropertyReference::binding() const -{ - return m_binding; -} - -bool QDeclarativeDebugPropertyReference::hasNotifySignal() const -{ - return m_hasNotifySignal; -} - -QT_END_NAMESPACE - diff --git a/src/declarative/debugger/qdeclarativedebug_p.h b/src/declarative/debugger/qdeclarativedebug_p.h deleted file mode 100644 index f822637..0000000 --- a/src/declarative/debugger/qdeclarativedebug_p.h +++ /dev/null @@ -1,387 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef QDECLARATIVEDEBUG_H -#define QDECLARATIVEDEBUG_H - -#include -#include -#include - -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Declarative) - -class QDeclarativeDebugConnection; -class QDeclarativeDebugWatch; -class QDeclarativeDebugPropertyWatch; -class QDeclarativeDebugObjectExpressionWatch; -class QDeclarativeDebugEnginesQuery; -class QDeclarativeDebugRootContextQuery; -class QDeclarativeDebugObjectQuery; -class QDeclarativeDebugExpressionQuery; -class QDeclarativeDebugPropertyReference; -class QDeclarativeDebugContextReference; -class QDeclarativeDebugObjectReference; -class QDeclarativeDebugFileReference; -class QDeclarativeDebugEngineReference; -class QDeclarativeEngineDebugPrivate; -class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeEngineDebug : public QObject -{ -Q_OBJECT -public: - enum Status { NotConnected, Unavailable, Enabled }; - - explicit QDeclarativeEngineDebug(QDeclarativeDebugConnection *, QObject * = 0); - - Status status() const; - - QDeclarativeDebugPropertyWatch *addWatch(const QDeclarativeDebugPropertyReference &, - QObject *parent = 0); - QDeclarativeDebugWatch *addWatch(const QDeclarativeDebugContextReference &, const QString &, - QObject *parent = 0); - QDeclarativeDebugObjectExpressionWatch *addWatch(const QDeclarativeDebugObjectReference &, const QString &, - QObject *parent = 0); - QDeclarativeDebugWatch *addWatch(const QDeclarativeDebugObjectReference &, - QObject *parent = 0); - QDeclarativeDebugWatch *addWatch(const QDeclarativeDebugFileReference &, - QObject *parent = 0); - - void removeWatch(QDeclarativeDebugWatch *watch); - - QDeclarativeDebugEnginesQuery *queryAvailableEngines(QObject *parent = 0); - QDeclarativeDebugRootContextQuery *queryRootContexts(const QDeclarativeDebugEngineReference &, - QObject *parent = 0); - QDeclarativeDebugObjectQuery *queryObject(const QDeclarativeDebugObjectReference &, - QObject *parent = 0); - QDeclarativeDebugObjectQuery *queryObjectRecursive(const QDeclarativeDebugObjectReference &, - QObject *parent = 0); - QDeclarativeDebugExpressionQuery *queryExpressionResult(int objectDebugId, - const QString &expr, - QObject *parent = 0); - bool setBindingForObject(int objectDebugId, const QString &propertyName, - const QVariant &bindingExpression, bool isLiteralValue, - QString source = QString(), int line = -1); - bool resetBindingForObject(int objectDebugId, const QString &propertyName); - bool setMethodBody(int objectDebugId, const QString &methodName, const QString &methodBody); - -Q_SIGNALS: - void newObjects(); - void statusChanged(Status status); - -private: - Q_DECLARE_PRIVATE(QDeclarativeEngineDebug) -}; - -class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugWatch : public QObject -{ -Q_OBJECT -public: - enum State { Waiting, Active, Inactive, Dead }; - - QDeclarativeDebugWatch(QObject *); - ~QDeclarativeDebugWatch(); - - int queryId() const; - int objectDebugId() const; - State state() const; - -Q_SIGNALS: - void stateChanged(QDeclarativeDebugWatch::State); - //void objectChanged(int, const QDeclarativeDebugObjectReference &); - //void valueChanged(int, const QVariant &); - - // Server sends value as string if it is a user-type variant - void valueChanged(const QByteArray &name, const QVariant &value); - -private: - friend class QDeclarativeEngineDebug; - friend class QDeclarativeEngineDebugPrivate; - void setState(State); - State m_state; - int m_queryId; - QDeclarativeEngineDebug *m_client; - int m_objectDebugId; -}; - -class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugPropertyWatch : public QDeclarativeDebugWatch -{ - Q_OBJECT -public: - QDeclarativeDebugPropertyWatch(QObject *parent); - - QString name() const; - -private: - friend class QDeclarativeEngineDebug; - QString m_name; -}; - -class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugObjectExpressionWatch : public QDeclarativeDebugWatch -{ - Q_OBJECT -public: - QDeclarativeDebugObjectExpressionWatch(QObject *parent); - - QString expression() const; - -private: - friend class QDeclarativeEngineDebug; - QString m_expr; - int m_debugId; -}; - - -class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugQuery : public QObject -{ -Q_OBJECT -public: - enum State { Waiting, Error, Completed }; - - State state() const; - bool isWaiting() const; - -// bool waitUntilCompleted(); - -Q_SIGNALS: - void stateChanged(QDeclarativeDebugQuery::State); - -protected: - QDeclarativeDebugQuery(QObject *); - -private: - friend class QDeclarativeEngineDebug; - friend class QDeclarativeEngineDebugPrivate; - void setState(State); - State m_state; -}; - -class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugFileReference -{ -public: - QDeclarativeDebugFileReference(); - QDeclarativeDebugFileReference(const QDeclarativeDebugFileReference &); - QDeclarativeDebugFileReference &operator=(const QDeclarativeDebugFileReference &); - - QUrl url() const; - void setUrl(const QUrl &); - int lineNumber() const; - void setLineNumber(int); - int columnNumber() const; - void setColumnNumber(int); - -private: - friend class QDeclarativeEngineDebugPrivate; - QUrl m_url; - int m_lineNumber; - int m_columnNumber; -}; - -class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugEngineReference -{ -public: - QDeclarativeDebugEngineReference(); - QDeclarativeDebugEngineReference(int); - QDeclarativeDebugEngineReference(const QDeclarativeDebugEngineReference &); - QDeclarativeDebugEngineReference &operator=(const QDeclarativeDebugEngineReference &); - - int debugId() const; - QString name() const; - -private: - friend class QDeclarativeEngineDebugPrivate; - int m_debugId; - QString m_name; -}; - -class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugObjectReference -{ -public: - QDeclarativeDebugObjectReference(); - QDeclarativeDebugObjectReference(int); - QDeclarativeDebugObjectReference(const QDeclarativeDebugObjectReference &); - QDeclarativeDebugObjectReference &operator=(const QDeclarativeDebugObjectReference &); - - int debugId() const; - QString className() const; - QString idString() const; - QString name() const; - - QDeclarativeDebugFileReference source() const; - int contextDebugId() const; - - QList properties() const; - QList children() const; - -private: - friend class QDeclarativeEngineDebugPrivate; - int m_debugId; - QString m_class; - QString m_idString; - QString m_name; - QDeclarativeDebugFileReference m_source; - int m_contextDebugId; - QList m_properties; - QList m_children; -}; - -class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugContextReference -{ -public: - QDeclarativeDebugContextReference(); - QDeclarativeDebugContextReference(const QDeclarativeDebugContextReference &); - QDeclarativeDebugContextReference &operator=(const QDeclarativeDebugContextReference &); - - int debugId() const; - QString name() const; - - QList objects() const; - QList contexts() const; - -private: - friend class QDeclarativeEngineDebugPrivate; - int m_debugId; - QString m_name; - QList m_objects; - QList m_contexts; -}; - -class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugPropertyReference -{ -public: - QDeclarativeDebugPropertyReference(); - QDeclarativeDebugPropertyReference(const QDeclarativeDebugPropertyReference &); - QDeclarativeDebugPropertyReference &operator=(const QDeclarativeDebugPropertyReference &); - - int objectDebugId() const; - QString name() const; - QVariant value() const; - QString valueTypeName() const; - QString binding() const; - bool hasNotifySignal() const; - -private: - friend class QDeclarativeEngineDebugPrivate; - int m_objectDebugId; - QString m_name; - QVariant m_value; - QString m_valueTypeName; - QString m_binding; - bool m_hasNotifySignal; -}; - - -class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugEnginesQuery : public QDeclarativeDebugQuery -{ -Q_OBJECT -public: - virtual ~QDeclarativeDebugEnginesQuery(); - QList engines() const; -private: - friend class QDeclarativeEngineDebug; - friend class QDeclarativeEngineDebugPrivate; - QDeclarativeDebugEnginesQuery(QObject *); - QDeclarativeEngineDebug *m_client; - int m_queryId; - QList m_engines; -}; - -class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugRootContextQuery : public QDeclarativeDebugQuery -{ -Q_OBJECT -public: - virtual ~QDeclarativeDebugRootContextQuery(); - QDeclarativeDebugContextReference rootContext() const; -private: - friend class QDeclarativeEngineDebug; - friend class QDeclarativeEngineDebugPrivate; - QDeclarativeDebugRootContextQuery(QObject *); - QDeclarativeEngineDebug *m_client; - int m_queryId; - QDeclarativeDebugContextReference m_context; -}; - -class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugObjectQuery : public QDeclarativeDebugQuery -{ -Q_OBJECT -public: - virtual ~QDeclarativeDebugObjectQuery(); - QDeclarativeDebugObjectReference object() const; -private: - friend class QDeclarativeEngineDebug; - friend class QDeclarativeEngineDebugPrivate; - QDeclarativeDebugObjectQuery(QObject *); - QDeclarativeEngineDebug *m_client; - int m_queryId; - QDeclarativeDebugObjectReference m_object; - -}; - -class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugExpressionQuery : public QDeclarativeDebugQuery -{ -Q_OBJECT -public: - virtual ~QDeclarativeDebugExpressionQuery(); - QVariant expression() const; - QVariant result() const; -private: - friend class QDeclarativeEngineDebug; - friend class QDeclarativeEngineDebugPrivate; - QDeclarativeDebugExpressionQuery(QObject *); - QDeclarativeEngineDebug *m_client; - int m_queryId; - QVariant m_expr; - QVariant m_result; -}; - -QT_END_NAMESPACE - -Q_DECLARE_METATYPE(QDeclarativeDebugEngineReference) -Q_DECLARE_METATYPE(QDeclarativeDebugObjectReference) -Q_DECLARE_METATYPE(QDeclarativeDebugContextReference) -Q_DECLARE_METATYPE(QDeclarativeDebugPropertyReference) - -QT_END_HEADER - -#endif // QDECLARATIVEDEBUG_H diff --git a/src/declarative/debugger/qdeclarativeenginedebug.cpp b/src/declarative/debugger/qdeclarativeenginedebug.cpp new file mode 100644 index 0000000..85ce710 --- /dev/null +++ b/src/declarative/debugger/qdeclarativeenginedebug.cpp @@ -0,0 +1,1068 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "private/qdeclarativeenginedebug_p.h" + +#include "private/qdeclarativedebugclient_p.h" + +#include + +#include + +QT_BEGIN_NAMESPACE + +class QDeclarativeEngineDebugClient : public QDeclarativeDebugClient +{ +public: + QDeclarativeEngineDebugClient(QDeclarativeDebugConnection *client, QDeclarativeEngineDebugPrivate *p); + +protected: + virtual void statusChanged(Status status); + virtual void messageReceived(const QByteArray &); + +private: + QDeclarativeEngineDebugPrivate *priv; + friend class QDeclarativeEngineDebugPrivate; +}; + +class QDeclarativeEngineDebugPrivate : public QObjectPrivate +{ + Q_DECLARE_PUBLIC(QDeclarativeEngineDebug) +public: + QDeclarativeEngineDebugPrivate(QDeclarativeDebugConnection *); + ~QDeclarativeEngineDebugPrivate(); + + void statusChanged(QDeclarativeEngineDebug::Status status); + void message(const QByteArray &); + + QDeclarativeEngineDebugClient *client; + int nextId; + int getId(); + + void decode(QDataStream &, QDeclarativeDebugContextReference &); + void decode(QDataStream &, QDeclarativeDebugObjectReference &, bool simple); + + static void remove(QDeclarativeEngineDebug *, QDeclarativeDebugEnginesQuery *); + static void remove(QDeclarativeEngineDebug *, QDeclarativeDebugRootContextQuery *); + static void remove(QDeclarativeEngineDebug *, QDeclarativeDebugObjectQuery *); + static void remove(QDeclarativeEngineDebug *, QDeclarativeDebugExpressionQuery *); + static void remove(QDeclarativeEngineDebug *, QDeclarativeDebugWatch *); + + QHash enginesQuery; + QHash rootContextQuery; + QHash objectQuery; + QHash expressionQuery; + + QHash watched; +}; + +QDeclarativeEngineDebugClient::QDeclarativeEngineDebugClient(QDeclarativeDebugConnection *client, + QDeclarativeEngineDebugPrivate *p) +: QDeclarativeDebugClient(QLatin1String("QDeclarativeEngine"), client), priv(p) +{ +} + +void QDeclarativeEngineDebugClient::statusChanged(Status status) +{ + if (priv) + priv->statusChanged(static_cast(status)); +} + +void QDeclarativeEngineDebugClient::messageReceived(const QByteArray &data) +{ + if (priv) + priv->message(data); +} + +QDeclarativeEngineDebugPrivate::QDeclarativeEngineDebugPrivate(QDeclarativeDebugConnection *c) +: client(new QDeclarativeEngineDebugClient(c, this)), nextId(0) +{ +} + +QDeclarativeEngineDebugPrivate::~QDeclarativeEngineDebugPrivate() +{ + if (client) + client->priv = 0; + delete client; + + QHash::iterator enginesIter = enginesQuery.begin(); + for (; enginesIter != enginesQuery.end(); ++enginesIter) { + enginesIter.value()->m_client = 0; + if (enginesIter.value()->state() == QDeclarativeDebugQuery::Waiting) + enginesIter.value()->setState(QDeclarativeDebugQuery::Error); + } + + QHash::iterator rootContextIter = rootContextQuery.begin(); + for (; rootContextIter != rootContextQuery.end(); ++rootContextIter) { + rootContextIter.value()->m_client = 0; + if (rootContextIter.value()->state() == QDeclarativeDebugQuery::Waiting) + rootContextIter.value()->setState(QDeclarativeDebugQuery::Error); + } + + QHash::iterator objectIter = objectQuery.begin(); + for (; objectIter != objectQuery.end(); ++objectIter) { + objectIter.value()->m_client = 0; + if (objectIter.value()->state() == QDeclarativeDebugQuery::Waiting) + objectIter.value()->setState(QDeclarativeDebugQuery::Error); + } + + QHash::iterator exprIter = expressionQuery.begin(); + for (; exprIter != expressionQuery.end(); ++exprIter) { + exprIter.value()->m_client = 0; + if (exprIter.value()->state() == QDeclarativeDebugQuery::Waiting) + exprIter.value()->setState(QDeclarativeDebugQuery::Error); + } + + QHash::iterator watchIter = watched.begin(); + for (; watchIter != watched.end(); ++watchIter) { + watchIter.value()->m_client = 0; + watchIter.value()->setState(QDeclarativeDebugWatch::Dead); + } +} + +int QDeclarativeEngineDebugPrivate::getId() +{ + return nextId++; +} + +void QDeclarativeEngineDebugPrivate::remove(QDeclarativeEngineDebug *c, QDeclarativeDebugEnginesQuery *q) +{ + if (c && q) { + QDeclarativeEngineDebugPrivate *p = (QDeclarativeEngineDebugPrivate *)QObjectPrivate::get(c); + p->enginesQuery.remove(q->m_queryId); + } +} + +void QDeclarativeEngineDebugPrivate::remove(QDeclarativeEngineDebug *c, + QDeclarativeDebugRootContextQuery *q) +{ + if (c && q) { + QDeclarativeEngineDebugPrivate *p = (QDeclarativeEngineDebugPrivate *)QObjectPrivate::get(c); + p->rootContextQuery.remove(q->m_queryId); + } +} + +void QDeclarativeEngineDebugPrivate::remove(QDeclarativeEngineDebug *c, QDeclarativeDebugObjectQuery *q) +{ + if (c && q) { + QDeclarativeEngineDebugPrivate *p = (QDeclarativeEngineDebugPrivate *)QObjectPrivate::get(c); + p->objectQuery.remove(q->m_queryId); + } +} + +void QDeclarativeEngineDebugPrivate::remove(QDeclarativeEngineDebug *c, QDeclarativeDebugExpressionQuery *q) +{ + if (c && q) { + QDeclarativeEngineDebugPrivate *p = (QDeclarativeEngineDebugPrivate *)QObjectPrivate::get(c); + p->expressionQuery.remove(q->m_queryId); + } +} + +void QDeclarativeEngineDebugPrivate::remove(QDeclarativeEngineDebug *c, QDeclarativeDebugWatch *w) +{ + if (c && w) { + QDeclarativeEngineDebugPrivate *p = (QDeclarativeEngineDebugPrivate *)QObjectPrivate::get(c); + p->watched.remove(w->m_queryId); + } +} + +void QDeclarativeEngineDebugPrivate::decode(QDataStream &ds, QDeclarativeDebugObjectReference &o, + bool simple) +{ + QDeclarativeEngineDebugService::QDeclarativeObjectData data; + ds >> data; + o.m_debugId = data.objectId; + o.m_class = data.objectType; + o.m_idString = data.idString; + o.m_name = data.objectName; + o.m_source.m_url = data.url; + o.m_source.m_lineNumber = data.lineNumber; + o.m_source.m_columnNumber = data.columnNumber; + o.m_contextDebugId = data.contextId; + + if (simple) + return; + + int childCount; + bool recur; + ds >> childCount >> recur; + + for (int ii = 0; ii < childCount; ++ii) { + o.m_children.append(QDeclarativeDebugObjectReference()); + decode(ds, o.m_children.last(), !recur); + } + + int propCount; + ds >> propCount; + + for (int ii = 0; ii < propCount; ++ii) { + QDeclarativeEngineDebugService::QDeclarativeObjectProperty data; + ds >> data; + QDeclarativeDebugPropertyReference prop; + prop.m_objectDebugId = o.m_debugId; + prop.m_name = data.name; + prop.m_binding = data.binding; + prop.m_hasNotifySignal = data.hasNotifySignal; + prop.m_valueTypeName = data.valueTypeName; + switch (data.type) { + case QDeclarativeEngineDebugService::QDeclarativeObjectProperty::Basic: + case QDeclarativeEngineDebugService::QDeclarativeObjectProperty::List: + case QDeclarativeEngineDebugService::QDeclarativeObjectProperty::SignalProperty: + { + prop.m_value = data.value; + break; + } + case QDeclarativeEngineDebugService::QDeclarativeObjectProperty::Object: + { + QDeclarativeDebugObjectReference obj; + obj.m_debugId = prop.m_value.toInt(); + prop.m_value = QVariant::fromValue(obj); + break; + } + case QDeclarativeEngineDebugService::QDeclarativeObjectProperty::Unknown: + break; + } + o.m_properties << prop; + } +} + +void QDeclarativeEngineDebugPrivate::decode(QDataStream &ds, QDeclarativeDebugContextReference &c) +{ + ds >> c.m_name >> c.m_debugId; + + int contextCount; + ds >> contextCount; + + for (int ii = 0; ii < contextCount; ++ii) { + c.m_contexts.append(QDeclarativeDebugContextReference()); + decode(ds, c.m_contexts.last()); + } + + int objectCount; + ds >> objectCount; + + for (int ii = 0; ii < objectCount; ++ii) { + QDeclarativeDebugObjectReference obj; + decode(ds, obj, true); + + obj.m_contextDebugId = c.m_debugId; + c.m_objects << obj; + } +} + +void QDeclarativeEngineDebugPrivate::statusChanged(QDeclarativeEngineDebug::Status status) +{ + emit q_func()->statusChanged(status); +} + +void QDeclarativeEngineDebugPrivate::message(const QByteArray &data) +{ + QDataStream ds(data); + + QByteArray type; + ds >> type; + + //qDebug() << "QDeclarativeEngineDebugPrivate::message()" << type; + + if (type == "LIST_ENGINES_R") { + int queryId; + ds >> queryId; + + QDeclarativeDebugEnginesQuery *query = enginesQuery.value(queryId); + if (!query) + return; + enginesQuery.remove(queryId); + + int count; + ds >> count; + + for (int ii = 0; ii < count; ++ii) { + QDeclarativeDebugEngineReference ref; + ds >> ref.m_name; + ds >> ref.m_debugId; + query->m_engines << ref; + } + + query->m_client = 0; + query->setState(QDeclarativeDebugQuery::Completed); + } else if (type == "LIST_OBJECTS_R") { + int queryId; + ds >> queryId; + + QDeclarativeDebugRootContextQuery *query = rootContextQuery.value(queryId); + if (!query) + return; + rootContextQuery.remove(queryId); + + if (!ds.atEnd()) + decode(ds, query->m_context); + + query->m_client = 0; + query->setState(QDeclarativeDebugQuery::Completed); + } else if (type == "FETCH_OBJECT_R") { + int queryId; + ds >> queryId; + + QDeclarativeDebugObjectQuery *query = objectQuery.value(queryId); + if (!query) + return; + objectQuery.remove(queryId); + + if (!ds.atEnd()) + decode(ds, query->m_object, false); + + query->m_client = 0; + query->setState(QDeclarativeDebugQuery::Completed); + } else if (type == "EVAL_EXPRESSION_R") { + int queryId; + QVariant result; + ds >> queryId >> result; + + QDeclarativeDebugExpressionQuery *query = expressionQuery.value(queryId); + if (!query) + return; + expressionQuery.remove(queryId); + + query->m_result = result; + query->m_client = 0; + query->setState(QDeclarativeDebugQuery::Completed); + } else if (type == "WATCH_PROPERTY_R") { + int queryId; + bool ok; + ds >> queryId >> ok; + + QDeclarativeDebugWatch *watch = watched.value(queryId); + if (!watch) + return; + + watch->setState(ok ? QDeclarativeDebugWatch::Active : QDeclarativeDebugWatch::Inactive); + } else if (type == "WATCH_OBJECT_R") { + int queryId; + bool ok; + ds >> queryId >> ok; + + QDeclarativeDebugWatch *watch = watched.value(queryId); + if (!watch) + return; + + watch->setState(ok ? QDeclarativeDebugWatch::Active : QDeclarativeDebugWatch::Inactive); + } else if (type == "WATCH_EXPR_OBJECT_R") { + int queryId; + bool ok; + ds >> queryId >> ok; + + QDeclarativeDebugWatch *watch = watched.value(queryId); + if (!watch) + return; + + watch->setState(ok ? QDeclarativeDebugWatch::Active : QDeclarativeDebugWatch::Inactive); + } else if (type == "UPDATE_WATCH") { + int queryId; + int debugId; + QByteArray name; + QVariant value; + ds >> queryId >> debugId >> name >> value; + + QDeclarativeDebugWatch *watch = watched.value(queryId, 0); + if (!watch) + return; + emit watch->valueChanged(name, value); + } else if (type == "OBJECT_CREATED") { + emit q_func()->newObjects(); + } +} + +QDeclarativeEngineDebug::QDeclarativeEngineDebug(QDeclarativeDebugConnection *client, QObject *parent) +: QObject(*(new QDeclarativeEngineDebugPrivate(client)), parent) +{ +} + +QDeclarativeEngineDebug::Status QDeclarativeEngineDebug::status() const +{ + Q_D(const QDeclarativeEngineDebug); + + return static_cast(d->client->status()); +} + +QDeclarativeDebugPropertyWatch *QDeclarativeEngineDebug::addWatch(const QDeclarativeDebugPropertyReference &property, QObject *parent) +{ + Q_D(QDeclarativeEngineDebug); + + QDeclarativeDebugPropertyWatch *watch = new QDeclarativeDebugPropertyWatch(parent); + if (d->client->status() == QDeclarativeDebugClient::Enabled) { + int queryId = d->getId(); + watch->m_queryId = queryId; + watch->m_client = this; + watch->m_objectDebugId = property.objectDebugId(); + watch->m_name = property.name(); + d->watched.insert(queryId, watch); + + QByteArray message; + QDataStream ds(&message, QIODevice::WriteOnly); + ds << QByteArray("WATCH_PROPERTY") << queryId << property.objectDebugId() << property.name().toUtf8(); + d->client->sendMessage(message); + } else { + watch->m_state = QDeclarativeDebugWatch::Dead; + } + + return watch; +} + +QDeclarativeDebugWatch *QDeclarativeEngineDebug::addWatch(const QDeclarativeDebugContextReference &, const QString &, QObject *) +{ + qWarning("QDeclarativeEngineDebug::addWatch(): Not implemented"); + return 0; +} + +QDeclarativeDebugObjectExpressionWatch *QDeclarativeEngineDebug::addWatch(const QDeclarativeDebugObjectReference &object, const QString &expr, QObject *parent) +{ + Q_D(QDeclarativeEngineDebug); + QDeclarativeDebugObjectExpressionWatch *watch = new QDeclarativeDebugObjectExpressionWatch(parent); + if (d->client->status() == QDeclarativeDebugClient::Enabled) { + int queryId = d->getId(); + watch->m_queryId = queryId; + watch->m_client = this; + watch->m_objectDebugId = object.debugId(); + watch->m_expr = expr; + d->watched.insert(queryId, watch); + + QByteArray message; + QDataStream ds(&message, QIODevice::WriteOnly); + ds << QByteArray("WATCH_EXPR_OBJECT") << queryId << object.debugId() << expr; + d->client->sendMessage(message); + } else { + watch->m_state = QDeclarativeDebugWatch::Dead; + } + return watch; +} + +QDeclarativeDebugWatch *QDeclarativeEngineDebug::addWatch(const QDeclarativeDebugObjectReference &object, QObject *parent) +{ + Q_D(QDeclarativeEngineDebug); + + QDeclarativeDebugWatch *watch = new QDeclarativeDebugWatch(parent); + if (d->client->status() == QDeclarativeDebugClient::Enabled) { + int queryId = d->getId(); + watch->m_queryId = queryId; + watch->m_client = this; + watch->m_objectDebugId = object.debugId(); + d->watched.insert(queryId, watch); + + QByteArray message; + QDataStream ds(&message, QIODevice::WriteOnly); + ds << QByteArray("WATCH_OBJECT") << queryId << object.debugId(); + d->client->sendMessage(message); + } else { + watch->m_state = QDeclarativeDebugWatch::Dead; + } + + return watch; +} + +QDeclarativeDebugWatch *QDeclarativeEngineDebug::addWatch(const QDeclarativeDebugFileReference &, QObject *) +{ + qWarning("QDeclarativeEngineDebug::addWatch(): Not implemented"); + return 0; +} + +void QDeclarativeEngineDebug::removeWatch(QDeclarativeDebugWatch *watch) +{ + Q_D(QDeclarativeEngineDebug); + + if (!watch || !watch->m_client) + return; + + watch->m_client = 0; + watch->setState(QDeclarativeDebugWatch::Inactive); + + d->watched.remove(watch->queryId()); + + if (d->client && d->client->status() == QDeclarativeDebugClient::Enabled) { + QByteArray message; + QDataStream ds(&message, QIODevice::WriteOnly); + ds << QByteArray("NO_WATCH") << watch->queryId(); + d->client->sendMessage(message); + } +} + +QDeclarativeDebugEnginesQuery *QDeclarativeEngineDebug::queryAvailableEngines(QObject *parent) +{ + Q_D(QDeclarativeEngineDebug); + + QDeclarativeDebugEnginesQuery *query = new QDeclarativeDebugEnginesQuery(parent); + if (d->client->status() == QDeclarativeDebugClient::Enabled) { + query->m_client = this; + int queryId = d->getId(); + query->m_queryId = queryId; + d->enginesQuery.insert(queryId, query); + + QByteArray message; + QDataStream ds(&message, QIODevice::WriteOnly); + ds << QByteArray("LIST_ENGINES") << queryId; + d->client->sendMessage(message); + } else { + query->m_state = QDeclarativeDebugQuery::Error; + } + + return query; +} + +QDeclarativeDebugRootContextQuery *QDeclarativeEngineDebug::queryRootContexts(const QDeclarativeDebugEngineReference &engine, QObject *parent) +{ + Q_D(QDeclarativeEngineDebug); + + QDeclarativeDebugRootContextQuery *query = new QDeclarativeDebugRootContextQuery(parent); + if (d->client->status() == QDeclarativeDebugClient::Enabled && engine.debugId() != -1) { + query->m_client = this; + int queryId = d->getId(); + query->m_queryId = queryId; + d->rootContextQuery.insert(queryId, query); + + QByteArray message; + QDataStream ds(&message, QIODevice::WriteOnly); + ds << QByteArray("LIST_OBJECTS") << queryId << engine.debugId(); + d->client->sendMessage(message); + } else { + query->m_state = QDeclarativeDebugQuery::Error; + } + + return query; +} + +QDeclarativeDebugObjectQuery *QDeclarativeEngineDebug::queryObject(const QDeclarativeDebugObjectReference &object, QObject *parent) +{ + Q_D(QDeclarativeEngineDebug); + + QDeclarativeDebugObjectQuery *query = new QDeclarativeDebugObjectQuery(parent); + if (d->client->status() == QDeclarativeDebugClient::Enabled && object.debugId() != -1) { + query->m_client = this; + int queryId = d->getId(); + query->m_queryId = queryId; + d->objectQuery.insert(queryId, query); + + QByteArray message; + QDataStream ds(&message, QIODevice::WriteOnly); + ds << QByteArray("FETCH_OBJECT") << queryId << object.debugId() + << false << true; + d->client->sendMessage(message); + } else { + query->m_state = QDeclarativeDebugQuery::Error; + } + + return query; +} + +QDeclarativeDebugObjectQuery *QDeclarativeEngineDebug::queryObjectRecursive(const QDeclarativeDebugObjectReference &object, QObject *parent) +{ + Q_D(QDeclarativeEngineDebug); + + QDeclarativeDebugObjectQuery *query = new QDeclarativeDebugObjectQuery(parent); + if (d->client->status() == QDeclarativeDebugClient::Enabled && object.debugId() != -1) { + query->m_client = this; + int queryId = d->getId(); + query->m_queryId = queryId; + d->objectQuery.insert(queryId, query); + + QByteArray message; + QDataStream ds(&message, QIODevice::WriteOnly); + ds << QByteArray("FETCH_OBJECT") << queryId << object.debugId() + << true << true; + d->client->sendMessage(message); + } else { + query->m_state = QDeclarativeDebugQuery::Error; + } + + return query; +} + +QDeclarativeDebugExpressionQuery *QDeclarativeEngineDebug::queryExpressionResult(int objectDebugId, const QString &expr, QObject *parent) +{ + Q_D(QDeclarativeEngineDebug); + + QDeclarativeDebugExpressionQuery *query = new QDeclarativeDebugExpressionQuery(parent); + if (d->client->status() == QDeclarativeDebugClient::Enabled && objectDebugId != -1) { + query->m_client = this; + query->m_expr = expr; + int queryId = d->getId(); + query->m_queryId = queryId; + d->expressionQuery.insert(queryId, query); + + QByteArray message; + QDataStream ds(&message, QIODevice::WriteOnly); + ds << QByteArray("EVAL_EXPRESSION") << queryId << objectDebugId << expr; + d->client->sendMessage(message); + } else { + query->m_state = QDeclarativeDebugQuery::Error; + } + + return query; +} + +bool QDeclarativeEngineDebug::setBindingForObject(int objectDebugId, const QString &propertyName, + const QVariant &bindingExpression, + bool isLiteralValue, + QString source, int line) +{ + Q_D(QDeclarativeEngineDebug); + + if (d->client->status() == QDeclarativeDebugClient::Enabled && objectDebugId != -1) { + QByteArray message; + QDataStream ds(&message, QIODevice::WriteOnly); + ds << QByteArray("SET_BINDING") << objectDebugId << propertyName << bindingExpression << isLiteralValue << source << line; + d->client->sendMessage(message); + return true; + } else { + return false; + } +} + +bool QDeclarativeEngineDebug::resetBindingForObject(int objectDebugId, const QString &propertyName) +{ + Q_D(QDeclarativeEngineDebug); + + if (d->client->status() == QDeclarativeDebugClient::Enabled && objectDebugId != -1) { + QByteArray message; + QDataStream ds(&message, QIODevice::WriteOnly); + ds << QByteArray("RESET_BINDING") << objectDebugId << propertyName; + d->client->sendMessage(message); + return true; + } else { + return false; + } +} + +bool QDeclarativeEngineDebug::setMethodBody(int objectDebugId, const QString &methodName, + const QString &methodBody) +{ + Q_D(QDeclarativeEngineDebug); + + if (d->client->status() == QDeclarativeDebugClient::Enabled && objectDebugId != -1) { + QByteArray message; + QDataStream ds(&message, QIODevice::WriteOnly); + ds << QByteArray("SET_METHOD_BODY") << objectDebugId << methodName << methodBody; + d->client->sendMessage(message); + return true; + } else { + return false; + } +} + +QDeclarativeDebugWatch::QDeclarativeDebugWatch(QObject *parent) +: QObject(parent), m_state(Waiting), m_queryId(-1), m_client(0), m_objectDebugId(-1) +{ +} + +QDeclarativeDebugWatch::~QDeclarativeDebugWatch() +{ + if (m_client && m_queryId != -1) + QDeclarativeEngineDebugPrivate::remove(m_client, this); +} + +int QDeclarativeDebugWatch::queryId() const +{ + return m_queryId; +} + +int QDeclarativeDebugWatch::objectDebugId() const +{ + return m_objectDebugId; +} + +QDeclarativeDebugWatch::State QDeclarativeDebugWatch::state() const +{ + return m_state; +} + +void QDeclarativeDebugWatch::setState(State s) +{ + if (m_state == s) + return; + m_state = s; + emit stateChanged(m_state); +} + +QDeclarativeDebugPropertyWatch::QDeclarativeDebugPropertyWatch(QObject *parent) + : QDeclarativeDebugWatch(parent) +{ +} + +QString QDeclarativeDebugPropertyWatch::name() const +{ + return m_name; +} + + +QDeclarativeDebugObjectExpressionWatch::QDeclarativeDebugObjectExpressionWatch(QObject *parent) + : QDeclarativeDebugWatch(parent) +{ +} + +QString QDeclarativeDebugObjectExpressionWatch::expression() const +{ + return m_expr; +} + + +QDeclarativeDebugQuery::QDeclarativeDebugQuery(QObject *parent) +: QObject(parent), m_state(Waiting) +{ +} + +QDeclarativeDebugQuery::State QDeclarativeDebugQuery::state() const +{ + return m_state; +} + +bool QDeclarativeDebugQuery::isWaiting() const +{ + return m_state == Waiting; +} + +void QDeclarativeDebugQuery::setState(State s) +{ + if (m_state == s) + return; + m_state = s; + emit stateChanged(m_state); +} + +QDeclarativeDebugEnginesQuery::QDeclarativeDebugEnginesQuery(QObject *parent) +: QDeclarativeDebugQuery(parent), m_client(0), m_queryId(-1) +{ +} + +QDeclarativeDebugEnginesQuery::~QDeclarativeDebugEnginesQuery() +{ + if (m_client && m_queryId != -1) + QDeclarativeEngineDebugPrivate::remove(m_client, this); +} + +QList QDeclarativeDebugEnginesQuery::engines() const +{ + return m_engines; +} + +QDeclarativeDebugRootContextQuery::QDeclarativeDebugRootContextQuery(QObject *parent) +: QDeclarativeDebugQuery(parent), m_client(0), m_queryId(-1) +{ +} + +QDeclarativeDebugRootContextQuery::~QDeclarativeDebugRootContextQuery() +{ + if (m_client && m_queryId != -1) + QDeclarativeEngineDebugPrivate::remove(m_client, this); +} + +QDeclarativeDebugContextReference QDeclarativeDebugRootContextQuery::rootContext() const +{ + return m_context; +} + +QDeclarativeDebugObjectQuery::QDeclarativeDebugObjectQuery(QObject *parent) +: QDeclarativeDebugQuery(parent), m_client(0), m_queryId(-1) +{ +} + +QDeclarativeDebugObjectQuery::~QDeclarativeDebugObjectQuery() +{ + if (m_client && m_queryId != -1) + QDeclarativeEngineDebugPrivate::remove(m_client, this); +} + +QDeclarativeDebugObjectReference QDeclarativeDebugObjectQuery::object() const +{ + return m_object; +} + +QDeclarativeDebugExpressionQuery::QDeclarativeDebugExpressionQuery(QObject *parent) +: QDeclarativeDebugQuery(parent), m_client(0), m_queryId(-1) +{ +} + +QDeclarativeDebugExpressionQuery::~QDeclarativeDebugExpressionQuery() +{ + if (m_client && m_queryId != -1) + QDeclarativeEngineDebugPrivate::remove(m_client, this); +} + +QVariant QDeclarativeDebugExpressionQuery::expression() const +{ + return m_expr; +} + +QVariant QDeclarativeDebugExpressionQuery::result() const +{ + return m_result; +} + +QDeclarativeDebugEngineReference::QDeclarativeDebugEngineReference() +: m_debugId(-1) +{ +} + +QDeclarativeDebugEngineReference::QDeclarativeDebugEngineReference(int debugId) +: m_debugId(debugId) +{ +} + +QDeclarativeDebugEngineReference::QDeclarativeDebugEngineReference(const QDeclarativeDebugEngineReference &o) +: m_debugId(o.m_debugId), m_name(o.m_name) +{ +} + +QDeclarativeDebugEngineReference & +QDeclarativeDebugEngineReference::operator=(const QDeclarativeDebugEngineReference &o) +{ + m_debugId = o.m_debugId; m_name = o.m_name; + return *this; +} + +int QDeclarativeDebugEngineReference::debugId() const +{ + return m_debugId; +} + +QString QDeclarativeDebugEngineReference::name() const +{ + return m_name; +} + +QDeclarativeDebugObjectReference::QDeclarativeDebugObjectReference() +: m_debugId(-1), m_contextDebugId(-1) +{ +} + +QDeclarativeDebugObjectReference::QDeclarativeDebugObjectReference(int debugId) +: m_debugId(debugId), m_contextDebugId(-1) +{ +} + +QDeclarativeDebugObjectReference::QDeclarativeDebugObjectReference(const QDeclarativeDebugObjectReference &o) +: m_debugId(o.m_debugId), m_class(o.m_class), m_idString(o.m_idString), + m_name(o.m_name), m_source(o.m_source), m_contextDebugId(o.m_contextDebugId), + m_properties(o.m_properties), m_children(o.m_children) +{ +} + +QDeclarativeDebugObjectReference & +QDeclarativeDebugObjectReference::operator=(const QDeclarativeDebugObjectReference &o) +{ + m_debugId = o.m_debugId; m_class = o.m_class; m_idString = o.m_idString; + m_name = o.m_name; m_source = o.m_source; m_contextDebugId = o.m_contextDebugId; + m_properties = o.m_properties; m_children = o.m_children; + return *this; +} + +int QDeclarativeDebugObjectReference::debugId() const +{ + return m_debugId; +} + +QString QDeclarativeDebugObjectReference::className() const +{ + return m_class; +} + +QString QDeclarativeDebugObjectReference::idString() const +{ + return m_idString; +} + +QString QDeclarativeDebugObjectReference::name() const +{ + return m_name; +} + +QDeclarativeDebugFileReference QDeclarativeDebugObjectReference::source() const +{ + return m_source; +} + +int QDeclarativeDebugObjectReference::contextDebugId() const +{ + return m_contextDebugId; +} + +QList QDeclarativeDebugObjectReference::properties() const +{ + return m_properties; +} + +QList QDeclarativeDebugObjectReference::children() const +{ + return m_children; +} + +QDeclarativeDebugContextReference::QDeclarativeDebugContextReference() +: m_debugId(-1) +{ +} + +QDeclarativeDebugContextReference::QDeclarativeDebugContextReference(const QDeclarativeDebugContextReference &o) +: m_debugId(o.m_debugId), m_name(o.m_name), m_objects(o.m_objects), m_contexts(o.m_contexts) +{ +} + +QDeclarativeDebugContextReference &QDeclarativeDebugContextReference::operator=(const QDeclarativeDebugContextReference &o) +{ + m_debugId = o.m_debugId; m_name = o.m_name; m_objects = o.m_objects; + m_contexts = o.m_contexts; + return *this; +} + +int QDeclarativeDebugContextReference::debugId() const +{ + return m_debugId; +} + +QString QDeclarativeDebugContextReference::name() const +{ + return m_name; +} + +QList QDeclarativeDebugContextReference::objects() const +{ + return m_objects; +} + +QList QDeclarativeDebugContextReference::contexts() const +{ + return m_contexts; +} + +QDeclarativeDebugFileReference::QDeclarativeDebugFileReference() +: m_lineNumber(-1), m_columnNumber(-1) +{ +} + +QDeclarativeDebugFileReference::QDeclarativeDebugFileReference(const QDeclarativeDebugFileReference &o) +: m_url(o.m_url), m_lineNumber(o.m_lineNumber), m_columnNumber(o.m_columnNumber) +{ +} + +QDeclarativeDebugFileReference &QDeclarativeDebugFileReference::operator=(const QDeclarativeDebugFileReference &o) +{ + m_url = o.m_url; m_lineNumber = o.m_lineNumber; m_columnNumber = o.m_columnNumber; + return *this; +} + +QUrl QDeclarativeDebugFileReference::url() const +{ + return m_url; +} + +void QDeclarativeDebugFileReference::setUrl(const QUrl &u) +{ + m_url = u; +} + +int QDeclarativeDebugFileReference::lineNumber() const +{ + return m_lineNumber; +} + +void QDeclarativeDebugFileReference::setLineNumber(int l) +{ + m_lineNumber = l; +} + +int QDeclarativeDebugFileReference::columnNumber() const +{ + return m_columnNumber; +} + +void QDeclarativeDebugFileReference::setColumnNumber(int c) +{ + m_columnNumber = c; +} + +QDeclarativeDebugPropertyReference::QDeclarativeDebugPropertyReference() +: m_objectDebugId(-1), m_hasNotifySignal(false) +{ +} + +QDeclarativeDebugPropertyReference::QDeclarativeDebugPropertyReference(const QDeclarativeDebugPropertyReference &o) +: m_objectDebugId(o.m_objectDebugId), m_name(o.m_name), m_value(o.m_value), + m_valueTypeName(o.m_valueTypeName), m_binding(o.m_binding), + m_hasNotifySignal(o.m_hasNotifySignal) +{ +} + +QDeclarativeDebugPropertyReference &QDeclarativeDebugPropertyReference::operator=(const QDeclarativeDebugPropertyReference &o) +{ + m_objectDebugId = o.m_objectDebugId; m_name = o.m_name; m_value = o.m_value; + m_valueTypeName = o.m_valueTypeName; m_binding = o.m_binding; + m_hasNotifySignal = o.m_hasNotifySignal; + return *this; +} + +int QDeclarativeDebugPropertyReference::objectDebugId() const +{ + return m_objectDebugId; +} + +QString QDeclarativeDebugPropertyReference::name() const +{ + return m_name; +} + +QString QDeclarativeDebugPropertyReference::valueTypeName() const +{ + return m_valueTypeName; +} + +QVariant QDeclarativeDebugPropertyReference::value() const +{ + return m_value; +} + +QString QDeclarativeDebugPropertyReference::binding() const +{ + return m_binding; +} + +bool QDeclarativeDebugPropertyReference::hasNotifySignal() const +{ + return m_hasNotifySignal; +} + +QT_END_NAMESPACE + diff --git a/src/declarative/debugger/qdeclarativeenginedebug_p.h b/src/declarative/debugger/qdeclarativeenginedebug_p.h new file mode 100644 index 0000000..9b70e1c --- /dev/null +++ b/src/declarative/debugger/qdeclarativeenginedebug_p.h @@ -0,0 +1,387 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef QDECLARATIVEENGINEDEBUG_H +#define QDECLARATIVEENGINEDEBUG_H + +#include +#include +#include + +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Declarative) + +class QDeclarativeDebugConnection; +class QDeclarativeDebugWatch; +class QDeclarativeDebugPropertyWatch; +class QDeclarativeDebugObjectExpressionWatch; +class QDeclarativeDebugEnginesQuery; +class QDeclarativeDebugRootContextQuery; +class QDeclarativeDebugObjectQuery; +class QDeclarativeDebugExpressionQuery; +class QDeclarativeDebugPropertyReference; +class QDeclarativeDebugContextReference; +class QDeclarativeDebugObjectReference; +class QDeclarativeDebugFileReference; +class QDeclarativeDebugEngineReference; +class QDeclarativeEngineDebugPrivate; +class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeEngineDebug : public QObject +{ +Q_OBJECT +public: + enum Status { NotConnected, Unavailable, Enabled }; + + explicit QDeclarativeEngineDebug(QDeclarativeDebugConnection *, QObject * = 0); + + Status status() const; + + QDeclarativeDebugPropertyWatch *addWatch(const QDeclarativeDebugPropertyReference &, + QObject *parent = 0); + QDeclarativeDebugWatch *addWatch(const QDeclarativeDebugContextReference &, const QString &, + QObject *parent = 0); + QDeclarativeDebugObjectExpressionWatch *addWatch(const QDeclarativeDebugObjectReference &, const QString &, + QObject *parent = 0); + QDeclarativeDebugWatch *addWatch(const QDeclarativeDebugObjectReference &, + QObject *parent = 0); + QDeclarativeDebugWatch *addWatch(const QDeclarativeDebugFileReference &, + QObject *parent = 0); + + void removeWatch(QDeclarativeDebugWatch *watch); + + QDeclarativeDebugEnginesQuery *queryAvailableEngines(QObject *parent = 0); + QDeclarativeDebugRootContextQuery *queryRootContexts(const QDeclarativeDebugEngineReference &, + QObject *parent = 0); + QDeclarativeDebugObjectQuery *queryObject(const QDeclarativeDebugObjectReference &, + QObject *parent = 0); + QDeclarativeDebugObjectQuery *queryObjectRecursive(const QDeclarativeDebugObjectReference &, + QObject *parent = 0); + QDeclarativeDebugExpressionQuery *queryExpressionResult(int objectDebugId, + const QString &expr, + QObject *parent = 0); + bool setBindingForObject(int objectDebugId, const QString &propertyName, + const QVariant &bindingExpression, bool isLiteralValue, + QString source = QString(), int line = -1); + bool resetBindingForObject(int objectDebugId, const QString &propertyName); + bool setMethodBody(int objectDebugId, const QString &methodName, const QString &methodBody); + +Q_SIGNALS: + void newObjects(); + void statusChanged(Status status); + +private: + Q_DECLARE_PRIVATE(QDeclarativeEngineDebug) +}; + +class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugWatch : public QObject +{ +Q_OBJECT +public: + enum State { Waiting, Active, Inactive, Dead }; + + QDeclarativeDebugWatch(QObject *); + ~QDeclarativeDebugWatch(); + + int queryId() const; + int objectDebugId() const; + State state() const; + +Q_SIGNALS: + void stateChanged(QDeclarativeDebugWatch::State); + //void objectChanged(int, const QDeclarativeDebugObjectReference &); + //void valueChanged(int, const QVariant &); + + // Server sends value as string if it is a user-type variant + void valueChanged(const QByteArray &name, const QVariant &value); + +private: + friend class QDeclarativeEngineDebug; + friend class QDeclarativeEngineDebugPrivate; + void setState(State); + State m_state; + int m_queryId; + QDeclarativeEngineDebug *m_client; + int m_objectDebugId; +}; + +class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugPropertyWatch : public QDeclarativeDebugWatch +{ + Q_OBJECT +public: + QDeclarativeDebugPropertyWatch(QObject *parent); + + QString name() const; + +private: + friend class QDeclarativeEngineDebug; + QString m_name; +}; + +class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugObjectExpressionWatch : public QDeclarativeDebugWatch +{ + Q_OBJECT +public: + QDeclarativeDebugObjectExpressionWatch(QObject *parent); + + QString expression() const; + +private: + friend class QDeclarativeEngineDebug; + QString m_expr; + int m_debugId; +}; + + +class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugQuery : public QObject +{ +Q_OBJECT +public: + enum State { Waiting, Error, Completed }; + + State state() const; + bool isWaiting() const; + +// bool waitUntilCompleted(); + +Q_SIGNALS: + void stateChanged(QDeclarativeDebugQuery::State); + +protected: + QDeclarativeDebugQuery(QObject *); + +private: + friend class QDeclarativeEngineDebug; + friend class QDeclarativeEngineDebugPrivate; + void setState(State); + State m_state; +}; + +class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugFileReference +{ +public: + QDeclarativeDebugFileReference(); + QDeclarativeDebugFileReference(const QDeclarativeDebugFileReference &); + QDeclarativeDebugFileReference &operator=(const QDeclarativeDebugFileReference &); + + QUrl url() const; + void setUrl(const QUrl &); + int lineNumber() const; + void setLineNumber(int); + int columnNumber() const; + void setColumnNumber(int); + +private: + friend class QDeclarativeEngineDebugPrivate; + QUrl m_url; + int m_lineNumber; + int m_columnNumber; +}; + +class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugEngineReference +{ +public: + QDeclarativeDebugEngineReference(); + QDeclarativeDebugEngineReference(int); + QDeclarativeDebugEngineReference(const QDeclarativeDebugEngineReference &); + QDeclarativeDebugEngineReference &operator=(const QDeclarativeDebugEngineReference &); + + int debugId() const; + QString name() const; + +private: + friend class QDeclarativeEngineDebugPrivate; + int m_debugId; + QString m_name; +}; + +class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugObjectReference +{ +public: + QDeclarativeDebugObjectReference(); + QDeclarativeDebugObjectReference(int); + QDeclarativeDebugObjectReference(const QDeclarativeDebugObjectReference &); + QDeclarativeDebugObjectReference &operator=(const QDeclarativeDebugObjectReference &); + + int debugId() const; + QString className() const; + QString idString() const; + QString name() const; + + QDeclarativeDebugFileReference source() const; + int contextDebugId() const; + + QList properties() const; + QList children() const; + +private: + friend class QDeclarativeEngineDebugPrivate; + int m_debugId; + QString m_class; + QString m_idString; + QString m_name; + QDeclarativeDebugFileReference m_source; + int m_contextDebugId; + QList m_properties; + QList m_children; +}; + +class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugContextReference +{ +public: + QDeclarativeDebugContextReference(); + QDeclarativeDebugContextReference(const QDeclarativeDebugContextReference &); + QDeclarativeDebugContextReference &operator=(const QDeclarativeDebugContextReference &); + + int debugId() const; + QString name() const; + + QList objects() const; + QList contexts() const; + +private: + friend class QDeclarativeEngineDebugPrivate; + int m_debugId; + QString m_name; + QList m_objects; + QList m_contexts; +}; + +class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugPropertyReference +{ +public: + QDeclarativeDebugPropertyReference(); + QDeclarativeDebugPropertyReference(const QDeclarativeDebugPropertyReference &); + QDeclarativeDebugPropertyReference &operator=(const QDeclarativeDebugPropertyReference &); + + int objectDebugId() const; + QString name() const; + QVariant value() const; + QString valueTypeName() const; + QString binding() const; + bool hasNotifySignal() const; + +private: + friend class QDeclarativeEngineDebugPrivate; + int m_objectDebugId; + QString m_name; + QVariant m_value; + QString m_valueTypeName; + QString m_binding; + bool m_hasNotifySignal; +}; + + +class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugEnginesQuery : public QDeclarativeDebugQuery +{ +Q_OBJECT +public: + virtual ~QDeclarativeDebugEnginesQuery(); + QList engines() const; +private: + friend class QDeclarativeEngineDebug; + friend class QDeclarativeEngineDebugPrivate; + QDeclarativeDebugEnginesQuery(QObject *); + QDeclarativeEngineDebug *m_client; + int m_queryId; + QList m_engines; +}; + +class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugRootContextQuery : public QDeclarativeDebugQuery +{ +Q_OBJECT +public: + virtual ~QDeclarativeDebugRootContextQuery(); + QDeclarativeDebugContextReference rootContext() const; +private: + friend class QDeclarativeEngineDebug; + friend class QDeclarativeEngineDebugPrivate; + QDeclarativeDebugRootContextQuery(QObject *); + QDeclarativeEngineDebug *m_client; + int m_queryId; + QDeclarativeDebugContextReference m_context; +}; + +class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugObjectQuery : public QDeclarativeDebugQuery +{ +Q_OBJECT +public: + virtual ~QDeclarativeDebugObjectQuery(); + QDeclarativeDebugObjectReference object() const; +private: + friend class QDeclarativeEngineDebug; + friend class QDeclarativeEngineDebugPrivate; + QDeclarativeDebugObjectQuery(QObject *); + QDeclarativeEngineDebug *m_client; + int m_queryId; + QDeclarativeDebugObjectReference m_object; + +}; + +class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugExpressionQuery : public QDeclarativeDebugQuery +{ +Q_OBJECT +public: + virtual ~QDeclarativeDebugExpressionQuery(); + QVariant expression() const; + QVariant result() const; +private: + friend class QDeclarativeEngineDebug; + friend class QDeclarativeEngineDebugPrivate; + QDeclarativeDebugExpressionQuery(QObject *); + QDeclarativeEngineDebug *m_client; + int m_queryId; + QVariant m_expr; + QVariant m_result; +}; + +QT_END_NAMESPACE + +Q_DECLARE_METATYPE(QDeclarativeDebugEngineReference) +Q_DECLARE_METATYPE(QDeclarativeDebugObjectReference) +Q_DECLARE_METATYPE(QDeclarativeDebugContextReference) +Q_DECLARE_METATYPE(QDeclarativeDebugPropertyReference) + +QT_END_HEADER + +#endif // QDECLARATIVEENGINEDEBUG_H diff --git a/tests/auto/declarative/qdeclarativedebug/tst_qdeclarativedebug.cpp b/tests/auto/declarative/qdeclarativedebug/tst_qdeclarativedebug.cpp index 0821245..be9b402 100644 --- a/tests/auto/declarative/qdeclarativedebug/tst_qdeclarativedebug.cpp +++ b/tests/auto/declarative/qdeclarativedebug/tst_qdeclarativedebug.cpp @@ -52,7 +52,7 @@ #include #include -#include +#include #include #include #include diff --git a/tests/auto/declarative/qdeclarativedebugclient/tst_qdeclarativedebugclient.cpp b/tests/auto/declarative/qdeclarativedebugclient/tst_qdeclarativedebugclient.cpp index 0d371d0..4846d67 100644 --- a/tests/auto/declarative/qdeclarativedebugclient/tst_qdeclarativedebugclient.cpp +++ b/tests/auto/declarative/qdeclarativedebugclient/tst_qdeclarativedebugclient.cpp @@ -47,9 +47,7 @@ #include -#include #include -#include #include "../../../shared/util.h" #include "../shared/debugutil_p.h" diff --git a/tests/auto/declarative/qdeclarativedebugservice/tst_qdeclarativedebugservice.cpp b/tests/auto/declarative/qdeclarativedebugservice/tst_qdeclarativedebugservice.cpp index 1ca3b8f..85d459b 100644 --- a/tests/auto/declarative/qdeclarativedebugservice/tst_qdeclarativedebugservice.cpp +++ b/tests/auto/declarative/qdeclarativedebugservice/tst_qdeclarativedebugservice.cpp @@ -47,7 +47,6 @@ #include -#include #include #include -- cgit v0.12 From 8ba781b01e900148fec2e9d26485369b3295487f Mon Sep 17 00:00:00 2001 From: Jocelyn Turcotte Date: Wed, 14 Sep 2011 16:12:10 +0200 Subject: Remove support for multiple cookies in one Set-Cookie header to follow RFC6265. This also allows cookie values to contain commas to increase compatibility like most popular browsers do even though the RFC still reserves them for future uses. Reviewed-by: Peter Hartmann Task-number: QTBUG-21456 --- dist/changes-4.8.0 | 1 + src/network/access/qnetworkcookie.cpp | 18 +++----- tests/auto/qnetworkcookie/tst_qnetworkcookie.cpp | 54 +++++++----------------- 3 files changed, 21 insertions(+), 52 deletions(-) diff --git a/dist/changes-4.8.0 b/dist/changes-4.8.0 index b8e3842..e208fa1 100644 --- a/dist/changes-4.8.0 +++ b/dist/changes-4.8.0 @@ -105,6 +105,7 @@ QtNetwork - HTTP cache: do not load resources from cache that must be revalidated [QTBUG-18983] - HTTP cache: change file organization (MR-2505) - SOCKS5: write errors are propagated to the outer socket [QTBUG-18713] + - Cookies: Commas are no longer used to support multiple cookies in a single Set-Cookie header [QTBUG-21456] QtOpenGL -------- diff --git a/src/network/access/qnetworkcookie.cpp b/src/network/access/qnetworkcookie.cpp index 0670738..a9bb318 100644 --- a/src/network/access/qnetworkcookie.cpp +++ b/src/network/access/qnetworkcookie.cpp @@ -372,7 +372,7 @@ static QPair nextField(const QByteArray &text, int &posi // parse the first part, before the equal sign for (i = position; i < length; ++i) { register char c = text.at(i); - if (c == ';' || c == ',' || c == '=') + if (c == ';' || c == '=') break; } @@ -423,7 +423,7 @@ static QPair nextField(const QByteArray &text, int &posi for ( ; i < length; ++i) { register char c = text.at(i); - if (c == ',' || c == ';') + if (c == ';') break; } position = i; @@ -434,7 +434,7 @@ static QPair nextField(const QByteArray &text, int &posi register char c = text.at(i); // for name value pairs, we want to parse until reaching the next ';' // and not break when reaching a space char - if (c == ',' || c == ';' || ((isNameValue && (c == '\n' || c == '\r')) || (!isNameValue && isLWS(c)))) + if (c == ';' || ((isNameValue && (c == '\n' || c == '\r')) || (!isNameValue && isLWS(c)))) break; } @@ -461,8 +461,7 @@ static QPair nextField(const QByteArray &text, int &posi \value Full makes toRawForm() return the full cookie contents, as suitable for sending to a client in a - server's "Set-Cookie:" header. Multiple cookies are separated - by commas in a "Set-Cookie:" header. + server's "Set-Cookie:" header. Note that only the Full form of the cookie can be parsed back into its original contents. @@ -488,7 +487,6 @@ QByteArray QNetworkCookie::toRawForm(RawForm form) const result = d->name; result += '='; if ((d->value.contains(';') || - d->value.contains(',') || d->value.contains('"')) && (!d->value.startsWith('"') && !d->value.endsWith('"'))) { @@ -967,14 +965,8 @@ QList QNetworkCookiePrivate::parseSetCookieHeaderLine(const QByt cookie.setValue(field.second); position = nextNonWhitespace(cookieString, position); - bool endOfCookie = false; - while (!endOfCookie && position < length) { + while (position < length) { switch (cookieString.at(position++)) { - case ',': - // end of the cookie - endOfCookie = true; - break; - case ';': // new field in the cookie field = nextField(cookieString, position, false); diff --git a/tests/auto/qnetworkcookie/tst_qnetworkcookie.cpp b/tests/auto/qnetworkcookie/tst_qnetworkcookie.cpp index a83f6dd..e4c88cd 100644 --- a/tests/auto/qnetworkcookie/tst_qnetworkcookie.cpp +++ b/tests/auto/qnetworkcookie/tst_qnetworkcookie.cpp @@ -181,6 +181,14 @@ void tst_QNetworkCookie::parseSingleCookie_data() QTest::newRow("with-value-with-special4") << "a = \"\\\"\" " << cookie; cookie.setValue("\"\\\"a, b; c\\\"\""); QTest::newRow("with-value-with-special5") << "a = \"\\\"a, b; c\\\"\"" << cookie; + // RFC6265 states that cookie values shouldn't contain commas, but we still allow them + // since they are only reserved for future compatibility and other browsers do the same. + cookie.setValue(","); + QTest::newRow("with-value-with-special6") << "a = ," << cookie; + cookie.setValue(",b"); + QTest::newRow("with-value-with-special7") << "a = ,b" << cookie; + cookie.setValue("b,"); + QTest::newRow("with-value-with-special8") << "a = b," << cookie; cookie.setValue("b c"); QTest::newRow("with-value-with-whitespace") << "a = b c" << cookie; @@ -599,7 +607,6 @@ void tst_QNetworkCookie::parseSingleCookie() //QEXPECT_FAIL("network2", "QDateTime parsing problem: the date is beyond year 8000", Abort); QCOMPARE(result.count(), 1); - QEXPECT_FAIL("network3", "Cookie value contains commas, violating the HTTP spec", Abort); QCOMPARE(result.at(0), expectedCookie); result = QNetworkCookie::parseCookies(result.at(0).toRawForm()); @@ -634,48 +641,17 @@ void tst_QNetworkCookie::parseMultipleCookies_data() // reason: malformed NAME=VALUE pair QTest::newRow("invalid-05") << "foo" << list; QTest::newRow("invalid-06") << "=b" << list; - QTest::newRow("invalid-09") << "foo,a=b" << list; - QTest::newRow("invalid-11") << ";path=/" << list; + QTest::newRow("invalid-07") << ";path=/" << list; // reason: malformed expiration date string - QTest::newRow("invalid-12") << "a=b;expires=" << list; - QTest::newRow("invalid-13") << "a=b;expires=foobar" << list; - QTest::newRow("invalid-14") << "a=b;expires=foobar, abc" << list; - QTest::newRow("invalid-15") << "a=b;expires=foobar, dd-mmm-yyyy hh:mm:ss GMT; path=/" << list; - QTest::newRow("invalid-16") << "a=b;expires=foobar, 32-Caz-1999 24:01:60 GMT; path=/" << list; - - QNetworkCookie cookie; - cookie.setName("a"); - list += cookie; - cookie.setName("c"); - cookie.setValue("d"); - list += cookie; - QTest::newRow("two-1") << "a=,c=d" << list; - QTest::newRow("two-2") << "a=, c=d" << list; - QTest::newRow("two-3") << "a= ,c=d" << list; - QTest::newRow("two-4") << "a= , c=d" << list; - - list.clear(); - list += cookie; - cookie.setName("a"); - cookie.setValue(QByteArray()); - list += cookie; - QTest::newRow("two-5") << "c=d,a=" << list; - QTest::newRow("two-6") << "c=d, a=" << list; - QTest::newRow("two-7") << "c=d , a=" << list; - - cookie.setName("foo"); - cookie.setValue("bar"); - cookie.setPath("/"); - list += cookie; - QTest::newRow("complex-1") << "c=d, a=, foo=bar; path=/" << list; - - cookie.setName("baz"); - cookie.setDomain(".qt.nokia.com"); - list.prepend(cookie); - QTest::newRow("complex-2") << "baz=bar; path=/; domain=.qt.nokia.com, c=d,a=,foo=bar; path=/" << list; + QTest::newRow("invalid-08") << "a=b;expires=" << list; + QTest::newRow("invalid-09") << "a=b;expires=foobar" << list; + QTest::newRow("invalid-10") << "a=b;expires=foobar, abc" << list; + QTest::newRow("invalid-11") << "a=b;expires=foobar, dd-mmm-yyyy hh:mm:ss GMT; path=/" << list; + QTest::newRow("invalid-12") << "a=b;expires=foobar, 32-Caz-1999 24:01:60 GMT; path=/" << list; // cookies obtained from the network: + QNetworkCookie cookie; cookie = QNetworkCookie("id", "51706646077999719"); cookie.setDomain(".bluestreak.com"); cookie.setPath("/"); -- cgit v0.12 From 32e2ea24df71f3078b03598360aea76c0ebe1cba Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Mon, 19 Sep 2011 09:25:20 +0200 Subject: Debugger: Fix autotest breakage Fix compilation breakage caused by 160e1eed007f43a68ee03a6e8c0bfd2602a64ee0 Change-Id: I664a45454f247cf0bc85b09d8787443a75e62568 --- tests/auto/declarative/qdeclarativedebugjs/tst_qdeclarativedebugjs.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/auto/declarative/qdeclarativedebugjs/tst_qdeclarativedebugjs.cpp b/tests/auto/declarative/qdeclarativedebugjs/tst_qdeclarativedebugjs.cpp index f841272..bad7b8f 100644 --- a/tests/auto/declarative/qdeclarativedebugjs/tst_qdeclarativedebugjs.cpp +++ b/tests/auto/declarative/qdeclarativedebugjs/tst_qdeclarativedebugjs.cpp @@ -43,7 +43,6 @@ #include #include #include -#include #include #include #include -- cgit v0.12 From d04f37fa73d2fbb78dd85a02e9d3180ed4ddbdab Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Mon, 19 Sep 2011 14:34:04 +0100 Subject: symbian bearer: fix tst_qnetworksession test failures Symbian is not reporting the expected KLinkLayerClosed event on the last RConnection handle. Instead, it reports the event KConfigDaemonFinishedDeregistrationStop, which indicates the nif plugin is being destroyed (this is followed by unload events) To fix, this event is treated the same as a link down event, and results in the state change to disconnected. Either there has been a behaviour change in the platform, or the test was previously run with another user of the API running in the background (e.g. WLAN wizard, connection monitor) which prevented the unload. Task-Number: QTBUG-21382 Reviewed-By: mread (cherry picked from commit a0ad54acd33873316908080f432768fdf3e3bfc2) --- src/plugins/bearer/symbian/qnetworksession_impl.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/plugins/bearer/symbian/qnetworksession_impl.cpp b/src/plugins/bearer/symbian/qnetworksession_impl.cpp index 5514511..29f0637 100644 --- a/src/plugins/bearer/symbian/qnetworksession_impl.cpp +++ b/src/plugins/bearer/symbian/qnetworksession_impl.cpp @@ -1438,6 +1438,9 @@ void QNetworkSessionPrivateImpl::handleSymbianConnectionStatusChange(TInt aConne newState(QNetworkSession::Closing,accessPointId); break; + // Connection stopped + case KConfigDaemonFinishedDeregistrationStop: //this comes if this is the last session, instead of KLinkLayerClosed + case KConfigDaemonFinishedDeregistrationPreserve: // Connection closed case KConnectionClosed: case KLinkLayerClosed: -- cgit v0.12 From fa717293080c9d00b02028bebece1935aef6e093 Mon Sep 17 00:00:00 2001 From: aavit Date: Fri, 25 Mar 2011 13:50:41 +0100 Subject: Avoid runtime warning about interlace handling from libpng 1.5 Task-number: QTBUG-13298, QTBUG-21408 (cherry picked from commit c8851ce8e109fb6b403ae80036d9f319f1b69d7a) --- src/gui/image/qpnghandler.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gui/image/qpnghandler.cpp b/src/gui/image/qpnghandler.cpp index 7f5cbe8..c0cebf9 100644 --- a/src/gui/image/qpnghandler.cpp +++ b/src/gui/image/qpnghandler.cpp @@ -217,6 +217,7 @@ void setup_qt(QImage& image, png_structp png_ptr, png_infop info_ptr, float scre png_colorp palette = 0; int num_palette; png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, 0, 0, 0); + png_set_interlace_handling(png_ptr); if (color_type == PNG_COLOR_TYPE_GRAY) { // Black & White or 8-bit grayscale -- cgit v0.12 From 7147a0c0df5278dad3594c0d01599bd9424d946e Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Wed, 21 Sep 2011 11:48:39 +1000 Subject: Compile fix for Symbian --- src/declarative/qml/qdeclarativenotifier_p.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/declarative/qml/qdeclarativenotifier_p.h b/src/declarative/qml/qdeclarativenotifier_p.h index e46b843..dd0bee6 100644 --- a/src/declarative/qml/qdeclarativenotifier_p.h +++ b/src/declarative/qml/qdeclarativenotifier_p.h @@ -106,7 +106,7 @@ private: qint64 q_for_alignment_1; double q_for_alignment_2; }; - }; + } signal; Notifier notifier; }; @@ -251,15 +251,15 @@ QDeclarativeNotifierEndpoint::Signal *QDeclarativeNotifierEndpoint::toSignal() return asSignal(); disconnect(); - signal = new (&signalData) Signal; + signal.signal = new (&signal.signalData) Signal; type = SignalType; - return signal; + return signal.signal; } QDeclarativeNotifierEndpoint::Signal *QDeclarativeNotifierEndpoint::asSignal() { Q_ASSERT(type == SignalType); - return signal; + return signal.signal; } QT_END_NAMESPACE -- cgit v0.12 From 849694e4cb9d010517b54b2b30035485487b0e12 Mon Sep 17 00:00:00 2001 From: mread Date: Wed, 21 Sep 2011 11:35:14 +0100 Subject: QML import path puts Qt dirs in correct Symbian order The QML import path contains an entry for the standard import location on each drive on Symbian. These were being ordered so that Z:, the ROM drive, was listed first. In fact the drive order was the reverse of the normal Symbian drive search order. This had the effect that upgraded versions of QML imports installed on the device were generally ignored for older ROM based versions. The import path has now been changed to match the normal Symbian drive search order. This will make it more likely for upgraded QML imports to be picked up and used. Task-number: QTBUG-21409 Reviewed-by: Shane Kearns Reviewed-by: Martin Jones --- src/declarative/qml/qdeclarativeimport.cpp | 10 ++++++++- .../tst_qdeclarativemoduleplugin.cpp | 25 ++++++++++++++++++++++ .../tst_qdeclarativemoduleplugin.pro | 2 +- 3 files changed, 35 insertions(+), 2 deletions(-) diff --git a/src/declarative/qml/qdeclarativeimport.cpp b/src/declarative/qml/qdeclarativeimport.cpp index 6e0b348..c25207a 100644 --- a/src/declarative/qml/qdeclarativeimport.cpp +++ b/src/declarative/qml/qdeclarativeimport.cpp @@ -46,6 +46,7 @@ #include #include #include +#include #include #include #include @@ -733,8 +734,12 @@ QDeclarativeImportDatabase::QDeclarativeImportDatabase(QDeclarativeEngine *e) } RFs& fs = qt_s60GetRFs(); TPtrC tempPathPtr(reinterpret_cast (tempPath.constData())); + // Symbian searches should start from Y:. Fix start drive otherwise TFindFile starts from the session drive + _LIT(KStartDir, "Y:"); + TFileName dirPath(KStartDir); + dirPath.Append(tempPathPtr); TFindFile finder(fs); - TInt err = finder.FindByDir(tempPathPtr, tempPathPtr); + TInt err = finder.FindByDir(tempPathPtr, dirPath); while (err == KErrNone) { QString foundDir(reinterpret_cast(finder.File().Ptr()), finder.File().Length()); @@ -742,6 +747,9 @@ QDeclarativeImportDatabase::QDeclarativeImportDatabase(QDeclarativeEngine *e) addImportPath(foundDir); err = finder.Find(); } + // TFindFile found the directories in the order we want, but addImportPath reverses it. + // Reverse the order again to get it right. + QAlgorithmsPrivate::qReverse(fileImportPath.begin(), fileImportPath.end()); } else { addImportPath(installImportsPath); } diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.cpp b/tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.cpp index 2cc2971..96bea68 100644 --- a/tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.cpp +++ b/tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.cpp @@ -43,6 +43,7 @@ #include #include #include +#include #include "../shared/testhttpserver.h" #include "../../../shared/util.h" @@ -70,6 +71,7 @@ private slots: void remoteImportWithUnquotedUri(); void versionNotInstalled(); void versionNotInstalled_data(); + void importPath(); }; #ifdef Q_OS_SYMBIAN @@ -308,6 +310,29 @@ void tst_qdeclarativemoduleplugin::versionNotInstalled() VERIFY_ERRORS(errorFile.toLatin1().constData()); } +void tst_qdeclarativemoduleplugin::importPath() +{ +#ifndef Q_OS_SYMBIAN + QSKIP("Import path order testing for Symbian only", SkipAll); +#else + QDeclarativeEngine engine; + QStringList imports = engine.importPathList(); + QString installImportsPath = QDir::cleanPath(QLibraryInfo::location(QLibraryInfo::ImportsPath)); + QString driveOrder(QLatin1String("ZABCDEFGHIJKLMNOPQRSTUVWXY")); + int lastOrder = 30; + foreach(QString import, imports) + { + if (import.endsWith(installImportsPath)) + { + int order = driveOrder.indexOf(import[0]); + QVERIFY(order < lastOrder); + lastOrder = order; + } + } + QVERIFY(lastOrder != 30); +#endif +} + QTEST_MAIN(tst_qdeclarativemoduleplugin) #include "tst_qdeclarativemoduleplugin.moc" diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.pro b/tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.pro index a92d3a2..2716a8b 100644 --- a/tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.pro +++ b/tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.pro @@ -9,7 +9,7 @@ CONFIG -= app_bundle symbian: { importFiles.sources = data importFiles.path = . - DEPLOYMENT = importFiles + DEPLOYMENT += importFiles } else { DEFINES += SRCDIR=\\\"$$PWD\\\" } -- cgit v0.12 From c3669d24b498aa0661ade5ed7465260788f629b5 Mon Sep 17 00:00:00 2001 From: Sami Merila Date: Thu, 22 Sep 2011 11:23:23 +0300 Subject: QLineControl: selectedTextChanged() signal is omitted in some cases QLineControl does not emit selectionChanged() signal when selection is changed due to handling of input method query. As a fix, the signal is emitted when internal values for selection end and beginning are changed in processInputMethodEvent(). Additionally, added deselect() test case for both QDeclarativeTextEdit and QDeclarativeTextInput to help out autotesting of text selections. Note that there are some differences in the QLineControl and QTextControl implementations. This causes the different signal counts even if the test steps are similar. Task-number: QTBUG-21429 Reviewed-by: Miikka Heikkinen --- src/gui/widgets/qlinecontrol.cpp | 4 + .../tst_qdeclarativetextedit.cpp | 115 ++++++++++++++++++++ .../tst_qdeclarativetextinput.cpp | 117 ++++++++++++++++++++- 3 files changed, 235 insertions(+), 1 deletion(-) diff --git a/src/gui/widgets/qlinecontrol.cpp b/src/gui/widgets/qlinecontrol.cpp index 198bc04..c5232ad 100644 --- a/src/gui/widgets/qlinecontrol.cpp +++ b/src/gui/widgets/qlinecontrol.cpp @@ -447,6 +447,8 @@ void QLineControl::moveCursor(int pos, bool mark) void QLineControl::processInputMethodEvent(QInputMethodEvent *event) { int priorState = 0; + int originalSelectionStart = m_selstart; + int originalSelectionEnd = m_selend; bool isGettingInput = !event->commitString().isEmpty() || event->preeditString() != preeditAreaText() || event->replacementLength() > 0; @@ -525,6 +527,8 @@ void QLineControl::processInputMethodEvent(QInputMethodEvent *event) } m_textLayout.setAdditionalFormats(formats); updateDisplayText(/*force*/ true); + if (originalSelectionStart != m_selstart || originalSelectionEnd != m_selend) + emit selectionChanged(); if (cursorPositionChanged) emitCursorPositionChanged(); else if (m_preeditCursor != oldPreeditCursor) diff --git a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp index fde0588..b6df308 100644 --- a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp +++ b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp @@ -154,6 +154,7 @@ private slots: void inputContextMouseHandler(); void inputMethodComposing(); void cursorRectangleSize(); + void deselect(); private: void simulateKey(QDeclarativeView *, int key, Qt::KeyboardModifiers modifiers = 0); @@ -2655,6 +2656,120 @@ void tst_qdeclarativetextedit::cursorRectangleSize() QCOMPARE(microFocusFromScene.size(), cursorRect.size()); QCOMPARE(microFocusFromApp.size(), cursorRect.size()); } + +void tst_qdeclarativetextedit::deselect() +{ + QDeclarativeView *canvas = createView(SRCDIR "/data/CursorRect.qml"); + QVERIFY(canvas->rootObject() != 0); + canvas->show(); + canvas->setFocus(); + QApplication::setActiveWindow(canvas); + QTest::qWaitForWindowShown(canvas); + + QDeclarativeTextEdit *textEdit = qobject_cast(canvas->rootObject()); + QVERIFY(textEdit != 0); + + textEdit->setText("Select"); + + QSignalSpy selectionStartSpy(textEdit, SIGNAL(selectionStartChanged())); + QSignalSpy selectionEndSpy(textEdit, SIGNAL(selectionEndChanged())); + QSignalSpy selectionSpy(textEdit, SIGNAL(selectionChanged())); + + textEdit->select(5, 6); + + QCOMPARE(selectionStartSpy.count(), 1); + QCOMPARE(selectionEndSpy.count(), 1); + QCOMPARE(selectionSpy.count(), 1); + QCOMPARE(textEdit->selectionStart(), 5); + QCOMPARE(textEdit->selectionEnd(), 6); + QCOMPARE(textEdit->selectedText(), QLatin1String("t")); + QCOMPARE(textEdit->cursorPosition(), 6); + + textEdit->deselect(); + + QCOMPARE(selectionStartSpy.count(), 2); + QCOMPARE(selectionEndSpy.count(), 1); + QCOMPARE(selectionSpy.count(), 2); + QCOMPARE(textEdit->selectionStart(), textEdit->cursorPosition()); + QCOMPARE(textEdit->selectionEnd(), textEdit->cursorPosition()); + QCOMPARE(textEdit->selectedText(), QLatin1String("")); + QCOMPARE(textEdit->cursorPosition(), 6); + + textEdit->select(5, 6); + + QCOMPARE(selectionStartSpy.count(), 3); + QCOMPARE(selectionEndSpy.count(), 1); + QCOMPARE(selectionSpy.count(), 3); + QCOMPARE(textEdit->selectionStart(), 5); + QCOMPARE(textEdit->selectionEnd(), 6); + QCOMPARE(textEdit->selectedText(), QLatin1String("t")); + QCOMPARE(textEdit->cursorPosition(), 6); + + QKeyEvent leftArrowPress(QEvent::KeyPress, Qt::Key_Left, Qt::NoModifier); + QKeyEvent leftArrowRelese(QEvent::KeyRelease, Qt::Key_Left, Qt::NoModifier); + QApplication::sendEvent(canvas, &leftArrowPress); + QApplication::sendEvent(canvas, &leftArrowRelese); + + QCOMPARE(selectionStartSpy.count(), 3); + QCOMPARE(selectionEndSpy.count(), 2); + QCOMPARE(selectionSpy.count(), 4); + QCOMPARE(textEdit->selectionStart(), textEdit->cursorPosition()); + QCOMPARE(textEdit->selectionEnd(), textEdit->cursorPosition()); + QCOMPARE(textEdit->selectedText(), QLatin1String("")); + QCOMPARE(textEdit->cursorPosition(), 5); + + textEdit->select(5, 6); + + QCOMPARE(selectionStartSpy.count(), 3); + QCOMPARE(selectionEndSpy.count(), 3); + QCOMPARE(selectionSpy.count(), 5); + QCOMPARE(textEdit->selectionStart(), 5); + QCOMPARE(textEdit->selectionEnd(), 6); + QCOMPARE(textEdit->selectedText(), QLatin1String("t")); + QCOMPARE(textEdit->cursorPosition(), 6); + + QList attributes; + attributes << QInputMethodEvent::Attribute(QInputMethodEvent::Selection, 0, 0, QVariant()); + QInputMethodEvent event(QLatin1String(""), attributes); + QApplication::sendEvent(canvas, &event); + + QCOMPARE(selectionStartSpy.count(), 4); + QCOMPARE(selectionEndSpy.count(), 4); + QCOMPARE(selectionSpy.count(), 6); + QCOMPARE(textEdit->selectionStart(), textEdit->cursorPosition()); + QCOMPARE(textEdit->selectionEnd(), textEdit->cursorPosition()); + QCOMPARE(textEdit->selectedText(), QLatin1String("")); + QCOMPARE(textEdit->cursorPosition(), 0); + + textEdit->setCursorPosition(1); + + QCOMPARE(selectionStartSpy.count(), 5); + QCOMPARE(selectionEndSpy.count(), 5); + QCOMPARE(selectionSpy.count(), 6); + + QKeyEvent leftArrowShiftPress(QEvent::KeyPress, Qt::Key_Left, Qt::ShiftModifier); + QKeyEvent leftArrowShiftRelese(QEvent::KeyRelease, Qt::Key_Left, Qt::ShiftModifier); + QApplication::sendEvent(canvas, &leftArrowShiftPress); + QApplication::sendEvent(canvas, &leftArrowShiftRelese); + + QCOMPARE(selectionStartSpy.count(), 6); + QCOMPARE(selectionEndSpy.count(), 5); + QCOMPARE(selectionSpy.count(), 7); + QCOMPARE(textEdit->selectionStart(), 0); + QCOMPARE(textEdit->selectionEnd(), 1); + QCOMPARE(textEdit->selectedText(), QLatin1String("S")); + QCOMPARE(textEdit->cursorPosition(), 0); + + QApplication::sendEvent(canvas, &event); + + QCOMPARE(selectionStartSpy.count(), 6); + QCOMPARE(selectionEndSpy.count(), 6); + QCOMPARE(selectionSpy.count(), 8); + QCOMPARE(textEdit->selectionStart(), textEdit->cursorPosition()); + QCOMPARE(textEdit->selectionEnd(), textEdit->cursorPosition()); + QCOMPARE(textEdit->selectedText(), QLatin1String("")); + QCOMPARE(textEdit->cursorPosition(), 0); +} QTEST_MAIN(tst_qdeclarativetextedit) #include "tst_qdeclarativetextedit.moc" diff --git a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp index bb895bf..b077670 100644 --- a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp +++ b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp @@ -147,6 +147,7 @@ private slots: void inputContextMouseHandler(); void inputMethodComposing(); void cursorRectangleSize(); + void deselect(); private: void simulateKey(QDeclarativeView *, int key); @@ -2367,7 +2368,7 @@ void tst_qdeclarativetextinput::openInputPanelOnFocus() QVERIFY(!view.testAttribute(Qt::WA_InputMethodEnabled)); // input method should not be enabled - // if TextEdit is read only. + // if TextInput is read only. input.setReadOnly(true); ic.openInputPanelReceived = false; input.setFocus(true); @@ -2815,6 +2816,120 @@ void tst_qdeclarativetextinput::cursorRectangleSize() QCOMPARE(microFocusFromApp.size(), cursorRect.size()); } +void tst_qdeclarativetextinput::deselect() +{ + QDeclarativeView *canvas = createView(SRCDIR "/data/positionAt.qml"); + QVERIFY(canvas->rootObject() != 0); + canvas->show(); + canvas->setFocus(); + QApplication::setActiveWindow(canvas); + QTest::qWaitForWindowShown(canvas); + + QDeclarativeTextInput *textInput = qobject_cast(canvas->rootObject()); + QVERIFY(textInput != 0); + + textInput->setText("Select"); + + QSignalSpy selectionStartSpy(textInput, SIGNAL(selectionStartChanged())); + QSignalSpy selectionEndSpy(textInput, SIGNAL(selectionEndChanged())); + QSignalSpy selectedTextSpy(textInput, SIGNAL(selectedTextChanged())); + + textInput->select(5, 6); + + QCOMPARE(selectionStartSpy.count(), 1); + QCOMPARE(selectionEndSpy.count(), 0); + QCOMPARE(selectedTextSpy.count(), 1); + QCOMPARE(textInput->selectionStart(), 5); + QCOMPARE(textInput->selectionEnd(), 6); + QCOMPARE(textInput->selectedText(), QLatin1String("t")); + QCOMPARE(textInput->cursorPosition(), 6); + + textInput->deselect(); + + QCOMPARE(selectionStartSpy.count(), 2); + QCOMPARE(selectionEndSpy.count(), 1); + QCOMPARE(selectedTextSpy.count(), 2); + QCOMPARE(textInput->selectionStart(), textInput->cursorPosition()); + QCOMPARE(textInput->selectionEnd(), textInput->cursorPosition()); + QCOMPARE(textInput->selectedText(), QLatin1String("")); + QCOMPARE(textInput->cursorPosition(), 6); + + textInput->select(5, 6); + + QCOMPARE(selectionStartSpy.count(), 3); + QCOMPARE(selectionEndSpy.count(), 1); + QCOMPARE(selectedTextSpy.count(), 3); + QCOMPARE(textInput->selectionStart(), 5); + QCOMPARE(textInput->selectionEnd(), 6); + QCOMPARE(textInput->selectedText(), QLatin1String("t")); + QCOMPARE(textInput->cursorPosition(), 6); + + QKeyEvent leftArrowPress(QEvent::KeyPress, Qt::Key_Left, Qt::NoModifier); + QKeyEvent leftArrowRelese(QEvent::KeyRelease, Qt::Key_Left, Qt::NoModifier); + QApplication::sendEvent(canvas, &leftArrowPress); + QApplication::sendEvent(canvas, &leftArrowRelese); + + QCOMPARE(selectionStartSpy.count(), 4); + QCOMPARE(selectionEndSpy.count(), 2); + QCOMPARE(selectedTextSpy.count(), 4); + QCOMPARE(textInput->selectionStart(), textInput->cursorPosition()); + QCOMPARE(textInput->selectionEnd(), textInput->cursorPosition()); + QCOMPARE(textInput->selectedText(), QLatin1String("")); + QCOMPARE(textInput->cursorPosition(), 5); + + textInput->select(5, 6); + + QCOMPARE(selectionStartSpy.count(), 4); + QCOMPARE(selectionEndSpy.count(), 3); + QCOMPARE(selectedTextSpy.count(), 5); + QCOMPARE(textInput->selectionStart(), 5); + QCOMPARE(textInput->selectionEnd(), 6); + QCOMPARE(textInput->selectedText(), QLatin1String("t")); + QCOMPARE(textInput->cursorPosition(), 6); + + QList attributes; + attributes << QInputMethodEvent::Attribute(QInputMethodEvent::Selection, 0, 0, QVariant()); + QInputMethodEvent event(QLatin1String(""), attributes); + QApplication::sendEvent(canvas, &event); + + QCOMPARE(selectionStartSpy.count(), 5); + QCOMPARE(selectionEndSpy.count(), 4); + QCOMPARE(selectedTextSpy.count(), 6); + QCOMPARE(textInput->selectionStart(), textInput->cursorPosition()); + QCOMPARE(textInput->selectionEnd(), textInput->cursorPosition()); + QCOMPARE(textInput->selectedText(), QLatin1String("")); + QCOMPARE(textInput->cursorPosition(), 0); + + textInput->setCursorPosition(1); + + QCOMPARE(selectionStartSpy.count(), 6); + QCOMPARE(selectionEndSpy.count(), 5); + QCOMPARE(selectedTextSpy.count(), 6); + + QKeyEvent leftArrowShiftPress(QEvent::KeyPress, Qt::Key_Left, Qt::ShiftModifier); + QKeyEvent leftArrowShiftRelese(QEvent::KeyRelease, Qt::Key_Left, Qt::ShiftModifier); + QApplication::sendEvent(canvas, &leftArrowShiftPress); + QApplication::sendEvent(canvas, &leftArrowShiftRelese); + + QCOMPARE(selectionStartSpy.count(), 7); + QCOMPARE(selectionEndSpy.count(), 5); + QCOMPARE(selectedTextSpy.count(), 7); + QCOMPARE(textInput->selectionStart(), 0); + QCOMPARE(textInput->selectionEnd(), 1); + QCOMPARE(textInput->selectedText(), QLatin1String("S")); + QCOMPARE(textInput->cursorPosition(), 0); + + QApplication::sendEvent(canvas, &event); + + QCOMPARE(selectionStartSpy.count(), 8); + QCOMPARE(selectionEndSpy.count(), 6); + QCOMPARE(selectedTextSpy.count(), 8); + QCOMPARE(textInput->selectionStart(), textInput->cursorPosition()); + QCOMPARE(textInput->selectionEnd(), textInput->cursorPosition()); + QCOMPARE(textInput->selectedText(), QLatin1String("")); + QCOMPARE(textInput->cursorPosition(), 0); +} + QTEST_MAIN(tst_qdeclarativetextinput) #include "tst_qdeclarativetextinput.moc" -- cgit v0.12 From 6f6493747121db428a71d494c8cb3f04a0292279 Mon Sep 17 00:00:00 2001 From: Viktor Kolesnyk Date: Mon, 5 Sep 2011 15:08:23 +0300 Subject: Incorrect 'break' in switch-case was replaced by 'return' --- src/gui/kernel/qcursor_win.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/kernel/qcursor_win.cpp b/src/gui/kernel/qcursor_win.cpp index cef83f5..a68472c 100644 --- a/src/gui/kernel/qcursor_win.cpp +++ b/src/gui/kernel/qcursor_win.cpp @@ -477,7 +477,7 @@ void QCursorData::update() QPixmap pixmap = QApplicationPrivate::instance()->getPixmapCursor(cshape); hcurs = create32BitCursor(pixmap, hx, hy); } - break; + return; default: qWarning("QCursor::update: Invalid cursor shape %d", cshape); return; -- cgit v0.12 From 872872f3d3f0d89010d3a196b70e8445a08d0784 Mon Sep 17 00:00:00 2001 From: Jani Hautakangas Date: Fri, 23 Sep 2011 07:47:24 +0300 Subject: Fix to QtOpenGL crash Exiting the native video recorder on Symbian and going back to Qt app which runs on opengl graphics system crashed on some devices because there was not enough GPU memory and also because low GPU mem device environment detection was flawed. This patch fixes 32MB GPU memory detection and adds wait/retrial to EGL surface creation if it fails. Task-number: QTBUG-21499 Reviewed-by: Laszlo Agocs --- src/gui/egl/qegl.cpp | 32 ++++++++ src/gui/painting/qgraphicssystemex_symbian.cpp | 105 +++++++++++++++++++++---- 2 files changed, 123 insertions(+), 14 deletions(-) diff --git a/src/gui/egl/qegl.cpp b/src/gui/egl/qegl.cpp index 4db4a6a..02adef8 100644 --- a/src/gui/egl/qegl.cpp +++ b/src/gui/egl/qegl.cpp @@ -684,6 +684,37 @@ EGLSurface QEgl::createSurface(QPaintDevice *device, EGLConfig cfg, const QEglPr else props = 0; EGLSurface surf; +#ifdef Q_OS_SYMBIAN + // On Symbian there might be situations (especially on 32MB GPU devices) + // where Qt is trying to create EGL surface while some other application + // is still holding all available GPU memory but is about to release it + // soon. For an example when exiting native video recorder and going back to + // Qt application behind it. Video stack tear down takes some time and Qt + // app might be too quick in reserving its EGL surface and thus running out + // of GPU memory right away. So if EGL surface creation fails due to bad + // alloc, let's try recreating it four times within ~1 second if needed. + // This strategy gives some time for video recorder to tear down its stack + // and a chance to Qt for creating a valid surface. + int tries = 4; + while(tries--) { + if (devType == QInternal::Widget) + surf = eglCreateWindowSurface(QEgl::display(), cfg, windowDrawable, props); + else + surf = eglCreatePixmapSurface(QEgl::display(), cfg, pixmapDrawable, props); + if (surf == EGL_NO_SURFACE) { + EGLint error = eglGetError(); + if (error == EGL_BAD_ALLOC) { + if (tries) { + User::After(1000 * 250); // 250ms + continue; + } + } + qWarning("QEglContext::createSurface(): Unable to create EGL surface, error = 0x%x", error); + } else { + break; + } + } +#else if (devType == QInternal::Widget) surf = eglCreateWindowSurface(QEgl::display(), cfg, windowDrawable, props); else @@ -691,6 +722,7 @@ EGLSurface QEgl::createSurface(QPaintDevice *device, EGLConfig cfg, const QEglPr if (surf == EGL_NO_SURFACE) { qWarning("QEglContext::createSurface(): Unable to create EGL surface, error = 0x%x", eglGetError()); } +#endif return surf; } #endif diff --git a/src/gui/painting/qgraphicssystemex_symbian.cpp b/src/gui/painting/qgraphicssystemex_symbian.cpp index 4469704..46731d8 100644 --- a/src/gui/painting/qgraphicssystemex_symbian.cpp +++ b/src/gui/painting/qgraphicssystemex_symbian.cpp @@ -46,31 +46,106 @@ #include +#ifdef Q_SYMBIAN_SUPPORTS_SURFACES +#include "private/qegl_p.h" +#endif + QT_BEGIN_NAMESPACE static bool bcm2727Initialized = false; static bool bcm2727 = false; +typedef EGLBoolean (*NOK_resource_profiling)(EGLDisplay, EGLint, EGLint*, EGLint, EGLint*); +#define EGL_PROF_TOTAL_MEMORY_NOK 0x3070 + +// Detect if Qt is running on BCM2727 chip. +// BCM2727 is a special case on Symbian because +// it has only 32MB GPU memory which exposes +// significant limitations to hw accelerated UI. bool QSymbianGraphicsSystemEx::hasBCM2727() { if (bcm2727Initialized) return bcm2727; - const TUid KIvePropertyCat = {0x2726beef}; - enum TIvePropertyChipType { - EVCBCM2727B1 = 0x00000000, - EVCBCM2763A0 = 0x04000100, - EVCBCM2763B0 = 0x04000102, - EVCBCM2763C0 = 0x04000103, - EVCBCM2763C1 = 0x04000104, - EVCBCMUnknown = 0x7fffffff - }; - - TInt chipType = EVCBCMUnknown; - if (RProperty::Get(KIvePropertyCat, 0, chipType) == KErrNone) { - if (chipType == EVCBCM2727B1) +#ifdef Q_SYMBIAN_SUPPORTS_SURFACES + EGLDisplay display = QEgl::display(); +#if 1 + // Hacky but fast ~0ms. + const char* vendor = eglQueryString(display, EGL_VENDOR); + if (strstr(vendor, "Broadcom")) { + const TUid KIvePropertyCat = {0x2726beef}; + enum TIvePropertyChipType { + EVCBCM2727B1 = 0x00000000, + EVCBCM2763A0 = 0x04000100, + EVCBCM2763B0 = 0x04000102, + EVCBCM2763C0 = 0x04000103, + EVCBCM2763C1 = 0x04000104, + EVCBCMUnknown = 0x7fffffff + }; + + // Broadcom driver publishes KIvePropertyCat PS key on + // devices which are running on BCM2727 chip and post Anna Symbian. + TInt chipType = EVCBCMUnknown; + if (RProperty::Get(KIvePropertyCat, 0, chipType) == KErrNone) { + if (chipType == EVCBCM2727B1) + bcm2727 = true; + } else if (QSysInfo::symbianVersion() <= QSysInfo::SV_SF_3) { + // Device is running on Symbian Anna or older Symbian^3 in which + // KIvePropertyCat is not published. These ones are always 32MB devices. + bcm2727 = true; + } else { + // We have some other Broadcom chip on post Anna Symbian. + // Should have > 32MB GPU memory. + } + } +#else + // Fool proof but takes 15-20ms and we don't want this delay on app startup... + + // All devices with <= 32MB GPU memory should be + // dealed in similar manner to BCM2727 + // So let's query max GPU memory amount. + NOK_resource_profiling eglQueryProfilingData = (NOK_resource_profiling)eglGetProcAddress("eglQueryProfilingDataNOK"); + if (eglQueryProfilingData) { + EGLint dataCount; + eglQueryProfilingData(display, + EGL_PROF_QUERY_GLOBAL_BIT_NOK | + EGL_PROF_QUERY_MEMORY_USAGE_BIT_NOK, + NULL, + 0, + (EGLint*)&dataCount); + + // Allocate room for the profiling data + EGLint* profData = (EGLint*)malloc(dataCount * sizeof(EGLint)); + memset(profData,0,dataCount * sizeof(EGLint)); + + // Retrieve the profiling data + eglQueryProfilingData(display, + EGL_PROF_QUERY_GLOBAL_BIT_NOK | + EGL_PROF_QUERY_MEMORY_USAGE_BIT_NOK, + profData, + dataCount, + (EGLint*)&dataCount); + + int totalMemory; + EGLint i = 0; + while (profData && i < dataCount) { + switch (profData[i++]) { + case EGL_PROF_TOTAL_MEMORY_NOK: + totalMemory = profData[i++]; + break; + default: + i++; + } + } + + // ok, hasBCM2727() naming is a bit misleading but Qt must + // behave the same on all chips like BCM2727 (<= 32MB GPU memory) + // and our code (and others) are already using this function. + if (totalMemory <= 33554432) bcm2727 = true; } +#endif +#endif // Q_SYMBIAN_SUPPORTS_SURFACES bcm2727Initialized = true; @@ -80,7 +155,9 @@ bool QSymbianGraphicsSystemEx::hasBCM2727() void QSymbianGraphicsSystemEx::releaseCachedGpuResources() { // Do nothing here - // This is implemented in graphics system specific plugin + + // This virtual function should be implemented in graphics system specific + // plugin } void QSymbianGraphicsSystemEx::releaseAllGpuResources() -- cgit v0.12 From e05734987594f0e54f58a2ab3037cdf4956e9036 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Mon, 26 Sep 2011 12:18:46 +0200 Subject: Fix possible crash in QFontEngineFT Avoid crash if set pointer is null. Task-number: QTBUG-21647 Reviewed-by: Jiang Jiang --- src/gui/text/qfontengine_ft.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/text/qfontengine_ft.cpp b/src/gui/text/qfontengine_ft.cpp index e20aa25..d00a048 100644 --- a/src/gui/text/qfontengine_ft.cpp +++ b/src/gui/text/qfontengine_ft.cpp @@ -801,7 +801,7 @@ int QFontEngineFT::loadFlags(QGlyphSet *set, GlyphFormat format, int flags, if (set && set->outline_drawing) load_flags = FT_LOAD_NO_BITMAP; - if (default_hint_style == HintNone || (flags & HB_ShaperFlag_UseDesignMetrics) || set->outline_drawing) + if (default_hint_style == HintNone || (flags & HB_ShaperFlag_UseDesignMetrics) || (set && set->outline_drawing)) load_flags |= FT_LOAD_NO_HINTING; else load_flags |= load_target; -- cgit v0.12 From e90cffc2c5f313cc813d0a21a1d9d0afe8d0ea7a Mon Sep 17 00:00:00 2001 From: Sami Merila Date: Tue, 27 Sep 2011 08:17:25 +0300 Subject: Crash in QDeclarativeCompiler::indexOfProperty In QDeclarativePropertyCache, plain integer bitfield overrideIndex is initialized with -1 in class constructor. Unfortunately, ARM compiler treats bitfields as unsigned, unless explicitly defined as signed [1]. Therefore, overrideIndex actually gets initial value of 2147483647, which causes array operations done with the index to fail. As a fix, define overrideIndex as signed int bitfield. [1] http://www.keil.com/support/man/docs/armccref/armccref_Babjddhe.htm Under bitfields/Note: "A plain bitfield, declared without either signed or unsigned qualifiers, is treated as unsigned" Task-number: QT-5285 Reviewed-by: Aaron Kennedy --- src/declarative/qml/qdeclarativepropertycache_p.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/declarative/qml/qdeclarativepropertycache_p.h b/src/declarative/qml/qdeclarativepropertycache_p.h index 581f519..c648d25 100644 --- a/src/declarative/qml/qdeclarativepropertycache_p.h +++ b/src/declarative/qml/qdeclarativepropertycache_p.h @@ -111,7 +111,7 @@ public: int relatedIndex; // When IsFunction }; uint overrideIndexIsProperty : 1; - int overrideIndex : 31; + signed int overrideIndex : 31; int revision; int metaObjectOffset; -- cgit v0.12 From 24855ef3983fa5d87b3e3a06fe891a769e670ae5 Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Wed, 31 Aug 2011 15:52:25 +0100 Subject: Always recreate backing store when TLW transparency changes When using either the opengl or openvg graphics system on Symbian, if a TLW is made transparent, the widget switches to using raster rendering, because EGL surface transparency is currently not supported by the platform. This patch enables the reverse to occur: when the widget is subsequently made opaque, rendering switches back to using GL/VG. Task-number: QTBUG-21211 Reviewed-by: Jani Hautakangas Reviewed-by: Laszlo Agocs Reviewed-by: Sami Merila --- src/gui/kernel/qwidget.cpp | 24 ++++++++++++---- src/gui/kernel/qwidget_p.h | 1 + src/gui/kernel/qwidget_s60.cpp | 58 ++++++++++++++++++++++++-------------- tests/auto/qwidget/tst_qwidget.cpp | 45 ++++++++++++++++++++++++++++- 4 files changed, 101 insertions(+), 27 deletions(-) diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index 8e8266c..bda0885 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -2238,10 +2238,16 @@ void QWidgetPrivate::updateIsOpaque() #endif #ifdef Q_WS_S60 - if (q->windowType() == Qt::Dialog && q->testAttribute(Qt::WA_TranslucentBackground) - && S60->avkonComponentsSupportTransparency) { - setOpaque(false); - return; + if (q->testAttribute(Qt::WA_TranslucentBackground)) { + if (q->windowType() & Qt::Dialog || q->windowType() & Qt::Popup) { + if (S60->avkonComponentsSupportTransparency) { + setOpaque(false); + return; + } + } else { + setOpaque(false); + return; + } } #endif @@ -2261,11 +2267,16 @@ void QWidgetPrivate::updateIsOpaque() } if (q->isWindow() && !q->testAttribute(Qt::WA_NoSystemBackground)) { +#ifdef Q_WS_S60 + setOpaque(true); + return; +#else const QBrush &windowBrush = q->palette().brush(QPalette::Window); if (windowBrush.style() != Qt::NoBrush && windowBrush.isOpaque()) { setOpaque(true); return; } +#endif } setOpaque(false); } @@ -10845,11 +10856,14 @@ void QWidget::setAttribute(Qt::WidgetAttribute attribute, bool on) } break; case Qt::WA_TranslucentBackground: +#if defined(Q_OS_SYMBIAN) + setAttribute(Qt::WA_NoSystemBackground, on); +#else if (on) { setAttribute(Qt::WA_NoSystemBackground); d->updateIsTranslucent(); } - +#endif break; case Qt::WA_AcceptTouchEvents: #if defined(Q_WS_WIN) || defined(Q_WS_MAC) || defined(Q_OS_SYMBIAN) diff --git a/src/gui/kernel/qwidget_p.h b/src/gui/kernel/qwidget_p.h index e30497c..caa6454 100644 --- a/src/gui/kernel/qwidget_p.h +++ b/src/gui/kernel/qwidget_p.h @@ -228,6 +228,7 @@ struct QTLWExtra { uint inExpose : 1; // Prevents drawing recursion uint nativeWindowTransparencyEnabled : 1; // Tracks native window transparency uint forcedToRaster : 1; + uint noSystemRotationDisabled : 1; #endif }; diff --git a/src/gui/kernel/qwidget_s60.cpp b/src/gui/kernel/qwidget_s60.cpp index e80eced..e12dfa7 100644 --- a/src/gui/kernel/qwidget_s60.cpp +++ b/src/gui/kernel/qwidget_s60.cpp @@ -820,19 +820,12 @@ void QWidgetPrivate::setConstraints_sys() void QWidgetPrivate::s60UpdateIsOpaque() { Q_Q(QWidget); - if (!q->testAttribute(Qt::WA_WState_Created)) return; - const bool writeAlpha = extraData()->nativePaintMode == QWExtra::BlitWriteAlpha; - if (!q->testAttribute(Qt::WA_TranslucentBackground) && !writeAlpha) - return; const bool requireAlphaChannel = !isOpaque || writeAlpha; - createTLExtra(); - RWindow *const window = static_cast(q->effectiveWinId()->DrawableWindow()); - #ifdef Q_SYMBIAN_SEMITRANSPARENT_BG_SURFACE if (QApplicationPrivate::instance()->useTranslucentEGLSurfaces && !extra->topextra->forcedToRaster) { @@ -841,25 +834,47 @@ void QWidgetPrivate::s60UpdateIsOpaque() return; } #endif + const bool recreateBackingStore = extra->topextra->backingStore.data() && ( + QApplicationPrivate::graphics_system_name == QLatin1String("openvg") || + QApplicationPrivate::graphics_system_name == QLatin1String("opengl") + ); if (requireAlphaChannel) { - const TDisplayMode displayMode = static_cast(window->SetRequiredDisplayMode(EColor16MA)); - if (window->SetTransparencyAlphaChannel() == KErrNone) { + window->SetRequiredDisplayMode(EColor16MA); + if (window->SetTransparencyAlphaChannel() == KErrNone) window->SetBackgroundColor(TRgb(255, 255, 255, 0)); - extra->topextra->nativeWindowTransparencyEnabled = 1; - if (extra->topextra->backingStore.data() && ( - QApplicationPrivate::graphics_system_name == QLatin1String("openvg") - || QApplicationPrivate::graphics_system_name == QLatin1String("opengl"))) { - // Semi-transparent EGL surfaces aren't supported. We need to - // recreate backing store to get translucent surface (raster surface). - extra->topextra->backingStore.create(q); - extra->topextra->backingStore.registerWidget(q); - // FixNativeOrientation() will not work without an EGL surface. + } else { + if (recreateBackingStore) { + // Clear the UI surface to ensure that the EGL surface content is visible + CWsScreenDevice *screenDevice = S60->screenDevice(q); + QScopedPointer gc(new CWindowGc(screenDevice)); + const int err = gc->Construct(); + if (!err) { + gc->Activate(*window); + window->BeginRedraw(); + gc->SetDrawMode(CWindowGc::EDrawModeWriteAlpha); + gc->SetBrushColor(TRgb(0, 0, 0, 0)); + gc->Clear(TRect(0, 0, q->width(), q->height())); + window->EndRedraw(); + } + } + if (extra->topextra->nativeWindowTransparencyEnabled) + window->SetTransparentRegion(TRegionFix<1>()); + } + extra->topextra->nativeWindowTransparencyEnabled = requireAlphaChannel; + if (recreateBackingStore) { + extra->topextra->backingStore.create(q); + extra->topextra->backingStore.registerWidget(q); + bool noSystemRotationDisabled = false; + if (requireAlphaChannel) { + if (q->testAttribute(Qt::WA_SymbianNoSystemRotation)) { + // FixNativeOrientation() will not work without an EGL surface q->setAttribute(Qt::WA_SymbianNoSystemRotation, false); + noSystemRotationDisabled = true; } + } else { + q->setAttribute(Qt::WA_SymbianNoSystemRotation, extra->topextra->noSystemRotationDisabled); } - } else if (extra->topextra->nativeWindowTransparencyEnabled) { - window->SetTransparentRegion(TRegionFix<1>()); - extra->topextra->nativeWindowTransparencyEnabled = 0; + extra->topextra->noSystemRotationDisabled = noSystemRotationDisabled; } } @@ -1020,6 +1035,7 @@ void QWidgetPrivate::createTLSysExtra() extra->topextra->inExpose = 0; extra->topextra->nativeWindowTransparencyEnabled = 0; extra->topextra->forcedToRaster = 0; + extra->topextra->noSystemRotationDisabled = 0; } void QWidgetPrivate::deleteTLSysExtra() diff --git a/tests/auto/qwidget/tst_qwidget.cpp b/tests/auto/qwidget/tst_qwidget.cpp index 43dd077..2161f99 100644 --- a/tests/auto/qwidget/tst_qwidget.cpp +++ b/tests/auto/qwidget/tst_qwidget.cpp @@ -397,6 +397,9 @@ private slots: void minimizedWindowModeTransitions(); void normalWindowModeTransitions(); void focusSwitchClosesPopupMenu(); +#if !defined(Q_SYMBIAN_SEMITRANSPARENT_BG_SURFACE) + void opacityChangeCausesBackingStoreRecreation(); +#endif #endif void focusProxyAndInputMethods(); @@ -10336,7 +10339,47 @@ void tst_QWidget::focusSwitchClosesPopupMenu() mainWindow.activateWindow(); QVERIFY(!CEikonEnv::Static()->AppUiFactory()->MenuBar()->IsDisplayed()); } -#endif + +#if !defined(Q_SYMBIAN_SEMITRANSPARENT_BG_SURFACE) +class OpacityChangeWidget : public QWidget +{ +public: + OpacityChangeWidget() : m_paintEngineType(QPaintEngine::MaxUser) { } + void paintEvent(QPaintEvent *) + { + QPainter painter(this); + m_paintEngineType = painter.paintEngine()->type(); + } + QPaintEngine::Type paintEngineType() const { return m_paintEngineType; } +private: + QPaintEngine::Type m_paintEngineType; +}; + +void tst_QWidget::opacityChangeCausesBackingStoreRecreation() +{ + OpacityChangeWidget w; + w.show(); + QTest::qWaitForWindowShown(&w); + const QPaintEngine::Type type = w.paintEngineType(); + if (QPaintEngine::OpenGL != type && QPaintEngine::OpenVG != type) { + QSKIP("Test case is only valid when using opengl or openvg graphics system", SkipAll); + } else { + if (QApplicationPrivate::instance()->useTranslucentEGLSurfaces) { + QSKIP("Test case is only valid when EGL surface transparency is not supported", SkipAll); + } else { + // Making window transparent should force switch to raster graphics system + w.setAttribute(Qt::WA_TranslucentBackground, true); + w.repaint(); + QCOMPARE(w.paintEngineType(), QPaintEngine::Raster); + // Making window opaque should cause switch back to previous graphics system + w.setAttribute(Qt::WA_TranslucentBackground, false); + w.repaint(); + QCOMPARE(w.paintEngineType(), type); + } + } +} +#endif // !Q_SYMBIAN_SEMITRANSPARENT_BG_SURFACE +#endif // Q_OS_SYMBIAN class InputContextTester : public QInputContext { -- cgit v0.12 From 5d809703aa2d2a08ae7e9610fd42025b081d3d0c Mon Sep 17 00:00:00 2001 From: Peter Hartmann Date: Tue, 27 Sep 2011 13:59:17 +0200 Subject: QNetworkRequest autotest: adapt to new cookie parsing (re. commas) Cookies cannot be separated by commas anymore, but are separated by new lines. See "Remove support for multiple cookies in one Set-Cookie header to follow RFC6265." Reviewed-by: Martin Petersson Task-number: QTBUG-21456 --- tests/auto/qnetworkrequest/tst_qnetworkrequest.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/auto/qnetworkrequest/tst_qnetworkrequest.cpp b/tests/auto/qnetworkrequest/tst_qnetworkrequest.cpp index 9052716..02d1e5a 100644 --- a/tests/auto/qnetworkrequest/tst_qnetworkrequest.cpp +++ b/tests/auto/qnetworkrequest/tst_qnetworkrequest.cpp @@ -414,7 +414,7 @@ void tst_QNetworkRequest::rawHeaderParsing_data() QTest::newRow("SetCookie-3") << QNetworkRequest::SetCookieHeader << qVariantFromValue(QList() << cookie << cookie2) << true << "Set-Cookie" - << "a=b; path=/, c=d"; + << "a=b; path=/\nc=d"; } void tst_QNetworkRequest::rawHeaderParsing() -- cgit v0.12 From 55d25e4471074241a4edf9b9c0033cce4e211bdf Mon Sep 17 00:00:00 2001 From: Eero Hyyti Date: Tue, 27 Sep 2011 16:09:42 +0300 Subject: Document updates to Qt for Symbian installation instructions and platform notes. --- doc/src/getting-started/installation.qdoc | 570 ++++++++++++++++-------------- doc/src/platforms/platform-notes.qdoc | 95 +++-- 2 files changed, 374 insertions(+), 291 deletions(-) diff --git a/doc/src/getting-started/installation.qdoc b/doc/src/getting-started/installation.qdoc index ef010b4..bec9ee4 100644 --- a/doc/src/getting-started/installation.qdoc +++ b/doc/src/getting-started/installation.qdoc @@ -79,6 +79,8 @@ for your platform from the following list. \snippet doc/src/snippets/code/doc_src_installation.qdoc 1 Type \c{./configure -help} to get a list of all available options. + The \l{Configuration Options for Qt} page gives a brief overview + of these. To create the library and compile all the demos, examples, tools, and tutorials, type: @@ -218,7 +220,8 @@ for your platform from the following list. \snippet doc/src/snippets/code/doc_src_installation.qdoc 8 - Type \c{configure -help} to get a list of all available options. + Type \c{configure -help} to get a list of all available options. The + \l{Configuration Options for Qt} page gives a brief overview of these. If you have multiple compilers installed, and want to build the Qt library using a specific compiler, you must specify a \c qmake specification. @@ -433,7 +436,9 @@ in the \l{Qt for Windows CE Requirements} document. If you want to configure Qt for another platform or with other options, type \c{configure -help} to get a list of all available - options. See the \c README file for the list of supported platforms. + options. The \l{Configuration Options for Qt} page gives a brief + overview of these. See the \c README file for the list of supported + platforms. \section1 Step 4: Build Qt Library @@ -505,7 +510,10 @@ in the \l{Qt for the Symbian platform Requirements} document. \section1 Step 1: Install Qt - Run \c{qt-symbian-opensource-%VERSION%.exe} and follow the instructions. + Download the \c {Qt libraries 4.x for Windows} package (for \c minGW or \c {VS 2008}) + from the \l {http://qt.nokia.com/downloads#qt-lib}{downloads} page. + + Run the downloaded package and follow the instructions. \note Qt must be installed on the same drive as the Symbian SDK you are using, and the install path must not contain any spaces. @@ -626,6 +634,10 @@ Binary Package} document. \snippet doc/src/snippets/code/doc_src_installation.qdoc 31 (to build the tools using MinGW, and the libraries using SBSv2) + Type \c{./configure -help} to get a list of all available options. + The \l{Configuration Options for Qt} page gives a brief overview + of these. + SBSv2 (also known as \l{http://developer.symbian.org/wiki/index.php/Introduction_to_RAPTOR} {Raptor}) is a next-generation Symbian build system. SBSv2 is not officially supported by any of the S60 SDKs currently available from Forum Nokia. @@ -643,23 +655,39 @@ Binary Package} document. Congratulations, Qt is now ready to use. \section1 Step 7: Installing Qt Libraries on the Device - - To run the demo on a real device, you first have to install - the Qt libraries on the device: + + To run a Qt application on a device, it must have Qt libraries installed. + + Symbian devices have a pre-installed Qt as follows: + \list + \o Symbian Anna devices have the pre-installed Qt, Qt Mobility, and Qt Webkit. + \o Symbian Belle and later devices have the pre-installed Qt on the device firmware. + \endlist + + \l {http://www.developer.nokia.com/Community/Wiki/Nokia_Smart_Installer_for_Symbian} + {Nokia Smart Installer for Symbian} deploys the required Qt libraries to supported S60 + and Symbian devices if the libraries are not pre-installed. + + Nokia Developer site's \l {http://www.developer.nokia.com/Devices/Device_specifications/?filter1=qt} + {Device specifications} provide information on which devices have a + pre-installed Qt and the used Qt version. + + To create your own Qt installation package, do as follows: \snippet doc/src/snippets/code/doc_src_installation.qdoc 29 - The Qt libraries are built with "All -Tcb" capability, so that - they can support all types of application. - If you don't have a suitable certificate, it is possible to patch - the binaries as follows: - - If you have no certificate, build a self signed Qt: -\snippet doc/src/snippets/code/doc_src_installation.qdoc 34 + The Qt libraries are built with "All -Tcb" capability, so they can support + all types of applications. If you don't have a suitable certificate, you can + patch the binaries in either of the following ways: + + \list + \o If you have no certificate, build a self-signed Qt: + \snippet doc/src/snippets/code/doc_src_installation.qdoc 34 - If you have a symbian-signed developer certificate, specify the + \o If you have a symbian-signed developer certificate, specify the capabilities you can sign for, for example: -\snippet doc/src/snippets/code/doc_src_installation.qdoc 35 + \snippet doc/src/snippets/code/doc_src_installation.qdoc 35 + \endlist \section1 Running Qt demos @@ -740,6 +768,9 @@ to build the libraries using RVCT or to build the libraries using GCCE. +Type \c{./configure -help} to get a list of all available options. +The \l{Configuration Options for Qt} page gives a brief overview +of these. \section1 Step 5: Build Qt @@ -1303,7 +1334,12 @@ We hope you will enjoy using Qt. \brief Setting up the Symbian platform environment for Qt. \previouspage General Qt Requirements - Qt for the Symbian platform requires the following software installed on your development PC: + \l {http://qt.nokia.com/downloads}{Qt SDK} provides all the necessary tools + and libraries for developing Qt applications. However, if you want to build + Qt itself for Symbian, follow the instructions below. + + Qt for the Symbian platform requires the following software installed on + your development PC: \list \o \l{http://www.forum.nokia.com/Library/Tools_and_downloads/Other/Carbide.c++/}{Carbide.c++ v2.3.0 or higher recommended}. \list @@ -1368,253 +1404,263 @@ We hope you will enjoy using Qt. /*! \page configure-options.html - \title Configure options for Qt + \title Configuration Options for Qt \ingroup installation - \brief Brief description of available options building Qt. - - This page gives a brief description of the different options - available when building Qt using configure. To build Qt using - default options, just call configure from the command line like - showed below. If you would like to customize your build, please - use the options listed in the following tables. - - \c {.\configure.exe} - - \section2 Cross platform options: - - \table - \header \o Option \o Description \o Note - \row \o \c {-buildkey } \o Build the Qt library and plugins - using the specified \o - \row \o \c {} \o When the library loads plugins, it will only - load those that have a matching . \o - \row \o \c {-release } \o Compile and link Qt with debugging turned off. \o - \row \o \c {-debug } \o Compile and link Qt with debugging turned on. - \o Default value. - \row \o \c {-debug-and-release} \o Compile and link two Qt libraries, - with and without debugging turned on. \o This option denotes a default - value and needs to be evaluated. If the evaluation succeeds, the - feature is included. - \row \o \c {-opensource} \o Compile and link the Open-Source Edition - of Qt. \o - \row \o \c {-commercial } \o Compile and link the Commercial Edition - of Qt. \o - \row \o \c {-developer-build} \o Compile and link Qt with Qt developer - options including auto-tests exporting) \o - \row \o \c {-shared} \o Create and use shared Qt libraries. \o Default - value. - \row \o \c {-static} \o Create and use static Qt libraries. \o - \row \o \c {-ltcg} \o Use Link Time Code Generation. \o Apply to release - builds only. - \row \o \c {-no-ltcg} \o Do not use Link Time Code Generation. \o Default - value. - \row \o \c {-no-fast} \o Configure Qt normally by generating Makefiles for - all project files. \o Default value. - \row \o \c {-fast} \o Configure Qt quickly by generating Makefiles only for - library and subdirectory targets. \o All other Makefiles are created as - wrappers which will in turn run qmake. - \row \o \c {-no-exceptions} \o Disable exceptions on platforms that support - it. \o - \row \o \c {-exceptions} \o Enable exceptions on platforms that support it. - \o Default value. - \row \o \c {-no-accessibility} \o Do not compile Windows Active - Accessibility support. \o - \row \o \c {-accessibility} \o Compile Windows Active Accessibility - support. \o Default value. - \row \o \c {-no-stl} \o Do not compile STL support. \o - \row \o \c {-stl} \o Compile STL support. \o Default value. - \row \o \c {-no-sql-} \o Disable SQL entirely, by default - none are turned on. \o - \row \o \c {-qt-sql-} \o Enable a SQL in the Qt Library. - \o - \row \o \c {-plugin-sql-} \o Enable SQL as a plugin to be - linked to at run time. \o Available values for : mysql, psql, - oci, odbc, tds, db2, sqlite, sqlite2, ibase. Drivers marked with a - '+' during configure have been detected as available on this system. - \row \o \c {-system-sqlite} \o Use sqlite from the operating system. \o - \row \o \c {-no-qt3support} \o Disables the Qt 3 support functionality. \o - \row \o \c {-no-opengl} \o Disables OpenGL functionality \o - \row \o \c {-opengl } \o Enable OpenGL support with specified API - version. \o Available values for : desktop - Enable support for - Desktop OpenGL (Default), es1 - Enable support for OpenGL ES Common - Profile, es2 - Enable support for OpenGL ES 2.0. - \row \o \c {-no-openvg} \o Disables OpenVG functionality \o Default value. - \row \o \c {-openvg} \o Enables OpenVG functionality \o Requires EGL - support, typically supplied by an OpenGL or other graphics - implementation. - \row \o \c {-platform } \o The operating system and compiler you - are building on. \o The default value is %QMAKESPEC%. - \row \o \c {-xplatform } \o The operating system and compiler you - are cross compiling for. \o See the README file for a list of supported - operating systems and compilers. - \row \o \c {-qtnamespace } \o Wraps all Qt library code in - 'namespace name {..} \o - \row \o \c {-qtlibinfix } \o Renames all Qt* libs to Qt* - \o - \row \o \c {-D } \o Add an explicit define to the preprocessor. - \o - \row \o \c {-I } \o Add an explicit include path. \o - \row \o \c {-L } \o Add an explicit library path. \o - \row \o \c {-l } \o Add an explicit library name, residing - in a librarypath. \o - \row \o \c {-graphicssystem } \o Specify which graphics system should - be used. \o Available values for : * raster - Software rasterizer, - opengl - Using OpenGL acceleration, experimental!, openvg - Using - OpenVG acceleration, experimental! - \row \o \c {-help, -h, -?} \o Display this information. \o - \endtable - - \section2 Third Party Libraries: - \table - \header \o Option \o Description \o Note - \row \o \c {-qt-zlib} \o Use the zlib bundled with Qt. \o - \row \o \c {-system-zlib} \o Use zlib from the operating system. - \o See http://www.gzip.org/zlib - \row \o \c {-no-gif} \o Do not compile GIF reading support. - \o This option denotes a default value and needs to be evaluated. - If the evaluation succeeds, the feature is included. - \row \o \c {-qt-gif} \o Compile GIF reading support. \o See also - src/gui/image/qgifhandler_p.h - \row \o \c {-no-libpng} \o Do not compile PNG support. \o - \row \o \c {-qt-libpng} \o Use the libpng bundled with Qt. - \o This option denotes a default value and needs to be evaluated. - If the evaluation succeeds, the feature is included. - \row \o \c {-system-libpng} \o Use libpng from the operating system. - \o See http://www.libpng.org/pub/png - \row \o \c {-no-libmng} \o Do not compile MNG support. \o This option - denotes a default value and needs to be evaluated. If the evaluation - succeeds, the feature is included. - \row \o \c {-qt-libmng} \o Use the libmng bundled with Qt. \o - \row \o \c {-system-libmng} \o Use libmng from the operating system. - \o See http://www.libmng.com - \row \o \c {-no-libtiff} \o Do not compile TIFF support. \o This option - denotes a default value and needs to be evaluated. If the evaluation - succeeds, the feature is included. - \row \o \c {-qt-libtiff} \o Use the libtiff bundled with Qt. \o - \row \o \c {-system-libtiff} \o Use libtiff from the operating system. - \o See http://www.libtiff.org - \row \o \c {-no-libjpeg} \o Do not compile JPEG support. \o This option - denotes a default value and needs to be evaluated. If the evaluation - succeeds, the feature is included. - \row \o \c {-qt-libjpeg} \o Use the libjpeg bundled with Qt. \o - \row \o \c {-system-libjpeg} \o Use libjpeg from the operating system. - \o See http://www.ijg.org. This option denotes a default value and - needs to be evaluated. If the evaluation succeeds, the feature is - included. - \endtable - - \section2 Qt for Windows only: - \table - \header \o Option \o Description \o Note - \row \o \c {-no-dsp} \o Do not generate VC++ .dsp files. \o - \row \o \c {-dsp} \o Generate VC++ .dsp files, only if spec "win32-msvc". - \o Default value. - \row \o \c {-no-vcproj} \o Do not generate VC++ .vcproj files. \o - \row \o \c {-vcproj} \o Generate VC++ .vcproj files, only if platform - "win32-msvc.net". \o Default value. - \row \o \c {-no-incredibuild-xge} \o Do not add IncrediBuild XGE distribution - commands to custom build steps. \o - \row \o \c {-incredibuild-xge} \o Add IncrediBuild XGE distribution commands - to custom build steps. This will distribute MOC and UIC steps, and other - custom buildsteps which are added to the INCREDIBUILD_XGE variable. - \o The IncrediBuild distribution commands are only added to Visual Studio - projects. This option denotes a default value and needs to be evaluated. - If the evaluation succeeds, the feature is included. - \row \o \c {-no-plugin-manifests} \o Do not embed manifests in plugins. \o - \row \o \c {-plugin-manifests} \o Embed manifests in plugins. - \o Default value. - \row \o \c {-no-qmake} \o Do not compile qmake. \o - \row \o \c {-qmake} \o Compile qmake. \o Default value - \row \o \c {-dont-process} \o Do not generate Makefiles/Project files. This - will override -no-fast if specified. \o - \row \o \c {-process} \o Generate Makefiles/Project files. \o Default value. - \row \o \c {-no-rtti} \o Do not compile runtime type information. \o - \row \o \c {-rtti} \o Compile runtime type information. \o Default value. - \row \o \c {-no-mmx} \o Do not compile with use of MMX instructions \o - \row \o \c {-mmx} \o Compile with use of MMX instructions \o This option - denotes a default value and needs to be evaluated. If the evaluation - succeeds, the feature is included. - \row \o \c {-no-3dnow} \o Do not compile with use of 3DNOW instructions \o - \row \o \c {-3dnow} \o Compile with use of 3DNOW instructions \o This - option denotes a default value and needs to be evaluated. If the - evaluation succeeds, the feature is included. - \row \o \c {-no-sse} \o Do not compile with use of SSE instructions \o - \row \o \c {-sse} \o Compile with use of SSE instructions \o This option - denotes a default value and needs to be evaluated. If the evaluation - succeeds, the feature is included. - \row \o \c {-no-sse2} \o Do not compile with use of SSE2 instructions \o - \row \o \c {-sse2} \o Compile with use of SSE2 instructions \o This option - denotes a default value and needs to be evaluated. If the evaluation - succeeds, the feature is included. - \row \o \c {-no-openssl} \o Do not compile in OpenSSL support \o - \row \o \c {-openssl} \o Compile in run-time OpenSSL support \o This option - denotes a default value and needs to be evaluated. If the evaluation - succeeds, the feature is included. - \row \o \c {-openssl-linked} \o Compile in linked OpenSSL support \o - \row \o \c {-no-dbus} \o Do not compile in D-Bus support \o - \row \o \c {-dbus} \o Compile in D-Bus support and load libdbus-1 dynamically. - \o This option denotes a default value and needs to be evaluated. - If the evaluation succeeds, the feature is included. - \row \o \c {-dbus-linked} \o Compile in D-Bus support and link to - libdbus-1 \o - \row \o \c {-no-phonon} \o Do not compile in the Phonon module \o - \row \o \c {-phonon} \o Compile the Phonon module. \o Phonon is built if a - decent C++ compiler is used. This option denotes a default value and needs - to be evaluated. If the evaluation succeeds, the feature is included. - \row \o \c {-no-phonon-backend} \o Do not compile the platform-specific - Phonon backend-plugin \o - \row \o \c {-phonon-backend} \o Compile in the platform-specific Phonon - backend-plugin \o Default value. - \row \o \c {-no-multimedia} \o Do not compile the multimedia module \o - \row \o \c {-multimedia} \o Compile in multimedia module \o Default value. - \row \o \c {-no-audio-backend} \o Do not compile in the platform audio - backend into QtMultimedia \o - \row \o \c {-audio-backend} \o Compile in the platform audio backend into - QtMultimedia \o This option denotes a default value and needs to be - evaluated. If the evaluation succeeds, the feature is included. - \row \o \c {-no-webkit} \o Do not compile in the WebKit module \o - \row \o \c {-webkit} \o Compile in the WebKit module \o WebKit is built - if a decent C++ compiler is used. This option denotes a default value - and needs to be evaluated. If the evaluation succeeds, the feature is - included. - \row \o \c {-webkit-debug} \o Compile in the WebKit module with debug - symbols. \o - \row \o \c {-no-script} \o Do not build the QtScript module. \o - \row \o \c {-script} \o Build the QtScript module. \o This option - denotes a default value and needs to be evaluated. If the evaluation - succeeds, the feature is included. - \row \o \c {-no-scripttools} \o Do not build the QtScriptTools module. \o - \row \o \c {-scripttools} \o Build the QtScriptTools module. \o This - option denotes a default value and needs to be evaluated. If the - evaluation succeeds, the feature is included. - \row \o \c {-no-declarative} \o Do not build the declarative module \o - \row \o \c {-declarative} \o Build the declarative module \o This option - denotes a default value and needs to be evaluated. If the evaluation - succeeds, the feature is included. - \row \o \c {-no-declarative-debug} \o Do not build the declarative debugging - support \o - \row \o \c {-declarative-debug} \o Build the declarative debugging support - \o Default value. - \row \o \c {-arch } \o Specify an architecture. \o Available values for - : * windows, windowsce, symbian, boundschecker, generic. - \row \o \c {-no-style-