Skip to content

Commit e2931a5

Browse files
committed
Make conversions from NodePath to String explicit.
1 parent 51b0379 commit e2931a5

39 files changed

+99
-99
lines changed

core/string/node_path.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ class [[nodiscard]] NodePath {
7878
return data->hash_cache;
7979
}
8080

81-
operator String() const;
81+
explicit operator String() const;
8282
bool is_empty() const;
8383

8484
bool operator==(const NodePath &p_path) const;

core/variant/variant.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1642,7 +1642,7 @@ String Variant::stringify(int recursion_count) const {
16421642
case STRING_NAME:
16431643
return operator StringName();
16441644
case NODE_PATH:
1645-
return operator NodePath();
1645+
return String(operator NodePath());
16461646
case COLOR:
16471647
return String(operator Color());
16481648
case DICTIONARY: {

editor/animation_bezier_editor.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ void AnimationBezierTrackEdit::_notification(int p_what) {
328328
continue;
329329
}
330330

331-
String base_path = animation->track_get_path(i);
331+
String base_path = String(animation->track_get_path(i));
332332
int end = base_path.find_char(':');
333333
if (end != -1) {
334334
base_path = base_path.substr(0, end + 1);
@@ -405,7 +405,7 @@ void AnimationBezierTrackEdit::_notification(int p_what) {
405405

406406
int current_track = tracks[i];
407407

408-
String path = animation->track_get_path(current_track);
408+
String path = String(animation->track_get_path(current_track));
409409
path = path.replace_first(base_path, "");
410410

411411
Color cc = color;
@@ -763,7 +763,7 @@ bool AnimationBezierTrackEdit::_is_track_displayed(int p_track_index) {
763763
}
764764

765765
if (is_filtered) {
766-
String path = animation->track_get_path(p_track_index);
766+
String path = String(animation->track_get_path(p_track_index));
767767
if (root && root->has_node(path)) {
768768
Node *node = root->get_node(path);
769769
if (!node) {
@@ -899,7 +899,7 @@ void AnimationBezierTrackEdit::set_filtered(bool p_filtered) {
899899
if (animation.is_null()) {
900900
return;
901901
}
902-
String base_path = animation->track_get_path(selected_track);
902+
String base_path = String(animation->track_get_path(selected_track));
903903
if (is_filtered) {
904904
if (root && root->has_node(base_path)) {
905905
Node *node = root->get_node(base_path);
@@ -909,7 +909,7 @@ void AnimationBezierTrackEdit::set_filtered(bool p_filtered) {
909909
continue;
910910
}
911911

912-
base_path = animation->track_get_path(i);
912+
base_path = String(animation->track_get_path(i));
913913
if (root && root->has_node(base_path)) {
914914
node = root->get_node(base_path);
915915
if (!node) {

editor/animation_track_editor.cpp

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2191,7 +2191,7 @@ void AnimationTrackEdit::_notification(int p_what) {
21912191
} else {
21922192
icon_cache = key_type_icon;
21932193

2194-
text = anim_path;
2194+
text = String(anim_path);
21952195
}
21962196

21972197
path_cache = text;
@@ -2822,7 +2822,7 @@ String AnimationTrackEdit::get_tooltip(const Point2 &p_pos) const {
28222822

28232823
// Don't overlap track keys if they start at 0.
28242824
if (path_rect.has_point(p_pos + Size2(type_icon->get_width(), 0))) {
2825-
return animation->track_get_path(track);
2825+
return String(animation->track_get_path(track));
28262826
}
28272827

28282828
if (update_mode_rect.has_point(p_pos)) {
@@ -3230,7 +3230,7 @@ void AnimationTrackEdit::gui_input(const Ref<InputEvent> &p_event) {
32303230
path->connect(SceneStringName(text_submitted), callable_mp(this, &AnimationTrackEdit::_path_submitted));
32313231
}
32323232

3233-
path->set_text(animation->track_get_path(track));
3233+
path->set_text(String(animation->track_get_path(track)));
32343234
const Vector2 theme_ofs = path->get_theme_stylebox(CoreStringName(normal), SNAME("LineEdit"))->get_offset();
32353235

32363236
moving_selection_attempt = false;
@@ -3462,7 +3462,7 @@ Variant AnimationTrackEdit::get_drag_data(const Point2 &p_point) {
34623462

34633463
Dictionary drag_data;
34643464
drag_data["type"] = "animation_track";
3465-
String base_path = animation->track_get_path(track);
3465+
String base_path = String(animation->track_get_path(track));
34663466
base_path = base_path.get_slicec(':', 0); // Remove sub-path.
34673467
drag_data["group"] = base_path;
34683468
drag_data["index"] = track;
@@ -3493,7 +3493,7 @@ bool AnimationTrackEdit::can_drop_data(const Point2 &p_point, const Variant &p_d
34933493

34943494
// Don't allow moving tracks outside their groups.
34953495
if (get_editor()->is_grouping_tracks()) {
3496-
String base_path = animation->track_get_path(track);
3496+
String base_path = String(animation->track_get_path(track));
34973497
base_path = base_path.get_slicec(':', 0); // Remove sub-path.
34983498
if (d["group"] != base_path) {
34993499
return false;
@@ -3524,7 +3524,7 @@ void AnimationTrackEdit::drop_data(const Point2 &p_point, const Variant &p_data)
35243524

35253525
// Don't allow moving tracks outside their groups.
35263526
if (get_editor()->is_grouping_tracks()) {
3527-
String base_path = animation->track_get_path(track);
3527+
String base_path = String(animation->track_get_path(track));
35283528
base_path = base_path.get_slicec(':', 0); // Remove sub-path.
35293529
if (d["group"] != base_path) {
35303530
return;
@@ -4370,7 +4370,7 @@ void AnimationTrackEditor::insert_transform_key(Node3D *p_node, const String &p_
43704370
}
43714371

43724372
// Let's build a node path.
4373-
String path = root->get_path_to(p_node, true);
4373+
String path = String(root->get_path_to(p_node, true));
43744374
if (!p_sub.is_empty()) {
43754375
path += ":" + p_sub;
43764376
}
@@ -4410,7 +4410,7 @@ bool AnimationTrackEditor::has_track(Node3D *p_node, const String &p_sub, const
44104410
}
44114411

44124412
// Let's build a node path.
4413-
String path = root->get_path_to(p_node, true);
4413+
String path = String(root->get_path_to(p_node, true));
44144414
if (!p_sub.is_empty()) {
44154415
path += ":" + p_sub;
44164416
}
@@ -4423,11 +4423,11 @@ bool AnimationTrackEditor::has_track(Node3D *p_node, const String &p_sub, const
44234423
}
44244424

44254425
void AnimationTrackEditor::_insert_animation_key(NodePath p_path, const Variant &p_value) {
4426-
String path = p_path;
4426+
String path = String(p_path);
44274427

44284428
// Animation property is a special case, always creates an animation track.
44294429
for (int i = 0; i < animation->get_track_count(); i++) {
4430-
String np = animation->track_get_path(i);
4430+
String np = String(animation->track_get_path(i));
44314431

44324432
if (path == np && animation->track_get_type(i) == Animation::TYPE_ANIMATION) {
44334433
// Exists.
@@ -4460,7 +4460,7 @@ void AnimationTrackEditor::insert_node_value_key(Node *p_node, const String &p_p
44604460
ERR_FAIL_NULL(root);
44614461

44624462
// Let's build a node path.
4463-
String path = root->get_path_to(p_node, true);
4463+
String path = String(root->get_path_to(p_node, true));
44644464

44654465
// Get the value from the subpath.
44664466
Vector<StringName> subpath = NodePath(p_property).get_as_property_path().get_subnames();
@@ -4509,14 +4509,14 @@ void AnimationTrackEditor::insert_node_value_key(Node *p_node, const String &p_p
45094509
inserted = true;
45104510
} else if (animation->track_get_type(i) == Animation::TYPE_BEZIER) {
45114511
Variant actual_value;
4512-
String track_path = animation->track_get_path(i);
4513-
if (track_path == np) {
4512+
String track_path = String(animation->track_get_path(i));
4513+
if (track_path == String(np)) {
45144514
actual_value = value; // All good.
45154515
} else {
45164516
int sep = track_path.rfind_char(':');
45174517
if (sep != -1) {
45184518
String base_path = track_path.substr(0, sep);
4519-
if (base_path == np) {
4519+
if (base_path == String(np)) {
45204520
String value_name = track_path.substr(sep + 1);
45214521
actual_value = value.get(value_name);
45224522
} else {
@@ -5017,7 +5017,7 @@ void AnimationTrackEditor::_update_tracks() {
50175017
String filter_text = timeline->filter_track->get_text();
50185018

50195019
if (!filter_text.is_empty()) {
5020-
String target = animation->track_get_path(i);
5020+
String target = String(animation->track_get_path(i));
50215021
if (!target.containsn(filter_text)) {
50225022
continue;
50235023
}
@@ -5087,7 +5087,7 @@ void AnimationTrackEditor::_update_tracks() {
50875087
track_edits.push_back(track_edit);
50885088

50895089
if (use_grouping) {
5090-
String base_path = animation->track_get_path(i);
5090+
String base_path = String(animation->track_get_path(i));
50915091
base_path = base_path.get_slicec(':', 0); // Remove sub-path.
50925092

50935093
if (!group_sort.has(base_path)) {
@@ -5100,7 +5100,7 @@ void AnimationTrackEditor::_update_tracks() {
51005100
if (n) {
51015101
icon = EditorNode::get_singleton()->get_object_icon(n, "Node");
51025102
name = n->get_name();
5103-
tooltip = root->get_path_to(n);
5103+
tooltip = String(root->get_path_to(n));
51045104
}
51055105
}
51065106

@@ -6711,7 +6711,7 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) {
67116711

67126712
path = NodePath(node->get_path().get_names(), path.get_subnames(), true); // Store full path instead for copying.
67136713
} else {
6714-
text = path;
6714+
text = String(path);
67156715
int sep = text.find_char(':');
67166716
if (sep != -1) {
67176717
text = text.substr(sep + 1);

editor/animation_track_editor_plugins.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ Rect2 AnimationTrackEditSpriteFrame::get_key_rect(int p_index, float p_pixels_se
413413
animation_name = animations.front()->get();
414414
} else {
415415
// Go through other track to find if animation is set
416-
String animation_path = get_animation()->track_get_path(get_track());
416+
String animation_path = String(get_animation()->track_get_path(get_track()));
417417
animation_path = animation_path.replace(":frame", ":animation");
418418
int animation_track = get_animation()->find_track(animation_path, get_animation()->track_get_type(get_track()));
419419
float track_time = get_animation()->track_get_key_time(get_track(), p_index);
@@ -505,7 +505,7 @@ void AnimationTrackEditSpriteFrame::draw_key(int p_index, float p_pixels_sec, in
505505
animation_name = animations.front()->get();
506506
} else {
507507
// Go through other track to find if animation is set
508-
String animation_path = get_animation()->track_get_path(get_track());
508+
String animation_path = String(get_animation()->track_get_path(get_track()));
509509
animation_path = animation_path.replace(":frame", ":animation");
510510
int animation_track = get_animation()->find_track(animation_path, get_animation()->track_get_type(get_track()));
511511
float track_time = get_animation()->track_get_key_time(get_track(), p_index);

editor/debugger/script_editor_debugger.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1531,7 +1531,7 @@ void ScriptEditorDebugger::update_live_edit_root() {
15311531
msg.push_back("");
15321532
}
15331533
_put_msg("scene:live_set_root", msg);
1534-
live_edit_root->set_text(np);
1534+
live_edit_root->set_text(String(np));
15351535
}
15361536

15371537
void ScriptEditorDebugger::live_debug_create_node(const NodePath &p_parent, const String &p_type, const String &p_name) {

editor/editor_node.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6636,7 +6636,7 @@ void EditorNode::reload_instances_with_path_in_edited_scenes() {
66366636
// it's a multi-level inheritance scene. We should use
66376637
NodePath scene_path_to_node = current_edited_scene->get_path_to(original_node);
66386638
Ref<SceneState> scene_state = current_edited_scene->get_scene_inherited_state();
6639-
if (scene_path_to_node != "." && scene_state.is_valid() && scene_state->get_path() != instance_modifications.instance_path && scene_state->find_node_by_path(scene_path_to_node) >= 0) {
6639+
if (String(scene_path_to_node) != "." && scene_state.is_valid() && scene_state->get_path() != instance_modifications.instance_path && scene_state->find_node_by_path(scene_path_to_node) >= 0) {
66406640
Node *root_node = scene_state->instantiate(SceneState::GenEditState::GEN_EDIT_STATE_INSTANCE);
66416641
instantiated_node = root_node->get_node(scene_path_to_node);
66426642

editor/editor_properties.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2866,15 +2866,15 @@ void EditorPropertyNodePath::_menu_option(int p_idx) {
28662866
} break;
28672867

28682868
case ACTION_COPY: {
2869-
DisplayServer::get_singleton()->clipboard_set(_get_node_path());
2869+
DisplayServer::get_singleton()->clipboard_set(String(_get_node_path()));
28702870
} break;
28712871

28722872
case ACTION_EDIT: {
28732873
assign->hide();
28742874
menu->hide();
28752875

28762876
const NodePath &np = _get_node_path();
2877-
edit->set_text(np);
2877+
edit->set_text(String(np));
28782878
edit->show();
28792879
callable_mp((Control *)edit, &Control::grab_focus).call_deferred();
28802880
} break;
@@ -2976,7 +2976,7 @@ bool EditorPropertyNodePath::is_drop_valid(const Dictionary &p_drag_data) const
29762976
void EditorPropertyNodePath::update_property() {
29772977
const Node *base_node = get_base_node();
29782978
const NodePath &p = _get_node_path();
2979-
assign->set_tooltip_text(p);
2979+
assign->set_tooltip_text(String(p));
29802980

29812981
if (p.is_empty()) {
29822982
assign->set_button_icon(Ref<Texture2D>());
@@ -2988,7 +2988,7 @@ void EditorPropertyNodePath::update_property() {
29882988

29892989
if (!base_node || !base_node->has_node(p)) {
29902990
assign->set_button_icon(Ref<Texture2D>());
2991-
assign->set_text(p);
2991+
assign->set_text(String(p));
29922992
return;
29932993
}
29942994

@@ -2997,7 +2997,7 @@ void EditorPropertyNodePath::update_property() {
29972997

29982998
if (String(target_node->get_name()).contains_char('@')) {
29992999
assign->set_button_icon(Ref<Texture2D>());
3000-
assign->set_text(p);
3000+
assign->set_text(String(p));
30013001
return;
30023002
}
30033003

editor/import/3d/editor_import_collada.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1565,7 +1565,7 @@ void ColladaImport::create_animation(int p_clip, bool p_import_value_tracks) {
15651565
}
15661566

15671567
NodeMap &nm = node_map[E];
1568-
String path = scene->get_path_to(nm.node);
1568+
String path = String(scene->get_path_to(nm.node));
15691569

15701570
if (nm.bone >= 0) {
15711571
Skeleton3D *sk = static_cast<Skeleton3D *>(nm.node);
@@ -1756,7 +1756,7 @@ void ColladaImport::create_animation(int p_clip, bool p_import_value_tracks) {
17561756
}
17571757

17581758
NodeMap &nm = node_map[at.target];
1759-
String path = scene->get_path_to(nm.node);
1759+
String path = String(scene->get_path_to(nm.node));
17601760

17611761
animation->add_track(Animation::TYPE_BLEND_SHAPE);
17621762
int track = animation->get_track_count() - 1;

editor/import/3d/post_import_plugin_skeleton_renamer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,9 +228,9 @@ void PostImportPluginSkeletonRenamer::internal_process(InternalImportCategory p_
228228
}
229229
} else {
230230
if (anim->track_get_path(i).get_subname_count() > 0) {
231-
anim->track_set_path(i, UNIQUE_NODE_PREFIX + unique_name + "/" + node->get_path_to(orig_node) + String(":") + anim->track_get_path(i).get_concatenated_subnames());
231+
anim->track_set_path(i, UNIQUE_NODE_PREFIX + unique_name + "/" + String(node->get_path_to(orig_node)) + String(":") + anim->track_get_path(i).get_concatenated_subnames());
232232
} else {
233-
anim->track_set_path(i, UNIQUE_NODE_PREFIX + unique_name + "/" + node->get_path_to(orig_node));
233+
anim->track_set_path(i, UNIQUE_NODE_PREFIX + unique_name + "/" + String(node->get_path_to(orig_node)));
234234
}
235235
}
236236
break;

0 commit comments

Comments
 (0)