mirror of
https://github.com/godotengine/godot.git
synced 2024-11-22 12:12:28 +00:00
Merge pull request #43788 from RandomShaper/ref_singleton
Make warning about Reference singletons more accurate
This commit is contained in:
commit
18023cc3ed
@ -224,8 +224,9 @@ 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.");
|
||||
Reference *ref = Object::cast_to<Reference>(p_ptr);
|
||||
if (ref && !ref->is_referenced()) {
|
||||
WARN_PRINT("You must use Ref<> to ensure the lifetime of a Reference object intended to be used as a singleton.");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user