From 4b5eeb351f1bf2e6dc1a73135501bbe8d2dcd8cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Br=C3=A6strup=20Sayoc?= Date: Wed, 5 Apr 2023 16:20:26 +0200 Subject: [PATCH] [TechDraw] Improve readability of DrawTemplatePyImp.cpp --- src/Mod/TechDraw/App/DrawTemplatePyImp.cpp | 24 +++++++++++----------- 1 file changed, 12 insertions(+), 12 deletions(-) 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; }