diff --git a/src/libs/qmljsdebugger/include/qdeclarativedesigndebugserver.h b/src/libs/qmljsdebugger/include/qdeclarativedesigndebugserver.h index ac35f143d88..f93508194ac 100644 --- a/src/libs/qmljsdebugger/include/qdeclarativedesigndebugserver.h +++ b/src/libs/qmljsdebugger/include/qdeclarativedesigndebugserver.h @@ -91,6 +91,7 @@ Q_SIGNALS: void animationSpeedChangeRequested(qreal speedFactor); void contextPathIndexChanged(int contextPathIndex); + void clearComponentCacheRequested(); protected: virtual void messageReceived(const QByteArray &); diff --git a/src/libs/qmljsdebugger/include/qdeclarativedesignview.h b/src/libs/qmljsdebugger/include/qdeclarativedesignview.h index 6bfc5a4578a..2f0e7b6e3d4 100644 --- a/src/libs/qmljsdebugger/include/qdeclarativedesignview.h +++ b/src/libs/qmljsdebugger/include/qdeclarativedesignview.h @@ -108,6 +108,7 @@ private: Q_PRIVATE_SLOT(d_func(), void _q_changeToZoomTool()) Q_PRIVATE_SLOT(d_func(), void _q_changeToColorPickerTool()) Q_PRIVATE_SLOT(d_func(), void _q_changeContextPathIndex(int index)) + Q_PRIVATE_SLOT(d_func(), void _q_clearComponentCache()); inline QDeclarativeDesignViewPrivate *d_func() { return data.data(); } QScopedPointer data; diff --git a/src/libs/qmljsdebugger/qdeclarativedesigndebugserver.cpp b/src/libs/qmljsdebugger/qdeclarativedesigndebugserver.cpp index 8be445394c8..dc20ae1bed1 100644 --- a/src/libs/qmljsdebugger/qdeclarativedesigndebugserver.cpp +++ b/src/libs/qmljsdebugger/qdeclarativedesigndebugserver.cpp @@ -83,6 +83,8 @@ void QDeclarativeDesignDebugServer::messageReceived(const QByteArray &message) int contextPathIndex; ds >> contextPathIndex; emit contextPathIndexChanged(contextPathIndex); + } else if (type == "CLEAR_COMPONENT_CACHE") { + emit clearComponentCacheRequested(); } } diff --git a/src/libs/qmljsdebugger/qdeclarativedesignview.cpp b/src/libs/qmljsdebugger/qdeclarativedesignview.cpp index 14eb40ebfb3..80c6140e8cb 100644 --- a/src/libs/qmljsdebugger/qdeclarativedesignview.cpp +++ b/src/libs/qmljsdebugger/qdeclarativedesignview.cpp @@ -95,6 +95,7 @@ QDeclarativeDesignView::QDeclarativeDesignView(QWidget *parent) : SIGNAL(objectCreationRequested(QString,QObject*,QStringList,QString)), SLOT(_q_createQmlObject(QString,QObject*,QStringList,QString))); connect(qmlDesignDebugServer(), SIGNAL(contextPathIndexChanged(int)), SLOT(_q_changeContextPathIndex(int))); + connect(qmlDesignDebugServer(), SIGNAL(clearComponentCacheRequested()), SLOT(_q_clearComponentCache())); connect(this, SIGNAL(statusChanged(QDeclarativeView::Status)), SLOT(_q_onStatusChanged(QDeclarativeView::Status))); connect(data->colorPickerTool, SIGNAL(selectedColorChanged(QColor)), SIGNAL(selectedColorChanged(QColor))); @@ -268,6 +269,11 @@ void QDeclarativeDesignViewPrivate::_q_createQmlObject(const QString &qml, QObje } } +void QDeclarativeDesignViewPrivate::_q_clearComponentCache() +{ + q->engine()->clearComponentCache(); +} + QGraphicsItem *QDeclarativeDesignViewPrivate::currentRootItem() const { return subcomponentEditorTool->currentRootItem(); diff --git a/src/libs/qmljsdebugger/qdeclarativedesignview_p.h b/src/libs/qmljsdebugger/qdeclarativedesignview_p.h index ca34d634d65..9ff33421f71 100644 --- a/src/libs/qmljsdebugger/qdeclarativedesignview_p.h +++ b/src/libs/qmljsdebugger/qdeclarativedesignview_p.h @@ -123,6 +123,7 @@ public: void _q_changeToZoomTool(); void _q_changeToColorPickerTool(); void _q_changeContextPathIndex(int index); + void _q_clearComponentCache(); static QDeclarativeDesignViewPrivate *get(QDeclarativeDesignView *v) { return v->d_func(); } }; diff --git a/src/plugins/qmljsinspector/qmljsclientproxy.cpp b/src/plugins/qmljsinspector/qmljsclientproxy.cpp index e7d7bfb9fee..5eb0f38f4dd 100644 --- a/src/plugins/qmljsinspector/qmljsclientproxy.cpp +++ b/src/plugins/qmljsinspector/qmljsclientproxy.cpp @@ -321,7 +321,9 @@ bool ClientProxy::setBindingForObject(int objectDebugId, if (propertyName == QLatin1String("id")) return false; // Crashes the QMLViewer. - return m_client->setBindingForObject(objectDebugId, propertyName, value.toString(), isLiteralValue); + bool result = m_client->setBindingForObject(objectDebugId, propertyName, value.toString(), isLiteralValue); + + return result; } bool ClientProxy::setMethodBodyForObject(int objectDebugId, const QString &methodName, const QString &methodBody) @@ -341,6 +343,11 @@ bool ClientProxy::resetBindingForObject(int objectDebugId, const QString& proper return m_client->resetBindingForObject(objectDebugId, propertyName); } +void ClientProxy::clearComponentCache() +{ + if (isDesignClientConnected()) + m_designClient->clearComponentCache(); +} void ClientProxy::queryEngineContext(int id) { diff --git a/src/plugins/qmljsinspector/qmljsclientproxy.h b/src/plugins/qmljsinspector/qmljsclientproxy.h index 8575376a3e1..83803c73375 100644 --- a/src/plugins/qmljsinspector/qmljsclientproxy.h +++ b/src/plugins/qmljsinspector/qmljsclientproxy.h @@ -55,6 +55,7 @@ public: bool setMethodBodyForObject(int objectDebugId, const QString &methodName, const QString &methodBody); bool resetBindingForObject(int objectDebugId, const QString &propertyName); + void clearComponentCache(); // returns the object references for the given url. QList objectReferences(const QUrl &url = QUrl()) const; diff --git a/src/plugins/qmljsinspector/qmljsdesigndebugclient.cpp b/src/plugins/qmljsinspector/qmljsdesigndebugclient.cpp index 1e881722a7f..5bc160b5200 100644 --- a/src/plugins/qmljsinspector/qmljsdesigndebugclient.cpp +++ b/src/plugins/qmljsinspector/qmljsdesigndebugclient.cpp @@ -180,6 +180,18 @@ void QmlJSDesignDebugClient::setContextPathIndex(int contextPathIndex) sendMessage(message); } +void QmlJSDesignDebugClient::clearComponentCache() +{ + if (!m_connection || !m_connection->isConnected()) + return; + + QByteArray message; + QDataStream ds(&message, QIODevice::WriteOnly); + + ds << QByteArray("CLEAR_COMPONENT_CACHE"); + sendMessage(message); +} + void QmlJSDesignDebugClient::reloadViewer() { if (!m_connection || !m_connection->isConnected()) diff --git a/src/plugins/qmljsinspector/qmljsdesigndebugclient.h b/src/plugins/qmljsinspector/qmljsdesigndebugclient.h index abc432915fb..406495844bd 100644 --- a/src/plugins/qmljsinspector/qmljsdesigndebugclient.h +++ b/src/plugins/qmljsinspector/qmljsdesigndebugclient.h @@ -76,6 +76,7 @@ public: void setObjectIdList(const QList &objectRoots); void setContextPathIndex(int contextPathIndex); + void clearComponentCache(); signals: void currentObjectsChanged(const QList &debugIds); diff --git a/src/plugins/qmljsinspector/qmljslivetextpreview.cpp b/src/plugins/qmljsinspector/qmljslivetextpreview.cpp index 802d54c5545..1f8318c167b 100644 --- a/src/plugins/qmljsinspector/qmljslivetextpreview.cpp +++ b/src/plugins/qmljsinspector/qmljslivetextpreview.cpp @@ -429,7 +429,7 @@ protected: ClientProxy::instance()->setMethodBodyForObject(debugId, methodName, methodBody); } -virtual void updateScriptBinding(DebugId debugId, UiScriptBinding* scriptBinding, + virtual void updateScriptBinding(DebugId debugId, UiScriptBinding* scriptBinding, const QString& propertyName, const QString& scriptCode) { if (propertyName == QLatin1String("id") && !hasUnsyncronizableChanges) { @@ -508,6 +508,8 @@ void QmlJSLiveTextPreview::documentChanged(QmlJS::Document::Ptr doc) m_previousDoc = doc; if (!delta.newObjects.isEmpty()) m_createdObjects[doc] += delta.newObjects; + + ClientProxy::instance()->clearComponentCache(); } } else { m_docWithUnappliedChanges = doc;