Currently we have many methods that do an explicit: VclPtr<VirtualDevice> aDev = VclPtr<VirtualDevice>::Create(...); .... aDev.disposeAndClear(); This construct is not exception safe and can easily introduce GDI leaks with new return paths. For these cases we actually have ScopedVclPtrInstance which automatically calls dispose when the object out of scope. This task is about going through the list returned by git grep VclPtr<VirtualDevice>::Create and transform the ones that call the disposeAndClear inside of the same method to a ScopedVclPtrInstance. An example that shows where this can be done is https://cgit.freedesktop.org/libreoffice/core/tree/sw/source/core/view/viewsh.cxx?id=509c91aca5a9e89e9453082486ac7d67f649a7f5#n329 All the other places need to be checked if this works there as well.
Christian Barth committed a patch related to this issue. It has been pushed to "master": http://cgit.freedesktop.org/libreoffice/core/commit/?id=89494fc501142f83a4ae387394d939d25252f796 tdf#107880: Make use of ScopedVclPtr It will be available in 6.0.0. The patch should be included in the daily builds available at http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More information about daily builds can be found at: http://wiki.documentfoundation.org/Testing_Daily_Builds Affected users are encouraged to test the fix and report feedback.
Seems like this is the only place to do this. The most of the other occurrences are class members with destruction in DTOR.
I want to work on this issue, want to know if it's still open.
@Markus can you please provide your feedback on this? I briefly check that myself and there doesn't seem to be much to be done on this one.
This change has been merged in https://gerrit.libreoffice.org/#/c/39321/ .