QDialog - avoid potential crash
In case the dialog is deleted while signals are emitted, we should likely prevent a crash. Now, obviously it would be remarkable if people deleted the dialog meanwhile, but it can also happen if the attribute WA_DeleteOnClose is set and QAppliction::processEvents() is called in a slot connected to accepted or rejected. Pick-to: 6.5 Change-Id: Iafa708dec2c1064ea890f222ff5a8d15c94cbe4c Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This commit is contained in:
parent
c891d16490
commit
178da993a0
@ -159,13 +159,15 @@ void QDialogPrivate::close(int resultCode)
|
||||
void QDialogPrivate::finalize(int resultCode, int dialogCode)
|
||||
{
|
||||
Q_Q(QDialog);
|
||||
QPointer<QDialog> guard(q);
|
||||
|
||||
if (dialogCode == QDialog::Accepted)
|
||||
emit q->accepted();
|
||||
else if (dialogCode == QDialog::Rejected)
|
||||
emit q->rejected();
|
||||
|
||||
emit q->finished(resultCode);
|
||||
if (guard)
|
||||
emit q->finished(resultCode);
|
||||
}
|
||||
|
||||
QWindow *QDialogPrivate::transientParentWindow() const
|
||||
|
Loading…
x
Reference in New Issue
Block a user