[Differential] [Commented On] D4439: KDirWatch: fix memory leak on destruction.

Mark Gaiser noreply at phabricator.kde.org
Sun Feb 5 12:18:08 UTC 2017


markg added a comment.


  Hmm, this is exactly the reason why i always go for either smart pointers or stack objects. Both prevent this issue from occurring in the first place.
  
  It's probably a bit much to make the Entry class own the objects (basically the diff of Albert). But there i would be a bit worried about needless copies.
  Which you can then prohibit by not allowing copies thus forcing move semantics, but then QList/QVector become unusable and you'd have to switch to std::vector. That is probably one step too far as well.
  
  So, the last possible solution that might work is:
  QList<QScopedPointer<Client>> m_clients;
  
  But i don't know enough about the Qt smart pointers to say for sure if that works as intended (aka, no leaks and no needless copies).

REPOSITORY
  R244 KCoreAddons

BRANCH
  master

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

EMAIL PREFERENCES
  https://phabricator.kde.org/settings/panel/emailpreferences/

To: dfaure, mpyne, aacid
Cc: markg, #frameworks
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-frameworks-devel/attachments/20170205/9b27d332/attachment.html>


More information about the Kde-frameworks-devel mailing list