Win32 Event Handling Quit Cleanup

Reporter: RobertBColton  |  Status: open  |  Last Modified: June 28, 2020, 12:36:50 PM

In an effort to better understand if we are handling quit messages, closing, and ending the game properly I reached the conclusion that this line in the Win32 event handling is useless for several reasons. In GM8.1 it is not possible for game_end(); to cause an event loop driven by functions like io_handle(); to break, the current event always finishes. If game_isending is true when this loop enters, meaning game_end(); was called, it can not have any effect anyway regardless of whether it posts a quit message to the loop. The only time it can possibly have any effect is when the engine's outer main loop calls it, which doesn't matter anyway because that loop is a while loop whose predicate is the same variable!
RobertBColton  
ockquote>

What is responsible for posting that quit message, now?

The quit message is only posted by the WM_CLOSE event now if the setting to treat it as the Escape key is enabled. Otherwise the close button should not close the window.

If we don't post it, Win32-specific extensions can't pick up on the game ending without a hook.

Extensions do have the ability to check enigma::game_isending but otherwise checking for WM_QUIT would not have worked before in the case that game_end(); was called. Therefore, if we want such a hook for extensions, we either change the main loop to exit this way or we add our own hook, which was proposed in #997 by you.

codecov[bot]  

Codecov Report

Merging #2054 into master will increase coverage by 0.01%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2054      +/-   ##
==========================================
+ Coverage   30.93%   30.94%   +0.01%     
==========================================
  Files         197      197              
  Lines       19106    19106              
==========================================
+ Hits         5910     5913       +3     
+ Misses      13196    13193       -3     
Impacted Files Coverage Δ
ENIGMAsystem/SHELL/Platforms/xlib/XLIBmain.cpp 35.00% <0.00%> (+3.00%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update bd90334...d280f82. Read the comment docs.

Please sign in to post comments, or you can view this issue on GitHub.