Qt: More memory leak fixes
Vicki Pfau vi@endrift.com
Thu, 05 Jul 2018 20:30:47 -0700
3 files changed,
12 insertions(+),
6 deletions(-)
M
src/platform/qt/library/LibraryController.cpp
→
src/platform/qt/library/LibraryController.cpp
@@ -45,10 +45,10 @@ }
mLibraryAttachGameDB(m_library.get(), GBAApp::app()->gameDB()); - m_libraryTree = new LibraryTree(this); + m_libraryTree = std::make_unique<LibraryTree>(this); addWidget(m_libraryTree->widget()); - m_libraryGrid = new LibraryGrid(this); + m_libraryGrid = std::make_unique<LibraryGrid>(this); addWidget(m_libraryGrid->widget()); setViewStyle(LibraryStyle::STYLE_LIST);@@ -67,9 +67,9 @@ m_currentStyle = newStyle;
AbstractGameList* newCurrentList = nullptr; if (newStyle == LibraryStyle::STYLE_LIST || newStyle == LibraryStyle::STYLE_TREE) { - newCurrentList = m_libraryTree; + newCurrentList = m_libraryTree.get(); } else { - newCurrentList = m_libraryGrid; + newCurrentList = m_libraryGrid.get(); } newCurrentList->selectEntry(selectedEntry()); newCurrentList->setViewStyle(newStyle);
M
src/platform/qt/library/LibraryController.h
→
src/platform/qt/library/LibraryController.h
@@ -107,8 +107,8 @@
LibraryStyle m_currentStyle; AbstractGameList* m_currentList = nullptr; - LibraryGrid* m_libraryGrid = nullptr; - LibraryTree* m_libraryTree = nullptr; + std::unique_ptr<LibraryGrid> m_libraryGrid; + std::unique_ptr<LibraryTree> m_libraryTree; }; }
M
src/platform/qt/library/LibraryTree.cpp
→
src/platform/qt/library/LibraryTree.cpp
@@ -62,6 +62,12 @@ }
}); } +LibraryTree::~LibraryTree() { + for (QTreeWidgetItem* i : m_items.values()) { + delete i; + } +} + void LibraryTree::resizeAllCols() { for (int i = 0; i < m_widget->columnCount(); i++) { m_widget->resizeColumnToContents(i);