From b08c939f43ea0471ebb1546204daf8954d80fc8e Mon Sep 17 00:00:00 2001 From: wmayer Date: Tue, 12 Sep 2017 16:28:31 +0200 Subject: [PATCH] when accessing view provider of object make sure the object hasn't been removed from the document, raise an exception otherwise --- src/App/DocumentObjectPyImp.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/App/DocumentObjectPyImp.cpp b/src/App/DocumentObjectPyImp.cpp index 2c984643fe..42013879e3 100644 --- a/src/App/DocumentObjectPyImp.cpp +++ b/src/App/DocumentObjectPyImp.cpp @@ -189,7 +189,12 @@ Py::Object DocumentObjectPy::getViewObject(void) const arg.setItem(0, Py::String(getDocumentObjectPtr()->getDocument()->getName())); Py::Object doc = method.apply(arg); method = doc.getAttr("getObject"); - arg.setItem(0, Py::String(getDocumentObjectPtr()->getNameInDocument())); + const char* internalName = getDocumentObjectPtr()->getNameInDocument(); + if (!internalName) { + throw Py::RuntimeError("Object has been removed from document"); + } + + arg.setItem(0, Py::String(internalName)); Py::Object obj = method.apply(arg); return obj; }