mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 15:40:19 +00:00
LibGUI: Remove Indices with dangling FileSystemModel::Node on deletion
When a file deletion event happens, we now iterate over all views of the FileSystemModel and remove any selection & cursor indices that hold dangling references do the deleted filesystem node. This fixes #9602.
This commit is contained in:
parent
a2f5589d3a
commit
de31603028
Notes:
sideshowbarker
2024-07-18 04:05:54 +09:00
Author: https://github.com/itamar8910 Commit: https://github.com/SerenityOS/serenity/commit/de31603028e Pull-request: https://github.com/SerenityOS/serenity/pull/9929 Issue: https://github.com/SerenityOS/serenity/issues/9602 Reviewed-by: https://github.com/sin-ack ✅
1 changed files with 11 additions and 0 deletions
|
@ -12,6 +12,7 @@
|
|||
#include <LibCore/DirIterator.h>
|
||||
#include <LibCore/File.h>
|
||||
#include <LibCore/StandardPaths.h>
|
||||
#include <LibGUI/AbstractView.h>
|
||||
#include <LibGUI/FileIconProvider.h>
|
||||
#include <LibGUI/FileSystemModel.h>
|
||||
#include <LibGUI/Painter.h>
|
||||
|
@ -420,6 +421,16 @@ void FileSystemModel::handle_file_event(Core::FileWatcherEvent const& event)
|
|||
parent->m_children.remove(index.row());
|
||||
|
||||
end_delete_rows();
|
||||
|
||||
for_each_view([&](AbstractView& view) {
|
||||
view.selection().remove_matching([&](auto& selection_index) {
|
||||
return selection_index.internal_data() == index.internal_data();
|
||||
});
|
||||
if (view.cursor_index().internal_data() == index.internal_data()) {
|
||||
view.set_cursor({}, GUI::AbstractView::SelectionUpdate::None);
|
||||
}
|
||||
});
|
||||
|
||||
break;
|
||||
}
|
||||
case Core::FileWatcherEvent::Type::MetadataModified: {
|
||||
|
|
Loading…
Reference in a new issue