diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2016-09-30 22:21:37 +0200 |
---|---|---|
committer | Marc Mutz <marc.mutz@kdab.com> | 2016-10-11 20:52:42 +0000 |
commit | f6498fd6776b08b6bd33395e3f716b6d5d79a8b8 (patch) | |
tree | dc9bc1507129030a583cbfc9594cdecd06d5eea2 /tests | |
parent | 6d6074e04fa55a0e42c7d8970f6db1cc3913a26e (diff) |
Plug more than 4k leaks in tst_QGraphicsView
The vast majority is due to leaking styles in a data-driven
test with almost 100 rows (scrollBarRanges()).
Fix by creating the style into a QScopedPointer.
The remaining ~500 leaks were due to leaked QGraphicsScenes.
They had no parent, and QGraphicsView::addScene() does not
adopt them.
Fix those by passing the resp. view as their (QObject) parent.
Change-Id: I4316798019114ea3d7504d72cd83d534a21149c0
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp index f5083795c7..da2606c160 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp @@ -2938,6 +2938,9 @@ void tst_QGraphicsView::scrollBarRanges() if (useStyledPanel && style == QStringLiteral("Macintosh") && platformName == QStringLiteral("cocoa")) QSKIP("Insignificant on OSX"); + + QScopedPointer<QStyle> stylePtr; + QGraphicsScene scene; QGraphicsView view(&scene); view.setRenderHint(QPainter::Antialiasing); @@ -2945,9 +2948,10 @@ void tst_QGraphicsView::scrollBarRanges() view.setFrameStyle(useStyledPanel ? QFrame::StyledPanel : QFrame::NoFrame); if (style == QString("motif")) - view.setStyle(new FauxMotifStyle); + stylePtr.reset(new FauxMotifStyle); else - view.setStyle(QStyleFactory::create(style)); + stylePtr.reset(QStyleFactory::create(style)); + view.setStyle(stylePtr.data()); view.setStyleSheet(" "); // enables style propagation ;-) int adjust = 0; @@ -3514,7 +3518,7 @@ void tst_QGraphicsView::task245469_itemsAtPointWithClip() static QGraphicsView *createSimpleViewAndScene() { QGraphicsView *view = new QGraphicsView; - QGraphicsScene *scene = new QGraphicsScene; + QGraphicsScene *scene = new QGraphicsScene(view); view->setScene(scene); view->setBackgroundBrush(Qt::blue); @@ -3642,7 +3646,7 @@ void tst_QGraphicsView::moveItemWhileScrolling() MoveItemScrollView() { setWindowFlags(Qt::X11BypassWindowManagerHint); - setScene(new QGraphicsScene(0, 0, 1000, 1000)); + setScene(new QGraphicsScene(0, 0, 1000, 1000, this)); rect = scene()->addRect(0, 0, 10, 10); rect->setPos(50, 50); rect->setPen(QPen(Qt::black, 0)); @@ -3708,7 +3712,7 @@ void tst_QGraphicsView::centerOnDirtyItem() toplevel.setWindowFlags(view.windowFlags() | Qt::WindowStaysOnTopHint); view.resize(200, 200); - QGraphicsScene *scene = new QGraphicsScene; + QGraphicsScene *scene = new QGraphicsScene(&view); view.setScene(scene); view.setSceneRect(-1000, -1000, 2000, 2000); |