Fix updating of closed script files #114430
Fix updating of closed script files #114430Kn1feKillz wants to merge 1 commit intogodotengine:masterfrom
Conversation
|
I suppose the same fix is valid for replacing individual results, right? |
|
It was my mistake; I didn't see that PackedArray is also a vector of strings. I thought it was a different container. This needs to be changed.
I assumed that this function's callback changes the state of many files, and therefore updating them in the editor should be done after all replacements are complete. Furthermore, I don't see much of a difference in behavior, as the |
|
@HolonProduction |
editor/script/find_in_files.cpp
Outdated
| modified_files.push_back(fpath); | ||
| } | ||
| } | ||
|
|
There was a problem hiding this comment.
Please restore, it will just make a noise in git history.
|
And unfortunately, I can still reproduce this bug... |
Can you tell me what operating system this bug is reproduced on? I'm using Ubuntu 25.10, and the bug doesn't reproduce on it. |
|
Windows 11 (build 26100) - Single-window, 2 monitors - OpenGL ES 3/ANGLE (Compatibility) - ANGLE (Intel, Intel(R) HD Graphics 620 (0x00005916) Direct3D11 vs_5_0 ps_5_0, D3D11-31.0.101.2115) - Intel(R) Core(TM) i3-7130U CPU @ 2.70GHz (4 threads) - 7.86 GiB memory |
You were able to reproduce it, though? I can reproduce it consistently on Xubuntu 22.04.5 LTS, X11. Make sure to:
|
i cant reproduce this bug with my changes in this PR |
| @@ -1266,6 +1266,8 @@ void FindInFilesPanel::apply_replaces_in_file(const String &fpath, const Vector< | |||
| ERR_FAIL_COND_MSG(err != OK, "Cannot create file in path '" + fpath + "'."); | |||
|
|
|||
| f->store_string(buffer); | |||
|
|
|||
| EditorFileSystem::get_singleton()->update_file(fpath); | |||
There was a problem hiding this comment.
Ok, I spend some time trying to figure out why it does now always work on my side (as I wrote before, Windows-based system).
Looks like it is caused by the fact that file (FileAccess) is not closed before updating it using EditorFileSystem. I'm not 100% sure because I don't have much experience with filesystem operations, so I decided just test it.
And after adding f.unref(); between f->store_string(buffer); and EditorFileSystem::get_singleton()->update_file(fpath); I get instant updates in Godot editor (toast notifications after breaking all scripts using replace)!
But this change still needs verification from contributors, more experienced in this area.
There was a problem hiding this comment.
Makes sense to me that it should be closed first. Though it should use f->close() instead of unref.
Fix: Add updating of closed script files after changing them in the Replace menu
Search Result#108960