]> git.tdb.fi Git - libs/gl.git/blobdiff - source/resources/resourcemanager.cpp
Add a safeguard into ResourceManager::add_resource
[libs/gl.git] / source / resources / resourcemanager.cpp
index 5358183f24bc5a39d156b6f9bcab1c87136bac31..02a93d949997c3aae421b3f4322e3bfb0881a855 100644 (file)
@@ -3,6 +3,7 @@
 #include <msp/debug/demangle.h>
 #include <msp/strings/format.h>
 #include <msp/time/utils.h>
+#include "error.h"
 #include "resourcemanager.h"
 #include "resources.h"
 #include "resourceobserver.h"
@@ -21,17 +22,6 @@ resource_load_error::resource_load_error(const string &name, const exception &ex
 { }
 
 
-ResourceManager::ResourceManager():
-       policy(LOAD_ON_DEMAND),
-       async_loads(true),
-       total_data_size(0),
-       size_limit(0),
-       frame(0),
-       min_retain_frames(30),
-       max_retain_frames(0),
-       next_unload(0)
-{ }
-
 ResourceManager::~ResourceManager()
 {
        thread.terminate();
@@ -67,6 +57,8 @@ void ResourceManager::set_max_retain_frames(unsigned f)
 
 void ResourceManager::add_resource(Resource &r)
 {
+       if(r.get_manager()!=this)
+               throw invalid_operation("ResourceManager::add_resource");
        MutexLock lock(map_mutex);
        insert_unique(resources, &r, ManagedResource(r));
 }