]> git.tdb.fi Git - libs/gl.git/commitdiff
Add a safeguard into ResourceManager::add_resource
authorMikko Rasa <tdb@tdb.fi>
Sat, 13 Nov 2021 14:17:20 +0000 (16:17 +0200)
committerMikko Rasa <tdb@tdb.fi>
Sat, 13 Nov 2021 14:26:46 +0000 (16:26 +0200)
source/resources/resourcemanager.cpp

index f25e6ad1db1b53e609b68cf8d8d9559848da7b66..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"
@@ -56,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));
 }