Commit efb1b7fc authored by Aurindam Jana's avatar Aurindam Jana

QmlJSInspector: Check for null pointers

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