diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2020-11-23 11:26:10 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-23 11:26:10 +0100 |
commit | 18023cc3ede6fd84842db77019085c383e807016 (patch) | |
tree | a7ae3386ad92765723c34199e6faa94ea2c4de49 | |
parent | a248e6f8c324ead983d9cf4cc201ffda68ae5158 (diff) | |
parent | e79162ec4e7f7813a38d5df3b508a6dce65bb6d4 (diff) |
Merge pull request #43788 from RandomShaper/ref_singleton
Make warning about Reference singletons more accurate
-rw-r--r-- | core/config/engine.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/core/config/engine.cpp b/core/config/engine.cpp index 8e2ab094b0..26f8cdf840 100644 --- a/core/config/engine.cpp +++ b/core/config/engine.cpp @@ -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 } |