Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
6.4.2, 6.5.3
-
None
-
Windows 64bit
Linux 64bit
Description
Hi,
The scenario we have is this:
We have 2 MainWindows. The second one is set to ApplicationModal. The first one is not accessible, as expected. In our specific application, we found that if we then opened a 3rd modal window or dialog, like say a QFileDialog or a QMessageBox, and then close it, the first mainwindow becomes active again. We narrowed it down to dynamically adding a QOpenGLWidget to a modal window breaks the list of modal windows. This is the explanation from my colleague:
Making a window modal will add it to the modal window list of QApplication.
Dynamically adding a QOpenGLWidget will remove its parent window from the list (but the tricky part is that at this point, the blocking state of widgets and widow is not updated, so everything still act normal even if the list of modal window is empty. Showing and closing another modal window will update the blocking state, so this is why we only see the broken state when we close the file dialog).
A subsequent Hide/Show of the window will then add it again in the list and update the blocking state correctly
For a minimal example with PyQt6, please see the attached python file.
To reproduce the problem, run the python script. You will have a simple main window with a button and TextEditor widget. Click on the "Open Modal 2" button. It will create a new MainWindow. In MainWindow 2, there are 2 buttons. If you click on "Open File" and close it, Main Window 1 stays modal as expected. If you click click on "Add OoenGLWidget" which will add a dummy QOpenGLWidget to Mainwindow 2 and also add a new button lablled "Fix Modality".
1. On linux, MainWindow 1 becomes active again, which is unexpected.
2. On windows, MainWindow 1 stays inactive. Then, if you click on the "Open File" to open the QFileDialog, and then close it, MainWindow 1 now becomes active, which is unexpected.
Then, to fix the problem, clicking on the "Fix Modality" will inadvertantly fix the modality problem by hiding and showing MainWindow 2.
We haven't tested on MacOS as we don't have access to MacOS.
We built it with the public conan available on https://github.com/conan-io/conan-center-index/
We can provide more info on the actual build if needed.