mirror of
https://github.com/love2d/love.git
synced 2026-08-12 08:30:56 +02:00
Modules now properly remove themselves from the global registry when they're deleted
This commit is contained in:
+16
-1
@@ -35,6 +35,21 @@ namespace
|
||||
namespace love
|
||||
{
|
||||
|
||||
Module::~Module()
|
||||
{
|
||||
std::map<std::string, Module*>::iterator it;
|
||||
|
||||
// We can't use the overridden Module::getName() in this destructor.
|
||||
for (it = registry.begin(); it != registry.end(); ++it)
|
||||
{
|
||||
if (it->second == this)
|
||||
{
|
||||
registry.erase(it);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Module::registerInstance(Module *instance)
|
||||
{
|
||||
if (instance == NULL)
|
||||
@@ -44,7 +59,7 @@ void Module::registerInstance(Module *instance)
|
||||
|
||||
std::map<std::string, Module*>::iterator it = registry.find(name);
|
||||
|
||||
if (registry.end() != it)
|
||||
if (it != registry.end())
|
||||
{
|
||||
if (it->second == instance)
|
||||
return;
|
||||
|
||||
+1
-1
@@ -38,7 +38,7 @@ public:
|
||||
/**
|
||||
* Destructor.
|
||||
**/
|
||||
virtual ~Module() {};
|
||||
virtual ~Module();
|
||||
|
||||
/**
|
||||
* Gets the name of the module. This is used in case of errors
|
||||
|
||||
Reference in New Issue
Block a user