diff options
author | Adam Jakubek <ajakubek@gmail.com> | 2022-08-29 21:52:07 +0200 |
---|---|---|
committer | Sam Atkins <atkinssj@gmail.com> | 2022-08-31 10:32:41 +0100 |
commit | f7e6593910ccc22babaf670607ffcd8b90f5bf37 (patch) | |
tree | 6de782e002618971141bfcd250537b7e8dcd3af0 /Userland | |
parent | 265b035dd54768685068ddec90f09541ee010904 (diff) | |
download | serenity-f7e6593910ccc22babaf670607ffcd8b90f5bf37.zip |
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.
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Libraries/LibGUI/FileSystemModel.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/Userland/Libraries/LibGUI/FileSystemModel.cpp b/Userland/Libraries/LibGUI/FileSystemModel.cpp index dae02d35b9..9872055acf 100644 --- a/Userland/Libraries/LibGUI/FileSystemModel.cpp +++ b/Userland/Libraries/LibGUI/FileSystemModel.cpp @@ -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()); |