问题遇到的现象和发生背景
ui线程点击右上角x 关闭时,会提示这个bug
底下报这个
ASSERT failure in MyWidget: "Called object is not of the correct type (class destructor may have already run)", file D:\QT6\6.3.1\msvc2019_64\include\QtCore/qobjectdefs_impl.h, line 156
问题相关代码,请勿粘贴截图
connect(this, &MyWidget::destroyed, this, &MyWidget::dealclose);
void MyWidget::dealclose()
{
on_pushButtonstop_clicked();
delete myT;
}
void MyWidget::on_pushButtonstop_clicked()
{
if(thread->isRunning() == false)
{
return;
}
myT->setFlag(true);
thread->quit();
thread->wait();
}
但是我已经处理过关闭时的信号了,不知道为什么还会报这个错!
之前子线程会报这个,但通过设置标志位退出循环解决了。主线程为什么也会提示这个bug?