mirror of
https://github.com/AxioDL/PrimeWorldEditor.git
synced 2025-12-17 08:57:09 +00:00
Fixed various bugs and crashes and moved more functionality into the world editor
This commit is contained in:
@@ -356,6 +356,7 @@ CResource* CResourceEntry::LoadCooked(IInputStream& rInput)
|
||||
bool CResourceEntry::Unload()
|
||||
{
|
||||
ASSERT(mpResource != nullptr);
|
||||
ASSERT(!mpResource->IsReferenced());
|
||||
delete mpResource;
|
||||
mpResource = nullptr;
|
||||
return true;
|
||||
|
||||
@@ -277,6 +277,21 @@ void CResourceStore::CloseProject()
|
||||
// various TResPtrs are destroyed. There might be a cleaner solution than this.)
|
||||
DestroyUnreferencedResources();
|
||||
|
||||
// There should be no loaded resources!!!
|
||||
// If there are, that means something didn't clean up resource references properly on project close!!!
|
||||
if (!mLoadedResources.empty())
|
||||
{
|
||||
Log::Error(TString::FromInt32(mLoadedResources.size(), 0, 10) + " resources still loaded on project close:");
|
||||
|
||||
for (auto Iter = mLoadedResources.begin(); Iter != mLoadedResources.end(); Iter++)
|
||||
{
|
||||
CResourceEntry *pEntry = Iter->second;
|
||||
Log::Write("\t" + pEntry->Name().ToUTF8() + "." + pEntry->CookedExtension().ToString());
|
||||
}
|
||||
|
||||
ASSERT(false);
|
||||
}
|
||||
|
||||
// Delete all entries from old project
|
||||
auto It = mResourceEntries.begin();
|
||||
|
||||
@@ -286,16 +301,6 @@ void CResourceStore::CloseProject()
|
||||
|
||||
if (!pEntry->IsTransient())
|
||||
{
|
||||
if (pEntry->IsLoaded())
|
||||
{
|
||||
bool UnloadSuccess = pEntry->Unload();
|
||||
ASSERT(UnloadSuccess);
|
||||
|
||||
auto LoadIt = mLoadedResources.find(pEntry->ID());
|
||||
ASSERT(LoadIt != mLoadedResources.end());
|
||||
mLoadedResources.erase(LoadIt);
|
||||
}
|
||||
|
||||
delete pEntry;
|
||||
It = mResourceEntries.erase(It);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user