Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[4.3] Cherry-picks for the 4.3 (4.3.1) branch - 1st editor bugs batch #946

Merged
merged 29 commits into from
Jan 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
b341c0d
Fix editing exported nodes in array as text.
ajreckof Mar 30, 2024
6602d31
[macOS] Change the shortcut for Align Transform with View
passivestar Jul 7, 2024
5c6cecb
Add `EditorHelpBitTooltip` as a child of `p_target` to avoid jitter
Rindbee Oct 14, 2024
023e91e
Fix connecting a signal with a double click is too difficult
Hilderin Aug 2, 2024
781b0c3
Fix Lock and Group for canvas items not updated in editor after chang…
Giganzo Aug 9, 2024
0ec5916
Fix jumping to editor help does not scroll correctly sometimes
Maran23 Sep 1, 2024
f43d341
Hide white circle outline during instant transformations
ryevdokimov Sep 9, 2024
964337a
Update AnimationTree parameter list when updating AnimationNodeTransi…
timothyqiu Sep 20, 2024
74009d8
Add `String.is_valid_unicode_identifier()`
timothyqiu Aug 23, 2024
30f5ae7
Fix script editor wrongly replaces and quotes non-ASCII letters
timothyqiu Sep 22, 2024
e1219b8
Handle handle_modes being undefined by giving default values rather t…
TheSofox Sep 23, 2024
9dd2972
Fix CheckButton mirrored icon in editor theme
timothyqiu Oct 7, 2024
9933e2d
Editor: forbid deleting inherited metadata properties
dustdfg Oct 1, 2024
62352f6
Fix ControlEditorPopupButton arrow position in RTL language
timothyqiu Oct 9, 2024
be4a4da
Fix inverted vertical zoom interaction in animation curve editor
MajorMcDoom Oct 9, 2024
6b570ce
Fix `ColorPicker`'s remote synchronization when typing values
ydeltastar Oct 26, 2024
4ef7e37
Fix run instances dialog scaling bug
Nova840 Oct 26, 2024
3c28a9f
Fix issue where scrolling to item center would overflow on top
adamscott Nov 4, 2024
b80e4fe
Make possible to scale multiple nodes at once in the canvas editor
YeldhamDev Oct 25, 2024
a89ecbf
Change how multi selection scale is applied to canvas item
Giganzo Nov 21, 2024
3b5e7b1
Enable editing of controls inside viewports in editor
Black-Cat Nov 18, 2024
f23cd15
Fix load error popup showing on every progress dialog
Hilderin Sep 10, 2024
e6e4569
Fix empty load errors popup
Hilderin Sep 14, 2024
970d5c3
Compare localized path against editor scene path when reloading and
a-johnston Nov 27, 2024
3796fbe
Make reimported models reimport their owner.
SaracenOne Aug 27, 2024
fcb9285
Show correct icons in EditorDebuggerRemoteObject
jaydensipe Oct 15, 2024
c6a5635
Cleanup editor history when opening the history menu popup & set appr…
AeioMuch Dec 6, 2024
83d3778
Forced fixed undo history to make editor shortcuts use global history.
allenwp Dec 5, 2024
bfee6a8
Fix selecting root node before button released
dbnicholson Oct 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion core/core_bind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1752,7 +1752,7 @@ Object *Engine::get_singleton_object(const StringName &p_name) const {

void Engine::register_singleton(const StringName &p_name, Object *p_object) {
ERR_FAIL_COND_MSG(has_singleton(p_name), "Singleton already registered: " + String(p_name));
ERR_FAIL_COND_MSG(!String(p_name).is_valid_identifier(), "Singleton name is not a valid identifier: " + p_name);
ERR_FAIL_COND_MSG(!String(p_name).is_valid_ascii_identifier(), "Singleton name is not a valid identifier: " + p_name);
::Engine::Singleton s;
s.class_name = p_name;
s.name = p_name;
Expand Down
2 changes: 1 addition & 1 deletion core/extension/gdextension.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ void GDExtension::_register_extension_class_internal(GDExtensionClassLibraryPtr

StringName class_name = *reinterpret_cast<const StringName *>(p_class_name);
StringName parent_class_name = *reinterpret_cast<const StringName *>(p_parent_class_name);
ERR_FAIL_COND_MSG(!String(class_name).is_valid_identifier(), "Attempt to register extension class '" + class_name + "', which is not a valid class identifier.");
ERR_FAIL_COND_MSG(!String(class_name).is_valid_ascii_identifier(), "Attempt to register extension class '" + class_name + "', which is not a valid class identifier.");
ERR_FAIL_COND_MSG(ClassDB::class_exists(class_name), "Attempt to register extension class '" + class_name + "', which appears to be already registered.");

Extension *parent_extension = nullptr;
Expand Down
16 changes: 16 additions & 0 deletions core/input/input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,22 @@ bool Input::is_anything_pressed() const {
return false;
}

bool Input::is_anything_pressed_except_mouse() const {
_THREAD_SAFE_METHOD_

if (!keys_pressed.is_empty() || !joy_buttons_pressed.is_empty()) {
return true;
}

for (const KeyValue<StringName, Input::ActionState> &E : action_states) {
if (E.value.cache.pressed) {
return true;
}
}

return false;
}

bool Input::is_key_pressed(Key p_keycode) const {
_THREAD_SAFE_METHOD_
return keys_pressed.has(p_keycode);
Expand Down
1 change: 1 addition & 0 deletions core/input/input.h
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ class Input : public Object {
static Input *get_singleton();

bool is_anything_pressed() const;
bool is_anything_pressed_except_mouse() const;
bool is_key_pressed(Key p_keycode) const;
bool is_physical_key_pressed(Key p_keycode) const;
bool is_key_label_pressed(Key p_keycode) const;
Expand Down
2 changes: 1 addition & 1 deletion core/object/object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -999,7 +999,7 @@ void Object::set_meta(const StringName &p_name, const Variant &p_value) {
if (E) {
E->value = p_value;
} else {
ERR_FAIL_COND_MSG(!p_name.operator String().is_valid_identifier(), "Invalid metadata identifier: '" + p_name + "'.");
ERR_FAIL_COND_MSG(!p_name.operator String().is_valid_ascii_identifier(), "Invalid metadata identifier: '" + p_name + "'.");
Variant *V = &metadata.insert(p_name, p_value)->value;

const String &sname = p_name;
Expand Down
49 changes: 46 additions & 3 deletions core/string/ustring.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4589,9 +4589,9 @@ bool String::is_absolute_path() const {
}
}

String String::validate_identifier() const {
String String::validate_ascii_identifier() const {
if (is_empty()) {
return "_"; // Empty string is not a valid identifier;
return "_"; // Empty string is not a valid identifier.
}

String result;
Expand All @@ -4612,7 +4612,30 @@ String String::validate_identifier() const {
return result;
}

bool String::is_valid_identifier() const {
String String::validate_unicode_identifier() const {
if (is_empty()) {
return "_"; // Empty string is not a valid identifier.
}

String result;
if (is_unicode_identifier_start(operator[](0))) {
result = *this;
} else {
result = "_" + *this;
}

int len = result.length();
char32_t *buffer = result.ptrw();
for (int i = 0; i < len; i++) {
if (!is_unicode_identifier_continue(buffer[i])) {
buffer[i] = '_';
}
}

return result;
}

bool String::is_valid_ascii_identifier() const {
int len = length();

if (len == 0) {
Expand All @@ -4634,6 +4657,26 @@ bool String::is_valid_identifier() const {
return true;
}

bool String::is_valid_unicode_identifier() const {
const char32_t *str = ptr();
int len = length();

if (len == 0) {
return false; // Empty string.
}

if (!is_unicode_identifier_start(str[0])) {
return false;
}

for (int i = 1; i < len; i++) {
if (!is_unicode_identifier_continue(str[i])) {
return false;
}
}
return true;
}

bool String::is_valid_string() const {
int l = length();
const char32_t *src = get_data();
Expand Down
9 changes: 7 additions & 2 deletions core/string/ustring.h
Original file line number Diff line number Diff line change
Expand Up @@ -461,17 +461,22 @@ class String {
// node functions
static String get_invalid_node_name_characters(bool p_allow_internal = false);
String validate_node_name() const;
String validate_identifier() const;
String validate_ascii_identifier() const;
String validate_unicode_identifier() const;
String validate_filename() const;

bool is_valid_identifier() const;
bool is_valid_ascii_identifier() const;
bool is_valid_unicode_identifier() const;
bool is_valid_int() const;
bool is_valid_float() const;
bool is_valid_hex_number(bool p_with_prefix) const;
bool is_valid_html_color() const;
bool is_valid_ip_address() const;
bool is_valid_filename() const;

// Use `is_valid_ascii_identifier()` instead. Kept for compatibility.
bool is_valid_identifier() const { return is_valid_ascii_identifier(); }

/**
* The constructors must not depend on other overloads
*/
Expand Down
2 changes: 2 additions & 0 deletions core/variant/variant_call.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1726,6 +1726,8 @@ static void _register_variant_builtin_methods_string() {
bind_string_method(validate_node_name, sarray(), varray());
bind_string_method(validate_filename, sarray(), varray());

bind_string_method(is_valid_ascii_identifier, sarray(), varray());
bind_string_method(is_valid_unicode_identifier, sarray(), varray());
bind_string_method(is_valid_identifier, sarray(), varray());
bind_string_method(is_valid_int, sarray(), varray());
bind_string_method(is_valid_float, sarray(), varray());
Expand Down
32 changes: 31 additions & 1 deletion doc/classes/String.xml
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,19 @@
Returns [code]true[/code] if all characters of this string can be found in [param text] in their original order, [b]ignoring case[/b].
</description>
</method>
<method name="is_valid_ascii_identifier" qualifiers="const">
<return type="bool" />
<description>
Returns [code]true[/code] if this string is a valid ASCII identifier. A valid ASCII identifier may contain only letters, digits, and underscores ([code]_[/code]), and the first character may not be a digit.
[codeblock]
print("node_2d".is_valid_ascii_identifier()) # Prints true
print("TYPE_FLOAT".is_valid_ascii_identifier()) # Prints true
print("1st_method".is_valid_ascii_identifier()) # Prints false
print("MyMethod#2".is_valid_ascii_identifier()) # Prints false
[/codeblock]
See also [method is_valid_unicode_identifier].
</description>
</method>
<method name="is_valid_filename" qualifiers="const">
<return type="bool" />
<description>
Expand Down Expand Up @@ -492,7 +505,7 @@
Returns [code]true[/code] if this string is a valid color in hexadecimal HTML notation. The string must be a hexadecimal value (see [method is_valid_hex_number]) of either 3, 4, 6 or 8 digits, and may be prefixed by a hash sign ([code]#[/code]). Other HTML notations for colors, such as names or [code]hsl()[/code], are not considered valid. See also [method Color.html].
</description>
</method>
<method name="is_valid_identifier" qualifiers="const">
<method name="is_valid_identifier" qualifiers="const" deprecated="Use [method is_valid_ascii_identifier] instead.">
<return type="bool" />
<description>
Returns [code]true[/code] if this string is a valid identifier. A valid identifier may contain only letters, digits and underscores ([code]_[/code]), and the first character may not be a digit.
Expand Down Expand Up @@ -523,6 +536,23 @@
Returns [code]true[/code] if this string represents a well-formatted IPv4 or IPv6 address. This method considers [url=https://en.wikipedia.org/wiki/Reserved_IP_addresses]reserved IP addresses[/url] such as [code]"0.0.0.0"[/code] and [code]"ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff"[/code] as valid.
</description>
</method>
<method name="is_valid_unicode_identifier" qualifiers="const">
<return type="bool" />
<description>
Returns [code]true[/code] if this string is a valid Unicode identifier.
A valid Unicode identifier must begin with a Unicode character of class [code]XID_Start[/code] or [code]"_"[/code], and may contain Unicode characters of class [code]XID_Continue[/code] in the other positions.
[codeblock]
print("node_2d".is_valid_unicode_identifier()) # Prints true
print("1st_method".is_valid_unicode_identifier()) # Prints false
print("MyMethod#2".is_valid_unicode_identifier()) # Prints false
print("állóképesség".is_valid_unicode_identifier()) # Prints true
print("выносливость".is_valid_unicode_identifier()) # Prints true
print("体力".is_valid_unicode_identifier()) # Prints true
[/codeblock]
See also [method is_valid_ascii_identifier].
[b]Note:[/b] This method checks identifiers the same way as GDScript. See [method TextServer.is_valid_identifier] for more advanced checks.
</description>
</method>
<method name="join" qualifiers="const">
<return type="String" />
<param index="0" name="parts" type="PackedStringArray" />
Expand Down
32 changes: 31 additions & 1 deletion doc/classes/StringName.xml
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,19 @@
Returns [code]true[/code] if all characters of this string can be found in [param text] in their original order, [b]ignoring case[/b].
</description>
</method>
<method name="is_valid_ascii_identifier" qualifiers="const">
<return type="bool" />
<description>
Returns [code]true[/code] if this string is a valid ASCII identifier. A valid ASCII identifier may contain only letters, digits, and underscores ([code]_[/code]), and the first character may not be a digit.
[codeblock]
print("node_2d".is_valid_ascii_identifier()) # Prints true
print("TYPE_FLOAT".is_valid_ascii_identifier()) # Prints true
print("1st_method".is_valid_ascii_identifier()) # Prints false
print("MyMethod#2".is_valid_ascii_identifier()) # Prints false
[/codeblock]
See also [method is_valid_unicode_identifier].
</description>
</method>
<method name="is_valid_filename" qualifiers="const">
<return type="bool" />
<description>
Expand Down Expand Up @@ -460,7 +473,7 @@
Returns [code]true[/code] if this string is a valid color in hexadecimal HTML notation. The string must be a hexadecimal value (see [method is_valid_hex_number]) of either 3, 4, 6 or 8 digits, and may be prefixed by a hash sign ([code]#[/code]). Other HTML notations for colors, such as names or [code]hsl()[/code], are not considered valid. See also [method Color.html].
</description>
</method>
<method name="is_valid_identifier" qualifiers="const">
<method name="is_valid_identifier" qualifiers="const" deprecated="Use [method is_valid_ascii_identifier] instead.">
<return type="bool" />
<description>
Returns [code]true[/code] if this string is a valid identifier. A valid identifier may contain only letters, digits and underscores ([code]_[/code]), and the first character may not be a digit.
Expand Down Expand Up @@ -491,6 +504,23 @@
Returns [code]true[/code] if this string represents a well-formatted IPv4 or IPv6 address. This method considers [url=https://en.wikipedia.org/wiki/Reserved_IP_addresses]reserved IP addresses[/url] such as [code]"0.0.0.0"[/code] and [code]"ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff"[/code] as valid.
</description>
</method>
<method name="is_valid_unicode_identifier" qualifiers="const">
<return type="bool" />
<description>
Returns [code]true[/code] if this string is a valid Unicode identifier.
A valid Unicode identifier must begin with a Unicode character of class [code]XID_Start[/code] or [code]"_"[/code], and may contain Unicode characters of class [code]XID_Continue[/code] in the other positions.
[codeblock]
print("node_2d".is_valid_unicode_identifier()) # Prints true
print("1st_method".is_valid_unicode_identifier()) # Prints false
print("MyMethod#2".is_valid_unicode_identifier()) # Prints false
print("állóképesség".is_valid_unicode_identifier()) # Prints true
print("выносливость".is_valid_unicode_identifier()) # Prints true
print("体力".is_valid_unicode_identifier()) # Prints true
[/codeblock]
See also [method is_valid_ascii_identifier].
[b]Note:[/b] This method checks identifiers the same way as GDScript. See [method TextServer.is_valid_identifier] for more advanced checks.
</description>
</method>
<method name="join" qualifiers="const">
<return type="String" />
<param index="0" name="parts" type="PackedStringArray" />
Expand Down
2 changes: 1 addition & 1 deletion editor/animation_bezier_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1656,7 +1656,7 @@ void AnimationBezierTrackEdit::_zoom_callback(float p_zoom_factor, Vector2 p_ori
Ref<InputEventWithModifiers> iewm = p_event;
if (iewm.is_valid() && iewm->is_alt_pressed()) {
// Alternate zoom (doesn't affect timeline).
timeline_v_zoom = CLAMP(timeline_v_zoom * p_zoom_factor, 0.000001, 100000);
timeline_v_zoom = CLAMP(timeline_v_zoom / p_zoom_factor, 0.000001, 100000);
} else {
float zoom_factor = p_zoom_factor > 1.0 ? AnimationTimelineEdit::SCROLL_ZOOM_FACTOR_IN : AnimationTimelineEdit::SCROLL_ZOOM_FACTOR_OUT;
timeline->_zoom_callback(zoom_factor, p_origin, p_event);
Expand Down
4 changes: 1 addition & 3 deletions editor/connections_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -902,9 +902,7 @@ Control *ConnectionsDockTree::make_custom_tooltip(const String &p_text) const {
return nullptr;
}

EditorHelpBit *help_bit = memnew(EditorHelpBit(p_text));
EditorHelpBitTooltip::show_tooltip(help_bit, const_cast<ConnectionsDockTree *>(this));
return memnew(Control); // Make the standard tooltip invisible.
return EditorHelpBitTooltip::show_tooltip(const_cast<ConnectionsDockTree *>(this), p_text);
}

struct _ConnectionsDockMethodInfoSort {
Expand Down
2 changes: 1 addition & 1 deletion editor/editor_autoload_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ void EditorAutoloadSettings::_notification(int p_what) {
}

bool EditorAutoloadSettings::_autoload_name_is_valid(const String &p_name, String *r_error) {
if (!p_name.is_valid_identifier()) {
if (!p_name.is_valid_ascii_identifier()) {
if (r_error) {
*r_error = TTR("Invalid name.") + " ";
if (p_name.size() > 0 && p_name.left(1).is_numeric()) {
Expand Down
Loading