summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/variant/variant_construct.cpp25
-rw-r--r--core/variant/variant_internal.h19
-rw-r--r--modules/gdscript/gdscript.cpp8
-rw-r--r--modules/gdscript/gdscript_vm.cpp2
4 files changed, 30 insertions, 24 deletions
diff --git a/core/variant/variant_construct.cpp b/core/variant/variant_construct.cpp
index 01f5b7df59..3bb3fa3634 100644
--- a/core/variant/variant_construct.cpp
+++ b/core/variant/variant_construct.cpp
@@ -777,18 +777,23 @@ String Variant::get_constructor_argument_name(Variant::Type p_type, int p_constr
return construct_data[p_type][p_constructor].arg_names[p_argument];
}
-void VariantInternal::object_assign(Variant *v, const Variant *o) {
- if (o->_get_obj().obj && o->_get_obj().id.is_reference()) {
- Reference *reference = static_cast<Reference *>(o->_get_obj().obj);
- if (!reference->reference()) {
- v->_get_obj().obj = nullptr;
- v->_get_obj().id = ObjectID();
- return;
+void VariantInternal::object_assign(Variant *v, const Object *o) {
+ if (o) {
+ if (o->is_reference()) {
+ Reference *reference = const_cast<Reference *>(static_cast<const Reference *>(o));
+ if (!reference->init_ref()) {
+ v->_get_obj().obj = nullptr;
+ v->_get_obj().id = ObjectID();
+ return;
+ }
}
- }
- v->_get_obj().obj = const_cast<Object *>(o->_get_obj().obj);
- v->_get_obj().id = o->_get_obj().id;
+ v->_get_obj().obj = const_cast<Object *>(o);
+ v->_get_obj().id = o->get_instance_id();
+ } else {
+ v->_get_obj().obj = nullptr;
+ v->_get_obj().id = ObjectID();
+ }
}
void Variant::get_constructor_list(Type p_type, List<MethodInfo> *r_list) {
diff --git a/core/variant/variant_internal.h b/core/variant/variant_internal.h
index bf7e46eed7..804abf8fbc 100644
--- a/core/variant/variant_internal.h
+++ b/core/variant/variant_internal.h
@@ -100,21 +100,14 @@ public:
case Variant::PACKED_COLOR_ARRAY:
init_color_array(v);
break;
+ case Variant::OBJECT:
+ object_assign_null(v);
+ break;
default:
break;
}
}
- _FORCE_INLINE_ static void set_object(Variant *v, Object *obj) {
- if (obj) {
- v->_get_obj().obj = obj;
- v->_get_obj().id = obj->get_instance_id();
- } else {
- v->_get_obj().obj = nullptr;
- v->_get_obj().id = ObjectID();
- }
- }
-
// Atomic types.
_FORCE_INLINE_ static bool *get_bool(Variant *v) { return &v->_data._bool; }
_FORCE_INLINE_ static const bool *get_bool(const Variant *v) { return &v->_data._bool; }
@@ -285,7 +278,11 @@ public:
v->clear();
}
- static void object_assign(Variant *v, const Variant *o); //needs to use reference, do away
+ static void object_assign(Variant *v, const Object *o); // Needs Reference, so it's implemented elsewhere.
+
+ _FORCE_INLINE_ static void object_assign(Variant *v, const Variant *o) {
+ object_assign(v, o->_get_obj().obj);
+ }
_FORCE_INLINE_ static void object_assign_null(Variant *v) {
v->_get_obj().obj = nullptr;
diff --git a/modules/gdscript/gdscript.cpp b/modules/gdscript/gdscript.cpp
index 53602f7a9b..6b74abf15d 100644
--- a/modules/gdscript/gdscript.cpp
+++ b/modules/gdscript/gdscript.cpp
@@ -628,8 +628,12 @@ Error GDScript::reload(bool p_keep_state) {
if (EngineDebugger::is_active()) {
GDScriptLanguage::get_singleton()->debug_break_parse(get_path(), parser.get_errors().front()->get().line, "Parser Error: " + parser.get_errors().front()->get().message);
}
- // TODO: Show all error messages.
- _err_print_error("GDScript::reload", path.empty() ? "built-in" : (const char *)path.utf8().get_data(), parser.get_errors().front()->get().line, ("Parse Error: " + parser.get_errors().front()->get().message).utf8().get_data(), ERR_HANDLER_SCRIPT);
+
+ const List<GDScriptParser::ParserError>::Element *e = parser.get_errors().front();
+ while (e != nullptr) {
+ _err_print_error("GDScript::reload", path.empty() ? "built-in" : (const char *)path.utf8().get_data(), e->get().line, ("Parse Error: " + e->get().message).utf8().get_data(), ERR_HANDLER_SCRIPT);
+ e = e->next();
+ }
ERR_FAIL_V(ERR_PARSE_ERROR);
}
diff --git a/modules/gdscript/gdscript_vm.cpp b/modules/gdscript/gdscript_vm.cpp
index 7c8bfcd944..7942ee8d97 100644
--- a/modules/gdscript/gdscript_vm.cpp
+++ b/modules/gdscript/gdscript_vm.cpp
@@ -1653,7 +1653,7 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
VariantInternal::initialize(ret, Variant::OBJECT);
Object **ret_opaque = VariantInternal::get_object(ret);
method->ptrcall(base_obj, argptrs, ret_opaque);
- VariantInternal::set_object(ret, *ret_opaque);
+ VariantInternal::object_assign(ret, *ret_opaque); // Set so ID is correct too.
#ifdef DEBUG_ENABLED
if (GDScriptLanguage::get_singleton()->profiling) {