From 20703b6d4dfd0836cdb787bd416d4ae9bf010602 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Sun, 31 Aug 2014 01:37:36 +0300 Subject: [PATCH] Dissolve the association to resources when ResourceManager is destroyed --- source/resourcemanager.cpp | 3 +++ source/resourcemanager.h | 5 +++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/source/resourcemanager.cpp b/source/resourcemanager.cpp index 81aea8c1..98a49744 100644 --- a/source/resourcemanager.cpp +++ b/source/resourcemanager.cpp @@ -15,6 +15,9 @@ ResourceManager::ResourceManager(): ResourceManager::~ResourceManager() { thread.terminate(); + + for(ResourceMap::iterator i=resources.begin(); i!=resources.end(); ++i) + i->second.resource->set_manager(0); } void ResourceManager::add_resource(Resource &r) diff --git a/source/resourcemanager.h b/source/resourcemanager.h index fb435335..49a4c0bd 100644 --- a/source/resourcemanager.h +++ b/source/resourcemanager.h @@ -65,12 +65,13 @@ private: void terminate(); }; + typedef std::map ResourceMap; typedef std::list LoadQueue; LoadingPolicy policy; bool async_loads; - std::map resources; - std::list queue; + ResourceMap resources; + LoadQueue queue; LoadingThread thread; public: -- 2.45.2