Merge pull request #65197 from Mickeon/rename-connect-one-shot

Rename CONNECT_ONESHOT to CONNECT_ONE_SHOT
This commit is contained in:
Rémi Verschelde 2022-09-07 08:51:10 +02:00
commit 5c5079b398
18 changed files with 27 additions and 26 deletions

View file

@ -1060,7 +1060,7 @@ Error Object::emit_signalp(const StringName &p_name, const Variant **p_args, int
} }
} }
bool disconnect = c.flags & CONNECT_ONESHOT; bool disconnect = c.flags & CONNECT_ONE_SHOT;
#ifdef TOOLS_ENABLED #ifdef TOOLS_ENABLED
if (disconnect && (c.flags & CONNECT_PERSIST) && Engine::get_singleton()->is_editor_hint()) { if (disconnect && (c.flags & CONNECT_PERSIST) && Engine::get_singleton()->is_editor_hint()) {
//this signal was connected from the editor, and is being edited. just don't disconnect for now //this signal was connected from the editor, and is being edited. just don't disconnect for now
@ -1575,7 +1575,7 @@ void Object::_bind_methods() {
BIND_ENUM_CONSTANT(CONNECT_DEFERRED); BIND_ENUM_CONSTANT(CONNECT_DEFERRED);
BIND_ENUM_CONSTANT(CONNECT_PERSIST); BIND_ENUM_CONSTANT(CONNECT_PERSIST);
BIND_ENUM_CONSTANT(CONNECT_ONESHOT); BIND_ENUM_CONSTANT(CONNECT_ONE_SHOT);
BIND_ENUM_CONSTANT(CONNECT_REFERENCE_COUNTED); BIND_ENUM_CONSTANT(CONNECT_REFERENCE_COUNTED);
} }

View file

@ -537,7 +537,7 @@ public:
enum ConnectFlags { enum ConnectFlags {
CONNECT_DEFERRED = 1, CONNECT_DEFERRED = 1,
CONNECT_PERSIST = 2, // hint for scene to save this connection CONNECT_PERSIST = 2, // hint for scene to save this connection
CONNECT_ONESHOT = 4, CONNECT_ONE_SHOT = 4,
CONNECT_REFERENCE_COUNTED = 8, CONNECT_REFERENCE_COUNTED = 8,
}; };

View file

@ -633,7 +633,7 @@
<constant name="CONNECT_PERSIST" value="2" enum="ConnectFlags"> <constant name="CONNECT_PERSIST" value="2" enum="ConnectFlags">
Persisting connections are saved when the object is serialized to file. Persisting connections are saved when the object is serialized to file.
</constant> </constant>
<constant name="CONNECT_ONESHOT" value="4" enum="ConnectFlags"> <constant name="CONNECT_ONE_SHOT" value="4" enum="ConnectFlags">
One-shot connections disconnect themselves after emission. One-shot connections disconnect themselves after emission.
</constant> </constant>
<constant name="CONNECT_REFERENCE_COUNTED" value="8" enum="ConnectFlags"> <constant name="CONNECT_REFERENCE_COUNTED" value="8" enum="ConnectFlags">

View file

@ -3518,7 +3518,7 @@ void AnimationTrackEditor::set_root(Node *p_root) {
root = p_root; root = p_root;
if (root) { if (root) {
root->connect("tree_exiting", callable_mp(this, &AnimationTrackEditor::_root_removed), CONNECT_ONESHOT); root->connect("tree_exiting", callable_mp(this, &AnimationTrackEditor::_root_removed), CONNECT_ONE_SHOT);
} }
_update_tracks(); _update_tracks();

View file

@ -322,7 +322,7 @@ void ConnectDialog::init(ConnectionData p_cd, bool p_edit) {
_update_ok_enabled(); _update_ok_enabled();
bool b_deferred = (p_cd.flags & CONNECT_DEFERRED) == CONNECT_DEFERRED; bool b_deferred = (p_cd.flags & CONNECT_DEFERRED) == CONNECT_DEFERRED;
bool b_oneshot = (p_cd.flags & CONNECT_ONESHOT) == CONNECT_ONESHOT; bool b_oneshot = (p_cd.flags & CONNECT_ONE_SHOT) == CONNECT_ONE_SHOT;
deferred->set_pressed(b_deferred); deferred->set_pressed(b_deferred);
one_shot->set_pressed(b_oneshot); one_shot->set_pressed(b_oneshot);
@ -565,7 +565,7 @@ void ConnectionsDock::_make_or_edit_connection() {
} }
bool b_deferred = connect_dialog->get_deferred(); bool b_deferred = connect_dialog->get_deferred();
bool b_oneshot = connect_dialog->get_one_shot(); bool b_oneshot = connect_dialog->get_one_shot();
cd.flags = CONNECT_PERSIST | (b_deferred ? CONNECT_DEFERRED : 0) | (b_oneshot ? CONNECT_ONESHOT : 0); cd.flags = CONNECT_PERSIST | (b_deferred ? CONNECT_DEFERRED : 0) | (b_oneshot ? CONNECT_ONE_SHOT : 0);
// Conditions to add function: must have a script and must not have the method already // Conditions to add function: must have a script and must not have the method already
// (in the class, the script itself, or inherited). // (in the class, the script itself, or inherited).
@ -1083,8 +1083,8 @@ void ConnectionsDock::update_tree() {
if (cd.flags & CONNECT_DEFERRED) { if (cd.flags & CONNECT_DEFERRED) {
path += " (deferred)"; path += " (deferred)";
} }
if (cd.flags & CONNECT_ONESHOT) { if (cd.flags & CONNECT_ONE_SHOT) {
path += " (oneshot)"; path += " (one-shot)";
} }
if (cd.unbinds > 0) { if (cd.unbinds > 0) {
path += " unbinds(" + itos(cd.unbinds) + ")"; path += " unbinds(" + itos(cd.unbinds) + ")";

View file

@ -1056,7 +1056,7 @@ void EditorSelection::add_node(Node *p_node) {
} }
selection[p_node] = meta; selection[p_node] = meta;
p_node->connect("tree_exiting", callable_mp(this, &EditorSelection::_node_removed).bind(p_node), CONNECT_ONESHOT); p_node->connect("tree_exiting", callable_mp(this, &EditorSelection::_node_removed).bind(p_node), CONNECT_ONE_SHOT);
} }
void EditorSelection::remove_node(Node *p_node) { void EditorSelection::remove_node(Node *p_node) {

View file

@ -307,7 +307,7 @@ Ref<Texture2D> EditorMaterialPreviewPlugin::generate(const Ref<Resource> &p_from
if (material->get_shader_mode() == Shader::MODE_SPATIAL) { if (material->get_shader_mode() == Shader::MODE_SPATIAL) {
RS::get_singleton()->mesh_surface_set_material(sphere, 0, material->get_rid()); RS::get_singleton()->mesh_surface_set_material(sphere, 0, material->get_rid());
RS::get_singleton()->connect(SNAME("frame_pre_draw"), callable_mp(const_cast<EditorMaterialPreviewPlugin *>(this), &EditorMaterialPreviewPlugin::_generate_frame_started), Object::CONNECT_ONESHOT); RS::get_singleton()->connect(SNAME("frame_pre_draw"), callable_mp(const_cast<EditorMaterialPreviewPlugin *>(this), &EditorMaterialPreviewPlugin::_generate_frame_started), Object::CONNECT_ONE_SHOT);
preview_done.wait(); preview_done.wait();
@ -709,7 +709,7 @@ Ref<Texture2D> EditorMeshPreviewPlugin::generate(const Ref<Resource> &p_from, co
xform.origin.z -= rot_aabb.size.z * 2; xform.origin.z -= rot_aabb.size.z * 2;
RS::get_singleton()->instance_set_transform(mesh_instance, xform); RS::get_singleton()->instance_set_transform(mesh_instance, xform);
RS::get_singleton()->connect(SNAME("frame_pre_draw"), callable_mp(const_cast<EditorMeshPreviewPlugin *>(this), &EditorMeshPreviewPlugin::_generate_frame_started), Object::CONNECT_ONESHOT); RS::get_singleton()->connect(SNAME("frame_pre_draw"), callable_mp(const_cast<EditorMeshPreviewPlugin *>(this), &EditorMeshPreviewPlugin::_generate_frame_started), Object::CONNECT_ONE_SHOT);
preview_done.wait(); preview_done.wait();
@ -826,7 +826,7 @@ Ref<Texture2D> EditorFontPreviewPlugin::generate_from_path(const String &p_path,
const float fg = c.get_luminance() < 0.5 ? 1.0 : 0.0; const float fg = c.get_luminance() < 0.5 ? 1.0 : 0.0;
sampled_font->draw_string(canvas_item, pos, sample, HORIZONTAL_ALIGNMENT_LEFT, -1.f, 50, Color(fg, fg, fg)); sampled_font->draw_string(canvas_item, pos, sample, HORIZONTAL_ALIGNMENT_LEFT, -1.f, 50, Color(fg, fg, fg));
RS::get_singleton()->connect(SNAME("frame_pre_draw"), callable_mp(const_cast<EditorFontPreviewPlugin *>(this), &EditorFontPreviewPlugin::_generate_frame_started), Object::CONNECT_ONESHOT); RS::get_singleton()->connect(SNAME("frame_pre_draw"), callable_mp(const_cast<EditorFontPreviewPlugin *>(this), &EditorFontPreviewPlugin::_generate_frame_started), Object::CONNECT_ONE_SHOT);
preview_done.wait(); preview_done.wait();

View file

@ -882,7 +882,7 @@ void ScriptEditor::_queue_close_tabs() {
// Maybe there are unsaved changes. // Maybe there are unsaved changes.
if (se->is_unsaved()) { if (se->is_unsaved()) {
_ask_close_current_unsaved_tab(se); _ask_close_current_unsaved_tab(se);
erase_tab_confirm->connect(SceneStringNames::get_singleton()->visibility_changed, callable_mp(this, &ScriptEditor::_queue_close_tabs), CONNECT_ONESHOT); erase_tab_confirm->connect(SceneStringNames::get_singleton()->visibility_changed, callable_mp(this, &ScriptEditor::_queue_close_tabs), CONNECT_ONE_SHOT);
break; break;
} }
} }

View file

@ -835,7 +835,7 @@ void Skeleton3DEditor::_notification(int p_what) {
skeleton->connect("show_rest_only_changed", callable_mp(this, &Skeleton3DEditor::_update_gizmo_visible)); skeleton->connect("show_rest_only_changed", callable_mp(this, &Skeleton3DEditor::_update_gizmo_visible));
#endif #endif
get_tree()->connect("node_removed", callable_mp(this, &Skeleton3DEditor::_node_removed), Object::CONNECT_ONESHOT); get_tree()->connect("node_removed", callable_mp(this, &Skeleton3DEditor::_node_removed), Object::CONNECT_ONE_SHOT);
} break; } break;
case NOTIFICATION_READY: { case NOTIFICATION_READY: {
// Will trigger NOTIFICATION_THEME_CHANGED, but won't cause any loops if called here. // Will trigger NOTIFICATION_THEME_CHANGED, but won't cause any loops if called here.

View file

@ -116,7 +116,7 @@ void TilesEditorPlugin::_thread() {
// Add the viewport at the last moment to avoid rendering too early. // Add the viewport at the last moment to avoid rendering too early.
EditorNode::get_singleton()->add_child(viewport); EditorNode::get_singleton()->add_child(viewport);
RS::get_singleton()->connect(SNAME("frame_pre_draw"), callable_mp(const_cast<TilesEditorPlugin *>(this), &TilesEditorPlugin::_preview_frame_started), Object::CONNECT_ONESHOT); RS::get_singleton()->connect(SNAME("frame_pre_draw"), callable_mp(const_cast<TilesEditorPlugin *>(this), &TilesEditorPlugin::_preview_frame_started), Object::CONNECT_ONE_SHOT);
pattern_preview_done.wait(); pattern_preview_done.wait();

View file

@ -91,6 +91,7 @@ static const char *enum_renames[][2] = {
{ "BUTTON_XBUTTON2", "MOUSE_BUTTON_XBUTTON2" }, // Globals { "BUTTON_XBUTTON2", "MOUSE_BUTTON_XBUTTON2" }, // Globals
{ "CLEAR_MODE_ONLY_NEXT_FRAME", "CLEAR_MODE_ONCE" }, // SubViewport { "CLEAR_MODE_ONLY_NEXT_FRAME", "CLEAR_MODE_ONCE" }, // SubViewport
{ "COMPRESS_PVRTC4", "COMPRESS_PVRTC1_4" }, // Image { "COMPRESS_PVRTC4", "COMPRESS_PVRTC1_4" }, // Image
{ "CONNECT_ONESHOT", "CONNECT_ONE_SHOT" }, // Object
{ "CUBEMAP_BACK", "CUBEMAP_LAYER_BACK" }, // RenderingServer { "CUBEMAP_BACK", "CUBEMAP_LAYER_BACK" }, // RenderingServer
{ "CUBEMAP_BOTTOM", "CUBEMAP_LAYER_BOTTOM" }, // RenderingServer { "CUBEMAP_BOTTOM", "CUBEMAP_LAYER_BOTTOM" }, // RenderingServer
{ "CUBEMAP_FRONT", "CUBEMAP_LAYER_FRONT" }, // RenderingServer { "CUBEMAP_FRONT", "CUBEMAP_LAYER_FRONT" }, // RenderingServer

View file

@ -2163,7 +2163,7 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
OPCODE(OPCODE_AWAIT) { OPCODE(OPCODE_AWAIT) {
CHECK_SPACE(2); CHECK_SPACE(2);
// Do the oneshot connect. // Do the one-shot connect.
GET_INSTRUCTION_ARG(argobj, 0); GET_INSTRUCTION_ARG(argobj, 0);
Signal sig; Signal sig;
@ -2234,7 +2234,7 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
retvalue = gdfs; retvalue = gdfs;
Error err = sig.connect(Callable(gdfs.ptr(), "_signal_callback").bind(retvalue), Object::CONNECT_ONESHOT); Error err = sig.connect(Callable(gdfs.ptr(), "_signal_callback").bind(retvalue), Object::CONNECT_ONE_SHOT);
if (err != OK) { if (err != OK) {
err_text = "Error connecting to signal: " + sig.get_name() + " during await."; err_text = "Error connecting to signal: " + sig.get_name() + " during await.";
OPCODE_BREAK; OPCODE_BREAK;

View file

@ -42,7 +42,7 @@ Error gd_mono_connect_signal_awaiter(Object *p_source, const StringName &p_signa
SignalAwaiterCallable *awaiter_callable = memnew(SignalAwaiterCallable(p_target, awaiter_handle, p_signal)); SignalAwaiterCallable *awaiter_callable = memnew(SignalAwaiterCallable(p_target, awaiter_handle, p_signal));
Callable callable = Callable(awaiter_callable); Callable callable = Callable(awaiter_callable);
return p_source->connect(p_signal, callable, Object::CONNECT_ONESHOT); return p_source->connect(p_signal, callable, Object::CONNECT_ONE_SHOT);
} }
bool SignalAwaiterCallable::compare_equal(const CallableCustom *p_a, const CallableCustom *p_b) { bool SignalAwaiterCallable::compare_equal(const CallableCustom *p_a, const CallableCustom *p_b) {

View file

@ -230,8 +230,8 @@ void MultiplayerSpawner::_track(Node *p_node, const Variant &p_argument, int p_s
ObjectID oid = p_node->get_instance_id(); ObjectID oid = p_node->get_instance_id();
if (!tracked_nodes.has(oid)) { if (!tracked_nodes.has(oid)) {
tracked_nodes[oid] = SpawnInfo(p_argument.duplicate(true), p_scene_id); tracked_nodes[oid] = SpawnInfo(p_argument.duplicate(true), p_scene_id);
p_node->connect(SceneStringNames::get_singleton()->tree_exiting, callable_mp(this, &MultiplayerSpawner::_node_exit).bind(p_node->get_instance_id()), CONNECT_ONESHOT); p_node->connect(SceneStringNames::get_singleton()->tree_exiting, callable_mp(this, &MultiplayerSpawner::_node_exit).bind(p_node->get_instance_id()), CONNECT_ONE_SHOT);
p_node->connect(SceneStringNames::get_singleton()->ready, callable_mp(this, &MultiplayerSpawner::_node_ready).bind(p_node->get_instance_id()), CONNECT_ONESHOT); p_node->connect(SceneStringNames::get_singleton()->ready, callable_mp(this, &MultiplayerSpawner::_node_ready).bind(p_node->get_instance_id()), CONNECT_ONE_SHOT);
} }
} }

View file

@ -39,7 +39,7 @@ SceneReplicationState::TrackedNode &SceneReplicationState::_track(const ObjectID
if (!tracked_nodes.has(p_id)) { if (!tracked_nodes.has(p_id)) {
tracked_nodes[p_id] = TrackedNode(p_id); tracked_nodes[p_id] = TrackedNode(p_id);
Node *node = Object::cast_to<Node>(ObjectDB::get_instance(p_id)); Node *node = Object::cast_to<Node>(ObjectDB::get_instance(p_id));
node->connect(SceneStringNames::get_singleton()->tree_exited, callable_mp(this, &SceneReplicationState::_untrack).bind(p_id), Node::CONNECT_ONESHOT); node->connect(SceneStringNames::get_singleton()->tree_exited, callable_mp(this, &SceneReplicationState::_untrack).bind(p_id), Node::CONNECT_ONE_SHOT);
} }
return tracked_nodes[p_id]; return tracked_nodes[p_id];
} }

View file

@ -323,7 +323,7 @@ void AnimationPlayer::_ensure_node_caches(AnimationData *p_anim, Node *p_root_ov
#endif // _3D_DISABLED #endif // _3D_DISABLED
if (!child->is_connected("tree_exiting", callable_mp(this, &AnimationPlayer::_node_removed))) { if (!child->is_connected("tree_exiting", callable_mp(this, &AnimationPlayer::_node_removed))) {
child->connect("tree_exiting", callable_mp(this, &AnimationPlayer::_node_removed).bind(child), CONNECT_ONESHOT); child->connect("tree_exiting", callable_mp(this, &AnimationPlayer::_node_removed).bind(child), CONNECT_ONE_SHOT);
} }
TrackNodeCacheKey key; TrackNodeCacheKey key;

View file

@ -2821,7 +2821,7 @@ void Control::_notification(int p_notification) {
case NOTIFICATION_READY: { case NOTIFICATION_READY: {
#ifdef DEBUG_ENABLED #ifdef DEBUG_ENABLED
connect("ready", callable_mp(this, &Control::_clear_size_warning), CONNECT_DEFERRED | CONNECT_ONESHOT); connect("ready", callable_mp(this, &Control::_clear_size_warning), CONNECT_DEFERRED | CONNECT_ONE_SHOT);
#endif #endif
} break; } break;

View file

@ -321,7 +321,7 @@ void ScrollBar::_notification(int p_what) {
if (drag_node) { if (drag_node) {
drag_node->connect("gui_input", callable_mp(this, &ScrollBar::_drag_node_input)); drag_node->connect("gui_input", callable_mp(this, &ScrollBar::_drag_node_input));
drag_node->connect("tree_exiting", callable_mp(this, &ScrollBar::_drag_node_exit), CONNECT_ONESHOT); drag_node->connect("tree_exiting", callable_mp(this, &ScrollBar::_drag_node_exit), CONNECT_ONE_SHOT);
} }
} break; } break;
@ -613,7 +613,7 @@ void ScrollBar::set_drag_node(const NodePath &p_path) {
if (drag_node) { if (drag_node) {
drag_node->connect("gui_input", callable_mp(this, &ScrollBar::_drag_node_input)); drag_node->connect("gui_input", callable_mp(this, &ScrollBar::_drag_node_input));
drag_node->connect("tree_exiting", callable_mp(this, &ScrollBar::_drag_node_exit), CONNECT_ONESHOT); drag_node->connect("tree_exiting", callable_mp(this, &ScrollBar::_drag_node_exit), CONNECT_ONE_SHOT);
} }
} }
} }