mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-03 23:25:20 +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:
@@ -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());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user