mirror of
https://github.com/godotengine/godot.git
synced 2026-01-03 18:11:19 +03:00
Refactor ref-counting code and fix ref counted releasing before aquiring
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user