fixes #0003424: 'basic_string::_M_construct null not valid' when opening a v0.16 project with v0.17

This commit is contained in:
wmayer
2018-04-10 10:51:34 +02:00
parent 0258808ccb
commit aa0f6b54d4
2 changed files with 30 additions and 18 deletions

View File

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

View File

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