Skip to content

Commit

Permalink
Make warning about Reference singletons more accurate
Browse files Browse the repository at this point in the history
  • Loading branch information
RandomShaper committed Nov 23, 2020
1 parent a248e6f commit e79162e
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions core/config/engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

0 comments on commit e79162e

Please sign in to comment.