summaryrefslogtreecommitdiff
path: root/src/installationmanager.cpp
diff options
context:
space:
mode:
authorAl <gabriel.cortesi@outlook.com>2019-02-16 20:41:27 +0100
committerGitHub <noreply@github.com>2019-02-16 20:41:27 +0100
commitee266e52209fc9fce32031fd5ae0c9703b64cada (patch)
treeadf38e2c6e7baebd1cf56011567ad733d7a363c1 /src/installationmanager.cpp
parentc19ba153376f5d8f4026a46701bb0f7c115c1651 (diff)
parentd0a6321a39a4b8511dc36e5023c8787cfa1356dc (diff)
Merge pull request #655 from przester/double-install-fix
Reject new mod installations if another one is already running
Diffstat (limited to 'src/installationmanager.cpp')
-rw-r--r--src/installationmanager.cpp14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/installationmanager.cpp b/src/installationmanager.cpp
index be838867..769394e7 100644
--- a/src/installationmanager.cpp
+++ b/src/installationmanager.cpp
@@ -80,7 +80,8 @@ static T resolveFunction(QLibrary &lib, const char *name)
InstallationManager::InstallationManager()
: m_ParentWidget(nullptr),
- m_SupportedExtensions({"zip", "rar", "7z", "fomod", "001"}) {
+ m_SupportedExtensions({"zip", "rar", "7z", "fomod", "001"}),
+ m_IsRunning(false) {
QLibrary archiveLib(QCoreApplication::applicationDirPath() +
"\\dlls\\archive.dll");
if (!archiveLib.load()) {
@@ -664,6 +665,11 @@ bool InstallationManager::wasCancelled()
return m_ArchiveHandler->getLastError() == Archive::ERROR_EXTRACT_CANCELLED;
}
+bool InstallationManager::isRunning()
+{
+ return m_IsRunning;
+}
+
void InstallationManager::postInstallCleanup()
{
@@ -705,6 +711,7 @@ bool InstallationManager::install(const QString &fileName,
bool &hasIniTweaks,
int modID)
{
+ m_IsRunning = true;
QFileInfo fileInfo(fileName);
if (m_SupportedExtensions.find(fileInfo.suffix()) == m_SupportedExtensions.end()) {
reportError(tr("File format \"%1\" not supported").arg(fileInfo.suffix()));
@@ -853,6 +860,7 @@ bool InstallationManager::install(const QString &fileName,
switch (installResult) {
case IPluginInstaller::RESULT_CANCELED:
case IPluginInstaller::RESULT_FAILED: {
+ m_IsRunning = false;
return false;
} break;
case IPluginInstaller::RESULT_SUCCESS:
@@ -861,8 +869,10 @@ bool InstallationManager::install(const QString &fileName,
DirectoryTree::node_iterator iniTweakNode = filesTree->nodeFind(DirectoryTreeInformation("INI Tweaks"));
hasIniTweaks = (iniTweakNode != filesTree->nodesEnd()) &&
((*iniTweakNode)->numLeafs() != 0);
+ m_IsRunning = false;
return true;
} else {
+ m_IsRunning = false;
return false;
}
} break;
@@ -871,6 +881,8 @@ bool InstallationManager::install(const QString &fileName,
reportError(tr("None of the available installer plugins were able to handle that archive.\n"
"This is likely due to a corrupted or incompatible download or unrecognized archive format."));
+
+ m_IsRunning = false;
return false;
}