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
This commit is contained in:
Sergey Bugaev 2020-03-30 21:39:26 +03:00 committed by Andreas Kling
parent 3fcea71538
commit 7bd077a3ae
Notes: sideshowbarker 2024-07-19 08:02:34 +09:00

View file

@ -60,8 +60,10 @@ void AbstractView::set_model(RefPtr<Model> 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()