Skip to content

Commit aa44561

Browse files
Change IOrganizer::profile return type to a shared_ptr (#2322)
1 parent 717b5ac commit aa44561

11 files changed

+24
-21
lines changed

src/editexecutablesdialog.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ int EditExecutablesDialog::exec()
139139

140140
void EditExecutablesDialog::loadCustomOverwrites()
141141
{
142-
const auto* p = m_organizerCore.currentProfile();
142+
const auto p = m_organizerCore.currentProfile();
143143

144144
for (const auto& e : m_executablesList) {
145145
const auto s = p->setting("custom_overwrites", e.title()).toString();
@@ -152,7 +152,7 @@ void EditExecutablesDialog::loadCustomOverwrites()
152152

153153
void EditExecutablesDialog::loadForcedLibraries()
154154
{
155-
const auto* p = m_organizerCore.currentProfile();
155+
const auto p = m_organizerCore.currentProfile();
156156

157157
for (const auto& e : m_executablesList) {
158158
m_forcedLibraries.set(e.title(), p->forcedLibrariesEnabled(e.title()),
@@ -237,7 +237,7 @@ bool EditExecutablesDialog::commitChanges()
237237
return false;
238238
}
239239

240-
auto* profile = m_organizerCore.currentProfile();
240+
auto profile = m_organizerCore.currentProfile();
241241

242242
// remove all the custom overwrites and forced libraries
243243
for (const auto& e : m_originalExecutables) {

src/mainwindow.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1802,14 +1802,14 @@ void MainWindow::on_profileBox_currentIndexChanged(int index)
18021802

18031803
auto saveGames = m_OrganizerCore.gameFeatures().gameFeature<LocalSavegames>();
18041804
if (saveGames != nullptr) {
1805-
if (saveGames->prepareProfile(m_OrganizerCore.currentProfile())) {
1805+
if (saveGames->prepareProfile(m_OrganizerCore.currentProfile().get())) {
18061806
m_SavesTab->refreshSaveList();
18071807
}
18081808
}
18091809

18101810
auto invalidation = m_OrganizerCore.gameFeatures().gameFeature<BSAInvalidation>();
18111811
if (invalidation != nullptr) {
1812-
if (invalidation->prepareProfile(m_OrganizerCore.currentProfile())) {
1812+
if (invalidation->prepareProfile(m_OrganizerCore.currentProfile().get())) {
18131813
QTimer::singleShot(5, [this] {
18141814
m_OrganizerCore.refresh();
18151815
});
@@ -2048,7 +2048,8 @@ void MainWindow::checkBSAList()
20482048
ui->bsaList->blockSignals(false);
20492049
});
20502050

2051-
QStringList defaultArchives = archives->archives(m_OrganizerCore.currentProfile());
2051+
QStringList defaultArchives =
2052+
archives->archives(m_OrganizerCore.currentProfile().get());
20522053

20532054
bool warning = false;
20542055

@@ -2400,14 +2401,14 @@ void MainWindow::on_actionAdd_Profile_triggered()
24002401

24012402
auto saveGames = m_OrganizerCore.gameFeatures().gameFeature<LocalSavegames>();
24022403
if (saveGames != nullptr) {
2403-
if (saveGames->prepareProfile(m_OrganizerCore.currentProfile())) {
2404+
if (saveGames->prepareProfile(m_OrganizerCore.currentProfile().get())) {
24042405
m_SavesTab->refreshSaveList();
24052406
}
24062407
}
24072408

24082409
auto invalidation = m_OrganizerCore.gameFeatures().gameFeature<BSAInvalidation>();
24092410
if (invalidation != nullptr) {
2410-
if (invalidation->prepareProfile(m_OrganizerCore.currentProfile())) {
2411+
if (invalidation->prepareProfile(m_OrganizerCore.currentProfile().get())) {
24112412
QTimer::singleShot(5, [this] {
24122413
m_OrganizerCore.refresh();
24132414
});

src/modinfodialogfiletree.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,7 @@ void FileTreeTab::onContextMenu(const QPoint& pos)
482482
bool enableRunHooked = false;
483483

484484
if (enableRun || enableOpen) {
485-
if (auto* p = core().currentProfile()) {
485+
if (auto p = core().currentProfile()) {
486486
if (mod().canBeEnabled()) {
487487
const auto index = ModInfo::getIndex(mod().name());
488488
if (index == UINT_MAX) {

src/modlist.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -832,7 +832,7 @@ QStringList ModList::allMods() const
832832

833833
QStringList ModList::allModsByProfilePriority(MOBase::IProfile* profile) const
834834
{
835-
Profile* mo2Profile = profile == nullptr ? m_Organizer->currentProfile()
835+
Profile* mo2Profile = profile == nullptr ? m_Organizer->currentProfile().get()
836836
: static_cast<Profile*>(profile);
837837

838838
QStringList res;

src/modlistview.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -735,7 +735,8 @@ void ModListView::setup(OrganizerCore& core, CategoryFactory& factory, MainWindo
735735
});
736736

737737
// proxy for various group by
738-
m_byPriorityProxy = new ModListByPriorityProxy(core.currentProfile(), core, this);
738+
m_byPriorityProxy =
739+
new ModListByPriorityProxy(core.currentProfile().get(), core, this);
739740
m_byCategoryProxy = new QtGroupingProxy(QModelIndex(), ModList::COL_CATEGORY,
740741
ModList::GroupingRole, 0, ModList::AggrRole);
741742
m_byNexusIdProxy = new QtGroupingProxy(
@@ -758,7 +759,7 @@ void ModListView::setup(OrganizerCore& core, CategoryFactory& factory, MainWindo
758759
});
759760

760761
// the top-level proxy
761-
m_sortProxy = new ModListSortProxy(core.currentProfile(), &core);
762+
m_sortProxy = new ModListSortProxy(core.currentProfile().get(), &core);
762763
setModel(m_sortProxy);
763764
connect(m_sortProxy, &ModList::modelReset, [=] {
764765
refreshExpandedItems();

src/organizercore.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,8 @@ class OrganizerCore : public QObject, public MOBase::IPluginDiagnose
270270
m_ExecutablesList = executablesList;
271271
}
272272

273-
Profile* currentProfile() const { return m_CurrentProfile.get(); }
273+
std::shared_ptr<Profile> currentProfile() const { return m_CurrentProfile; }
274+
274275
void setCurrentProfile(const QString& profileName);
275276

276277
QStringList profileNames() const;
@@ -540,7 +541,7 @@ private slots:
540541
MOBase::IPluginGame* m_GamePlugin;
541542
ModDataContentHolder m_Contents;
542543

543-
std::unique_ptr<Profile> m_CurrentProfile;
544+
std::shared_ptr<Profile> m_CurrentProfile;
544545

545546
Settings& m_Settings;
546547

src/organizerproxy.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ MOBase::IGameFeatures* OrganizerProxy::gameFeatures() const
370370
return m_GameFeaturesProxy.get();
371371
}
372372

373-
MOBase::IProfile* OrganizerProxy::profile() const
373+
std::shared_ptr<MOBase::IProfile> OrganizerProxy::profile() const
374374
{
375375
return m_Proxied->currentProfile();
376376
}

src/organizerproxy.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ class OrganizerProxy : public MOBase::IOrganizer
6565
MOBase::IDownloadManager* downloadManager() const override;
6666
MOBase::IPluginList* pluginList() const override;
6767
MOBase::IModList* modList() const override;
68-
MOBase::IProfile* profile() const override;
68+
std::shared_ptr<MOBase::IProfile> profile() const override;
6969
QStringList profileNames() const override;
7070
std::shared_ptr<const MOBase::IProfile>
7171
getProfile(const QString& name) const override;

src/plugincontainer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -787,7 +787,7 @@ void PluginContainer::startPluginsImpl(const std::vector<QObject*>& plugins) con
787787
auto* plugin = qobject_cast<IPlugin*>(object);
788788
auto* oproxy = organizerProxy(plugin);
789789
oproxy->connectSignals();
790-
oproxy->m_ProfileChanged(nullptr, m_Organizer->currentProfile());
790+
oproxy->m_ProfileChanged(nullptr, m_Organizer->currentProfile().get());
791791

792792
if (m_UserInterface) {
793793
oproxy->m_UserInterfaceInitialized(m_UserInterface->mainWindow());

src/pluginlist.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ QString PluginList::getColumnToolTip(int column)
137137
void PluginList::highlightPlugins(const std::vector<unsigned int>& modIndices,
138138
const MOShared::DirectoryEntry& directoryEntry)
139139
{
140-
auto* profile = m_Organizer.currentProfile();
140+
auto profile = m_Organizer.currentProfile();
141141

142142
for (auto& esp : m_ESPs) {
143143
esp.modSelected = false;

0 commit comments

Comments
 (0)