From 90421277e7ed0044b499d81f06df95bf62111ce9 Mon Sep 17 00:00:00 2001 From: Eran Mizrahi Date: Mon, 18 Dec 2017 00:26:59 +0200 Subject: Ensure all mostlist writing is done through the DelayedFileWriter --- src/profile.cpp | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'src/profile.cpp') 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; -- cgit v1.3.1