diff options
author | Rye Mutt <rye@alchemyviewer.org> | 2022-10-19 22:19:22 -0400 |
---|---|---|
committer | Rye Mutt <rye@alchemyviewer.org> | 2022-10-19 22:19:22 -0400 |
commit | 589a167147fd4a316f4cf588bbb2aaa103c9d3bb (patch) | |
tree | a65db33492d1fac5c4278557b83bf038941a8f99 | |
parent | 5326e3a206d8fb2ed79c909bb37a34f848b77672 (diff) |
Fix leak of LLFolderViewModel sorter and filter with unique_ptr
-rw-r--r-- | indra/llui/llfolderviewmodel.h | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/indra/llui/llfolderviewmodel.h b/indra/llui/llfolderviewmodel.h index 093e213be3..dd5eb47a63 100644 --- a/indra/llui/llfolderviewmodel.h +++ b/indra/llui/llfolderviewmodel.h @@ -419,21 +419,15 @@ public: mFilter(filter) {} - virtual ~LLFolderViewModel() - { - delete mSorter; - mSorter = NULL; - delete mFilter; - mFilter = NULL; - } + virtual ~LLFolderViewModel() {} virtual SortType& getSorter() { return *mSorter; } virtual const SortType& getSorter() const { return *mSorter; } - virtual void setSorter(const SortType& sorter) { mSorter = new SortType(sorter); requestSortAll(); } + virtual void setSorter(const SortType& sorter) { mSorter.reset(new SortType(sorter)); requestSortAll(); } virtual FilterType& getFilter() { return *mFilter; } virtual const FilterType& getFilter() const { return *mFilter; } - virtual void setFilter(const FilterType& filter) { mFilter = new FilterType(filter); } + virtual void setFilter(const FilterType& filter) { mFilter.reset(new FilterType(filter)); } // By default, we assume the content is available. If a network fetch mechanism is implemented for the model, // this method needs to be overloaded and return the relevant fetch status. @@ -471,8 +465,8 @@ public: } protected: - SortType* mSorter; - FilterType* mFilter; + std::unique_ptr<SortType> mSorter; + std::unique_ptr<FilterType> mFilter; }; #endif // LLFOLDERVIEWMODEL_H |