Gui: Use UTF-8 string instead of UTF-16 for Reset in Expression Editor
Currently `ExpLineEdit::apply()` passes `QString::constData()` to a printf-style format string with %s. `QString::constData() returns a const QChar* (UTF-16, 2 bytes per char), but %s expects a const char* (UTF-8/ASCII with 1 byte per char). This results in a string being interpreted as in "Container": Byte 0: 'C' Byte 1: 0x00 (high byte of UTF-16 'C', which gets interpreted as null terminator) So this patch uses proper conversion to null-terminated C-String before passing it further.
This commit is contained in:
@@ -1577,7 +1577,12 @@ bool ExpLineEdit::apply(const std::string& propName)
|
||||
if (!ExpressionBinding::apply(propName)) {
|
||||
if (!autoClose) {
|
||||
QString val = QString::fromUtf8(Base::Interpreter().strToPython(text().toUtf8()).c_str());
|
||||
Gui::Command::doCommand(Gui::Command::Doc, "%s = \"%s\"", propName.c_str(), val.constData());
|
||||
Gui::Command::doCommand(
|
||||
Gui::Command::Doc,
|
||||
"%s = \"%s\"",
|
||||
propName.c_str(),
|
||||
val.toUtf8().constData()
|
||||
);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user