MorrisLiang
23rd August 2010, 06:42
My application shows an icon in system tray which allows user to quit the application. Sometimes, my app will popup a dialog to let user verify.
void MyWidget::showWarning()
{
QDialog dialog;
...
...
int result = dialog.exec();
if(result == QDialog::Accepted)
{
...
}
}
The problem is, if the local QDialog object is executing when user quits the app.MyWidget will be deleted before the line
if(result == QDialog::Accepted) is called, which makes the app crash.
So, how do I safely finish the QDialog when the user quits the app?
void MyWidget::showWarning()
{
QDialog dialog;
...
...
int result = dialog.exec();
if(result == QDialog::Accepted)
{
...
}
}
The problem is, if the local QDialog object is executing when user quits the app.MyWidget will be deleted before the line
if(result == QDialog::Accepted) is called, which makes the app crash.
So, how do I safely finish the QDialog when the user quits the app?