diff --git a/src/Mod/Sketcher/App/SketchObjectPyImp.cpp b/src/Mod/Sketcher/App/SketchObjectPyImp.cpp index 0d051431e..90fbdb1cf 100644 --- a/src/Mod/Sketcher/App/SketchObjectPyImp.cpp +++ b/src/Mod/Sketcher/App/SketchObjectPyImp.cpp @@ -318,10 +318,13 @@ PyObject* SketchObjectPy::delConstraint(PyObject *args) PyObject* SketchObjectPy::renameConstraint(PyObject *args) { int Index; - char* Name; - if (!PyArg_ParseTuple(args, "is", &Index, &Name)) + char* utf8Name; + if (!PyArg_ParseTuple(args, "iet", &Index, "utf-8", &utf8Name)) return 0; + std::string Name = utf8Name; + PyMem_Free(utf8Name); + if (this->getSketchObjectPtr()->Constraints.getSize() <= Index) { std::stringstream str; str << "Not able to rename a constraint with the given index: " << Index; @@ -329,7 +332,7 @@ PyObject* SketchObjectPy::renameConstraint(PyObject *args) return 0; } - if (strcmp(Name, "") != 0) { + if (!Name.empty()) { if (!Sketcher::PropertyConstraintList::validConstraintName(Name)) { std::stringstream str; diff --git a/src/Mod/Sketcher/Gui/CommandConstraints.cpp b/src/Mod/Sketcher/Gui/CommandConstraints.cpp index 39fc1d4f4..0175c311a 100644 --- a/src/Mod/Sketcher/Gui/CommandConstraints.cpp +++ b/src/Mod/Sketcher/Gui/CommandConstraints.cpp @@ -166,7 +166,7 @@ void openEditDatumDialog(Sketcher::SketchObject* sketch, int ConstrNbr) QString constraintName = ui_ins_datum.name->text().trimmed(); if (Base::Tools::toStdString(constraintName) != sketch->Constraints[ConstrNbr]->Name) { std::string escapedstr = Base::Tools::escapedUnicodeFromUtf8(constraintName.toUtf8().constData()); - Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.renameConstraint(%d, '%s')", + Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.renameConstraint(%d, u'%s')", sketch->getNameInDocument(), ConstrNbr, escapedstr.c_str()); } @@ -2442,7 +2442,7 @@ void CmdSketcherConstrainRadius::activated(int iMsg) QString constraintName = ui_Datum.name->text().trimmed(); if (Base::Tools::toStdString(constraintName) != Obj->Constraints[indexConstr]->Name) { std::string escapedstr = Base::Tools::escapedUnicodeFromUtf8(constraintName.toUtf8().constData()); - Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.renameConstraint(%d, '%s')", + Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.renameConstraint(%d, u'%s')", Obj->getNameInDocument(), indexConstr, escapedstr.c_str()); } diff --git a/src/Mod/Sketcher/Gui/EditDatumDialog.cpp b/src/Mod/Sketcher/Gui/EditDatumDialog.cpp index adc62d318..8b2bd2388 100644 --- a/src/Mod/Sketcher/Gui/EditDatumDialog.cpp +++ b/src/Mod/Sketcher/Gui/EditDatumDialog.cpp @@ -175,7 +175,7 @@ void EditDatumDialog::exec(bool atCursor) QString constraintName = ui_ins_datum.name->text().trimmed(); if (Base::Tools::toStdString(constraintName) != sketch->Constraints[ConstrNbr]->Name) { std::string escapedstr = Base::Tools::escapedUnicodeFromUtf8(constraintName.toUtf8().constData()); - Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.renameConstraint(%d, '%s')", + Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.renameConstraint(%d, u'%s')", sketch->getNameInDocument(), ConstrNbr, escapedstr.c_str()); } diff --git a/src/Mod/Sketcher/Gui/TaskSketcherConstrains.cpp b/src/Mod/Sketcher/Gui/TaskSketcherConstrains.cpp index e8667e1ab..684071967 100644 --- a/src/Mod/Sketcher/Gui/TaskSketcherConstrains.cpp +++ b/src/Mod/Sketcher/Gui/TaskSketcherConstrains.cpp @@ -477,13 +477,13 @@ void ConstraintView::swapNamedOfSelectedItems() std::string tmpname = ss.str(); Gui::Command::openCommand("Swap constraint names"); - Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.renameConstraint(%d, '%s')", + Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.renameConstraint(%d, u'%s')", item1->sketch->getNameInDocument(), item1->ConstraintNbr, tmpname.c_str()); - Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.renameConstraint(%d, '%s')", + Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.renameConstraint(%d, u'%s')", item2->sketch->getNameInDocument(), item2->ConstraintNbr, escapedstr1.c_str()); - Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.renameConstraint(%d, '%s')", + Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.renameConstraint(%d, u'%s')", item1->sketch->getNameInDocument(), item1->ConstraintNbr, escapedstr2.c_str()); Gui::Command::commitCommand(); @@ -660,7 +660,7 @@ void TaskSketcherConstrains::on_listWidgetConstraints_itemChanged(QListWidgetIte Gui::Command::openCommand("Rename sketch constraint"); try { - Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.renameConstraint(%d, '%s')", + Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.renameConstraint(%d, u'%s')", sketch->getNameInDocument(), it->ConstraintNbr, escapedstr.c_str()); Gui::Command::commitCommand();