D16663: [import] Fix leaking AbstractFileFilters

Alexander Semke noreply at phabricator.kde.org
Wed Dec 5 07:24:09 GMT 2018


asemke added inline comments.

INLINE COMMENTS

> LiveDataSource.cpp:252
>  void LiveDataSource::setFilter(AbstractFileFilter* f) {
> +	delete m_filter;
>  	m_filter = f;

this needs only be done if m_filter != nulltpr,

> MQTTClient.cpp:104
>  
> +	delete m_filter;
>  	delete m_updateTimer;

same here. let's keep this safety check if (m_filter) for the case when MQTTClient is initialized and destroyed without the filter being set in-between.

> MQTTClient.cpp:153
> +void MQTTClient::setFilter(AsciiFilter* f) {
> +	delete m_filter;
>  	m_filter = f;

same here.

> ImportFileWidget.cpp:595
>  		DEBUG("	ASCII");
> -		//TODO			std::unique_ptr<AsciiFilter> filter(new AsciiFilter());
> -		auto* filter = new AsciiFilter();
> +		if (!m_currentFilter)
> +			m_currentFilter.reset(new AsciiFilter);

I think the following would also to the job completely without any smart pointers and static casts:

  if (m_currentFilter)
      delete m_currentFilter;
  
  auto filter = new AsciiFilter();
  filter->set*();
  m_currentFilter = filter;

> croick wrote in ImportFileWidget.h:103
> currentFileFilter() is marked const, but m_currentFilter is changed therein.

Ok.

REPOSITORY
  R262 LabPlot

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

To: croick, #labplot, asemke
Cc: asemke, kde-edu, narvaez, apol
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-edu/attachments/20181205/ad36ddeb/attachment.html>


More information about the kde-edu mailing list