fix(cpn): Ignore 'Quit' event in main window on MacOS simulator running #2874
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.
Prevents Companion app crashing on exit while the simulator is open.
In MacOS 10 the user cannot exit the app when the simulator window is open.
On MacOS 11, 12 and 13, the user can exit the app - from the Quit menu option or by pressing Command+Q.
However the app crashes while closing, prompting the user to send a bug report to apple.
This change stops the main window from closing, allowing the quit event to just close the simulator window.
Pressing Command+Q (or selecting Quit) a second time will close the Companion app.
I suspect there is a timing issue at play; but I have so far not been able to find it.
This change is probably not ideal; but I think is a reasonable work around for now.
Summary of changes:
Add a function to test if the simulator is running to helpers.cpp.
Ignore the quit event in MainWindow if the simulator is running.
The changes are limited to MacOS only.