From a43191497da10a874a5d9274dbaa50ce3f3d3662 Mon Sep 17 00:00:00 2001 From: Marcus Tillmanns Date: Tue, 26 Sep 2023 08:38:09 +0200 Subject: [PATCH] Utils: Fix StringSelectionAspect Previously the undo state was not updated when the value was set from the outside before the gui model was setup. Change-Id: I380916f888edd120f512089bdb94762977c11978 Reviewed-by: hjk --- src/libs/utils/aspects.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/libs/utils/aspects.cpp b/src/libs/utils/aspects.cpp index 05b4d8796bf..d9bf38688ac 100644 --- a/src/libs/utils/aspects.cpp +++ b/src/libs/utils/aspects.cpp @@ -3286,8 +3286,10 @@ QStandardItem *StringSelectionAspect::itemById(const QString &id) void StringSelectionAspect::bufferToGui() { - if (!m_model) + if (!m_model) { + m_undoable.setSilently(m_buffer); return; + } auto selected = itemById(m_buffer); if (selected) { @@ -3302,8 +3304,10 @@ void StringSelectionAspect::bufferToGui() m_selectionModel->setCurrentIndex(m_model->item(0)->index(), QItemSelectionModel::SelectionFlag::ClearAndSelect); } else { + m_undoable.setSilently(m_buffer); m_selectionModel->setCurrentIndex(QModelIndex(), QItemSelectionModel::SelectionFlag::Clear); } + handleGuiChanged(); }