Gui: Prevent crash when trying to access a deleted object from a SelectionObject
This commit is contained in:
committed by
abdullahtahiriyo
parent
94405e33c7
commit
1bfd7644b2
@@ -56,7 +56,7 @@
|
||||
</Attribute>
|
||||
<Attribute Name="Document" ReadOnly="true">
|
||||
<Documentation>
|
||||
<UserDocu>Selected document</UserDocu>
|
||||
<UserDocu>Document of the selected object</UserDocu>
|
||||
</Documentation>
|
||||
<Parameter Name="Document" Type="Object" />
|
||||
</Attribute>
|
||||
|
||||
@@ -100,12 +100,18 @@ Py::String SelectionObjectPy::getDocumentName(void) const
|
||||
|
||||
Py::Object SelectionObjectPy::getDocument(void) const
|
||||
{
|
||||
return Py::Object(getSelectionObjectPtr()->getObject()->getDocument()->getPyObject(), true);
|
||||
App::DocumentObject *obj = getSelectionObjectPtr()->getObject();
|
||||
if (!obj)
|
||||
throw Py::RuntimeError("Cannot get document of deleted object");
|
||||
return Py::Object(obj->getDocument()->getPyObject(), true);
|
||||
}
|
||||
|
||||
Py::Object SelectionObjectPy::getObject(void) const
|
||||
{
|
||||
return Py::Object(getSelectionObjectPtr()->getObject()->getPyObject(), true);
|
||||
App::DocumentObject *obj = getSelectionObjectPtr()->getObject();
|
||||
if (!obj)
|
||||
throw Py::RuntimeError("Object already deleted");
|
||||
return Py::Object(obj->getPyObject(), true);
|
||||
}
|
||||
|
||||
Py::Tuple SelectionObjectPy::getSubObjects(void) const
|
||||
|
||||
Reference in New Issue
Block a user