From 650af5eb64d3c560044cf1e806159f1d64985aa6 Mon Sep 17 00:00:00 2001 From: flow Date: Wed, 6 Jul 2022 13:21:06 -0300 Subject: [PATCH] change: use ModStatus as a simple member instead of a pointer Signed-off-by: flow --- launcher/minecraft/mod/Mod.cpp | 9 +++------ launcher/minecraft/mod/Mod.h | 2 +- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/launcher/minecraft/mod/Mod.cpp b/launcher/minecraft/mod/Mod.cpp index 7227fc94..588d76e3 100644 --- a/launcher/minecraft/mod/Mod.cpp +++ b/launcher/minecraft/mod/Mod.cpp @@ -147,10 +147,7 @@ void Mod::setStatus(ModStatus status) if (m_localDetails) { m_localDetails->status = status; } else { - if (!m_temp_status.get()) - m_temp_status.reset(new ModStatus()); - - *m_temp_status = status; + m_temp_status = status; } } void Mod::setMetadata(const Metadata::ModStruct& metadata) @@ -222,7 +219,7 @@ auto Mod::authors() const -> QStringList auto Mod::status() const -> ModStatus { if (!m_localDetails) - return m_temp_status ? *m_temp_status : ModStatus::NoMetadata; + return m_temp_status; return details().status; } @@ -246,7 +243,7 @@ void Mod::finishResolvingWithDetails(std::shared_ptr details) m_resolved = true; m_localDetails = details; - setStatus(m_temp_status ? *m_temp_status : ModStatus::NoMetadata); + setStatus(m_temp_status); if (m_localDetails && m_temp_metadata && m_temp_metadata->isValid()) { setMetadata(*m_temp_metadata); diff --git a/launcher/minecraft/mod/Mod.h b/launcher/minecraft/mod/Mod.h index 3d3becd7..7a13e44b 100644 --- a/launcher/minecraft/mod/Mod.h +++ b/launcher/minecraft/mod/Mod.h @@ -115,7 +115,7 @@ protected: std::shared_ptr m_temp_metadata; /* Set the mod status while it doesn't have local details just yet */ - std::shared_ptr m_temp_status; + ModStatus m_temp_status = ModStatus::NoMetadata; std::shared_ptr m_localDetails;