mirror of
https://github.com/godotengine/godot.git
synced 2025-10-20 08:23:29 +00:00
Changed logic and optimized ObjectID in ObjectDB and Variant, removed RefPtr.
This commit is contained in:
parent
53cf289f30
commit
867d073b98
51 changed files with 446 additions and 573 deletions
|
@ -137,18 +137,19 @@ static String _get_var_type(const Variant *p_var) {
|
|||
String basestr;
|
||||
|
||||
if (p_var->get_type() == Variant::OBJECT) {
|
||||
Object *bobj = *p_var;
|
||||
bool was_freed;
|
||||
Object *bobj = p_var->get_validated_object_with_check(was_freed);
|
||||
if (!bobj) {
|
||||
basestr = "null instance";
|
||||
} else {
|
||||
if (ObjectDB::instance_validate(bobj)) {
|
||||
if (bobj->get_script_instance())
|
||||
basestr = bobj->get_class() + " (" + bobj->get_script_instance()->get_script()->get_path().get_file() + ")";
|
||||
else
|
||||
basestr = bobj->get_class();
|
||||
if (was_freed) {
|
||||
basestr = "null instance";
|
||||
} else {
|
||||
basestr = "previously freed instance";
|
||||
basestr = "previously freed";
|
||||
}
|
||||
} else {
|
||||
if (bobj->get_script_instance())
|
||||
basestr = bobj->get_class() + " (" + bobj->get_script_instance()->get_script()->get_path().get_file() + ")";
|
||||
else
|
||||
basestr = bobj->get_class();
|
||||
}
|
||||
|
||||
} else {
|
||||
|
@ -497,14 +498,26 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
|
|||
|
||||
bool extends_ok = false;
|
||||
if (a->get_type() == Variant::OBJECT && a->operator Object *() != NULL) {
|
||||
Object *obj_A = *a;
|
||||
Object *obj_B = *b;
|
||||
|
||||
#ifdef DEBUG_ENABLED
|
||||
if (!ObjectDB::instance_validate(obj_A)) {
|
||||
err_text = "Left operand of 'is' was already freed.";
|
||||
bool was_freed;
|
||||
Object *obj_A = a->get_validated_object_with_check(was_freed);
|
||||
|
||||
if (was_freed) {
|
||||
err_text = "Left operand of 'is' is a previously freed instance.";
|
||||
OPCODE_BREAK;
|
||||
}
|
||||
|
||||
Object *obj_B = b->get_validated_object_with_check(was_freed);
|
||||
|
||||
if (was_freed) {
|
||||
err_text = "Right operand of 'is' is a previously freed instance.";
|
||||
OPCODE_BREAK;
|
||||
}
|
||||
#else
|
||||
|
||||
Object *obj_A = *a;
|
||||
Object *obj_B = *b;
|
||||
#endif // DEBUG_ENABLED
|
||||
|
||||
GDScript *scr_B = Object::cast_to<GDScript>(obj_B);
|
||||
|
@ -1298,20 +1311,20 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
|
|||
}
|
||||
#endif
|
||||
|
||||
Object *obj = argobj->operator Object *();
|
||||
#ifdef DEBUG_ENABLED
|
||||
bool was_freed;
|
||||
Object *obj = argobj->get_validated_object_with_check(was_freed);
|
||||
String signal = argname->operator String();
|
||||
|
||||
#ifdef DEBUG_ENABLED
|
||||
if (was_freed) {
|
||||
err_text = "First argument of yield() is a previously freed instance.";
|
||||
OPCODE_BREAK;
|
||||
}
|
||||
|
||||
if (!obj) {
|
||||
err_text = "First argument of yield() is null.";
|
||||
OPCODE_BREAK;
|
||||
}
|
||||
if (ScriptDebugger::get_singleton()) {
|
||||
if (!ObjectDB::instance_validate(obj)) {
|
||||
err_text = "First argument of yield() is a previously freed instance.";
|
||||
OPCODE_BREAK;
|
||||
}
|
||||
}
|
||||
if (signal.length() == 0) {
|
||||
|
||||
err_text = "Second argument of yield() is an empty string (for signal name).";
|
||||
|
@ -1324,6 +1337,9 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
|
|||
OPCODE_BREAK;
|
||||
}
|
||||
#else
|
||||
Object *obj = argobj->operator Object *();
|
||||
String signal = argname->operator String();
|
||||
|
||||
obj->connect(signal, gdfs.ptr(), "_signal_callback", varray(gdfs), Object::CONNECT_ONESHOT);
|
||||
#endif
|
||||
}
|
||||
|
@ -1565,14 +1581,14 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
|
|||
//error
|
||||
// function, file, line, error, explanation
|
||||
String err_file;
|
||||
if (p_instance && ObjectDB::instance_validate(p_instance->owner) && p_instance->script->is_valid() && p_instance->script->path != "")
|
||||
if (p_instance && ObjectDB::get_instance(p_instance->owner_id) != nullptr && p_instance->script->is_valid() && p_instance->script->path != "")
|
||||
err_file = p_instance->script->path;
|
||||
else if (script)
|
||||
err_file = script->path;
|
||||
if (err_file == "")
|
||||
err_file = "<built-in>";
|
||||
String err_func = name;
|
||||
if (p_instance && ObjectDB::instance_validate(p_instance->owner) && p_instance->script->is_valid() && p_instance->script->name != "")
|
||||
if (p_instance && ObjectDB::get_instance(p_instance->owner_id) != nullptr && p_instance->script->is_valid() && p_instance->script->name != "")
|
||||
err_func = p_instance->script->name + "." + err_func;
|
||||
int err_line = line;
|
||||
if (err_text == "") {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue