From 3f2264dc4d1230643b422f609cbaad5fcaee850e Mon Sep 17 00:00:00 2001 From: wmayer Date: Thu, 8 Sep 2016 16:08:01 +0200 Subject: [PATCH] fix regression with unicode support --- src/App/FeaturePythonPyImp.inl | 7 +++++-- src/Gui/ViewProviderPythonFeaturePyImp.cpp | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/App/FeaturePythonPyImp.inl b/src/App/FeaturePythonPyImp.inl index e280a13ba7..af076e56a3 100644 --- a/src/App/FeaturePythonPyImp.inl +++ b/src/App/FeaturePythonPyImp.inl @@ -330,13 +330,16 @@ PyObject* FeaturePythonPyT::addProperty(PyObject *args) { char *sType,*sName=0,*sGroup=0,*sDoc=0; short attr=0; + std::string sDocStr; PyObject *ro = Py_False, *hd = Py_False; if (!PyArg_ParseTuple(args, "s|ssethO!O!", &sType,&sName,&sGroup,"utf-8",&sDoc,&attr, &PyBool_Type, &ro, &PyBool_Type, &hd)) // convert args: Python->C return NULL; // NULL triggers exception - std::string sDocStr = std::string(sDoc); - PyMem_Free(sDoc); + if (sDoc) { + sDocStr = sDoc; + PyMem_Free(sDoc); + } Property* prop=0; prop = FeaturePyT::getDocumentObjectPtr()->addDynamicProperty(sType,sName,sGroup,sDocStr.c_str(),attr, diff --git a/src/Gui/ViewProviderPythonFeaturePyImp.cpp b/src/Gui/ViewProviderPythonFeaturePyImp.cpp index d8697ae294..2bbbdbbc45 100644 --- a/src/Gui/ViewProviderPythonFeaturePyImp.cpp +++ b/src/Gui/ViewProviderPythonFeaturePyImp.cpp @@ -67,13 +67,16 @@ PyObject* ViewProviderPythonFeaturePy::addProperty(PyObject *args) { char *sType,*sName=0,*sGroup=0,*sDoc=0; short attr=0; + std::string sDocStr; PyObject *ro = Py_False, *hd = Py_False; if (!PyArg_ParseTuple(args, "s|ssethO!O!", &sType,&sName,&sGroup,"utf-8",&sDoc,&attr, &PyBool_Type, &ro, &PyBool_Type, &hd)) // convert args: Python->C return NULL; // NULL triggers exception - std::string sDocStr = std::string(sDoc); - PyMem_Free(sDoc); + if (sDoc) { + sDocStr = sDoc; + PyMem_Free(sDoc); + } App::Property* prop=0; prop = getViewProviderPythonFeaturePtr()->addDynamicProperty(sType,sName,sGroup,sDocStr.c_str(),attr,