Path: [skip ci] fix memory leak in CommandPy::getParameters()

For some background information see: https://forum.freecadweb.org/viewtopic.php?f=15&t=50583
This commit is contained in:
wmayer
2020-10-04 19:43:54 +02:00
parent 99b5aaf64e
commit 0cc65089c4

View File

@@ -157,15 +157,11 @@ void CommandPy::setName(Py::String arg)
Py::Dict CommandPy::getParameters(void) const
{
PyObject *dict = PyDict_New();
Py::Dict dict;
for(std::map<std::string,double>::iterator i = getCommandPtr()->Parameters.begin(); i != getCommandPtr()->Parameters.end(); ++i) {
#if PY_MAJOR_VERSION >= 3
PyDict_SetItem(dict,PyUnicode_FromString(i->first.c_str()),PyFloat_FromDouble(i->second));
#else
PyDict_SetItem(dict,PyString_FromString(i->first.c_str()),PyFloat_FromDouble(i->second));
#endif
dict.setItem(i->first, Py::Float(i->second));
}
return Py::Dict(dict);
return dict;
}
void CommandPy::setParameters(Py::Dict arg)