comparison src/common/Module.cpp @ 1125:05f0d0e44cd5

Don't throw exception when loading module in thread. The module registry throws an exception when trying to register a module instances if an instance is already registered under the same name. This backfired in love.thread when requiring love-modules.
author vrld <vrld@vrld.org>
date Mon, 10 Sep 2012 12:39:37 +0200
parents 3c6206da8bcf
children b7f097053d74
comparison
equal deleted inserted replaced
1124:a66afb2d4fd0 1125:05f0d0e44cd5
40 throw Exception("Module instance is NULL"); 40 throw Exception("Module instance is NULL");
41 41
42 std::string name(instance->getName()); 42 std::string name(instance->getName());
43 43
44 std::map<std::string, Module*>::iterator it = registry.find(name); 44 std::map<std::string, Module*>::iterator it = registry.find(name);
45
45 if (registry.end() != it) 46 if (registry.end() != it)
47 {
48 if (it->second == instance)
49 return;
46 throw Exception("Module %s already registered!", instance->getName()); 50 throw Exception("Module %s already registered!", instance->getName());
51 }
47 52
48 registry.insert(make_pair(name, instance)); 53 registry.insert(make_pair(name, instance));
49 } 54 }
50 55
51 Module *Module::getInstance(const char *name) 56 Module *Module::getInstance(const char *name)