Skip to content

Commit

Permalink
Fix memory leak of ModelIndex user data
Browse files Browse the repository at this point in the history
  • Loading branch information
HazardousPeach committed Sep 19, 2024
1 parent cd6bea5 commit 5d59221
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion include/model/fsmodel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ namespace Toolbox {

public:
FileSystemModel() = default;
~FileSystemModel() = default;
~FileSystemModel();

void initialize();

Expand Down
6 changes: 6 additions & 0 deletions src/model/fsmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,12 @@ namespace Toolbox {
}
}

FileSystemModel::~FileSystemModel() {
for (auto &[key, value] : m_index_map) {
delete value.data<_FileSystemIndexData>();
}
}

void FileSystemModel::initialize() {
m_icon_map.clear();
m_index_map.clear();
Expand Down

0 comments on commit 5d59221

Please sign in to comment.