Commit 719b7757 authored by Lasse Holmstedt's avatar Lasse Holmstedt
Browse files

QML JS Inspector: Added method to clear component cache

This one should be called when a component is changed and components
using it need to be reloaded.
parent cc0050bb
......@@ -91,6 +91,7 @@ Q_SIGNALS:
void animationSpeedChangeRequested(qreal speedFactor);
void contextPathIndexChanged(int contextPathIndex);
void clearComponentCacheRequested();
protected:
virtual void messageReceived(const QByteArray &);
......
......@@ -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<QDeclarativeDesignViewPrivate> data;
......
......@@ -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();
}
}
......
......@@ -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();
......
......@@ -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(); }
};
......
......@@ -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)
{
......
......@@ -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<QDeclarativeDebugObjectReference> objectReferences(const QUrl &url = QUrl()) const;
......
......@@ -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())
......
......@@ -76,6 +76,7 @@ public:
void setObjectIdList(const QList<QDeclarativeDebugObjectReference> &objectRoots);
void setContextPathIndex(int contextPathIndex);
void clearComponentCache();
signals:
void currentObjectsChanged(const QList<int> &debugIds);
......
......@@ -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;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment