diff options
| author | Jonathan Feenstra <26406078+JonathanFeenstra@users.noreply.github.com> | 2026-01-11 17:31:26 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-01-11 17:31:26 +0100 |
| commit | aa44561e86b6520ee0ab10a58db52b6fdd77d991 (patch) | |
| tree | 0437239c99bb71d08b74bd590aee7cd019a412d1 | |
| parent | 717b5ac389ea15350d32f813a3f03d908de0ab06 (diff) | |
Change IOrganizer::profile return type to a shared_ptr (#2322)
| -rw-r--r-- | src/editexecutablesdialog.cpp | 6 | ||||
| -rw-r--r-- | src/mainwindow.cpp | 11 | ||||
| -rw-r--r-- | src/modinfodialogfiletree.cpp | 2 | ||||
| -rw-r--r-- | src/modlist.cpp | 2 | ||||
| -rw-r--r-- | src/modlistview.cpp | 5 | ||||
| -rw-r--r-- | src/organizercore.h | 5 | ||||
| -rw-r--r-- | src/organizerproxy.cpp | 2 | ||||
| -rw-r--r-- | src/organizerproxy.h | 2 | ||||
| -rw-r--r-- | src/plugincontainer.cpp | 2 | ||||
| -rw-r--r-- | src/pluginlist.cpp | 2 | ||||
| -rw-r--r-- | src/processrunner.cpp | 6 |
11 files changed, 24 insertions, 21 deletions
diff --git a/src/editexecutablesdialog.cpp b/src/editexecutablesdialog.cpp index f4a602c3..73fc8de7 100644 --- a/src/editexecutablesdialog.cpp +++ b/src/editexecutablesdialog.cpp @@ -139,7 +139,7 @@ int EditExecutablesDialog::exec() void EditExecutablesDialog::loadCustomOverwrites() { - const auto* p = m_organizerCore.currentProfile(); + const auto p = m_organizerCore.currentProfile(); for (const auto& e : m_executablesList) { const auto s = p->setting("custom_overwrites", e.title()).toString(); @@ -152,7 +152,7 @@ void EditExecutablesDialog::loadCustomOverwrites() void EditExecutablesDialog::loadForcedLibraries() { - const auto* p = m_organizerCore.currentProfile(); + const auto p = m_organizerCore.currentProfile(); for (const auto& e : m_executablesList) { m_forcedLibraries.set(e.title(), p->forcedLibrariesEnabled(e.title()), @@ -237,7 +237,7 @@ bool EditExecutablesDialog::commitChanges() return false; } - auto* profile = m_organizerCore.currentProfile(); + auto profile = m_organizerCore.currentProfile(); // remove all the custom overwrites and forced libraries for (const auto& e : m_originalExecutables) { diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index cd74165e..5d5a88ce 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -1802,14 +1802,14 @@ void MainWindow::on_profileBox_currentIndexChanged(int index) auto saveGames = m_OrganizerCore.gameFeatures().gameFeature<LocalSavegames>(); if (saveGames != nullptr) { - if (saveGames->prepareProfile(m_OrganizerCore.currentProfile())) { + if (saveGames->prepareProfile(m_OrganizerCore.currentProfile().get())) { m_SavesTab->refreshSaveList(); } } auto invalidation = m_OrganizerCore.gameFeatures().gameFeature<BSAInvalidation>(); if (invalidation != nullptr) { - if (invalidation->prepareProfile(m_OrganizerCore.currentProfile())) { + if (invalidation->prepareProfile(m_OrganizerCore.currentProfile().get())) { QTimer::singleShot(5, [this] { m_OrganizerCore.refresh(); }); @@ -2048,7 +2048,8 @@ void MainWindow::checkBSAList() ui->bsaList->blockSignals(false); }); - QStringList defaultArchives = archives->archives(m_OrganizerCore.currentProfile()); + QStringList defaultArchives = + archives->archives(m_OrganizerCore.currentProfile().get()); bool warning = false; @@ -2400,14 +2401,14 @@ void MainWindow::on_actionAdd_Profile_triggered() auto saveGames = m_OrganizerCore.gameFeatures().gameFeature<LocalSavegames>(); if (saveGames != nullptr) { - if (saveGames->prepareProfile(m_OrganizerCore.currentProfile())) { + if (saveGames->prepareProfile(m_OrganizerCore.currentProfile().get())) { m_SavesTab->refreshSaveList(); } } auto invalidation = m_OrganizerCore.gameFeatures().gameFeature<BSAInvalidation>(); if (invalidation != nullptr) { - if (invalidation->prepareProfile(m_OrganizerCore.currentProfile())) { + if (invalidation->prepareProfile(m_OrganizerCore.currentProfile().get())) { QTimer::singleShot(5, [this] { m_OrganizerCore.refresh(); }); diff --git a/src/modinfodialogfiletree.cpp b/src/modinfodialogfiletree.cpp index 140b813d..18220854 100644 --- a/src/modinfodialogfiletree.cpp +++ b/src/modinfodialogfiletree.cpp @@ -482,7 +482,7 @@ void FileTreeTab::onContextMenu(const QPoint& pos) bool enableRunHooked = false; if (enableRun || enableOpen) { - if (auto* p = core().currentProfile()) { + if (auto p = core().currentProfile()) { if (mod().canBeEnabled()) { const auto index = ModInfo::getIndex(mod().name()); if (index == UINT_MAX) { diff --git a/src/modlist.cpp b/src/modlist.cpp index d3552c73..4ff3654c 100644 --- a/src/modlist.cpp +++ b/src/modlist.cpp @@ -832,7 +832,7 @@ QStringList ModList::allMods() const QStringList ModList::allModsByProfilePriority(MOBase::IProfile* profile) const { - Profile* mo2Profile = profile == nullptr ? m_Organizer->currentProfile() + Profile* mo2Profile = profile == nullptr ? m_Organizer->currentProfile().get() : static_cast<Profile*>(profile); QStringList res; diff --git a/src/modlistview.cpp b/src/modlistview.cpp index 6091021b..7389c3a2 100644 --- a/src/modlistview.cpp +++ b/src/modlistview.cpp @@ -735,7 +735,8 @@ void ModListView::setup(OrganizerCore& core, CategoryFactory& factory, MainWindo }); // proxy for various group by - m_byPriorityProxy = new ModListByPriorityProxy(core.currentProfile(), core, this); + m_byPriorityProxy = + new ModListByPriorityProxy(core.currentProfile().get(), core, this); m_byCategoryProxy = new QtGroupingProxy(QModelIndex(), ModList::COL_CATEGORY, ModList::GroupingRole, 0, ModList::AggrRole); m_byNexusIdProxy = new QtGroupingProxy( @@ -758,7 +759,7 @@ void ModListView::setup(OrganizerCore& core, CategoryFactory& factory, MainWindo }); // the top-level proxy - m_sortProxy = new ModListSortProxy(core.currentProfile(), &core); + m_sortProxy = new ModListSortProxy(core.currentProfile().get(), &core); setModel(m_sortProxy); connect(m_sortProxy, &ModList::modelReset, [=] { refreshExpandedItems(); diff --git a/src/organizercore.h b/src/organizercore.h index 22c4f19a..80f340b6 100644 --- a/src/organizercore.h +++ b/src/organizercore.h @@ -270,7 +270,8 @@ public: m_ExecutablesList = executablesList; } - Profile* currentProfile() const { return m_CurrentProfile.get(); } + std::shared_ptr<Profile> currentProfile() const { return m_CurrentProfile; } + void setCurrentProfile(const QString& profileName); QStringList profileNames() const; @@ -540,7 +541,7 @@ private: MOBase::IPluginGame* m_GamePlugin; ModDataContentHolder m_Contents; - std::unique_ptr<Profile> m_CurrentProfile; + std::shared_ptr<Profile> m_CurrentProfile; Settings& m_Settings; diff --git a/src/organizerproxy.cpp b/src/organizerproxy.cpp index 72247b54..776f842c 100644 --- a/src/organizerproxy.cpp +++ b/src/organizerproxy.cpp @@ -370,7 +370,7 @@ MOBase::IGameFeatures* OrganizerProxy::gameFeatures() const return m_GameFeaturesProxy.get(); } -MOBase::IProfile* OrganizerProxy::profile() const +std::shared_ptr<MOBase::IProfile> OrganizerProxy::profile() const { return m_Proxied->currentProfile(); } diff --git a/src/organizerproxy.h b/src/organizerproxy.h index 9ff664b5..f5e87046 100644 --- a/src/organizerproxy.h +++ b/src/organizerproxy.h @@ -65,7 +65,7 @@ public: // IOrganizer interface MOBase::IDownloadManager* downloadManager() const override; MOBase::IPluginList* pluginList() const override; MOBase::IModList* modList() const override; - MOBase::IProfile* profile() const override; + std::shared_ptr<MOBase::IProfile> profile() const override; QStringList profileNames() const override; std::shared_ptr<const MOBase::IProfile> getProfile(const QString& name) const override; diff --git a/src/plugincontainer.cpp b/src/plugincontainer.cpp index dcb2bc7d..97c6bb09 100644 --- a/src/plugincontainer.cpp +++ b/src/plugincontainer.cpp @@ -787,7 +787,7 @@ void PluginContainer::startPluginsImpl(const std::vector<QObject*>& plugins) con auto* plugin = qobject_cast<IPlugin*>(object); auto* oproxy = organizerProxy(plugin); oproxy->connectSignals(); - oproxy->m_ProfileChanged(nullptr, m_Organizer->currentProfile()); + oproxy->m_ProfileChanged(nullptr, m_Organizer->currentProfile().get()); if (m_UserInterface) { oproxy->m_UserInterfaceInitialized(m_UserInterface->mainWindow()); diff --git a/src/pluginlist.cpp b/src/pluginlist.cpp index e476f8f2..a9512a1f 100644 --- a/src/pluginlist.cpp +++ b/src/pluginlist.cpp @@ -137,7 +137,7 @@ QString PluginList::getColumnToolTip(int column) void PluginList::highlightPlugins(const std::vector<unsigned int>& modIndices, const MOShared::DirectoryEntry& directoryEntry) { - auto* profile = m_Organizer.currentProfile(); + auto profile = m_Organizer.currentProfile(); for (auto& esp : m_ESPs) { esp.modSelected = false; diff --git a/src/processrunner.cpp b/src/processrunner.cpp index 65e44598..3fb3b9d6 100644 --- a/src/processrunner.cpp +++ b/src/processrunner.cpp @@ -544,7 +544,7 @@ ProcessRunner& ProcessRunner::setFromFile(QWidget* parent, const QFileInfo& targ ProcessRunner& ProcessRunner::setFromExecutable(const Executable& exe) { - const auto* profile = m_core.currentProfile(); + const auto profile = m_core.currentProfile(); if (!profile) { throw MyException(QObject::tr("No profile set")); } @@ -611,7 +611,7 @@ ProcessRunner& ProcessRunner::setFromFileOrExecutable( const QString& profileOverride, const QString& forcedCustomOverwrite, bool ignoreCustomOverwrite) { - const auto* profile = m_core.currentProfile(); + const auto profile = m_core.currentProfile(); if (!profile) { throw MyException(QObject::tr("No profile set")); } @@ -757,7 +757,7 @@ std::optional<ProcessRunner::Results> ProcessRunner::runBinary() { if (m_profileName.isEmpty()) { // get the current profile name if it wasn't overridden - const auto* profile = m_core.currentProfile(); + const auto profile = m_core.currentProfile(); if (!profile) { throw MyException(QObject::tr("No profile set")); } |
