Skip to content

fix(mfcwx): stop deferred tab activation from using a deleted main frame - #4

Merged
qamarq merged 1 commit into
mainfrom
fix/mdi-frame-after-destroy
Oct 8, 2026
Merged

qamarq merged 1 commit into
mainfrom
fix/mdi-frame-after-destroy

Conversation

@qamarq

@qamarq qamarq commented Oct 8, 2026

Copy link
Copy Markdown
Member

Fixes the crash in CMDIFrameWnd::OnChildActivated() reported from release build 10.

Closing an MDI child posted a call to the main frame's OnChildActivated, and the notebook's page-changed handler captured the frame pointer. When the main window closed right after (closing the app with documents open), the CMainFrame object was already deleted when those ran. Both now look the frame up by its window when they run and do nothing if it is gone.

Reproduced with the automation runner (open Caesar result, close a tab, close the main window): before 3/3 runs crashed with SIGSEGV, after 3/3 exit cleanly. The full sweep of 191 menu commands still passes and all 13 unit tests pass.

Also:

  • File > Exit did nothing: ID_APP_EXIT is now routed to CWinApp::OnAppExit, as in MFC's CWinApp message map.
  • MFCWX_AUTOMATION gains a close step (WM_CLOSE to the main window).

Closing an MDI child posted a call to the main frame's OnChildActivated, and
the notebook's page-changed handler captured the frame pointer. When the
main window closed right after (closing the app with documents open), the
CMainFrame object was already deleted when those ran, which crashed in
CMDIFrameWnd::OnChildActivated. Both now look the frame up by its window
when they run and do nothing if it is gone.

Also routes ID_APP_EXIT to CWinApp::OnAppExit as MFC's CWinApp message map
does (File > Exit did nothing), and adds a close step to MFCWX_AUTOMATION.
@qamarq
qamarq merged commit 6e0404c into main Oct 8, 2026
5 checks passed
@qamarq
qamarq deleted the fix/mdi-frame-after-destroy branch October 8, 2026 14:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant