diff --git a/src/Mod/TechDraw/App/DrawTemplatePyImp.cpp b/src/Mod/TechDraw/App/DrawTemplatePyImp.cpp index 8a1ded684d..0b8e52e391 100644 --- a/src/Mod/TechDraw/App/DrawTemplatePyImp.cpp +++ b/src/Mod/TechDraw/App/DrawTemplatePyImp.cpp @@ -49,18 +49,18 @@ int DrawTemplatePy::setCustomAttributes(const char* attr, PyObject* obj) { // search in PropertyList App::Property *prop = getDrawTemplatePtr()->getPropertyByName(attr); - if (prop) { - // Read-only attributes must not be set over its Python interface - short Type = getDrawTemplatePtr()->getPropertyType(prop); - if (Type & App::Prop_ReadOnly) { - std::stringstream s; - s << "Object attribute '" << attr << "' is read-only"; - throw Py::AttributeError(s.str()); - } - - prop->setPyObject(obj); - return 1; + if (!prop) { + return 0; } - return 0; + // Read-only attributes must not be set over its Python interface + short Type = getDrawTemplatePtr()->getPropertyType(prop); + if (Type & App::Prop_ReadOnly) { + std::stringstream s; + s << "Object attribute '" << attr << "' is read-only"; + throw Py::AttributeError(s.str()); + } + + prop->setPyObject(obj); + return 1; }