Checking that T is in fact derived from Dependency

This commit is contained in:
Atlante45 2014-12-14 21:34:27 -08:00
parent 1db3592d4c
commit e40961df12

View file

@ -16,6 +16,7 @@
#include <QString>
#include <typeinfo>
#include <assert.h>
class DependencyManager {
public:
@ -56,7 +57,9 @@ T* DependencyManager::get() {
// Found no instance in hash so we create one.
T* newInstance = new T();
getInstanceHash().insert(typeId, dynamic_cast<Dependency*>(newInstance));
instance = dynamic_cast<Dependency*>(newInstance);
assert(instance != NULL); // If this triggers, check that T is derived from Dependency
getInstanceHash().insert(typeId, instance);
return newInstance;
}