You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-06 12:20:30 +00:00
Fail when attempting to retrieve a non-existent singleton
This commit is contained in:
@@ -109,15 +109,14 @@ void Engine::add_singleton(const Singleton &p_singleton) {
|
|||||||
Object *Engine::get_singleton_object(const String &p_name) const {
|
Object *Engine::get_singleton_object(const String &p_name) const {
|
||||||
|
|
||||||
const Map<StringName, Object *>::Element *E = singleton_ptrs.find(p_name);
|
const Map<StringName, Object *>::Element *E = singleton_ptrs.find(p_name);
|
||||||
if (!E)
|
ERR_EXPLAIN("Failed to retrieve non-existent singleton '" + p_name + "'");
|
||||||
return NULL;
|
ERR_FAIL_COND_V(!E, NULL);
|
||||||
else
|
|
||||||
return E->get();
|
return E->get();
|
||||||
};
|
};
|
||||||
|
|
||||||
bool Engine::has_singleton(const String &p_name) const {
|
bool Engine::has_singleton(const String &p_name) const {
|
||||||
|
|
||||||
return get_singleton_object(p_name) != NULL;
|
return singleton_ptrs.has(p_name);
|
||||||
};
|
};
|
||||||
|
|
||||||
void Engine::get_singletons(List<Singleton> *p_singletons) {
|
void Engine::get_singletons(List<Singleton> *p_singletons) {
|
||||||
|
|||||||
Reference in New Issue
Block a user