Skip to content

Commit

Permalink
fix: double free of list item on exit
Browse files Browse the repository at this point in the history
The individual items are in the list, by deleting the item and the whole
list again will trigger a segfault.

This fixes the segfault when applications like deepin-system-monitor
exits.

Change-Id: I4ee7b9c759491fe83335ba971a7806488a02d98e
  • Loading branch information
felixonmars committed Apr 20, 2018
1 parent 18a4076 commit 3941dda
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/widgets/dsimplelistview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
#include <QStyleFactory>
#include <QWheelEvent>
#include <QtMath>
#include <QPointer>

#include "dhidpihelper.h"

DCORE_USE_NAMESPACE
Expand All @@ -48,10 +50,10 @@ class DSimpleListViewPrivate : public DTK_CORE_NAMESPACE::DObjectPrivate
int getTopRenderOffset();
void sortItemsByColumn(int column, bool descendingSort);

DSimpleListItem *lastHoverItem;
DSimpleListItem *lastSelectItem;
DSimpleListItem *drawHoverItem;
DSimpleListItem *mouseHoverItem;
QPointer<DSimpleListItem> lastHoverItem;
QPointer<DSimpleListItem> lastSelectItem;
QPointer<DSimpleListItem> drawHoverItem;
QPointer<DSimpleListItem> mouseHoverItem;
QList<DSimpleListItem*> *listItems;
QList<DSimpleListItem*> *renderItems;
QList<DSimpleListItem*> *selectionItems;
Expand Down Expand Up @@ -163,10 +165,10 @@ DSimpleListView::~DSimpleListView()
{
D_D(DSimpleListView);

delete d->lastHoverItem;
delete d->lastSelectItem;
delete d->drawHoverItem;
delete d->mouseHoverItem;
delete d->lastHoverItem.data();
delete d->lastSelectItem.data();
delete d->drawHoverItem.data();
delete d->mouseHoverItem.data();
delete d->listItems;
delete d->renderItems;
delete d->selectionItems;
Expand Down

0 comments on commit 3941dda

Please sign in to comment.