all repos — mgba @ cc0d582b38119d195b3e23a348562c812f76fd9a

mGBA Game Boy Advance Emulator

Qt: More memory leak fixes
Vicki Pfau vi@endrift.com
Thu, 05 Jul 2018 20:30:47 -0700
commit

cc0d582b38119d195b3e23a348562c812f76fd9a

parent

8fdfa130bd717f141a35dc77d6e724ba0c00c65e

M src/platform/qt/library/LibraryController.cppsrc/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.hsrc/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.cppsrc/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);