tst_QGraphicsScene: fix memleak in taskQTBUG_5904_crashWithDeviceCoordinateCache()
The test had it the wrong way around: it deleted the QWidget it had added to the QGraphicsScene, which thus becomes the widget's owner, but left the scene itself undeleted, leaking it and all the items (but not the widget ;-)). Create the scene on the stack, so it's deleted by the compiler, and release() the widget into the scene.addWidget() call. Since QScopedPointer::take() is deprecated, port to std::unique_ptr. Amends the start of the public history. Pick-to: 6.9 6.8 6.5 5.15 Change-Id: Idbf821a35a7db802a68923fc09b185ddc3181245 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
This commit is contained in:
parent
3651769d52
commit
fdcf54062c
@ -4401,17 +4401,17 @@ void tst_QGraphicsScene::taskQTBUG_5904_crashWithDeviceCoordinateCache()
|
||||
void tst_QGraphicsScene::taskQT657_paintIntoCacheWithTransparentParts()
|
||||
{
|
||||
// Test using DeviceCoordinateCache and opaque item
|
||||
QScopedPointer<QWidget> w(new QWidget);
|
||||
auto w = std::make_unique<QWidget>();
|
||||
w->setPalette(QColor(0, 0, 255));
|
||||
w->setGeometry(0, 0, 50, 50);
|
||||
|
||||
QGraphicsScene *scene = new QGraphicsScene();
|
||||
QGraphicsScene scene;
|
||||
CustomView view;
|
||||
view.resize(m_testSize);
|
||||
view.setWindowTitle(QTest::currentTestFunction());
|
||||
view.setScene(scene);
|
||||
view.setScene(&scene);
|
||||
|
||||
QGraphicsProxyWidget *proxy = scene->addWidget(w.data());
|
||||
QGraphicsProxyWidget *proxy = scene.addWidget(w.release());
|
||||
proxy->setCacheMode(QGraphicsItem::DeviceCoordinateCache);
|
||||
proxy->setTransform(QTransform().rotate(15), true);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user