From 66bb3000c25b98db9eeac84fdf27d1daa8afbe12 Mon Sep 17 00:00:00 2001 From: JosJuice Date: Mon, 9 Mar 2015 16:08:32 +0100 Subject: [PATCH] Don't construct NANDContentLoader classes before Main.cpp runs The cUIDsys constructor writes to /sys/uid.sys. This must not be done before Main.cpp sets the correct user paths. --- Source/Core/DiscIO/NANDContentLoader.cpp | 6 ------ Source/Core/DiscIO/NANDContentLoader.h | 19 ++++++++++++------- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/Source/Core/DiscIO/NANDContentLoader.cpp b/Source/Core/DiscIO/NANDContentLoader.cpp index 8da2cd65d8..830a9d75ff 100644 --- a/Source/Core/DiscIO/NANDContentLoader.cpp +++ b/Source/Core/DiscIO/NANDContentLoader.cpp @@ -25,9 +25,6 @@ namespace DiscIO { -CSharedContent CSharedContent::m_Instance; -cUIDsys cUIDsys::m_Instance; - CSharedContent::CSharedContent() { @@ -306,9 +303,6 @@ DiscIO::IVolume::ECountry CNANDContentLoader::GetCountry() const } -CNANDContentManager CNANDContentManager::m_Instance; - - CNANDContentManager::~CNANDContentManager() { for (auto& entry : m_Map) diff --git a/Source/Core/DiscIO/NANDContentLoader.h b/Source/Core/DiscIO/NANDContentLoader.h index 40fc9aeb04..bdb3691475 100644 --- a/Source/Core/DiscIO/NANDContentLoader.h +++ b/Source/Core/DiscIO/NANDContentLoader.h @@ -64,11 +64,11 @@ public: }; -// we open the NAND Content files to often... lets cache them +// we open the NAND Content files too often... let's cache them class CNANDContentManager { public: - static CNANDContentManager& Access() { return m_Instance; } + static CNANDContentManager& Access() { static CNANDContentManager instance; return instance; } u64 Install_WiiWAD(std::string &fileName); const INANDContentLoader& GetNANDLoader(const std::string& _rName, bool forceReload = false); @@ -79,7 +79,8 @@ private: CNANDContentManager() {} ~CNANDContentManager(); - static CNANDContentManager m_Instance; + CNANDContentManager(CNANDContentManager const&) = delete; + void operator=(CNANDContentManager const&) = delete; typedef std::map CNANDContentMap; CNANDContentMap m_Map; @@ -88,7 +89,7 @@ private: class CSharedContent { public: - static CSharedContent& AccessInstance() { return m_Instance; } + static CSharedContent& AccessInstance() { static CSharedContent instance; return instance; } std::string GetFilenameFromSHA1(const u8* _pHash); std::string AddSharedContent(const u8* _pHash); @@ -98,6 +99,9 @@ private: CSharedContent(); virtual ~CSharedContent(); + CSharedContent(CSharedContent const&) = delete; + void operator=(CSharedContent const&) = delete; + #pragma pack(push,1) struct SElement { @@ -109,13 +113,12 @@ private: u32 m_lastID; std::string m_contentMap; std::vector m_Elements; - static CSharedContent m_Instance; }; class cUIDsys { public: - static cUIDsys& AccessInstance() { return m_Instance; } + static cUIDsys& AccessInstance() { static cUIDsys instance; return instance; } u32 GetUIDFromTitle(u64 _Title); void AddTitle(u64 _Title); @@ -126,6 +129,9 @@ private: cUIDsys(); virtual ~cUIDsys(); + cUIDsys(cUIDsys const&) = delete; + void operator=(cUIDsys const&) = delete; + #pragma pack(push,1) struct SElement { @@ -137,7 +143,6 @@ private: u32 m_lastUID; std::string m_uidSys; std::vector m_Elements; - static cUIDsys m_Instance; }; }