From ca1528e2a964ce02c0f98ced29375a14b21938a7 Mon Sep 17 00:00:00 2001 From: tetektoza Date: Thu, 13 Nov 2025 21:24:43 +0100 Subject: [PATCH] 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. --- src/Gui/Widgets.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Gui/Widgets.cpp b/src/Gui/Widgets.cpp index bd3e6ffead..fe5c01c13a 100644 --- a/src/Gui/Widgets.cpp +++ b/src/Gui/Widgets.cpp @@ -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; }