use QPointer to guard possible crashes with dialog exec
Details
- Reviewers
dvratil - Group Reviewers
KDE PIM - Commits
- R95:31d081255687: pimcommon/autocorrection/autocorrectionwidget.cpp - QPionter dialog guards
Diff Detail
- Repository
- R95 PIM: Common Support
- Lint
Automatic diff as part of commit; lint not applicable. - Unit
Automatic diff as part of commit; unit tests not applicable.
This is not really a problem. When dialog is destroyed (e.g. from DBUS) exec() returns rejected (false) it's not safe when access dlg instance after that.
// Edit:
After quick thinking it can be a problem if destructor can be called twice and it access this pointer.
I'm following the recommendations found in this old blog https://blogs.kde.org/node/3919
Perhaps things have have changed since the KDE4 days??
Objects that live on the stack should not be subject to heap memory management; something that definitively hasn't changed. Memory management in Qt is already quite confusing. This change supports local reasoning about the code. This easily outweighs the micro performance hit.
As one consequence, the destructor of a dialog is called twice if this dialog's parent is deleted before exec returns when QPointer is not used, as anthonyfieroni pointed out in his edit. This is bound to cause trouble.
fwiw: +1 for this diff
This seems to be the reason that I can no longer build kmail on my openSuse 42.2 (gcc 4.8.5)
Had to make the attached changes.
Can you clarify, please ?