forked from qt-creator/qt-creator
Debugger: give item delegates a parent.
These delegates would otherwise be leaked. This is not a serious leak, as a few (about 10) are created once and kept/used for the whole lifetime of the application, but they do show up in leak-analysis tools. Change-Id: I1e281f06f21ae828199078253ae5719668d26bbc Reviewed-by: hjk <hjk121@nokiamail.com>
This commit is contained in:
@@ -40,7 +40,7 @@ namespace Utils {
|
|||||||
class BaseTreeViewDelegate : public QItemDelegate
|
class BaseTreeViewDelegate : public QItemDelegate
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
BaseTreeViewDelegate() {}
|
BaseTreeViewDelegate(QObject *parent): QItemDelegate(parent) {}
|
||||||
|
|
||||||
QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
|
QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
|
||||||
const QModelIndex &index) const
|
const QModelIndex &index) const
|
||||||
@@ -64,7 +64,7 @@ BaseTreeView::BaseTreeView(QWidget *parent)
|
|||||||
setIconSize(QSize(10, 10));
|
setIconSize(QSize(10, 10));
|
||||||
setSelectionMode(QAbstractItemView::ExtendedSelection);
|
setSelectionMode(QAbstractItemView::ExtendedSelection);
|
||||||
setUniformRowHeights(true);
|
setUniformRowHeights(true);
|
||||||
setItemDelegate(new BaseTreeViewDelegate);
|
setItemDelegate(new BaseTreeViewDelegate(this));
|
||||||
header()->setDefaultAlignment(Qt::AlignLeft);
|
header()->setDefaultAlignment(Qt::AlignLeft);
|
||||||
header()->setClickable(true);
|
header()->setClickable(true);
|
||||||
|
|
||||||
|
|||||||
@@ -65,8 +65,9 @@ public:
|
|||||||
class HistoryLineDelegate : public QItemDelegate
|
class HistoryLineDelegate : public QItemDelegate
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
HistoryLineDelegate()
|
HistoryLineDelegate(QObject *parent)
|
||||||
: pixmap(QLatin1String(":/core/images/editclear.png"))
|
: QItemDelegate(parent)
|
||||||
|
, pixmap(QLatin1String(":/core/images/editclear.png"))
|
||||||
{}
|
{}
|
||||||
|
|
||||||
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
|
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
|
||||||
@@ -85,7 +86,7 @@ public:
|
|||||||
HistoryLineView(HistoryCompleterPrivate *model_)
|
HistoryLineView(HistoryCompleterPrivate *model_)
|
||||||
: model(model_)
|
: model(model_)
|
||||||
{
|
{
|
||||||
HistoryLineDelegate *delegate = new HistoryLineDelegate;
|
HistoryLineDelegate *delegate = new HistoryLineDelegate(this);
|
||||||
pixmapWidth = delegate->pixmap.width();
|
pixmapWidth = delegate->pixmap.width();
|
||||||
setItemDelegate(delegate);
|
setItemDelegate(delegate);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user