Warn about singleton being a Reference
This commit is contained in:
parent
a3a3b02bed
commit
e1150bd912
2 changed files with 11 additions and 4 deletions
|
@ -219,3 +219,13 @@ Engine *Engine::get_singleton() {
|
||||||
Engine::Engine() {
|
Engine::Engine() {
|
||||||
singleton = this;
|
singleton = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Engine::Singleton::Singleton(const StringName &p_name, Object *p_ptr) :
|
||||||
|
name(p_name),
|
||||||
|
ptr(p_ptr) {
|
||||||
|
#ifdef DEBUG_ENABLED
|
||||||
|
if (Object::cast_to<Reference>(p_ptr)) {
|
||||||
|
ERR_PRINT("A class intended to be used as a singleton must *not* inherit from Reference.");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
|
@ -41,10 +41,7 @@ public:
|
||||||
struct Singleton {
|
struct Singleton {
|
||||||
StringName name;
|
StringName name;
|
||||||
Object *ptr;
|
Object *ptr;
|
||||||
Singleton(const StringName &p_name = StringName(), Object *p_ptr = nullptr) :
|
Singleton(const StringName &p_name = StringName(), Object *p_ptr = nullptr);
|
||||||
name(p_name),
|
|
||||||
ptr(p_ptr) {
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
Loading…
Reference in a new issue