From af43748dd5f4d0001a80da4c05d5fa8bc4ace0b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20=27dreamsComeTrue=27=20Jasi=C5=84ski?= Date: Fri, 19 Jun 2020 01:21:46 +0200 Subject: [PATCH] Prevent having spaces in signal's method in Connect Dialog Fixes: #39647 (cherry picked from commit 79f46da1a32192d20c3dd076f1cb59fabed2265b) --- editor/connections_dialog.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/editor/connections_dialog.cpp b/editor/connections_dialog.cpp index f6af92f231a..d0ee4acf69c 100644 --- a/editor/connections_dialog.cpp +++ b/editor/connections_dialog.cpp @@ -113,17 +113,26 @@ public: */ void ConnectDialog::ok_pressed() { - if (dst_method->get_text() == "") { + String method_name = dst_method->get_text(); + + if (method_name == "") { error->set_text(TTR("Method in target node must be specified.")); error->popup_centered_minsize(); return; } + + if (!method_name.strip_edges().is_valid_identifier()) { + error->set_text(TTR("Method name must be a valid identifier.")); + error->popup_centered(); + return; + } + Node *target = tree->get_selected(); if (!target) { return; // Nothing selected in the tree, not an error. } if (target->get_script().is_null()) { - if (!target->has_method(dst_method->get_text())) { + if (!target->has_method(method_name)) { error->set_text(TTR("Target method not found. Specify a valid method or attach a script to the target node.")); error->popup_centered_minsize(); return;