summaryrefslogtreecommitdiff
path: root/src/mainwindow.cpp
diff options
context:
space:
mode:
authorTannin <devnull@localhost>2013-03-13 19:35:20 +0100
committerTannin <devnull@localhost>2013-03-13 19:35:20 +0100
commitb3d0fcb2083143dc21c751adafd2523c3555e5d2 (patch)
tree6adeeedc26848af1d5dd96be17b4bca97ede085d /src/mainwindow.cpp
parent93e073c32445eefba5595123b28acf87d9f409e8 (diff)
- some more safety checks in the ini-limit removal code
- some code cleanup and minor bug fixes based on results from static code analysis - added naemfilter for the esp list - bsa changes are now stored automatically but delayed by up to 0.5 seconds (for performance reasons) - bugfix: buffer overrun when certain functions are called with empty file names - bugfix: reroute for the ini-limit fix was placed in the data segment - bugfix: mod list got mixed up when the mod directory was changed externally - bugfix: plugins.txt reroute on skyrim didn't work on winXP - bugfix: MO could become unresponsive if the tutorial script couldn't be interpreted
Diffstat (limited to 'src/mainwindow.cpp')
-rw-r--r--src/mainwindow.cpp56
1 files changed, 31 insertions, 25 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 4e3fa296..2d00580e 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -202,6 +202,7 @@ MainWindow::MainWindow(const QString &exeName, QSettings &initSettings, QWidget
connect(&m_ModList, SIGNAL(showMessage(QString)), this, SLOT(showMessage(QString)));
connect(&m_ModList, SIGNAL(modRenamed(QString,QString)), this, SLOT(modRenamed(QString,QString)));
connect(ui->modFilterEdit, SIGNAL(textChanged(QString)), m_ModListSortProxy, SLOT(updateFilter(QString)));
+ connect(ui->espFilterEdit, SIGNAL(textChanged(QString)), m_PluginListSortProxy, SLOT(updateFilter(QString)));
connect(&m_ModList, SIGNAL(modlist_changed(int)), m_ModListSortProxy, SLOT(invalidate()));
connect(&m_ModList, SIGNAL(removeSelectedMods()), this, SLOT(removeMod_clicked()));
@@ -221,6 +222,9 @@ MainWindow::MainWindow(const QString &exeName, QSettings &initSettings, QWidget
connect(&TutorialManager::instance(), SIGNAL(windowTutorialFinished(QString)), this, SLOT(windowTutorialFinished(QString)));
+ m_CheckBSATimer.setSingleShot(true);
+ connect(&m_CheckBSATimer, SIGNAL(timeout()), this, SLOT(checkBSAList()));
+
m_DirectoryRefresher.moveToThread(&m_RefresherThread);
m_RefresherThread.start();
@@ -478,6 +482,27 @@ void MainWindow::createHelpWidget()
}
+void MainWindow::saveArchiveList()
+{
+ if (m_ArchivesInit) {
+ QFile archiveFile(m_CurrentProfile->getArchivesFileName());
+ if (archiveFile.open(QIODevice::WriteOnly | QIODevice::Truncate)) {
+ for (int i = 0; i < ui->bsaList->topLevelItemCount(); ++i) {
+ QTreeWidgetItem *item = ui->bsaList->topLevelItem(i);
+ if ((item != NULL) && (item->checkState(0) == Qt::Checked)) {
+ archiveFile.write(item->text(0).toUtf8().append("\r\n"));
+ }
+ }
+ } else {
+ reportError(tr("failed to save archives order, do you have write access "
+ "to \"%1\"?").arg(m_CurrentProfile->getArchivesFileName()));
+ }
+ archiveFile.close();
+ } else {
+ qWarning("archive list not initialised");
+ }
+}
+
bool MainWindow::saveCurrentLists()
{
if (m_DirectoryUpdate) {
@@ -503,23 +528,6 @@ bool MainWindow::saveCurrentLists()
reportError(tr("failed to save load order: %1").arg(e.what()));
}
- if (m_ArchivesInit) {
- QFile archiveFile(m_CurrentProfile->getArchivesFileName());
- if (archiveFile.open(QIODevice::WriteOnly | QIODevice::Truncate)) {
- for (int i = 0; i < ui->bsaList->topLevelItemCount(); ++i) {
- QTreeWidgetItem *item = ui->bsaList->topLevelItem(i);
- if ((item != NULL) && (item->checkState(0) == Qt::Checked)) {
- archiveFile.write(item->text(0).toUtf8().append("\r\n"));
- }
- }
- } else {
- reportError(tr("failed to save archives order, do you have write access "
- "to \"%1\"?").arg(m_CurrentProfile->getArchivesFileName()));
- }
- archiveFile.close();
- } else {
- qWarning("archive list not initialised");
- }
return true;
}
@@ -1059,6 +1067,9 @@ void MainWindow::startExeAction()
void MainWindow::refreshModList()
{
+ // don't lose changes!
+ m_CurrentProfile->writeModlistNow(true);
+
ModInfo::updateFromDisc(m_Settings.getModDirectory(), &m_DirectoryStructure);
m_CurrentProfile->refreshModStatus();
@@ -1102,7 +1113,7 @@ void MainWindow::setExecutableIndex(int index)
void MainWindow::activateSelectedProfile()
{
QString profileName = ui->profileBox->currentText();
- qDebug() << "activate profile " << profileName;
+ qDebug("activate profile \"%s\"", qPrintable(profileName));
QString profileDir = QDir::fromNativeSeparators(ToQString(GameInfo::instance().getProfilesDir()))
.append("/").append(profileName);
delete m_CurrentProfile;
@@ -1650,12 +1661,6 @@ void MainWindow::on_tabWidget_currentChanged(int index)
}
-static QString guessModName(const QString &fileName)
-{
- return QFileInfo(fileName).baseName();
-}
-
-
void MainWindow::installMod(const QString &fileName)
{
bool hasIniTweaks = false;
@@ -3831,7 +3836,8 @@ void MainWindow::on_bsaList_customContextMenuRequested(const QPoint &pos)
void MainWindow::on_bsaList_itemChanged(QTreeWidgetItem*, int)
{
- checkBSAList();
+ saveArchiveList();
+ m_CheckBSATimer.start(500);
}
void MainWindow::on_actionProblems_triggered()