summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2018-09-06 21:07:46 -0300
committerJuan Linietsky <reduzio@gmail.com>2018-09-06 21:07:46 -0300
commitf1e5b7cf42010db1251ecef34695367c125f02e1 (patch)
tree162db34049ad239ef72076b25c55a5e463f6ea05
parent74359a1d1e288a156d89e052d6b4ae6e8c187c6b (diff)
downloadredot-engine-f1e5b7cf42010db1251ecef34695367c125f02e1.tar.gz
Print an error if you try to instantiate an editor class outside the editor, fixes #17624
-rw-r--r--core/class_db.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/core/class_db.cpp b/core/class_db.cpp
index 03b214aa41..eceefa1ee4 100644
--- a/core/class_db.cpp
+++ b/core/class_db.cpp
@@ -30,6 +30,7 @@
#include "class_db.h"
+#include "engine.h"
#include "os/mutex.h"
#include "version.h"
@@ -512,7 +513,12 @@ Object *ClassDB::instance(const StringName &p_class) {
ERR_FAIL_COND_V(ti->disabled, NULL);
ERR_FAIL_COND_V(!ti->creation_func, NULL);
}
-
+#ifdef TOOLS_ENABLED
+ if (ti->api == API_EDITOR && !Engine::get_singleton()->is_editor_hint()) {
+ ERR_PRINTS("Class '" + String(p_class) + "' can only be instantiated by editor.");
+ return NULL;
+ }
+#endif
return ti->creation_func();
}
bool ClassDB::can_instance(const StringName &p_class) {