mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-10 01:59:31 +00:00
FileManager+LibGUI: Fix two folder-related crashes (#569)
Fix a crash when opening a folder, and another one when trying to open a newly created folder. It was not safe to modify a GModelSelection while it's being iterated over. Fixes #536.
This commit is contained in:
parent
caf1b37e75
commit
a4d52b122d
Notes:
sideshowbarker
2024-07-19 12:04:50 +09:00
Author: https://github.com/xeons
Commit: a4d52b122d
Pull-request: https://github.com/SerenityOS/serenity/pull/569
Reviewed-by: https://github.com/awesomekling
4 changed files with 46 additions and 5 deletions
|
@ -33,17 +33,27 @@ public:
|
|||
template<typename Callback>
|
||||
void for_each_index(Callback callback)
|
||||
{
|
||||
for (auto& index : m_indexes)
|
||||
for (auto& index : indexes())
|
||||
callback(index);
|
||||
}
|
||||
|
||||
template<typename Callback>
|
||||
void for_each_index(Callback callback) const
|
||||
{
|
||||
for (auto& index : m_indexes)
|
||||
for (auto& index : indexes())
|
||||
callback(index);
|
||||
}
|
||||
|
||||
Vector<GModelIndex> indexes() const
|
||||
{
|
||||
Vector<GModelIndex> selected_indexes;
|
||||
|
||||
for (auto& index : m_indexes)
|
||||
selected_indexes.append(index);
|
||||
|
||||
return selected_indexes;
|
||||
}
|
||||
|
||||
// FIXME: This doesn't guarantee that what you get is the lowest or "first" index selected..
|
||||
GModelIndex first() const
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue