Repository navigation
P2: Editor tool dialogs stay open across New/Open, ask before losing edits, and FRED Revert no longer crashes - #8039
Open
dustinspace217 wants to merge 7 commits into
Conversation
A tool dialog's model copies the mission when it is built, so a dialog left open across New, Open or the FS1 import kept showing the old mission, and OK wrote the old mission's data into the new one (fiction viewer: the new mission saved with the old mission's three stages). Before a load, each open mission tool is closed through its own close path (its keep-your-changes prompt still applies; Cancel cancels the load), and after the load the same tools are opened again where they were. About, the music player and the campaign editor hold no mission data and stay as they are.
Most tool dialogs committed their edits on OK without telling the editor the mission changed, so New, Open or quitting right after did not offer to save and the edits were lost (fiction viewer: edit, OK, File > New, no prompt). These models now signal the change when they have one, the same way the events, goals and cutscenes editors already do; the shield system and global ship flags dialogs, which apply on their buttons, signal it there.
Both editors are modeless and copy the mission's events and messages when they are created. Left open across File > New or Open, they kept the old mission's events, and OK wrote them into the new mission. Before the save question on New, Open, FS1 import, Revert, the Campaign Editor and exit, each open editor now runs its own "Do you want to keep your changes?" prompt, as qtFRED's tools do: Yes applies, No discards, Cancel stops the action. The editors reopen afterwards, and are rebuilt from the new mission whenever it replaces the old one (New, Open, FS1 import, Undo, a failed load). The reload after a save keeps them and their edits, as before. Run FreeSpace does not replace the mission, so it skips the prompt.
… or global ship flags change it None of these called set_modified, so New, Open or exit right after did not offer to save and the change was lost. Each now marks the mission only when something actually changed.
The import cleared the modified flag right after the save question, before its two file pickers. Choosing Discard and then cancelling either picker left the unsaved mission marked as saved, so a later New or Open replaced it without asking. The flag is now cleared only once both pickers have returned a choice.
Revert called OnOpenDocument(NULL), which used to mean the current file. Since ee42e76 OnOpenDocument starts with strrchr on the path, so a null path is dereferenced. Revert now passes the document's path, the same way closing the Campaign Editor reloads the mission. The menu item now also needs that path: File > New clears the path but not the mission name, which left Revert enabled on a new mission.
The import saved the converted mission, set the title and added it to the recent files, but left the document's path on the mission open before the import. Revert and closing the Campaign Editor then reloaded that older mission instead of the imported one.
Contributor
Author
|
Heads-up on an overlap: #8030 also changes |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What?
Tool dialogs in qtFRED stay open when you start a new mission or open another one, and they show the new mission instead of the old one. Both editors now ask "keep your changes?" before throwing away unapplied edits, and they mark the mission as changed when a dialog's OK changes it. In FRED, Revert no longer crashes, and Revert after an FS1 import reloads the imported mission.
Why?
If you left a tool open and opened another mission, the tool kept showing the old mission. In FRED, pressing OK in the Event Editor then wrote the old mission's events into the new one. Several dialogs (Fiction Viewer, Shield System, Global Ship Flags, Mission Specs, Background) changed the mission without marking it as changed, so New or Open threw the work away without asking. FRED's File > Revert crashed every time. After importing a single FS1 mission, Revert or closing the Campaign Editor reloaded the mission you had open before the import.
How?
qtFRED closes its open tools before New/Open/Revert/quit, which lets each one ask about unsaved edits, then reopens them on the new mission. FRED does the same for the Event and Message editors through
SaveModified. Models mark the mission changed only when something actually changed. Revert passes the current file path instead of NULL. The FS1 import records the converted file's path.Testing?
Anything Else?
FRED's Event Editor still stops its sound twice on Cancel; the second call does nothing, so I left it alone. I used Claude Code to help find, fix and test these.