From b808af1d7f2df9937a175e8cfd1a49c0bc41aebc Mon Sep 17 00:00:00 2001 From: LPFaint99 Date: Sun, 5 Jun 2011 07:42:40 +0000 Subject: [PATCH] fix infinitely recursive deletion from r7587 and actually update locations of content.map and uid.sys git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@7588 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Core/Core/Src/ConfigManager.cpp | 3 ++ Source/Core/DiscIO/Src/NANDContentLoader.cpp | 43 ++++++-------------- Source/Core/DiscIO/Src/NANDContentLoader.h | 12 +++--- Source/Core/DolphinWX/Src/ConfigMain.cpp | 4 +- 4 files changed, 24 insertions(+), 38 deletions(-) diff --git a/Source/Core/Core/Src/ConfigManager.cpp b/Source/Core/Core/Src/ConfigManager.cpp index 581ca53302..31a359a32f 100644 --- a/Source/Core/Core/Src/ConfigManager.cpp +++ b/Source/Core/Core/Src/ConfigManager.cpp @@ -22,6 +22,7 @@ #include "IniFile.h" #include "ConfigManager.h" #include "FileUtil.h" +#include "NANDContentLoader.h" SConfig* SConfig::m_Instance; @@ -278,6 +279,8 @@ void SConfig::LoadSettings() ini.Get("General", "NANDRoot", &m_NANDPath); m_NANDPath = File::GetUserPath(D_WIIROOT_IDX, m_NANDPath); + DiscIO::cUIDsys::AccessInstance().UpdateLocation(); + DiscIO::CSharedContent::AccessInstance().UpdateLocation(); } { diff --git a/Source/Core/DiscIO/Src/NANDContentLoader.cpp b/Source/Core/DiscIO/Src/NANDContentLoader.cpp index 3419ea98f0..ff8be03f89 100644 --- a/Source/Core/DiscIO/Src/NANDContentLoader.cpp +++ b/Source/Core/DiscIO/Src/NANDContentLoader.cpp @@ -28,23 +28,18 @@ namespace DiscIO { -CSharedContent *CSharedContent::m_Instance = NULL; -cUIDsys *cUIDsys::m_Instance = NULL; +CSharedContent CSharedContent::m_Instance; +cUIDsys cUIDsys::m_Instance; -CSharedContent& CSharedContent::AccessInstance() + +CSharedContent::CSharedContent() { - if (!m_Instance) m_Instance = new CSharedContent; - return *m_Instance; + UpdateLocation(); } void CSharedContent::UpdateLocation() { - delete m_Instance; - m_Instance = new CSharedContent; -} - -CSharedContent::CSharedContent() -{ + m_Elements.clear(); lastID = 0; sprintf(contentMap, "%sshared1/content.map", File::GetUserPath(D_WIIUSER_IDX).c_str()); @@ -58,10 +53,7 @@ CSharedContent::CSharedContent() } CSharedContent::~CSharedContent() -{ - delete m_Instance; - m_Instance = NULL; -} +{} std::string CSharedContent::GetFilenameFromSHA1(u8* _pHash) { @@ -409,23 +401,17 @@ void CNANDContentLoader::RemoveTitle() const } } -cUIDsys& cUIDsys::AccessInstance() +cUIDsys::cUIDsys() { - if (!m_Instance) m_Instance = new cUIDsys; - return *m_Instance; + UpdateLocation(); } void cUIDsys::UpdateLocation() { - delete m_Instance; - m_Instance = new cUIDsys; -} - -cUIDsys::cUIDsys() -{ - sprintf(uidSys, "%ssys/uid.sys", File::GetUserPath(D_WIIUSER_IDX).c_str()); + m_Elements.clear(); lastUID = 0x00001000; - + sprintf(uidSys, "%ssys/uid.sys", File::GetUserPath(D_WIIUSER_IDX).c_str()); + File::IOFile pFile(uidSys, "rb"); SElement Element; while (pFile.ReadArray(&Element, 1)) @@ -448,10 +434,7 @@ cUIDsys::cUIDsys() } cUIDsys::~cUIDsys() -{ - delete m_Instance; - m_Instance = NULL; -} +{} u32 cUIDsys::GetUIDFromTitle(u64 _Title) { diff --git a/Source/Core/DiscIO/Src/NANDContentLoader.h b/Source/Core/DiscIO/Src/NANDContentLoader.h index 1a2f96a431..14a2062641 100644 --- a/Source/Core/DiscIO/Src/NANDContentLoader.h +++ b/Source/Core/DiscIO/Src/NANDContentLoader.h @@ -106,11 +106,11 @@ class CSharedContent { public: - static CSharedContent& AccessInstance(); - static void UpdateLocation(); + static CSharedContent& AccessInstance() { return m_Instance; } std::string GetFilenameFromSHA1(u8* _pHash); std::string AddSharedContent(u8* _pHash); + void UpdateLocation(); private: @@ -130,19 +130,19 @@ private: u32 lastID; char contentMap[1024]; std::vector m_Elements; - static CSharedContent *m_Instance; + static CSharedContent m_Instance; }; class cUIDsys { public: - static cUIDsys& AccessInstance(); - static void UpdateLocation(); + static cUIDsys& AccessInstance() { return m_Instance; } u32 GetUIDFromTitle(u64 _Title); void AddTitle(u64 _Title); void GetTitleIDs(std::vector& _TitleIDs, bool _owned = false); + void UpdateLocation(); private: @@ -160,7 +160,7 @@ private: u32 lastUID; char uidSys[1024]; std::vector m_Elements; - static cUIDsys *m_Instance; + static cUIDsys m_Instance; }; } diff --git a/Source/Core/DolphinWX/Src/ConfigMain.cpp b/Source/Core/DolphinWX/Src/ConfigMain.cpp index 91a36a44cd..25b4fe0639 100644 --- a/Source/Core/DolphinWX/Src/ConfigMain.cpp +++ b/Source/Core/DolphinWX/Src/ConfigMain.cpp @@ -1203,8 +1203,8 @@ void CConfigMain::NANDRootChanged(wxFileDirPickerEvent& WXUNUSED (event)) SConfig::GetInstance().m_NANDPath = File::GetUserPath(D_WIIROOT_IDX, std::string(NANDRoot->GetPath().mb_str())); NANDRoot->SetPath(wxString(NANDPath.c_str(), *wxConvCurrent)); SConfig::GetInstance().m_SYSCONF->UpdateLocation(); - DiscIO::cUIDsys::UpdateLocation(); - DiscIO::CSharedContent::UpdateLocation(); + DiscIO::cUIDsys::AccessInstance().UpdateLocation(); + DiscIO::CSharedContent::AccessInstance().UpdateLocation(); main_frame->UpdateWiiMenuChoice(); }