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

Add _get_unsaved_status() method to EditorPlugin and implement it for script and shader editors #67503

Conversation

KoBeWi
Copy link
Member

@KoBeWi KoBeWi commented Oct 16, 2022

This PR adds _get_unsaved_status(). When editor is being closed, it calls this method on every plugin. The method returns a string. If the string is not empty, its content will be displayed in save confirmation dialog and the user can normally choose to save or discard. If the returned string is empty, the editor will close normally.

I implemented this method for script editor and shader editor, so unsaved scripts will now prompt on editor exit. Unfortunately you can't discard them due to #18010

Fixes #55026
Fixes #36281
Supersedes #55586

@KoBeWi
Copy link
Member Author

KoBeWi commented Apr 5, 2023

Rebased and ready for review. I did a small modification: get_unsaved_status() is now called when closing a scene and passes the scene path as an argument. This allows to handle built-in resources and effectively fixes #44053

godot.windows.editor.dev.x86_64_Ms3syKkV8H.mp4

I added it as another commit, but I can rebase it into 2 commits if that's better.

@KoBeWi KoBeWi force-pushed the are_you_saving_this_or_are_you_not_saving_this branch 2 times, most recently from fd9af29 to ed159e4 Compare April 5, 2023 15:50
@KoBeWi KoBeWi force-pushed the are_you_saving_this_or_are_you_not_saving_this branch from ed159e4 to a741d60 Compare May 21, 2023 15:55
@akien-mga akien-mga requested a review from YuriSizov June 12, 2023 20:46
@akien-mga akien-mga modified the milestones: 4.x, 4.2 Jun 15, 2023
Copy link
Contributor

@YuriSizov YuriSizov left a comment

Choose a reason for hiding this comment

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

Haven't tested, but the code looks mostly correct (left a couple of notes).

The feature itself is fine, though I think we should at some point make it more convenient to handle unsaved resources specifically. I proposed before an API that would allow plugins to mark arbitrary strings as dirty, which could be used to identify resources and any other stuff as unsaved.

But maybe we just need this new method and some kind of _get_unsaved_files which returns a list. This can be done in a follow-up though.

editor/editor_node.cpp Outdated Show resolved Hide resolved
editor/editor_node.cpp Outdated Show resolved Hide resolved
editor/editor_node.cpp Show resolved Hide resolved
@KoBeWi KoBeWi force-pushed the are_you_saving_this_or_are_you_not_saving_this branch from a741d60 to b883f32 Compare July 18, 2023 12:28
@YuriSizov YuriSizov merged commit 77d96b2 into godotengine:master Jul 18, 2023
@YuriSizov
Copy link
Contributor

Thanks!

@KoBeWi KoBeWi deleted the are_you_saving_this_or_are_you_not_saving_this branch July 18, 2023 13:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants