forked from qt-creator/qt-creator
QmlJSInspector: Check for null pointers
Change-Id: I8d99b109909e596ead2e674eff0de576b2dca411 Reviewed-by: Christiaan Janssen <christiaan.janssen@nokia.com>
This commit is contained in:
@@ -174,6 +174,7 @@ void QmlInspectorAdapter::clientStatusChanged(QmlDebug::ClientStatus status)
|
|||||||
void QmlInspectorAdapter::toolsClientStatusChanged(QmlDebug::ClientStatus status)
|
void QmlInspectorAdapter::toolsClientStatusChanged(QmlDebug::ClientStatus status)
|
||||||
{
|
{
|
||||||
BaseToolsClient *client = qobject_cast<BaseToolsClient*>(sender());
|
BaseToolsClient *client = qobject_cast<BaseToolsClient*>(sender());
|
||||||
|
QTC_ASSERT(client, return);
|
||||||
if (status == QmlDebug::Enabled) {
|
if (status == QmlDebug::Enabled) {
|
||||||
m_toolsClient = client;
|
m_toolsClient = client;
|
||||||
|
|
||||||
@@ -212,8 +213,7 @@ void QmlInspectorAdapter::toolsClientStatusChanged(QmlDebug::ClientStatus status
|
|||||||
m_toolsClient->showAppOnTop(true);
|
m_toolsClient->showAppOnTop(true);
|
||||||
|
|
||||||
m_toolsClientConnected = true;
|
m_toolsClientConnected = true;
|
||||||
} else if (m_toolsClientConnected
|
} else if (m_toolsClientConnected && client == m_toolsClient) {
|
||||||
&& client == m_toolsClient) {
|
|
||||||
disconnect(client, SIGNAL(currentObjectsChanged(QList<int>)),
|
disconnect(client, SIGNAL(currentObjectsChanged(QList<int>)),
|
||||||
this, SLOT(selectObjectsFromToolsClient(QList<int>)));
|
this, SLOT(selectObjectsFromToolsClient(QList<int>)));
|
||||||
disconnect(client, SIGNAL(logActivity(QString,QString)),
|
disconnect(client, SIGNAL(logActivity(QString,QString)),
|
||||||
@@ -246,8 +246,7 @@ void QmlInspectorAdapter::engineClientStatusChanged(QmlDebug::ClientStatus statu
|
|||||||
if (status == QmlDebug::Enabled) {
|
if (status == QmlDebug::Enabled) {
|
||||||
QTC_ASSERT(client, return);
|
QTC_ASSERT(client, return);
|
||||||
setActiveEngineClient(client);
|
setActiveEngineClient(client);
|
||||||
} else if (m_engineClientConnected &&
|
} else if (m_engineClientConnected && client == m_engineClient) {
|
||||||
(client == m_engineClient)) {
|
|
||||||
m_engineClientConnected = false;
|
m_engineClientConnected = false;
|
||||||
deletePreviews();
|
deletePreviews();
|
||||||
}
|
}
|
||||||
@@ -367,6 +366,7 @@ void QmlInspectorAdapter::updatePendingPreviewDocuments(QmlJS::Document::Ptr doc
|
|||||||
|
|
||||||
void QmlInspectorAdapter::onSelectActionTriggered(bool checked)
|
void QmlInspectorAdapter::onSelectActionTriggered(bool checked)
|
||||||
{
|
{
|
||||||
|
QTC_ASSERT(toolsClient(), return);
|
||||||
if (checked) {
|
if (checked) {
|
||||||
toolsClient()->setDesignModeBehavior(true);
|
toolsClient()->setDesignModeBehavior(true);
|
||||||
toolsClient()->changeToSelectTool();
|
toolsClient()->changeToSelectTool();
|
||||||
@@ -378,6 +378,7 @@ void QmlInspectorAdapter::onSelectActionTriggered(bool checked)
|
|||||||
|
|
||||||
void QmlInspectorAdapter::onZoomActionTriggered(bool checked)
|
void QmlInspectorAdapter::onZoomActionTriggered(bool checked)
|
||||||
{
|
{
|
||||||
|
QTC_ASSERT(toolsClient(), return);
|
||||||
if (checked) {
|
if (checked) {
|
||||||
toolsClient()->setDesignModeBehavior(true);
|
toolsClient()->setDesignModeBehavior(true);
|
||||||
toolsClient()->changeToZoomTool();
|
toolsClient()->changeToZoomTool();
|
||||||
@@ -390,7 +391,7 @@ void QmlInspectorAdapter::onZoomActionTriggered(bool checked)
|
|||||||
void QmlInspectorAdapter::onShowAppOnTopChanged(const QVariant &value)
|
void QmlInspectorAdapter::onShowAppOnTopChanged(const QVariant &value)
|
||||||
{
|
{
|
||||||
bool showAppOnTop = value.toBool();
|
bool showAppOnTop = value.toBool();
|
||||||
if (m_toolsClient->status() == QmlDebug::Enabled)
|
if (m_toolsClient && m_toolsClient->status() == QmlDebug::Enabled)
|
||||||
m_toolsClient->showAppOnTop(showAppOnTop);
|
m_toolsClient->showAppOnTop(showAppOnTop);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -487,7 +488,7 @@ void QmlInspectorAdapter::gotoObjectReferenceDefinition(
|
|||||||
void QmlInspectorAdapter::selectObject(const ObjectReference &obj,
|
void QmlInspectorAdapter::selectObject(const ObjectReference &obj,
|
||||||
SelectionTarget target)
|
SelectionTarget target)
|
||||||
{
|
{
|
||||||
if (target == ToolTarget)
|
if (m_toolsClient && target == ToolTarget)
|
||||||
m_toolsClient->setObjectIdList(
|
m_toolsClient->setObjectIdList(
|
||||||
QList<ObjectReference>() << obj);
|
QList<ObjectReference>() << obj);
|
||||||
|
|
||||||
@@ -525,7 +526,8 @@ void QmlInspectorAdapter::onReload()
|
|||||||
fileContents);
|
fileContents);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m_toolsClient->reload(changesHash);
|
if (m_toolsClient)
|
||||||
|
m_toolsClient->reload(changesHash);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlInspectorAdapter::onReloaded()
|
void QmlInspectorAdapter::onReloaded()
|
||||||
|
@@ -189,8 +189,9 @@ protected:
|
|||||||
Q_UNUSED(scriptBinding);
|
Q_UNUSED(scriptBinding);
|
||||||
Q_UNUSED(parentDefinition);
|
Q_UNUSED(parentDefinition);
|
||||||
appliedChangesToViewer = true;
|
appliedChangesToViewer = true;
|
||||||
m_inspectorAdapter->engineClient()->setMethodBody(debugId,
|
if (m_inspectorAdapter->engineClient())
|
||||||
methodName, methodBody);
|
m_inspectorAdapter->engineClient()->setMethodBody(debugId,
|
||||||
|
methodName, methodBody);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void updateScriptBinding(DebugId debugId,
|
virtual void updateScriptBinding(DebugId debugId,
|
||||||
@@ -217,22 +218,25 @@ protected:
|
|||||||
if (isLiteral)
|
if (isLiteral)
|
||||||
expr = castToLiteral(scriptCode, scriptBinding);
|
expr = castToLiteral(scriptCode, scriptBinding);
|
||||||
appliedChangesToViewer = true;
|
appliedChangesToViewer = true;
|
||||||
m_inspectorAdapter->engineClient()->setBindingForObject(
|
if (m_inspectorAdapter->engineClient())
|
||||||
debugId, propertyName, expr,
|
m_inspectorAdapter->engineClient()->setBindingForObject(
|
||||||
isLiteral, document()->fileName(),
|
debugId, propertyName, expr,
|
||||||
scriptBinding->firstSourceLocation().startLine);
|
isLiteral, document()->fileName(),
|
||||||
|
scriptBinding->firstSourceLocation().startLine);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void resetBindingForObject(int debugId, const QString &propertyName)
|
virtual void resetBindingForObject(int debugId, const QString &propertyName)
|
||||||
{
|
{
|
||||||
appliedChangesToViewer = true;
|
appliedChangesToViewer = true;
|
||||||
m_inspectorAdapter->engineClient()->resetBindingForObject(debugId, propertyName);
|
if (m_inspectorAdapter->engineClient())
|
||||||
|
m_inspectorAdapter->engineClient()->resetBindingForObject(debugId, propertyName);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void removeObject(int debugId)
|
virtual void removeObject(int debugId)
|
||||||
{
|
{
|
||||||
appliedChangesToViewer = true;
|
appliedChangesToViewer = true;
|
||||||
m_inspectorAdapter->toolsClient()->destroyQmlObject(debugId);
|
if (m_inspectorAdapter->toolsClient())
|
||||||
|
m_inspectorAdapter->toolsClient()->destroyQmlObject(debugId);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void createObject(const QString &qmlText, DebugId ref,
|
virtual void createObject(const QString &qmlText, DebugId ref,
|
||||||
@@ -242,13 +246,15 @@ protected:
|
|||||||
{
|
{
|
||||||
appliedChangesToViewer = true;
|
appliedChangesToViewer = true;
|
||||||
referenceRefreshRequired = true;
|
referenceRefreshRequired = true;
|
||||||
m_inspectorAdapter->toolsClient()->createQmlObject(qmlText, ref, importList, filename, order);
|
if (m_inspectorAdapter->toolsClient())
|
||||||
|
m_inspectorAdapter->toolsClient()->createQmlObject(qmlText, ref, importList, filename, order);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void reparentObject(int debugId, int newParent)
|
virtual void reparentObject(int debugId, int newParent)
|
||||||
{
|
{
|
||||||
appliedChangesToViewer = true;
|
appliedChangesToViewer = true;
|
||||||
m_inspectorAdapter->toolsClient()->reparentQmlObject(debugId, newParent);
|
if (m_inspectorAdapter->toolsClient())
|
||||||
|
m_inspectorAdapter->toolsClient()->reparentQmlObject(debugId, newParent);
|
||||||
}
|
}
|
||||||
|
|
||||||
void notifyUnsyncronizableElementChange(UiObjectMember *parent)
|
void notifyUnsyncronizableElementChange(UiObjectMember *parent)
|
||||||
@@ -617,8 +623,8 @@ void QmlLiveTextPreview::documentChanged(QmlJS::Document::Ptr doc)
|
|||||||
m_previousDoc = doc;
|
m_previousDoc = doc;
|
||||||
if (!delta.newObjects.isEmpty())
|
if (!delta.newObjects.isEmpty())
|
||||||
m_createdObjects[doc] += delta.newObjects;
|
m_createdObjects[doc] += delta.newObjects;
|
||||||
|
if (m_inspectorAdapter->toolsClient())
|
||||||
m_inspectorAdapter->toolsClient()->clearComponentCache();
|
m_inspectorAdapter->toolsClient()->clearComponentCache();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -697,7 +703,8 @@ void QmlLiveTextPreview::showSyncWarning(
|
|||||||
if (editor) {
|
if (editor) {
|
||||||
Core::InfoBar *infoBar = editor->editorDocument()->infoBar();
|
Core::InfoBar *infoBar = editor->editorDocument()->infoBar();
|
||||||
Core::InfoBarEntry info(INFO_OUT_OF_SYNC, errorMessage);
|
Core::InfoBarEntry info(INFO_OUT_OF_SYNC, errorMessage);
|
||||||
if (m_inspectorAdapter->toolsClient()->supportReload())
|
BaseToolsClient *toolsClient = m_inspectorAdapter->toolsClient();
|
||||||
|
if (toolsClient && toolsClient->supportReload())
|
||||||
info.setCustomButtonInfo(tr("Reload QML"), this,
|
info.setCustomButtonInfo(tr("Reload QML"), this,
|
||||||
SLOT(reloadQml()));
|
SLOT(reloadQml()));
|
||||||
infoBar->addInfo(info);
|
infoBar->addInfo(info);
|
||||||
|
Reference in New Issue
Block a user