Details
-
Bug
-
Resolution: Fixed
-
P1: Critical
-
6.5.6
-
-
5e83def8f (dev), 3d7ce7533 (6.8), 21b6890e6 (tqtc/lts-6.5)
Description
A comercial user reported an issue as follows:
Our main window uses QOpenGLWindow to render and we have a dialog that the user can use to create 2D/3D Charts that are rendered through QMdiSubWindows.
However, when removing a 3D chart the main window crashes, or in some cases goes entirely black. I've reproduced this behaviour in the example attached.
I built the example with Qt Creator 13.0.1, MSVC 2019, and the Qt version I am using is 6.5.6.
To reproduce:
- Build with debug/release and launch
- Click on 'Open MDI Dialog' button
- Take focus away from the dialog by clicking on the main window
- Close the QMdiSubWindow by clicking on the close button in the top right
- Click back on the main window and the entire window goes black.
I found a similar issue posted on the Qt forums a while ago so it appears that the problem has existed for a while - https://forum.qt.io/topic/77345/qmainwindow-s-content-turns-black-after-qmdisubwindow-closes?_=1676384471167
It's hard to pinpoint what the issue is as any debugger does not tell me any useful information, but it appears that when there are two widgets using OpenGL such as the QOpenGLWidget and Q3DSurface in this case, when the Q3DSurface is destroyed it no longer draws anything for the parent main window either.
I've not been able to check the new Qt Graphs module to see if it will still be an issue if we migrated away from Qt Data Visualization, so would be interesting to see if migrating to Qt Graphs fixes that.
Further, one workaround is to remove the 'subWindow->setAttribute(Qt::WA_DeleteOnClose, true);' line from the MdiDialog constructor, however this means any deleted charts are stored in memory until the application closes in its entirety, so this can be expensive if many charts are created.
Attachments
For Gerrit Dashboard: QTBUG-128460 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
597385,5 | Add checks for opengl context switch upon cleanup | dev | qt/qtdatavis3d | Status: MERGED | +2 | +1 |
600146,2 | Add checks for opengl context switch upon cleanup | 6.8 | qt/qtdatavis3d | Status: MERGED | +2 | 0 |
600695,2 | Add checks for opengl context switch upon cleanup | tqtc/lts-6.5 | qt/tqtc-qtdatavis3d | Status: MERGED | +2 | 0 |