Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
qtws26_logo

The Qt Event of the Year: Qt World Summit 2026

Save Your Spot >
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Exception when closing QMainWindow (MFC CWinApp)
Qt 6.12 LTS is out! See what's new in the release blog

Exception when closing QMainWindow (MFC CWinApp)

Scheduled Pinned Locked Moved Solved General and Desktop
2 Posts 1 Posters 537 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • PerdrixP Offline
    PerdrixP Offline
    Perdrix
    wrote on last edited by Perdrix
    #1

    This is happening as the QMainWindow instance is being destroyed

    The error is happening at wincore.cpp line 1078 which reads:

    ASSERT(pMap->LookupPermanent(hWndOrig) == NULL);
    

    I tried adding a PostNcDestroy to the CDialog that is part of the QMainWindow subclass:

    void MyDialog::PostNcDestroy()
    {

    CDialog::PostNcDestroy();
    delete this;
    

    }

    but that didn't help :(

    1 Reply Last reply
    0
    • PerdrixP Offline
      PerdrixP Offline
      Perdrix
      wrote on last edited by
      #2

      I managed to fix this issue. As the processingDlg CDialog isn't a child of a CFrameWindow (e.g.), it isn't automatically destroyed (WM_DESTROY) when the QMainWindow is closed.

      I added a call to the QMainWIndow CloseEvent handler saying:

      	processingDlg.DestroyWindow();
      

      and all is now well :) :)

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt
      • Unsolved