From b64408a5644dc58585b968ecf96015ceef8ed2a2 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Fri, 19 Apr 2019 22:52:13 +0200 Subject: [PATCH] VisualBuilder: Make widget deletion work properly. --- Applications/VisualBuilder/VBForm.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Applications/VisualBuilder/VBForm.cpp b/Applications/VisualBuilder/VBForm.cpp index a0e4ae827d..06cd82d6ff 100644 --- a/Applications/VisualBuilder/VBForm.cpp +++ b/Applications/VisualBuilder/VBForm.cpp @@ -309,9 +309,13 @@ void VBForm::mouseup_event(GMouseEvent& event) void VBForm::delete_selected_widgets() { - for_each_selected_widget([this] (auto& widget) { - m_widgets.remove_first_matching([&widget] (auto& entry) { return entry == &widget; } ); + Vector to_delete; + for_each_selected_widget([&] (auto& widget) { + to_delete.append(&widget); }); + for (auto& widget : to_delete) + m_widgets.remove_first_matching([&widget] (auto& entry) { return entry == widget; } ); + on_widget_selected(single_selected_widget()); } template