From d0f2c4fcf79222d5c6f3c17188a811b0a47833c6 Mon Sep 17 00:00:00 2001 From: Tannin Date: Wed, 17 Jul 2013 20:58:58 +0200 Subject: - now avoids a few unnecessary copy operations during generation of the directory structure - bugfix: circular dependency caused a memory leak - bugfix: removing a single mod lead to the wrong mod being deleted --- src/mainwindow.cpp | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'src/mainwindow.cpp') diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 8c309131..99b37feb 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -93,6 +93,7 @@ along with Mod Organizer. If not, see . #include #include #include +#include #include #include #include @@ -310,6 +311,7 @@ MainWindow::~MainWindow() m_RefresherThread.wait(); delete ui; delete m_GameInfo; + delete m_DirectoryStructure; } void MainWindow::updateStyle(const QString&) @@ -1321,9 +1323,9 @@ void MainWindow::on_profileBox_currentIndexChanged(int index) void MainWindow::updateTo(QTreeWidgetItem *subTree, const std::wstring &directorySoFar, const DirectoryEntry &directoryEntry, bool conflictsOnly) { { - std::vector files = directoryEntry.getFiles(); + std::vector files = directoryEntry.getFiles(); for (auto iter = files.begin(); iter != files.end(); ++iter) { - FileEntry *current = *iter; + FileEntry::Ptr current = *iter; if (conflictsOnly && (current->getAlternatives().size() == 0)) { continue; } @@ -1626,9 +1628,9 @@ void MainWindow::refreshBSAList() std::vector > items; - std::vector files = m_DirectoryStructure->getFiles(); + std::vector files = m_DirectoryStructure->getFiles(); for (auto iter = files.begin(); iter != files.end(); ++iter) { - FileEntry *current = *iter; + FileEntry::Ptr current = *iter; QString filename = ToQString(current->getName().c_str()); QString extension = filename.right(3).toLower(); @@ -1898,8 +1900,8 @@ QString MainWindow::resolvePath(const QString &fileName) const if (m_DirectoryStructure == NULL) { return QString(); } - const FileEntry *file = m_DirectoryStructure->searchFile(ToWString(fileName), NULL); - if (file != NULL) { + const FileEntry::Ptr file = m_DirectoryStructure->searchFile(ToWString(fileName), NULL); + if (file.get() != NULL) { return ToQString(file->getFullPath()); } else { return QString(); @@ -2551,12 +2553,15 @@ void MainWindow::removeMod_clicked() { try { QItemSelectionModel *selection = ui->modList->selectionModel(); - if (selection->hasSelection() && selection->selectedRows().count() > 1 ) { + if (selection->hasSelection() && selection->selectedRows().count() > 1) { QString mods; QStringList modNames; foreach (QModelIndex idx, selection->selectedRows()) { // QString name = ModInfo::getByIndex(m_ModListGroupProxy->mapToSource(idx).row())->name(); QString name = idx.data().toString(); + if (!ModInfo::getByIndex(idx.data(Qt::UserRole + 1).toInt())->isRegular()) { + continue; + } mods += "
  • " + name + "
  • "; modNames.append(name); } @@ -3624,9 +3629,9 @@ void MainWindow::writeDataToFile(QFile &file, const QString &directory, const Di // directoryEntry.getFiles(current, end); // for (; current != end; ++current) { - std::vector files = directoryEntry.getFiles(); + std::vector files = directoryEntry.getFiles(); for (auto iter = files.begin(); iter != files.end(); ++iter) { - FileEntry *current = *iter; + FileEntry::Ptr current = *iter; bool isArchive = false; int origin = current->getOrigin(isArchive); if (isArchive) { -- cgit v1.3.1