From aa0f6b54d497eb810cc2774fa01ac0bb0408541a Mon Sep 17 00:00:00 2001 From: wmayer Date: Tue, 10 Apr 2018 10:51:34 +0200 Subject: [PATCH] fixes #0003424: 'basic_string::_M_construct null not valid' when opening a v0.16 project with v0.17 --- src/App/FeaturePython.cpp | 32 +++++++++++++++++---------- src/Gui/ViewProviderPythonFeature.cpp | 16 +++++++++----- 2 files changed, 30 insertions(+), 18 deletions(-) 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); + } } } }