when accessing view provider of object make sure the object hasn't been removed from the document, raise an exception otherwise

This commit is contained in:
wmayer
2017-09-12 16:28:31 +02:00
parent be6b8dcd40
commit b08c939f43

View File

@@ -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;
}