From 4dbb3b148d874238b0f8dab323f198cc8d4e40c6 Mon Sep 17 00:00:00 2001 From: Thomas Tanner Date: Sat, 21 Nov 2015 17:26:34 +0000 Subject: Replace some instances of qApp->property("managed_game") with the saved pointer. Pedantic note: This doesn't help the possibility of supporting multiple executables greatly, we'd have to have a lot of register-for-change events. --- src/mainwindow.cpp | 3 +-- src/organizercore.cpp | 3 +-- src/profile.cpp | 21 ++++++++++----------- src/profile.h | 1 + 4 files changed, 13 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 26ff4b98..84a51b62 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -1332,8 +1332,7 @@ void MainWindow::updateBSAList(const QStringList &defaultArchives, const QString std::vector> items; - IPluginGame *gamePlugin = qApp->property("managed_game").value(); - BSAInvalidation *invalidation = gamePlugin->feature(); + BSAInvalidation *invalidation = m_OrganizerCore.managedGame()->feature(); std::vector files = m_OrganizerCore.directoryStructure()->getFiles(); QStringList plugins = m_OrganizerCore.findFiles("", [] (const QString &fileName) -> bool { diff --git a/src/organizercore.cpp b/src/organizercore.cpp index d56f64cb..517a9bfb 100644 --- a/src/organizercore.cpp +++ b/src/organizercore.cpp @@ -1570,8 +1570,7 @@ void OrganizerCore::prepareStart() { std::vector> OrganizerCore::fileMapping() { - IPluginGame *game = qApp->property("managed_game").value(); - return fileMapping(game->dataDirectory().absolutePath(), + return fileMapping(managedGame()->dataDirectory().absolutePath(), directoryStructure(), directoryStructure()); } diff --git a/src/profile.cpp b/src/profile.cpp index b990fbc1..cf3622b0 100644 --- a/src/profile.cpp +++ b/src/profile.cpp @@ -18,6 +18,7 @@ along with Mod Organizer. If not, see . */ #include "profile.h" + #include "gameinfo.h" #include "windows_error.h" #include "modinfo.h" @@ -30,16 +31,18 @@ along with Mod Organizer. If not, see . #include #include #include + #include #include #include #include + #include +#include #define WIN32_LEAN_AND_MEAN #include #include -#include using namespace MOBase; using namespace MOShared; @@ -47,6 +50,7 @@ using namespace MOShared; Profile::Profile() : m_ModListWriter(std::bind(&Profile::writeModlistNow, this)) + , m_GamePlugin(qApp->property("managed_game").value()) { } @@ -101,6 +105,7 @@ Profile::Profile(const QString &name, IPluginGame *gamePlugin, bool useDefaultSe Profile::Profile(const QDir &directory, IPluginGame *gamePlugin) : m_Directory(directory) + , m_GamePlugin(gamePlugin) , m_ModListWriter(std::bind(&Profile::writeModlistNow, this)) { assert(gamePlugin != nullptr); @@ -568,10 +573,8 @@ void Profile::mergeTweaks(ModInfo::Ptr modInfo, const QString &tweakedIni) const bool Profile::invalidationActive(bool *supported) const { - IPluginGame *gamePlugin = qApp->property("managed_game").value(); - - BSAInvalidation *invalidation = gamePlugin->feature(); - DataArchives *dataArchives = gamePlugin->feature(); + BSAInvalidation *invalidation = m_GamePlugin->feature(); + DataArchives *dataArchives = m_GamePlugin->feature(); if ((invalidation != nullptr) && (dataArchives != nullptr)) { if (supported != nullptr) { @@ -593,9 +596,7 @@ bool Profile::invalidationActive(bool *supported) const void Profile::deactivateInvalidation() { - IPluginGame *gamePlugin = qApp->property("managed_game").value(); - - BSAInvalidation *invalidation = gamePlugin->feature(); + BSAInvalidation *invalidation = m_GamePlugin->feature(); if (invalidation != nullptr) { invalidation->deactivate(this); @@ -605,9 +606,7 @@ void Profile::deactivateInvalidation() void Profile::activateInvalidation() { - IPluginGame *gamePlugin = qApp->property("managed_game").value(); - - BSAInvalidation *invalidation = gamePlugin->feature(); + BSAInvalidation *invalidation = m_GamePlugin->feature(); if (invalidation != nullptr) { invalidation->activate(this); diff --git a/src/profile.h b/src/profile.h index 342b6fa0..9c8139e9 100644 --- a/src/profile.h +++ b/src/profile.h @@ -65,6 +65,7 @@ public: * @param filter save game filter. Defaults to <no filter>. **/ Profile(const QString &name, MOBase::IPluginGame *gamePlugin, bool useDefaultSettings); + /** * @brief constructor * -- cgit v1.3.1