godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
88.94k stars 20.17k forks source link

Adding an existing script to a node which has the same case-insensitive name warns for case mismatch #31995

Open Zylann opened 5 years ago

Zylann commented 5 years ago

Godot 3.2 master ccf294b92f02af6e60206e220dcf4a8474f73f0a

I have an existing script named interaction.gd and a node called Interaction. I used the right-click menu of the scene tree to add that script. The dialog popped up proposing the name Interaction.gd. I clicked on the folder icon to pick interaction.gd from the file system, then clicked OK.

Later I noticed the following warnings in the console:

WARNING: FileAccessWindows::_open: Case mismatch opening requested file 'Interaction.gd', stored as 'interaction.gd' in the filesystem. This file will not open when exported to other case-sensitive platforms.
     At: drivers\windows\file_access_windows.cpp:105
WARNING: FileAccessWindows::_open: Case mismatch opening requested file 'Interaction.gd', stored as 'interaction.gd' in the filesystem. This file will not open when exported to other case-sensitive platforms.
     At: drivers\windows\file_access_windows.cpp:105
Loading resource: res://dmc_terrain/Interaction.gd
WARNING: FileAccessWindows::_open: Case mismatch opening requested file 'Interaction.gd', stored as 'interaction.gd' in the filesystem. This file will not open when exported to other case-sensitive platforms.
     At: drivers\windows\file_access_windows.cpp:105
WARNING: FileAccessWindows::_open: Case mismatch opening requested file 'Interaction.gd', stored as 'interaction.gd' in the filesystem. This file will not open when exported to other case-sensitive platforms.
     At: drivers\windows\file_access_windows.cpp:105

Although the script loaded correctly, these warnings seem to hint a problem with this sequence of actions. Case-sensitivity should not matter at all since the script already existed and I didn't rename it. It also happened during file opening, so somehow Godot tried to open the script using the wrong name.

codecustard commented 5 years ago

I don't think that it's a bug, considering it's a warning and not an error. Linux's filesystem has case sensitivity. Maybe ignoring case mismatch on Windows would make sense, since it doesn't have case sensitivity, but I feel like that wouldn't be a great idea especially if you're working in a team where other people use Linux.

Zylann commented 5 years ago

I am well aware of case difference between OS, but I'm not asking to remove this warning. Read my issue again:

I clicked on the folder icon to pick interaction.gd from the file system

the script already existed and I didn't rename it

somehow Godot tried to open the script using the wrong name.

I told Godot to load interaction.gd, and it still tried to load Interaction.gd. Something definitely went wrong here, and could hide a potential bug :p At no point in this repro this should have happened, regardless of case sensitivity of the OS. Maybe the issue title is a bit misleading, since the warning is only a symptom, not the problem.

codecustard commented 5 years ago

If you told it to load interaction.gd and not Interaction.gd... I would say it's a bug.

When you clicked on the folder icon to load the script... did you actually click on "interaction.gd" to change the "file value". If you click on it.. it should change it to lowercase, if not, it'll leave the field to uppercase since it autofills with the name of your node.

Zylann commented 5 years ago

After testing again, it does replace the line edit with the lowercase version interaction.gd. However I noticed that it tried to load Interaction.gd when the file dialog opens, before I actually select the file...

codecustard commented 5 years ago

The error is triggered by the following: https://github.com/codecustard/godot/blob/24e1039eb6fe32115e8d1a62a84965e9be19a2ed/editor/editor_file_dialog.cpp#L255-L256

_request_single_thumbnail(get_current_dir().plus_file(get_current_file())); eventually checks if file exists, which does the test by opening the file.

KoBeWi commented 4 years ago

Still valid in 3.2.3 rc4 On master when creating script it doesn't have name for some reason, so it's impossible to test.

ODtian commented 1 year ago

Still valid in 4.0.2 release. It seems generates a upper-case naming file and causes Class "Xxx" hides a global script class. because there are actually 2 files loaded but one is invisible in file system.

CsloudX commented 2 months ago

image Everytime it report case mismatch when I start my project. and I don't know how to fix this.