Skip to content

Fix Ignore External Changes Bug #106714

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jorgekorgut
Copy link
Contributor

@jorgekorgut jorgekorgut commented May 22, 2025

Fix Issue #106410 : Add a check for external modified scene files (_is_scene_externally_modified()) before handling the logic of ignoring external changes.

ignore-external-changes-test

@KoBeWi
Copy link
Member

KoBeWi commented May 23, 2025

As I suggested in the issue, it would be better to save only the scenes in the list, instead of using _save_all_scenes().

@jorgekorgut
Copy link
Contributor Author

jorgekorgut commented May 23, 2025

@KoBeWi Thanks for your feedback.

I have been reading the code for a while and I found just one reference containing the information of external unsaved files. This tree, calleddisk_changed_list, keeps reference of the string of the scenes names ? (not so sure about it) and I think it is only used for the UI.

Just to be sure you have spotted, calling the _save_all_scenes() does actually the saving scene logic only for the lists that are not saved in the editor _is_scene_unsaved() AND with this pull request scenes that were externally modified _is_scene_externally_modified().

Do you still would prefer a new function like _save_scene(i) that is called somewhere for every externally modified files ? (dont know where or how do you want this function to be called)

Edit :

Reading the code again, I can see that _save_all_scenes() call _save_scene(String, i) for only the scenes that need an update. I see 2 ways of changing it to match what you suggested but I dont see any advantages when compared with what I I have implemented.

Suggestion 1 :
Having another list synchronised with disk_changed_list that keeps track of the index of lists that need to be saved. And then call _save_scene(String, i) for those scenes that needs to be modified.

Suggestion 2:
Having a outer loop (iterating over all scenes) in _resave_scenes() (I would rename it into _resave_externally_modified_scenes()) that checks if a scene needs to be saved and only call the _save_scene(String, i) if it needs to.

@KoBeWi
Copy link
Member

KoBeWi commented May 23, 2025

_save_scene() already exists and takes a scene path (index is optional), so you can use that.

The reason I think it's better to save only modified scenes is that this information is already available. _save_all_scenes() is used in other places too (e.g. when running project), and with your current code it will perform unnecessary check.

I'd go with your suggestion 1. You can add a LocalVector<String> with paths of the scenes (the same ones as added to disk_changed_list).
Alternatively you can reuse disk_changed_list, since it already has all the scene paths. However it may contain not only scenes, so you'd have to mark items whether they are a scene or not. While it would work, the above solution sounds cleaner.

@jorgekorgut jorgekorgut force-pushed the fix-ignore-external-changes branch from 248b865 to 7f5f1ef Compare May 23, 2025 19:37
@jorgekorgut
Copy link
Contributor Author

Note that the project is also saved only if it was externally modified. I assumed that it should work this way.

Fix Issue godotengine#106410 : Add a new list `disk_changed_scenes()` and a boolean `disk_changed_project` to keep track of modfied scenes and the project. Save them only if they are in the list or the boolean value is true, when ignoring external changes.
@jorgekorgut jorgekorgut force-pushed the fix-ignore-external-changes branch from 7f5f1ef to b39a2e5 Compare May 23, 2025 19:44
need_reload = true;

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

Unnecessary blank line. Same below.

Comment on lines +1314 to +1315
String scene_path = editor_data.get_scene_path(i);

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
String scene_path = editor_data.get_scene_path(i);
const String scene_path = editor_data.get_scene_path(i);

Comment on lines +1347 to +1348
for (uint32_t i = 0; i < disk_changed_scenes.size(); i++) {
String scene_path = disk_changed_scenes[i];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
for (uint32_t i = 0; i < disk_changed_scenes.size(); i++) {
String scene_path = disk_changed_scenes[i];
for (const String &scene_path : disk_changed_scenes) {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ignore External Changes no longer re-saves scenes
3 participants