summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEran Mizrahi <erasmux@gmail.com>2017-12-18 00:26:59 +0200
committerEran Mizrahi <erasmux@gmail.com>2017-12-18 20:04:44 +0200
commit90421277e7ed0044b499d81f06df95bf62111ce9 (patch)
tree5599140fc53f40e2ea1d5b2ffc93a9f8182bfe4e
parent4656ba9447d9bd0ebe5540a54892ec41abda047b (diff)
Ensure all mostlist writing is done through the DelayedFileWriter
-rw-r--r--src/mainwindow.cpp8
-rw-r--r--src/modlist.cpp4
-rw-r--r--src/organizercore.cpp10
-rw-r--r--src/profile.cpp23
-rw-r--r--src/profile.h9
5 files changed, 37 insertions, 17 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 22e99e37..3782b034 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -1958,7 +1958,7 @@ void MainWindow::modorder_changed()
}
}
m_OrganizerCore.refreshBSAList();
- m_OrganizerCore.currentProfile()->modlistWriter().write();
+ m_OrganizerCore.currentProfile()->writeModlist();
m_ArchiveListWriter.write();
m_OrganizerCore.directoryStructure()->getFileRegister()->sortOrigins();
@@ -2264,7 +2264,7 @@ void MainWindow::restoreBackup_clicked()
void MainWindow::modlistChanged(const QModelIndex&, int)
{
- m_OrganizerCore.currentProfile()->modlistWriter().write();
+ m_OrganizerCore.currentProfile()->writeModlist();
}
void MainWindow::modlistSelectionChanged(const QModelIndex &current, const QModelIndex&)
@@ -3307,7 +3307,7 @@ void MainWindow::fixMods_clicked(SaveGameInfo::MissingAssets const &missingAsset
}
}
- m_OrganizerCore.currentProfile()->modlistWriter().write();
+ m_OrganizerCore.currentProfile()->writeModlist();
m_OrganizerCore.refreshLists();
std::set<QString> espsToActivate = dialog.getESPsToActivate();
@@ -4678,7 +4678,7 @@ void MainWindow::on_restoreButton_clicked()
void MainWindow::on_saveModsButton_clicked()
{
- m_OrganizerCore.currentProfile()->modlistWriter().writeImmediately(true);
+ m_OrganizerCore.currentProfile()->writeModlistNow(true);
QDateTime now = QDateTime::currentDateTime();
if (createBackup(m_OrganizerCore.currentProfile()->getModlistFileName(), now)) {
MessageDialog::showMessage(tr("Backup of modlist created"), this);
diff --git a/src/modlist.cpp b/src/modlist.cpp
index 3afa94b5..c028432c 100644
--- a/src/modlist.cpp
+++ b/src/modlist.cpp
@@ -940,12 +940,12 @@ void ModList::removeRowForce(int row, const QModelIndex &parent)
m_Profile->setModEnabled(row, false);
- m_Profile->modlistWriter().cancel();
+ m_Profile->cancelModlistWrite();
beginRemoveRows(parent, row, row);
ModInfo::removeMod(row);
endRemoveRows();
m_Profile->refreshModStatus(); // removes the mod from the status list
- m_Profile->modlistWriter().write(); // this ensures the modified list gets written back before new mods can be installed
+ m_Profile->writeModlist(); // this ensures the modified list gets written back before new mods can be installed
if (wasEnabled) {
emit removeOrigin(modInfo->name());
diff --git a/src/organizercore.cpp b/src/organizercore.cpp
index 98920479..3be9559a 100644
--- a/src/organizercore.cpp
+++ b/src/organizercore.cpp
@@ -1181,7 +1181,7 @@ HANDLE OrganizerCore::spawnBinaryProcess(const QFileInfo &binary,
// need to make sure all data is saved before we start the application
if (m_CurrentProfile != nullptr) {
- m_CurrentProfile->modlistWriter().writeImmediately(true);
+ m_CurrentProfile->writeModlistNow(true);
}
// TODO: should also pass arguments
@@ -1438,7 +1438,7 @@ void OrganizerCore::refreshModList(bool saveChanges)
{
// don't lose changes!
if (saveChanges) {
- m_CurrentProfile->modlistWriter().writeImmediately(true);
+ m_CurrentProfile->writeModlistNow(true);
}
ModInfo::updateFromDisc(m_Settings.getModDirectory(), &m_DirectoryStructure,
m_Settings.displayForeign(), managedGame());
@@ -1460,7 +1460,7 @@ void OrganizerCore::refreshESPList()
});
return;
}
- m_CurrentProfile->modlistWriter().write();
+ m_CurrentProfile->writeModlist();
// clear list
try {
@@ -1670,7 +1670,7 @@ std::vector<QString> OrganizerCore::enabledArchives()
void OrganizerCore::refreshDirectoryStructure()
{
if (!m_DirectoryUpdate) {
- m_CurrentProfile->modlistWriter().writeImmediately(true);
+ m_CurrentProfile->writeModlistNow(true);
m_DirectoryUpdate = true;
std::vector<std::tuple<QString, QString, int>> activeModList
@@ -1925,7 +1925,7 @@ void OrganizerCore::prepareStart()
if (m_CurrentProfile == nullptr) {
return;
}
- m_CurrentProfile->modlistWriter().write();
+ m_CurrentProfile->writeModlist();
m_CurrentProfile->createTweakedIniFile();
saveCurrentLists();
m_Settings.setupLoadMechanism();
diff --git a/src/profile.cpp b/src/profile.cpp
index 6382a15c..3383ffee 100644
--- a/src/profile.cpp
+++ b/src/profile.cpp
@@ -66,7 +66,7 @@ void Profile::touchFile(QString fileName)
}
Profile::Profile(const QString &name, IPluginGame const *gamePlugin, bool useDefaultSettings)
- : m_ModListWriter(std::bind(&Profile::writeModlistNow, this))
+ : m_ModListWriter(std::bind(&Profile::doWriteModlist, this))
, m_GamePlugin(gamePlugin)
{
QString profilesDir = Settings::instance().getProfileDirectory();
@@ -111,7 +111,7 @@ Profile::Profile(const QString &name, IPluginGame const *gamePlugin, bool useDef
Profile::Profile(const QDir &directory, IPluginGame const *gamePlugin)
: m_Directory(directory)
, m_GamePlugin(gamePlugin)
- , m_ModListWriter(std::bind(&Profile::writeModlistNow, this))
+ , m_ModListWriter(std::bind(&Profile::doWriteModlist, this))
{
assert(gamePlugin != nullptr);
@@ -133,7 +133,7 @@ Profile::Profile(const QDir &directory, IPluginGame const *gamePlugin)
Profile::Profile(const Profile &reference)
: m_Directory(reference.m_Directory)
- , m_ModListWriter(std::bind(&Profile::writeModlistNow, this))
+ , m_ModListWriter(std::bind(&Profile::doWriteModlist, this))
, m_GamePlugin(reference.m_GamePlugin)
{
@@ -154,7 +154,22 @@ bool Profile::exists() const
return m_Directory.exists();
}
-void Profile::writeModlistNow()
+void Profile::writeModlist()
+{
+ m_ModListWriter.write();
+}
+
+void Profile::writeModlistNow(bool onlyIfPending)
+{
+ m_ModListWriter.writeImmediately(onlyIfPending);
+}
+
+void Profile::cancelModlistWrite()
+{
+ m_ModListWriter.cancel();
+}
+
+void Profile::doWriteModlist()
{
if (!m_Directory.exists()) return;
diff --git a/src/profile.h b/src/profile.h
index 996e561f..edbbffe7 100644
--- a/src/profile.h
+++ b/src/profile.h
@@ -89,7 +89,11 @@ public:
**/
static Profile *createPtrFrom(const QString &name, const Profile &reference, MOBase::IPluginGame const *gamePlugin);
- MOBase::DelayedFileWriter &modlistWriter() { return m_ModListWriter; }
+ void writeModlist();
+
+ void writeModlistNow(bool onlyIfPending=false);
+
+ void cancelModlistWrite();
/**
* @brief test if this profile uses archive invalidation
@@ -297,7 +301,8 @@ signals:
public slots:
- void writeModlistNow();
+ // should only be called by DelayedFileWriter, use writeModlist() and writeModlistNow() instead
+ void doWriteModlist();
private: