-
Bug
-
Resolution: Done
-
P2: Important
-
5.2.1
-
None
-
OSX 10.8.5, XCode
(Although I ran into it with 5.2.1, the problem probably exists in prior 5.x versions as well)
When user closes a modal dialog, the application should not get an ApplicationStateChange. Yet on Mac, we do - the application would get deactivated then immediately reactivated again.
Such an unexpected behavior has the potential to throw any code that relies on QGuiApplication::applicationStateChanged() to detect user switching away to another application into a tailspin.
Attached please find a sample app that repros the problem (file listings below).
Here are the steps:
1) launch the sample app
2) select "Test" from the menu bar, then "Random Dialog...", which just launches a modal generic QDialog
3) dismiss the dialog by clicking the red 'Close' button
4) notice that just by closing we get a pair of Qt::ApplicationInactive/Qt::ApplicationActive in the stdout
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
QMenuBar* menuBar = new QMenuBar;
QMenu* testMenu = menuBar->addMenu("Test");
QAction* act = testMenu->addAction("Random Dialog...");
connect(act, &QAction::triggered, this, &MainWindow::showRandomDialog);
setMenuBar(menuBar);
connect(qApp, &QGuiApplication::applicationStateChanged, this, &MainWindow::handleApplicationStateChanged);
}
MainWindow::~MainWindow()
{
delete ui;
}
void
MainWindow::handleApplicationStateChanged(Qt::ApplicationState state)
{
qDebug("App state changed to %d", (int) state);
}
void
MainWindow::showRandomDialog()
{
QDialog dlg;
dlg.exec();
}
- relates to
-
QTBUG-40857 ColorDialog: rejected signal doesn't get emitted when closing the window.
-
- Open
-