From 589a167147fd4a316f4cf588bbb2aaa103c9d3bb Mon Sep 17 00:00:00 2001 From: Rye Mutt Date: Wed, 19 Oct 2022 22:19:22 -0400 Subject: Fix leak of LLFolderViewModel sorter and filter with unique_ptr --- indra/llui/llfolderviewmodel.h | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) (limited to 'indra/llui/llfolderviewmodel.h') 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 mSorter; + std::unique_ptr mFilter; }; #endif // LLFOLDERVIEWMODEL_H -- cgit v1.2.3