1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-11 13:10:58 +00:00

Warn about singleton being a Reference

(cherry picked from commit e1150bd912)
This commit is contained in:
Pedro J. Estébanez
2020-11-19 11:46:05 +01:00
committed by Rémi Verschelde
parent b9641efc5c
commit 9df6edc7d7
2 changed files with 11 additions and 4 deletions

View File

@@ -236,3 +236,13 @@ Engine::Engine() {
_frame_step = 0; _frame_step = 0;
editor_hint = false; editor_hint = false;
} }
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
}

View File

@@ -42,10 +42,7 @@ public:
struct Singleton { struct Singleton {
StringName name; StringName name;
Object *ptr; Object *ptr;
Singleton(const StringName &p_name = StringName(), Object *p_ptr = NULL) : Singleton(const StringName &p_name = StringName(), Object *p_ptr = NULL);
name(p_name),
ptr(p_ptr) {
}
}; };
private: private: