D14666: Fixes memory leak in KUrlComboBox::setUrl

David Hallas noreply at phabricator.kde.org
Tue Aug 7 12:59:06 BST 2018


hallas added a comment.


  In D14666#304848 <https://phabricator.kde.org/D14666#304848>, @dfaure wrote:
  
  > Why shared? I don't see any ownership sharing happening. The list owns the pointers. I'm always wary of shared_ptr because it's often overused as "we don't really know who's responsible for deleting this, so let's just refcount it". But there's no refcounting needed here. The ownership is very clear here.
  
  
  My first approach was to use unique_ptr, but then I realized that pointers are shared between the defaultList and the itemMapper (see for example line 164) and also between the itemList and the itemMapper (see line 278, 291 and others), but I can't see any sharing between the defaultList and itemList. I thought of using a std::weak_ptr in the itemMapper, but I am not sure that entries are always removed from itemMapper when the are removed from the defaultList or itemMapper, also if the itemMapper should be able to hold objects from both lists I think it is more sane to use a shared_ptr.
  
  Let me know what you think

REPOSITORY
  R241 KIO

REVISION DETAIL
  https://phabricator.kde.org/D14666

To: hallas, dfaure
Cc: dfaure, kde-frameworks-devel, michaelh, ngraham, bruns
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-frameworks-devel/attachments/20180807/4557fa70/attachment.html>


More information about the Kde-frameworks-devel mailing list