Merge pull request #73705 from anvilfolk/doublewoopsie
Added check for null objects in gdscript typed assign.
This commit is contained in:
commit
d4bec5855e
3 changed files with 47 additions and 20 deletions
|
@ -1326,6 +1326,7 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
|
||||||
OPCODE_BREAK;
|
OPCODE_BREAK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (val_obj) { // src is not null
|
||||||
ScriptInstance *scr_inst = val_obj->get_script_instance();
|
ScriptInstance *scr_inst = val_obj->get_script_instance();
|
||||||
if (!scr_inst) {
|
if (!scr_inst) {
|
||||||
err_text = "Trying to assign value of type '" + val_obj->get_class_name() +
|
err_text = "Trying to assign value of type '" + val_obj->get_class_name() +
|
||||||
|
@ -1333,7 +1334,7 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
|
||||||
OPCODE_BREAK;
|
OPCODE_BREAK;
|
||||||
}
|
}
|
||||||
|
|
||||||
Script *src_type = val_obj->get_script_instance()->get_script().ptr();
|
Script *src_type = scr_inst->get_script().ptr();
|
||||||
bool valid = false;
|
bool valid = false;
|
||||||
|
|
||||||
while (src_type) {
|
while (src_type) {
|
||||||
|
@ -1350,6 +1351,7 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
|
||||||
OPCODE_BREAK;
|
OPCODE_BREAK;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
#endif // DEBUG_ENABLED
|
#endif // DEBUG_ENABLED
|
||||||
|
|
||||||
*dst = *src;
|
*dst = *src;
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
extends Node
|
||||||
|
|
||||||
|
class LocalClass extends Node:
|
||||||
|
pass
|
||||||
|
|
||||||
|
func test():
|
||||||
|
var typed: LocalClass = get_node_or_null("does_not_exist")
|
||||||
|
var untyped = null
|
||||||
|
var node_1: LocalClass = typed
|
||||||
|
var node_2: LocalClass = untyped
|
||||||
|
var node_3 = typed
|
||||||
|
var node_4 = untyped
|
||||||
|
print(typed)
|
||||||
|
print(untyped)
|
||||||
|
print(node_1)
|
||||||
|
print(node_2)
|
||||||
|
print(node_3)
|
||||||
|
print(node_4)
|
|
@ -0,0 +1,7 @@
|
||||||
|
GDTEST_OK
|
||||||
|
<Object#null>
|
||||||
|
<null>
|
||||||
|
<Object#null>
|
||||||
|
<null>
|
||||||
|
<Object#null>
|
||||||
|
<null>
|
Loading…
Add table
Reference in a new issue