diff options
| author | LostDragonist <lost.dragonist@gmail.com> | 2019-03-25 04:42:02 -0500 |
|---|---|---|
| committer | LostDragonist <lost.dragonist@gmail.com> | 2019-03-25 04:42:02 -0500 |
| commit | eb9ac6ca246c13a4f7d6d60a9ec3e9018fe209e8 (patch) | |
| tree | 37fc9eac0bd82abf03a43f8594d535b95deddd0d /src | |
| parent | 043a5fa9412f1d766f5f211beabf4bda8afab73a (diff) | |
Add more protection against missing game plugins
Diffstat (limited to 'src')
| -rw-r--r-- | src/downloadmanager.cpp | 6 | ||||
| -rw-r--r-- | src/mainwindow.cpp | 2 | ||||
| -rw-r--r-- | src/nexusinterface.cpp | 26 | ||||
| -rw-r--r-- | src/organizercore.cpp | 2 |
4 files changed, 28 insertions, 8 deletions
diff --git a/src/downloadmanager.cpp b/src/downloadmanager.cpp index 3fa282da..25542ef3 100644 --- a/src/downloadmanager.cpp +++ b/src/downloadmanager.cpp @@ -453,7 +453,7 @@ void DownloadManager::removePending(QString gameName, int modID, int fileID) games += m_ManagedGame->gameShortName(); for (auto game : games) { MOBase::IPluginGame *gamePlugin = m_OrganizerCore->getGame(game); - if (gamePlugin->gameNexusName().compare(gameName, Qt::CaseInsensitive) == 0) { + if (gamePlugin != nullptr && gamePlugin->gameNexusName().compare(gameName, Qt::CaseInsensitive) == 0) { gameShortName = gamePlugin->gameShortName(); break; } @@ -1640,7 +1640,7 @@ void DownloadManager::nxmFileInfoAvailable(QString gameName, int modID, int file games += m_ManagedGame->gameShortName(); for (auto game : games) { MOBase::IPluginGame *gamePlugin = m_OrganizerCore->getGame(game); - if (gamePlugin->gameNexusName().compare(gameName, Qt::CaseInsensitive) == 0) { + if (gamePlugin != nullptr && gamePlugin->gameNexusName().compare(gameName, Qt::CaseInsensitive) == 0) { info->gameName = gamePlugin->gameShortName(); } } @@ -1815,7 +1815,7 @@ void DownloadManager::nxmFileInfoFromMd5Available(QString gameName, QVariant use games += m_ManagedGame->gameShortName(); for (auto game : games) { MOBase::IPluginGame *gamePlugin = m_OrganizerCore->getGame(game); - if (gamePlugin->gameNexusName().compare(gameName, Qt::CaseInsensitive) == 0) { + if (gamePlugin != nullptr && gamePlugin->gameNexusName().compare(gameName, Qt::CaseInsensitive) == 0) { gameShortName = gamePlugin->gameShortName(); break; } diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index ea46b175..1569eba5 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -5623,7 +5623,7 @@ void MainWindow::nxmEndorsementsAvailable(QVariant userData, QVariant resultData } for (auto game : games) { IPluginGame *gamePlugin = m_OrganizerCore.getGame(game); - if (gamePlugin->gameShortName().compare("SkyrimSE", Qt::CaseInsensitive) == 0) + if (gamePlugin != nullptr && gamePlugin->gameShortName().compare("SkyrimSE", Qt::CaseInsensitive) == 0) searchedMO2NexusGame = true; auto iter = sorted.equal_range(gamePlugin->gameNexusName()); for (auto result = iter.first; result != iter.second; ++result) { diff --git a/src/nexusinterface.cpp b/src/nexusinterface.cpp index 3989aa35..9db0d54e 100644 --- a/src/nexusinterface.cpp +++ b/src/nexusinterface.cpp @@ -287,13 +287,23 @@ bool NexusInterface::isURLGameRelated(const QUrl &url) const QString NexusInterface::getGameURL(QString gameName) const { IPluginGame *game = getGame(gameName); - return "https://www.nexusmods.com/" + game->gameNexusName().toLower(); + if (game != nullptr) { + return "https://www.nexusmods.com/" + game->gameNexusName().toLower(); + } else { + qCritical("getGameURL can't find plugin for %s", qUtf8Printable(gameName)); + return ""; + } } QString NexusInterface::getOldModsURL(QString gameName) const { IPluginGame *game = getGame(gameName); - return "https://" + game->gameNexusName().toLower() + ".nexusmods.com/mods"; + if (game != nullptr) { + return "https://" + game->gameNexusName().toLower() + ".nexusmods.com/mods"; + } else { + qCritical("getOldModsURL can't find plugin for %s", qUtf8Printable(gameName)); + return ""; + } } @@ -395,6 +405,11 @@ int NexusInterface::requestUpdates(const int &modID, QObject *receiver, QVariant { if (std::max(m_RemainingDailyRequests, m_RemainingHourlyRequests) >= 200) { IPluginGame *game = getGame(gameName); + if (game == nullptr) { + qCritical("requestUpdates can't find plugin for %s", qUtf8Printable(gameName)); + return -1; + } + NXMRequestInfo requestInfo(modID, NXMRequestInfo::TYPE_GETUPDATES, userData, subModule, game); m_RequestQueue.enqueue(requestInfo); @@ -451,6 +466,11 @@ int NexusInterface::requestFiles(QString gameName, int modID, QObject *receiver, int NexusInterface::requestFileInfo(QString gameName, int modID, int fileID, QObject *receiver, QVariant userData, const QString &subModule) { IPluginGame *gamePlugin = getGame(gameName); + if (gamePlugin == nullptr) { + qCritical("requestFileInfo can't find plugin for %s", qUtf8Printable(gameName)); + return -1; + } + NXMRequestInfo requestInfo(modID, fileID, NXMRequestInfo::TYPE_FILEINFO, userData, subModule, gamePlugin); m_RequestQueue.enqueue(requestInfo); @@ -579,7 +599,7 @@ IPluginGame* NexusInterface::getGame(QString gameName) const auto gamePlugins = m_PluginContainer->plugins<IPluginGame>(); IPluginGame *gamePlugin = qApp->property("managed_game").value<IPluginGame*>(); for (auto plugin : gamePlugins) { - if (plugin->gameShortName().compare(gameName, Qt::CaseInsensitive) == 0) { + if (plugin != nullptr && plugin->gameShortName().compare(gameName, Qt::CaseInsensitive) == 0) { gamePlugin = plugin; break; } diff --git a/src/organizercore.cpp b/src/organizercore.cpp index 687fd6c9..747cfaba 100644 --- a/src/organizercore.cpp +++ b/src/organizercore.cpp @@ -885,7 +885,7 @@ MOBase::IModInterface *OrganizerCore::getMod(const QString &name) const MOBase::IPluginGame *OrganizerCore::getGame(const QString &name) const { for (IPluginGame *game : m_PluginContainer->plugins<IPluginGame>()) { - if (game->gameShortName().compare(name, Qt::CaseInsensitive) == 0) + if (game != nullptr && game->gameShortName().compare(name, Qt::CaseInsensitive) == 0) return game; } return nullptr; |
