Fix crashy dialogs (found by krazy and by hand)

Authored by croick on Jun 30 2017, 9:36 PM.

Description

Fix crashy dialogs (found by krazy and by hand)

Summary:

  • use a wrapper class which simplifies the use of QPointer for the creation of local QDialogs
  • some false positives are marked
  • some dialogs not identified by krazy have the main window as parent, they may still cause a crash, when the program is killed

Test Plan:
Before:

  • open "About KDevelop Platform" dialog
  • "killall kdevelop" -> kdevelop closes (as intended), but with crash

After:

  • open same dialog
  • "killall kdevelop" -> kdevelop silently quits

Reviewers: KDevelop, apol

Reviewed By: KDevelop, apol

Subscribers: apol, anthonyfieroni, kdevelop-devel

Differential Revision: https://phabricator.kde.org/D6308

Details

Committed
croickJun 30 2017, 9:57 PM
Reviewer
KDevelop
Differential Revision
D6308: Fix crashy dialogs (found by krazy and by hand)
Parents
R33:c6dd6e648481: Merge branch '5.1'
Branches
Unknown
Tags
Unknown
brauch added a subscriber: brauch.Jul 11 2017, 5:13 PM

Hmm. Why not use dialog->setAttribute(Qt::WA_DeleteOnClose) instead? That seems to be the standard way to do it, no?

Hmm. Why not use dialog->setAttribute(Qt::WA_DeleteOnClose) instead? That seems to be the standard way to do it, no?

It would not be possible to access elements of the dialog after exec(), which is required more often than not.

Hmm. Why not use dialog->setAttribute(Qt::WA_DeleteOnClose) instead? That seems to be the standard way to do it, no?

It would not be possible to access elements of the dialog after exec(), which is required more often than not.

I don't think that's true, it will only be deleted when the main event loop is next entered.

Hmm. Why not use dialog->setAttribute(Qt::WA_DeleteOnClose) instead? That seems to be the standard way to do it, no?

It would not be possible to access elements of the dialog after exec(), which is required more often than not.

I don't think that's true, it will only be deleted when the main event loop is next entered.

But

delete this;

is called before exec() returns. See https://github.com/qt/qtbase/blob/5.9/src/widgets/dialogs/qdialog.cpp#L553 for reference.

Oh, sorry then.

Oh, sorry then.

No problem, it made me learn about this as well :)