Refactor ref-counting code and fix ref counted releasing before aquiring

This commit is contained in:
rune-scape
2024-06-18 03:31:23 -07:00
committed by rune-scape
parent e4e024ab88
commit cee0e6667a
7 changed files with 154 additions and 189 deletions

View File

@@ -315,31 +315,32 @@ bool Callable::operator<(const Callable &p_callable) const {
}
void Callable::operator=(const Callable &p_callable) {
CallableCustom *cleanup_ref = nullptr;
if (is_custom()) {
if (p_callable.is_custom()) {
if (custom == p_callable.custom) {
return;
}
}
if (custom->ref_count.unref()) {
memdelete(custom);
custom = nullptr;
}
cleanup_ref = custom;
custom = nullptr;
}
if (p_callable.is_custom()) {
method = StringName();
if (!p_callable.custom->ref_count.ref()) {
object = 0;
} else {
object = 0;
object = 0;
if (p_callable.custom->ref_count.ref()) {
custom = p_callable.custom;
}
} else {
method = p_callable.method;
object = p_callable.object;
}
if (cleanup_ref != nullptr && cleanup_ref->ref_count.unref()) {
memdelete(cleanup_ref);
}
cleanup_ref = nullptr;
}
Callable::operator String() const {