Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

External WM_DESTROY issue



  • Hi! My application has Log window and Test window (main window), when I close the app I get the following error: External WM_DESTROY received for QWidgetWindow(0x2c9235f1890, name="LogWindow") , parent: QWindow(0x0) , transient parent: QWidgetWindow(0x2c920b375a0, name="TestClassWindow")

    Code:

    Log *appLog;
    appLog = new Log(this);
    appLog->show();
    

    I delete Log class object in the destructor.

    Test::~Test()
    {
        delete appLog;
    }
    

    I can't use setAttribute(Qt::WA_DeleteOnClose); function because it will delete the collected log, and it won't be available when open Log window again. How to fix this issue? Thanks in advance.



  • @Cobra91151

    Hi,

    You create it with parent, which mean it gets deleted automatically with the parent. And your delete appLog then deletes it a second time.

    -Michael.



  • @m.sue

    The issue is still present even when removing delete appLog; from destructor.


  • Lifetime Qt Champion

    Hi,

    Did you check whether you have other cases of multiple deletion in your code ?



  • @SGaist

    Yes. It was the only one. I think the problem is with Qt 5.7.1. I can't switch to the latest because it doesn't support Win XP.

    On Qt 5.8 or Qt 5.9 when deploying the app, it throws the following error:

    0_1498158164381_error.jpg

    I can't find where in the Qt source files it calls the GetUserPrefferrdUILanguages function?


  • Lifetime Qt Champion

    If you want to run on XP, stay with the latest Qt 5.6 release.



  • @SGaist

    Deployment also works on Qt 5.7.1 on Win XP. Anyway, the current issue is with External WM_DESTROY message. Windows can send this message in both cases:

    • I delete Log object twice
    • Qt doesn't delete it as parent


  • @SGaist

    I have fixed this issue by checking Log object for nullptr and emitting signal from QCloseEvent function and connect to the slot Log::deleteLater. So now it deletes when app closes.


Log in to reply