summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaj Grönholm <kaj.gronholm@qt.io>2019-04-26 16:44:11 +0300
committerKaj Grönholm <kaj.gronholm@qt.io>2019-04-29 06:41:14 +0000
commit34948f16dab26d876635f46842244f9ff54f5912 (patch)
tree71cf49d12f2bc84fb8b1d4b8da207129e458baac
parent8b609a797b84ef1ecf6d7f98fea51b911ba3f0ea (diff)
Check inspector instances remain valid
Deleting slide makes instance not valid causing a crash. So continue checking runtime validity. Also fix null checking typo. Task-number: QT3DS-3344 Change-Id: I7d08a93212aeb59d3a3850ce6941172abf88ae75 Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io> Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io>
-rw-r--r--src/Authoring/Studio/Application/StudioApp.cpp4
-rw-r--r--src/Authoring/Studio/Palettes/Inspector/Qt3DSDMInspectable.cpp9
-rw-r--r--src/Authoring/Studio/Palettes/Inspector/Qt3DSDMInspectable.h2
3 files changed, 12 insertions, 3 deletions
diff --git a/src/Authoring/Studio/Application/StudioApp.cpp b/src/Authoring/Studio/Application/StudioApp.cpp
index 888865f4..f0965d50 100644
--- a/src/Authoring/Studio/Application/StudioApp.cpp
+++ b/src/Authoring/Studio/Application/StudioApp.cpp
@@ -1421,7 +1421,7 @@ CInspectableBase *CStudioApp::getInspectableFromInstance(qt3dsdm::Qt3DSDMInstanc
CInspectableBase *inspectableBase = nullptr;
CDoc *doc = m_core->GetDoc();
- if (m_core->GetDoc()->GetDocumentReader().IsInstance(inInstance)) {
+ if (doc->GetDocumentReader().IsInstance(inInstance)) {
CClientDataModelBridge *theBridge = doc->GetStudioSystem()->GetClientDataModelBridge();
qt3dsdm::Qt3DSDMSlideHandle activeSlide = doc->GetActiveSlide();
@@ -1432,7 +1432,7 @@ CInspectableBase *CStudioApp::getInspectableFromInstance(qt3dsdm::Qt3DSDMInstanc
inspectableBase = new Qt3DSDMInspectable(inInstance, activeSlideInstance);
}
- if (inspectableBase) {
+ if (!inspectableBase) {
if (theBridge->IsMaterialBaseInstance(inInstance))
inspectableBase = new Qt3DSDMMaterialInspectable(inInstance);
else
diff --git a/src/Authoring/Studio/Palettes/Inspector/Qt3DSDMInspectable.cpp b/src/Authoring/Studio/Palettes/Inspector/Qt3DSDMInspectable.cpp
index 866ed29e..a82df79c 100644
--- a/src/Authoring/Studio/Palettes/Inspector/Qt3DSDMInspectable.cpp
+++ b/src/Authoring/Studio/Palettes/Inspector/Qt3DSDMInspectable.cpp
@@ -188,6 +188,15 @@ EStudioObjectType Qt3DSDMInspectable::getObjectType() const
return getDoc()->GetStudioSystem()->GetClientDataModelBridge()->GetObjectType(m_instance);
}
+bool Qt3DSDMInspectable::isValid() const
+{
+ if (m_activeSlideInstance) {
+ return getDoc()->GetStudioSystem()->IsInstance(m_instance)
+ && getDoc()->GetStudioSystem()->IsInstance(m_activeSlideInstance);
+ }
+ return getDoc()->GetStudioSystem()->IsInstance(m_instance);
+}
+
bool Qt3DSDMInspectable::isMaster() const
{
ISlideSystem *slideSystem = getDoc()->GetStudioSystem()->GetSlideSystem();
diff --git a/src/Authoring/Studio/Palettes/Inspector/Qt3DSDMInspectable.h b/src/Authoring/Studio/Palettes/Inspector/Qt3DSDMInspectable.h
index 69aae6f5..0da2916d 100644
--- a/src/Authoring/Studio/Palettes/Inspector/Qt3DSDMInspectable.h
+++ b/src/Authoring/Studio/Palettes/Inspector/Qt3DSDMInspectable.h
@@ -46,7 +46,7 @@ public:
long getGroupCount() const override;
CInspectorGroup *getGroup(long) override;
EStudioObjectType getObjectType() const override;
- bool isValid() const override { return true; } // asserted in the constructor
+ bool isValid() const override;
bool isMaster() const override;
qt3dsdm::Qt3DSDMInstanceHandle getInstance() const override { return m_instance; }
virtual qt3dsdm::TMetaDataPropertyHandleList GetGroupProperties(long inGroupIndex);