External WM_DESTROY issue
-
Hi! My application has
Log
window andTest
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 openLog
window again. How to fix this issue? Thanks in advance. -
Hi! My application has
Log
window andTest
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 openLog
window again. How to fix this issue? Thanks in advance.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.
-
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.
The issue is still present even when removing
delete appLog;
from destructor. -
Hi,
Did you check whether you have other cases of multiple deletion in your code ?
-
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 supportWin XP
.On
Qt 5.8
orQt 5.9
when deploying the app, it throws the following error:I can't find where in the
Qt
source files it calls theGetUserPrefferrdUILanguages
function? -
If you want to run on XP, stay with the latest Qt 5.6 release.
-
Deployment also works on
Qt 5.7.1
onWin XP
. Anyway, the current issue is withExternal WM_DESTROY
message. Windows can send this message in both cases:- I delete
Log
object twice Qt
doesn't delete it as parent
- I delete
-
I have fixed this issue by checking
Log
object fornullptr
and emitting signal fromQCloseEvent
function and connect to the slotLog::deleteLater
. So now it deletes when app closes.