Selaa lähdekoodia

Make warning about Reference singletons more accurate

Pedro J. Estébanez 4 vuotta sitten
vanhempi
commit
8ec5ffe17e
1 muutettua tiedostoa jossa 3 lisäystä ja 2 poistoa
  1. 3 2
      core/engine.cpp

+ 3 - 2
core/engine.cpp

@@ -241,8 +241,9 @@ Engine::Singleton::Singleton(const StringName &p_name, Object *p_ptr) :
 		name(p_name),
 		name(p_name),
 		ptr(p_ptr) {
 		ptr(p_ptr) {
 #ifdef DEBUG_ENABLED
 #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
 #endif
 }
 }