diff --git a/src/App/FeaturePython.cpp b/src/App/FeaturePython.cpp index 0a90b43a06..9d04fecad3 100644 --- a/src/App/FeaturePython.cpp +++ b/src/App/FeaturePython.cpp @@ -108,17 +108,21 @@ void FeaturePythonImp::onBeforeChange(const Property* prop) if (feature.hasAttr("__object__")) { Py::Callable method(feature.getAttr(std::string("onBeforeChange"))); Py::Tuple args(1); - std::string prop_name = object->getPropertyName(prop); - args.setItem(0, Py::String(prop_name)); - method.apply(args); + const char* prop_name = object->getPropertyName(prop); + if (prop_name) { + args.setItem(0, Py::String(prop_name)); + method.apply(args); + } } else { Py::Callable method(feature.getAttr(std::string("onBeforeChange"))); Py::Tuple args(2); args.setItem(0, Py::Object(object->getPyObject(), true)); - std::string prop_name = object->getPropertyName(prop); - args.setItem(1, Py::String(prop_name)); - method.apply(args); + const char* prop_name = object->getPropertyName(prop); + if (prop_name) { + args.setItem(1, Py::String(prop_name)); + method.apply(args); + } } } } @@ -141,17 +145,21 @@ void FeaturePythonImp::onChanged(const Property* prop) if (feature.hasAttr("__object__")) { Py::Callable method(feature.getAttr(std::string("onChanged"))); Py::Tuple args(1); - std::string prop_name = object->getPropertyName(prop); - args.setItem(0, Py::String(prop_name)); - method.apply(args); + const char* prop_name = object->getPropertyName(prop); + if (prop_name) { + args.setItem(0, Py::String(prop_name)); + method.apply(args); + } } else { Py::Callable method(feature.getAttr(std::string("onChanged"))); Py::Tuple args(2); args.setItem(0, Py::Object(object->getPyObject(), true)); - std::string prop_name = object->getPropertyName(prop); - args.setItem(1, Py::String(prop_name)); - method.apply(args); + const char* prop_name = object->getPropertyName(prop); + if (prop_name) { + args.setItem(1, Py::String(prop_name)); + method.apply(args); + } } } } diff --git a/src/Gui/ViewProviderPythonFeature.cpp b/src/Gui/ViewProviderPythonFeature.cpp index 9275570685..2fe1c4fd1a 100644 --- a/src/Gui/ViewProviderPythonFeature.cpp +++ b/src/Gui/ViewProviderPythonFeature.cpp @@ -643,17 +643,21 @@ void ViewProviderPythonFeatureImp::onChanged(const App::Property* prop) if (vp.hasAttr("__object__")) { Py::Callable method(vp.getAttr(std::string("onChanged"))); Py::Tuple args(1); - std::string prop_name = object->getPropertyName(prop); - args.setItem(0, Py::String(prop_name)); - method.apply(args); + const char* prop_name = object->getPropertyName(prop); + if (prop_name) { + args.setItem(0, Py::String(prop_name)); + method.apply(args); + } } else { Py::Callable method(vp.getAttr(std::string("onChanged"))); Py::Tuple args(2); args.setItem(0, Py::Object(object->getPyObject(), true)); - std::string prop_name = object->getPropertyName(prop); - args.setItem(1, Py::String(prop_name)); - method.apply(args); + const char* prop_name = object->getPropertyName(prop); + if (prop_name) { + args.setItem(1, Py::String(prop_name)); + method.apply(args); + } } } }