Review Request 126526: [hg]Fixed memory leak

Mark Gaiser markg85 at gmail.com
Sun Dec 27 19:52:38 GMT 2015



> On dec 27, 2015, 3:46 p.m., Mark Gaiser wrote:
> > This is exactly the reason (a forgotten delete) why i prefer to use smart pointers instead of naked pointers.
> > Could you put m_config in a std::unique_ptr<...> object? Or if you really want to use Qt smart pointers then put it in a QScopedPointer<...>.
> 
> Tomasz Bojczuk wrote:
>     But it doesn't match a type when KConfigGroup() is created with m_config as a first parameter. (Either for std::unique_ptr or QScopedPointer).
>     IMO, using destructor is much clearer and quite sufficient for this purpose.

I don't see what you mean..
This should work (QScopedPointer):

QScopedPointer<KConfig> scoped(new KConfig(QLatin1String("dolphin-hg"), KConfig::SimpleConfig, QStandardPaths::GenericConfigLocation));

Od std::unique_ptr version:
std::unique_ptr<KConfig> scoped(new KConfig(QLatin1String("dolphin-hg"), KConfig::SimpleConfig, QStandardPaths::GenericConfigLocation));

Be sure to include <memory> for std::unique_ptr and <QScopedPointer> for QScopedPointer.

Anyway, what you did (in the diff as it is right now) looks fine to me. Don't read my comment as "you must change it", it's fine imho. I simply prefer samrt pointers. You don't have to follow my preference :)


- Mark


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://git.reviewboard.kde.org/r/126526/#review90147
-----------------------------------------------------------


On dec 26, 2015, 1:52 p.m., Tomasz Bojczuk wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://git.reviewboard.kde.org/r/126526/
> -----------------------------------------------------------
> 
> (Updated dec 26, 2015, 1:52 p.m.)
> 
> 
> Review request for Dolphin.
> 
> 
> Repository: dolphin-plugins
> 
> 
> Description
> -------
> 
> There is KConfig instance
> KConfig *m_config;
> It is created in constructor but never deleted (no destructor).
> Added destructor then.
> In occasion, when m_config is created - wrapped file name text by QLatin1String
> 
> 
> Diffs
> -----
> 
>   hg/config-widgets/pluginsettings.h 42d3cec 
>   hg/config-widgets/pluginsettings.cpp 2267a3a 
> 
> Diff: https://git.reviewboard.kde.org/r/126526/diff/
> 
> 
> Testing
> -------
> 
> 
> Thanks,
> 
> Tomasz Bojczuk
> 
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.kde.org/mailman/private/kfm-devel/attachments/20151227/9fe3f12e/attachment.htm>


More information about the kfm-devel mailing list