We moved project from 5.7.x to 5.12.4 and face the issue with QDialog.
When QDialog is closed and we execute QDialog::exec second time the QEvent::Paint is not called. When you close Dialog using Escape key or with custom button it works properly.
When you resize window or call QWidget::repaint the QEvent::Paint is called but in more complicated views it bombards you with asserts.
I have found workaround to override close event (which also prevent asserts):
In attachment you can find test project.