**I have a dialog-based widget (Qt :: WA_DeleteOnClose is false) which I create one time and then show and hide many times.
When I close the widget and open it again then I see undefined behavior or application crash.
This began to happen when I switched to a Qt 5.12.4 instead of the 5.9 version.
Simple application is attached.
Some internal objects of QWidget that affect drawing are deleted when a QDialog-based object is closing.This happens despite that the attribute Qt :: WA_DeleteOnClose is false. The next time when the dialog is displayed, then it causes undefined behavior or application crash.
I found it in Qt 5.12.4 and I don't find it in Qt 5.9.
Application contains two QDialog-based classes: MainDialog and SecondDialog.
MainDialog creates SecondDialog in constructor with attribute Qt :: WA_DeleteOnClose = false. MainDialog shows SecondDialog each time then user clicks "Show Second" button.
SecondDialog contains system menu bar, push button "Hide" and text edit with multi-line text (automated vertical scroll bar is shown). When user click "Hide", SecondDialog object handles hideEvent. When user click close button in system menu then SecondDialog handles closeEvent.
It is expected that closeEvent and the hideEvent should cause to only hiding the window. In Qt 5.9 it's true but in Qt 5.12.4 it's not.
Steps to view the crash.
- Extract attached scrollBug_12.zip and build it (Desktop Qt 5.12.4 MinGV 64bit (debug or release) for Windows)
- Run application;
- Click "Show Second" button. SecondDialog window will be shown.
- Click close button in system menu. SecondDialog will be closed.
- Click "Show Second" button again. SecondDialog window will be shown again.
- Try to scroll text in SecondDialog. Application will be crashed.
Note. If on step 4 you click "Hide" button then on step 6 application will not be crashed.