From dedfc3dbe7f6657af90caa284e1237f0896fce44 Mon Sep 17 00:00:00 2001 From: Marcus Tillmanns Date: Thu, 21 Sep 2023 10:05:12 +0200 Subject: [PATCH] Utils: Fix StringAspect ui connection QLineEdit::textEdited is only called when the user types. It is not triggered if the text changes due to undo/redo. QLineEdit::textChanged is triggered for all changes. We also have to make sure that we don't call QLineEdit::setTextKeepingActiveCursor unnecessarily as that would clear the undo/redo stack of the QLineEdit. Change-Id: I19562d0804e6a34b11f19e86abd256a807e147d6 Reviewed-by: Reviewed-by: hjk --- src/libs/utils/aspects.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/libs/utils/aspects.cpp b/src/libs/utils/aspects.cpp index 4b6062bfeb7..1c4b1430b32 100644 --- a/src/libs/utils/aspects.cpp +++ b/src/libs/utils/aspects.cpp @@ -1165,7 +1165,7 @@ void StringAspect::addToLayout(LayoutItem &parent) handleGuiChanged(); }); } else { - connect(lineEditDisplay, &QLineEdit::textEdited, this, [this, lineEditDisplay]() { + connect(lineEditDisplay, &QLineEdit::textChanged, this, [this, lineEditDisplay]() { d->undoable.set(undoStack(), lineEditDisplay->text()); handleGuiChanged(); }); @@ -1188,7 +1188,9 @@ void StringAspect::addToLayout(LayoutItem &parent) &UndoSignaller::changed, lineEditDisplay, [this, lineEditDisplay] { - lineEditDisplay->setTextKeepingActiveCursor(d->undoable.get()); + if (lineEditDisplay->text() != d->undoable.get()) + lineEditDisplay->setTextKeepingActiveCursor(d->undoable.get()); + lineEditDisplay->validate(); });