1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 11:58:12 +00:00

LibGUI: Fix assertion when handling removal of FileSystemModel's root

This commit fixes FileSystemModel behaviour when the root path of the
model has been deleted.
In this case, the model index resolved for the root path is invalid and
passing it to 'begin_delete_rows' would trigger assertion failure.

Instead of deleting all children rows one by one, we simply invalidate
the whole model.
This commit is contained in:
Adam Jakubek 2022-08-29 21:52:07 +02:00 committed by Sam Atkins
parent 265b035dd5
commit f7e6593910

View file

@ -418,6 +418,12 @@ void FileSystemModel::handle_file_event(Core::FileWatcherEvent const& event)
break;
}
if (&child.value() == m_root) {
// Root directory of the filesystem model has been removed. All items became invalid.
invalidate();
break;
}
auto index = child->index(0);
begin_delete_rows(index.parent(), index.row(), index.row());