D14931: Eliminate duplicate QMaps in OutputWidget

Friedrich W. H. Kossebau noreply at phabricator.kde.org
Mon Sep 3 05:39:21 BST 2018

kossebau added inline comments.


> anthonyfieroni wrote in outputwidget.cpp:527
> It's not correct, 3 line above you get a raw managed pointer, here you make a distinct managed pointer with same source. It'll result in double deletion when goes out of scope.

As @anthonyfieroni said, there is a bug here:

  listview = m_views.begin().value().view.data();

takes a war copy of the pointer otherwise controlled by a QSharedPointer value.
` ` `
m_views[id].view = QSharedPointer<QTreeView>(listview);
` ` `
then creates a new QSharedPointer around that raw pointer.  As a result we have two sets of QSharedPointer for the very same pointer, which will result in double deletion once both sets go out of existance.

Please fix this by making listview a QSharedPointer itself, so in case an existing pointer is taking, there will be only one set of QSharedPointer around that.

> outputwidget.cpp:260
>      {
> -        QTreeView* view = m_views.value(id);
> +        QTreeView *view = m_views.value(id).view;
>          if( data->type & KDevelop::IOutputView::MultipleView || data->type & KDevelop::IOutputView::HistoryView )

KDevelop coding style is to have the * with the type, so please keep that (`QTreeView*`)

> outputwidget.h:110
> +    };
> +    QMap<int, FilteredView>::iterator getFilteredView(QAbstractItemView *view);
> +

Please remove the "get" prefix, name the method simply `filteredView(QAbstractItemView *view);`

  R32 KDevelop


To: vkorneev, #kdevelop, kfunk
Cc: kossebau, anthonyfieroni, aaronpuchert, kfunk, pino, kdevelop-devel, antismap, iodelay, vbspam, geetamc, Pilzschaf, akshaydeo, surgenight, arrowd
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kdevelop-devel/attachments/20180903/0ec5f7b6/attachment-0001.html>

More information about the KDevelop-devel mailing list