From 7bd077a3ae0e3b69cfb0e36455610e7f3429977b Mon Sep 17 00:00:00 2001 From: Sergey Bugaev Date: Mon, 30 Mar 2020 21:39:26 +0300 Subject: [PATCH] LibGUI: Fix index invalidation When the model gets updated, we have to let go of the old indexes, because they're invalid from that moment on. Fixes https://github.com/SerenityOS/serenity/issues/1541 --- Libraries/LibGUI/AbstractView.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Libraries/LibGUI/AbstractView.cpp b/Libraries/LibGUI/AbstractView.cpp index bc06ba4b2c..952064f467 100644 --- a/Libraries/LibGUI/AbstractView.cpp +++ b/Libraries/LibGUI/AbstractView.cpp @@ -60,8 +60,10 @@ void AbstractView::set_model(RefPtr model) void AbstractView::did_update_model() { - if (!model() || selection().first() != m_edit_index) - stop_editing(); + stop_editing(); + m_edit_index = {}; + m_hovered_index = {}; + selection().clear(); } void AbstractView::did_update_selection()