1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-14 13:41:12 +00:00

Speed up signal disconnects in the editor

This commit is contained in:
Mike Precup
2025-08-12 15:52:08 -07:00
parent 5950fca36c
commit abfc63b483
4 changed files with 22 additions and 4 deletions

View File

@@ -1522,6 +1522,18 @@ int Object::get_persistent_signal_connection_count() const {
return count; return count;
} }
uint32_t Object::get_signal_connection_flags(const StringName &p_name, const Callable &p_callable) const {
OBJ_SIGNAL_LOCK
const SignalData *signal_data = signal_map.getptr(p_name);
if (signal_data) {
const SignalData::Slot *slot = signal_data->slot_map.getptr(p_callable);
if (slot) {
return slot->conn.flags;
}
}
return 0;
}
void Object::get_signals_connected_to_this(List<Connection> *p_connections) const { void Object::get_signals_connected_to_this(List<Connection> *p_connections) const {
OBJ_SIGNAL_LOCK OBJ_SIGNAL_LOCK

View File

@@ -973,6 +973,7 @@ public:
DEBUG_VIRTUAL void get_signal_connection_list(const StringName &p_signal, List<Connection> *p_connections) const; DEBUG_VIRTUAL void get_signal_connection_list(const StringName &p_signal, List<Connection> *p_connections) const;
DEBUG_VIRTUAL void get_all_signal_connections(List<Connection> *p_connections) const; DEBUG_VIRTUAL void get_all_signal_connections(List<Connection> *p_connections) const;
DEBUG_VIRTUAL int get_persistent_signal_connection_count() const; DEBUG_VIRTUAL int get_persistent_signal_connection_count() const;
DEBUG_VIRTUAL uint32_t get_signal_connection_flags(const StringName &p_name, const Callable &p_callable) const;
DEBUG_VIRTUAL void get_signals_connected_to_this(List<Connection> *p_connections) const; DEBUG_VIRTUAL void get_signals_connected_to_this(List<Connection> *p_connections) const;
DEBUG_VIRTUAL Error connect(const StringName &p_signal, const Callable &p_callable, uint32_t p_flags = 0); DEBUG_VIRTUAL Error connect(const StringName &p_signal, const Callable &p_callable, uint32_t p_flags = 0);

View File

@@ -4191,6 +4191,11 @@ int Node::get_persistent_signal_connection_count() const {
return Object::get_persistent_signal_connection_count(); return Object::get_persistent_signal_connection_count();
} }
uint32_t Node::get_signal_connection_flags(const StringName &p_signal, const Callable &p_callable) const {
ERR_THREAD_GUARD_V(0);
return Object::get_signal_connection_flags(p_signal, p_callable);
}
void Node::get_signals_connected_to_this(List<Connection> *p_connections) const { void Node::get_signals_connected_to_this(List<Connection> *p_connections) const {
ERR_THREAD_GUARD; ERR_THREAD_GUARD;
Object::get_signals_connected_to_this(p_connections); Object::get_signals_connected_to_this(p_connections);
@@ -4214,14 +4219,13 @@ void Node::disconnect(const StringName &p_signal, const Callable &p_callable) {
#ifdef TOOLS_ENABLED #ifdef TOOLS_ENABLED
// Already under thread guard, don't check again. // Already under thread guard, don't check again.
int old_connection_count = Object::get_persistent_signal_connection_count(); uint32_t connection_flags = Object::get_signal_connection_flags(p_signal, p_callable);
#endif #endif
Object::disconnect(p_signal, p_callable); [[maybe_unused]] bool changed = Object::_disconnect(p_signal, p_callable);
#ifdef TOOLS_ENABLED #ifdef TOOLS_ENABLED
int new_connection_count = Object::get_persistent_signal_connection_count(); if (changed && connection_flags & CONNECT_PERSIST) {
if (old_connection_count != new_connection_count) {
_emit_editor_state_changed(); _emit_editor_state_changed();
} }
#endif #endif

View File

@@ -875,6 +875,7 @@ public:
virtual void get_signal_connection_list(const StringName &p_signal, List<Connection> *p_connections) const override; virtual void get_signal_connection_list(const StringName &p_signal, List<Connection> *p_connections) const override;
virtual void get_all_signal_connections(List<Connection> *p_connections) const override; virtual void get_all_signal_connections(List<Connection> *p_connections) const override;
virtual int get_persistent_signal_connection_count() const override; virtual int get_persistent_signal_connection_count() const override;
virtual uint32_t get_signal_connection_flags(const StringName &p_name, const Callable &p_callable) const override;
virtual void get_signals_connected_to_this(List<Connection> *p_connections) const override; virtual void get_signals_connected_to_this(List<Connection> *p_connections) const override;
virtual Error connect(const StringName &p_signal, const Callable &p_callable, uint32_t p_flags = 0) override; virtual Error connect(const StringName &p_signal, const Callable &p_callable, uint32_t p_flags = 0) override;