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>bb10
parent
6d6074e04f
commit
f6498fd677
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue