D6308: Fix crashy dialogs (found by krazy and by hand)
Christoph Roick
noreply at phabricator.kde.org
Tue Jun 27 22:37:11 UTC 2017
croick marked 4 inline comments as done.
croick added a comment.
In https://phabricator.kde.org/D6308#118881, @anthonyfieroni wrote:
> You still can make a wrapper around QPointer prevent call delete after exec() check i.e.
>
> template<class T>
> class QPointerWrapper
> {
> QPoniter<T> ptr;
> public:
> QPointerWrapper(T *rawPtr) : ptr(rawPtr) {}
> ~QPointerWrapper() { delete ptr; }
> QPointer<T>& operator->() { return ptr; }
> };
> // usage
> QPointerWrapper<VcsCommitDialog> commitDialog = new VcsCommitDialog(patchSource);
> commitDialog->exec();
> // without delete commitDialog :)
>
Your proposal is now in a utility class, hopefully in the right place. The dialog is constructed in the wrapper constructor, so the code only adds few overhead (in terms of characters) compared to the stack version:
DialogWrapper<VcsCommitDialog> commitDialog(patchSource);
commitDialog->exec();
REPOSITORY
R33 KDevPlatform
REVISION DETAIL
https://phabricator.kde.org/D6308
To: croick, #kdevelop
Cc: anthonyfieroni, kdevelop-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kdevelop-devel/attachments/20170627/77a2b1df/attachment.html>
More information about the KDevelop-devel
mailing list