Skip to content

Commit

Permalink
Merge pull request #93091 from RandomShaper/remove_false_safety
Browse files Browse the repository at this point in the history
Remove no longer needed thread safety measures
  • Loading branch information
akien-mga committed Jun 14, 2024
2 parents 08a21fd + b6994a4 commit 75eb8ad
Showing 1 changed file with 1 addition and 16 deletions.
17 changes: 1 addition & 16 deletions core/io/resource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,7 @@
#include <stdio.h>

void Resource::emit_changed() {
if (ResourceLoader::is_within_load() && !Thread::is_main_thread()) {
// Let the connection happen on the main thread, later, since signals are not thread-safe.
call_deferred("emit_signal", CoreStringName(changed));
} else {
emit_signal(CoreStringName(changed));
}
emit_signal(CoreStringName(changed));
}

void Resource::_resource_path_changed() {
Expand Down Expand Up @@ -166,22 +161,12 @@ bool Resource::editor_can_reload_from_file() {
}

void Resource::connect_changed(const Callable &p_callable, uint32_t p_flags) {
if (ResourceLoader::is_within_load() && !Thread::is_main_thread()) {
// Let the check and connection happen on the main thread, later, since signals are not thread-safe.
callable_mp(this, &Resource::connect_changed).call_deferred(p_callable, p_flags);
return;
}
if (!is_connected(CoreStringName(changed), p_callable) || p_flags & CONNECT_REFERENCE_COUNTED) {
connect(CoreStringName(changed), p_callable, p_flags);
}
}

void Resource::disconnect_changed(const Callable &p_callable) {
if (ResourceLoader::is_within_load() && !Thread::is_main_thread()) {
// Let the check and disconnection happen on the main thread, later, since signals are not thread-safe.
callable_mp(this, &Resource::disconnect_changed).call_deferred(p_callable);
return;
}
if (is_connected(CoreStringName(changed), p_callable)) {
disconnect(CoreStringName(changed), p_callable);
}
Expand Down

0 comments on commit 75eb8ad

Please sign in to comment.