forked from qt-creator/qt-creator
QmlDesigner: Fix crash on mode change
Added model pointer validity checks into a few places. Fixes: QDS-7191 Change-Id: I94beb134f4d9a0b1c7fc9dc87da1d02ad255beaa Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
committed by
Thomas Hartmann
parent
21ef02a016
commit
c97d056334
@@ -290,6 +290,8 @@ void MaterialBrowserView::instancesCompleted(const QVector<ModelNode> &completed
|
||||
if (node.isRootNode()) {
|
||||
m_puppetResetPending = false;
|
||||
QTimer::singleShot(1000, this, [this]() {
|
||||
if (!model() || !model()->nodeInstanceView())
|
||||
return;
|
||||
const QList<ModelNode> materials = m_widget->materialBrowserModel()->materials();
|
||||
for (const ModelNode &node : materials)
|
||||
model()->nodeInstanceView()->previewImageDataForGenericNode(node, {});
|
||||
|
@@ -416,6 +416,8 @@ void MaterialEditorView::handleToolBarAction(int action)
|
||||
}
|
||||
|
||||
case MaterialEditorContextObject::AddNewMaterial: {
|
||||
if (!model())
|
||||
break;
|
||||
executeInTransaction("MaterialEditorView:handleToolBarAction", [&] {
|
||||
NodeMetaInfo metaInfo = model()->metaInfo("QtQuick3D.DefaultMaterial");
|
||||
ModelNode newMatNode = createModelNode("QtQuick3D.DefaultMaterial", metaInfo.majorVersion(),
|
||||
@@ -634,7 +636,7 @@ void MaterialEditorView::auxiliaryDataChanged(const ModelNode &node, const Prope
|
||||
// request render image for the selected material node
|
||||
void MaterialEditorView::requestPreviewRender()
|
||||
{
|
||||
if (m_selectedMaterial.isValid())
|
||||
if (model() && model()->nodeInstanceView() && m_selectedMaterial.isValid())
|
||||
model()->nodeInstanceView()->previewImageDataForGenericNode(m_selectedMaterial, {});
|
||||
}
|
||||
|
||||
@@ -740,6 +742,9 @@ void MaterialEditorView::duplicateMaterial(const ModelNode &material)
|
||||
{
|
||||
QTC_ASSERT(material.isValid(), return);
|
||||
|
||||
if (!model())
|
||||
return;
|
||||
|
||||
TypeName matType = material.type();
|
||||
QmlObjectNode sourceMat(material);
|
||||
|
||||
|
Reference in New Issue
Block a user