diff options
| author | Al <gabriel.cortesi@outlook.com> | 2019-02-16 20:41:27 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-02-16 20:41:27 +0100 |
| commit | ee266e52209fc9fce32031fd5ae0c9703b64cada (patch) | |
| tree | adf38e2c6e7baebd1cf56011567ad733d7a363c1 /src | |
| parent | c19ba153376f5d8f4026a46701bb0f7c115c1651 (diff) | |
| parent | d0a6321a39a4b8511dc36e5023c8787cfa1356dc (diff) | |
Merge pull request #655 from przester/double-install-fix
Reject new mod installations if another one is already running
Diffstat (limited to 'src')
| -rw-r--r-- | src/installationmanager.cpp | 14 | ||||
| -rw-r--r-- | src/installationmanager.h | 7 | ||||
| -rw-r--r-- | src/organizer_en.ts | 130 | ||||
| -rw-r--r-- | src/organizercore.cpp | 14 |
4 files changed, 103 insertions, 62 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; } diff --git a/src/installationmanager.h b/src/installationmanager.h index 7c43b4e2..54fdf169 100644 --- a/src/installationmanager.h +++ b/src/installationmanager.h @@ -90,6 +90,11 @@ public: bool wasCancelled(); /** + * @return true if an installation is currently in progress + **/ + bool isRunning(); + + /** * @brief retrieve a string describing the specified error code * * @param errorCode an error code as returned by the archiving function @@ -202,6 +207,8 @@ private: private: + bool m_IsRunning; + QWidget *m_ParentWidget; QString m_ModsDirectory; diff --git a/src/organizer_en.ts b/src/organizer_en.ts index b9bcece4..50301bfa 100644 --- a/src/organizer_en.ts +++ b/src/organizer_en.ts @@ -1280,99 +1280,99 @@ p, li { white-space: pre-wrap; } <context> <name>InstallationManager</name> <message> - <location filename="installationmanager.cpp" line="119"/> + <location filename="installationmanager.cpp" line="120"/> <source>Password required</source> <translation type="unfinished"></translation> </message> <message> - <location filename="installationmanager.cpp" line="120"/> + <location filename="installationmanager.cpp" line="121"/> <source>Password</source> <translation type="unfinished"></translation> </message> <message> - <location filename="installationmanager.cpp" line="190"/> - <location filename="installationmanager.cpp" line="289"/> + <location filename="installationmanager.cpp" line="191"/> + <location filename="installationmanager.cpp" line="290"/> <source>Extracting files</source> <translation type="unfinished"></translation> </message> <message> - <location filename="installationmanager.cpp" line="488"/> + <location filename="installationmanager.cpp" line="489"/> <source>failed to create backup</source> <translation type="unfinished"></translation> </message> <message> - <location filename="installationmanager.cpp" line="497"/> + <location filename="installationmanager.cpp" line="498"/> <source>Mod Name</source> <translation type="unfinished"></translation> </message> <message> - <location filename="installationmanager.cpp" line="497"/> + <location filename="installationmanager.cpp" line="498"/> <source>Name</source> <translation type="unfinished"></translation> </message> <message> - <location filename="installationmanager.cpp" line="550"/> + <location filename="installationmanager.cpp" line="551"/> <source>Invalid name</source> <translation type="unfinished"></translation> </message> <message> - <location filename="installationmanager.cpp" line="551"/> + <location filename="installationmanager.cpp" line="552"/> <source>The name you entered is invalid, please enter a different one.</source> <translation type="unfinished"></translation> </message> <message> - <location filename="installationmanager.cpp" line="710"/> + <location filename="installationmanager.cpp" line="717"/> <source>File format "%1" not supported</source> <translation type="unfinished"></translation> </message> <message> - <location filename="installationmanager.cpp" line="872"/> + <location filename="installationmanager.cpp" line="882"/> <source>None of the available installer plugins were able to handle that archive. This is likely due to a corrupted or incompatible download or unrecognized archive format.</source> <translation type="unfinished"></translation> </message> <message> - <location filename="installationmanager.cpp" line="883"/> + <location filename="installationmanager.cpp" line="895"/> <source>no error</source> <translation type="unfinished"></translation> </message> <message> - <location filename="installationmanager.cpp" line="886"/> + <location filename="installationmanager.cpp" line="898"/> <source>7z.dll not found</source> <translation type="unfinished"></translation> </message> <message> - <location filename="installationmanager.cpp" line="889"/> + <location filename="installationmanager.cpp" line="901"/> <source>7z.dll isn't valid</source> <translation type="unfinished"></translation> </message> <message> - <location filename="installationmanager.cpp" line="892"/> + <location filename="installationmanager.cpp" line="904"/> <source>archive not found</source> <translation type="unfinished"></translation> </message> <message> - <location filename="installationmanager.cpp" line="895"/> + <location filename="installationmanager.cpp" line="907"/> <source>failed to open archive</source> <translation type="unfinished"></translation> </message> <message> - <location filename="installationmanager.cpp" line="898"/> + <location filename="installationmanager.cpp" line="910"/> <source>unsupported archive type</source> <translation type="unfinished"></translation> </message> <message> - <location filename="installationmanager.cpp" line="901"/> + <location filename="installationmanager.cpp" line="913"/> <source>internal library error</source> <translation type="unfinished"></translation> </message> <message> - <location filename="installationmanager.cpp" line="904"/> + <location filename="installationmanager.cpp" line="916"/> <source>archive invalid</source> <translation type="unfinished"></translation> </message> <message> - <location filename="installationmanager.cpp" line="908"/> + <location filename="installationmanager.cpp" line="920"/> <source>unknown archive error</source> <translation type="unfinished"></translation> </message> @@ -4422,172 +4422,180 @@ p, li { white-space: pre-wrap; } <translation type="unfinished"></translation> </message> <message> - <location filename="organizercore.cpp" line="999"/> - <location filename="organizercore.cpp" line="1057"/> + <location filename="organizercore.cpp" line="1006"/> + <location filename="organizercore.cpp" line="1071"/> <source>Installation successful</source> <translation type="unfinished"></translation> </message> <message> - <location filename="organizercore.cpp" line="1007"/> - <location filename="organizercore.cpp" line="1067"/> + <location filename="organizercore.cpp" line="1014"/> + <location filename="organizercore.cpp" line="1081"/> <source>Configure Mod</source> <translation type="unfinished"></translation> </message> <message> - <location filename="organizercore.cpp" line="1008"/> - <location filename="organizercore.cpp" line="1068"/> + <location filename="organizercore.cpp" line="1015"/> + <location filename="organizercore.cpp" line="1082"/> <source>This mod contains ini tweaks. Do you want to configure them now?</source> <translation type="unfinished"></translation> </message> <message> - <location filename="organizercore.cpp" line="1020"/> - <location filename="organizercore.cpp" line="1078"/> + <location filename="organizercore.cpp" line="1027"/> + <location filename="organizercore.cpp" line="1092"/> <source>mod not found: %1</source> <translation type="unfinished"></translation> </message> <message> - <location filename="organizercore.cpp" line="1023"/> - <location filename="organizercore.cpp" line="1085"/> + <location filename="organizercore.cpp" line="993"/> + <location filename="organizercore.cpp" line="1030"/> + <location filename="organizercore.cpp" line="1041"/> + <location filename="organizercore.cpp" line="1099"/> <source>Installation cancelled</source> <translation type="unfinished"></translation> </message> <message> - <location filename="organizercore.cpp" line="1024"/> - <location filename="organizercore.cpp" line="1086"/> + <location filename="organizercore.cpp" line="994"/> + <location filename="organizercore.cpp" line="1042"/> + <source>Another installation is currently in progress.</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="organizercore.cpp" line="1031"/> + <location filename="organizercore.cpp" line="1100"/> <source>The mod was not installed completely.</source> <translation type="unfinished"></translation> </message> <message> - <location filename="organizercore.cpp" line="1304"/> + <location filename="organizercore.cpp" line="1318"/> <source>Executable not found: %1</source> <translation type="unfinished"></translation> </message> <message> - <location filename="organizercore.cpp" line="1332"/> + <location filename="organizercore.cpp" line="1346"/> <source>Start Steam?</source> <translation type="unfinished"></translation> </message> <message> - <location filename="organizercore.cpp" line="1333"/> + <location filename="organizercore.cpp" line="1347"/> <source>Steam is required to be running already to correctly start the game. Should MO try to start steam now?</source> <translation type="unfinished"></translation> </message> <message> - <location filename="organizercore.cpp" line="1364"/> + <location filename="organizercore.cpp" line="1378"/> <source>Error</source> <translation type="unfinished"></translation> </message> <message> - <location filename="organizercore.cpp" line="1372"/> + <location filename="organizercore.cpp" line="1386"/> <source>Windows Event Log Error</source> <translation type="unfinished"></translation> </message> <message> - <location filename="organizercore.cpp" line="1373"/> + <location filename="organizercore.cpp" line="1387"/> <source>The Windows Event Log service is disabled and/or not running. This prevents USVFS from running properly. Your mods may not be working in the executable that you are launching. Note that you may have to restart MO and/or your PC after the service is fixed. Continue launching %1?</source> <translation type="unfinished"></translation> </message> <message> - <location filename="organizercore.cpp" line="1385"/> + <location filename="organizercore.cpp" line="1399"/> <source>Blacklisted Executable</source> <translation type="unfinished"></translation> </message> <message> - <location filename="organizercore.cpp" line="1386"/> + <location filename="organizercore.cpp" line="1400"/> <source>The executable you are attempted to launch is blacklisted in the virtual file system. This will likely prevent the executable, and any executables that are launched by this one, from seeing any mods. This could extend to INI files, save games and any other virtualized files. Continue launching %1?</source> <translation type="unfinished"></translation> </message> <message> - <location filename="organizercore.cpp" line="1481"/> + <location filename="organizercore.cpp" line="1495"/> <source>No profile set</source> <translation type="unfinished"></translation> </message> <message> - <location filename="organizercore.cpp" line="1777"/> + <location filename="organizercore.cpp" line="1791"/> <source>Failed to refresh list of esps: %1</source> <translation type="unfinished"></translation> </message> <message> - <location filename="organizercore.cpp" line="1886"/> + <location filename="organizercore.cpp" line="1900"/> <source>Multiple esps/esls activated, please check that they don't conflict.</source> <translation type="unfinished"></translation> </message> <message> - <location filename="organizercore.cpp" line="1974"/> + <location filename="organizercore.cpp" line="1988"/> <source>Download?</source> <translation type="unfinished"></translation> </message> <message> - <location filename="organizercore.cpp" line="1975"/> + <location filename="organizercore.cpp" line="1989"/> <source>A download has been started but no installed page plugin recognizes it. If you download anyway no information (i.e. version) will be associated with the download. Continue?</source> <translation type="unfinished"></translation> </message> <message> - <location filename="organizercore.cpp" line="2110"/> - <location filename="organizercore.cpp" line="2159"/> + <location filename="organizercore.cpp" line="2124"/> + <location filename="organizercore.cpp" line="2173"/> <source>failed to update mod list: %1</source> <translation type="unfinished"></translation> </message> <message> - <location filename="organizercore.cpp" line="2166"/> - <location filename="organizercore.cpp" line="2183"/> + <location filename="organizercore.cpp" line="2180"/> + <location filename="organizercore.cpp" line="2197"/> <source>login successful</source> <translation type="unfinished"></translation> </message> <message> - <location filename="organizercore.cpp" line="2190"/> + <location filename="organizercore.cpp" line="2204"/> <source>Login failed</source> <translation type="unfinished"></translation> </message> <message> - <location filename="organizercore.cpp" line="2191"/> + <location filename="organizercore.cpp" line="2205"/> <source>Login failed, try again?</source> <translation type="unfinished"></translation> </message> <message> - <location filename="organizercore.cpp" line="2200"/> + <location filename="organizercore.cpp" line="2214"/> <source>login failed: %1. Download will not be associated with an account</source> <translation type="unfinished"></translation> </message> <message> - <location filename="organizercore.cpp" line="2208"/> + <location filename="organizercore.cpp" line="2222"/> <source>login failed: %1</source> <translation type="unfinished"></translation> </message> <message> - <location filename="organizercore.cpp" line="2218"/> + <location filename="organizercore.cpp" line="2232"/> <source>login failed: %1. You need to log-in with Nexus to update MO.</source> <translation type="unfinished"></translation> </message> <message> - <location filename="organizercore.cpp" line="2271"/> + <location filename="organizercore.cpp" line="2285"/> <source>MO1 "Script Extender" load mechanism has left hook.dll in your game folder</source> <translation type="unfinished"></translation> </message> <message> - <location filename="organizercore.cpp" line="2274"/> - <location filename="organizercore.cpp" line="2290"/> + <location filename="organizercore.cpp" line="2288"/> + <location filename="organizercore.cpp" line="2304"/> <source>Description missing</source> <translation type="unfinished"></translation> </message> <message> - <location filename="organizercore.cpp" line="2283"/> + <location filename="organizercore.cpp" line="2297"/> <source><a href="%1">hook.dll</a> has been found in your game folder (right click to copy the full path). This is most likely a leftover of setting the ModOrganizer 1 load mechanism to "Script Extender", in which case you must remove this file either by changing the load mechanism in ModOrganizer 1 or manually removing the file, otherwise the game is likely to crash and burn.</source> <translation type="unfinished"></translation> </message> <message> - <location filename="organizercore.cpp" line="2317"/> + <location filename="organizercore.cpp" line="2331"/> <source>failed to save load order: %1</source> <translation type="unfinished"></translation> </message> <message> - <location filename="organizercore.cpp" line="2389"/> + <location filename="organizercore.cpp" line="2403"/> <source>The designated write target "%1" is not enabled.</source> <translation type="unfinished"></translation> </message> @@ -5362,7 +5370,7 @@ p, li { white-space: pre-wrap; } <translation type="unfinished"></translation> </message> <message> - <location filename="installationmanager.cpp" line="87"/> + <location filename="installationmanager.cpp" line="88"/> <source>archive.dll not loaded: "%1"</source> <translation type="unfinished"></translation> </message> diff --git a/src/organizercore.cpp b/src/organizercore.cpp index 4dceefbf..a668de6b 100644 --- a/src/organizercore.cpp +++ b/src/organizercore.cpp @@ -988,6 +988,13 @@ MOBase::IModInterface *OrganizerCore::installMod(const QString &fileName, return nullptr;
}
+ if (m_InstallationManager.isRunning()) {
+ QMessageBox::information(
+ qApp->activeWindow(), tr("Installation cancelled"),
+ tr("Another installation is currently in progress."), QMessageBox::Ok);
+ return nullptr;
+ }
+
bool hasIniTweaks = false;
GuessedValue<QString> modName;
if (!initModName.isEmpty()) {
@@ -1029,6 +1036,13 @@ MOBase::IModInterface *OrganizerCore::installMod(const QString &fileName, void OrganizerCore::installDownload(int index)
{
+ if (m_InstallationManager.isRunning()) {
+ QMessageBox::information(
+ qApp->activeWindow(), tr("Installation cancelled"),
+ tr("Another installation is currently in progress."), QMessageBox::Ok);
+ return;
+ }
+
try {
QString fileName = m_DownloadManager.getFilePath(index);
QString gameName = m_DownloadManager.getGameName(index);
|
