Permalink
Browse files
Qt: More memory leak fixes
- Loading branch information...
|
|
@@ -45,10 +45,10 @@ LibraryController::LibraryController(QWidget* parent, const QString& path, Confi |
|
|
|
|
|
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 @@ void LibraryController::setViewStyle(LibraryStyle 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);
|
|
|
|
|
|
@@ -107,8 +107,8 @@ private slots: |
|
|
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;
|
|
|
};
|
|
|
|
|
|
}
|
|
|
@@ -62,6 +62,12 @@ LibraryTree::LibraryTree(LibraryController* parent) |
|
|
});
|
|
|
}
|
|
|
|
|
|
+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);
|
|
|
|
0 comments on commit
cc0d582