From: Mikko Rasa Date: Sat, 13 Nov 2021 14:17:20 +0000 (+0200) Subject: Add a safeguard into ResourceManager::add_resource X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=28d12c73b197a16f7635badc01e42375728fde85;p=libs%2Fgl.git Add a safeguard into ResourceManager::add_resource --- diff --git a/source/resources/resourcemanager.cpp b/source/resources/resourcemanager.cpp index f25e6ad1..02a93d94 100644 --- a/source/resources/resourcemanager.cpp +++ b/source/resources/resourcemanager.cpp @@ -3,6 +3,7 @@ #include #include #include +#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)); }