diff options
author | Leon Krause <lk@leonkrause.com> | 2017-11-14 14:52:24 +0100 |
---|---|---|
committer | Leon Krause <lk@leonkrause.com> | 2017-11-14 16:15:00 +0100 |
commit | acb23adad37b459e64b8f9bafbbdd1185d46093d (patch) | |
tree | fb2e542c508d7b17676ca90a39e5deabfa7e6ea1 /core | |
parent | 9b7b46143d2df7d4f2efcb89ceb5034c7a57e79c (diff) |
Fail when attempting to retrieve a non-existent singleton
Diffstat (limited to 'core')
-rw-r--r-- | core/engine.cpp | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/core/engine.cpp b/core/engine.cpp index d2ef70d82b..31abcd62ef 100644 --- a/core/engine.cpp +++ b/core/engine.cpp @@ -109,15 +109,14 @@ void Engine::add_singleton(const Singleton &p_singleton) { Object *Engine::get_singleton_object(const String &p_name) const { const Map<StringName, Object *>::Element *E = singleton_ptrs.find(p_name); - if (!E) - return NULL; - else - return E->get(); + ERR_EXPLAIN("Failed to retrieve non-existent singleton '" + p_name + "'"); + ERR_FAIL_COND_V(!E, NULL); + return E->get(); }; 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) { |