Utils: Fix connection error

When add / remove buttons are disabled, the connection fails.

Change-Id: I6c9a3233f156b88e516481a6fc8e072ea5e1c13b
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Marcus Tillmanns
2024-05-31 16:17:10 +02:00
parent d8a582d813
commit e078d05f51

View File

@@ -2681,6 +2681,7 @@ void StringListAspect::addToLayout(Layout &parent)
} }
}; };
if (add) {
connect(add, &QPushButton::clicked, this, [this, populate, editor] { connect(add, &QPushButton::clicked, this, [this, populate, editor] {
d->undoable.setSilently(d->undoable.get() << ""); d->undoable.setSilently(d->undoable.get() << "");
populate(); populate();
@@ -2689,7 +2690,9 @@ void StringListAspect::addToLayout(Layout &parent)
const QModelIndex index = editor->indexFromItem(lastChild, 0); const QModelIndex index = editor->indexFromItem(lastChild, 0);
editor->edit(index); editor->edit(index);
}); });
}
if (remove) {
connect(remove, &QPushButton::clicked, this, [this, editor, itemsToStringList] { connect(remove, &QPushButton::clicked, this, [this, editor, itemsToStringList] {
const QList<QTreeWidgetItem *> selected = editor->selectedItems(); const QList<QTreeWidgetItem *> selected = editor->selectedItems();
QTC_ASSERT(selected.size() == 1, return); QTC_ASSERT(selected.size() == 1, return);
@@ -2697,6 +2700,7 @@ void StringListAspect::addToLayout(Layout &parent)
delete selected.first(); delete selected.first();
d->undoable.set(undoStack(), itemsToStringList()); d->undoable.set(undoStack(), itemsToStringList());
}); });
}
connect( connect(
&d->undoable.m_signal, &UndoSignaller::changed, editor, [this, populate, itemsToStringList] { &d->undoable.m_signal, &UndoSignaller::changed, editor, [this, populate, itemsToStringList] {