Plug memleaks in tst_QWidget

We need to delete the style returned from QStyleFactory::create()
ourselves, so put them into a QScopedPointer.

The alternative would have been to create this once, as a member
of tst_QWidget, but this is the minimal approach that ensures
behavior just as the old code, but without the leak.

Change-Id: I527f1031c57be6f05942f4acc057e7dae1af2571
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Marc Mutz 2016-09-27 10:22:46 +02:00
parent 24314c73ae
commit da2c73ad2b

View File

@ -5135,7 +5135,8 @@ void tst_QWidget::moveChild()
ColorWidget parent(0, Qt::Window | Qt::WindowStaysOnTopHint);
// prevent custom styles
parent.setStyle(QStyleFactory::create(QLatin1String("Windows")));
const QScopedPointer<QStyle> style(QStyleFactory::create(QLatin1String("Windows")));
parent.setStyle(style.data());
ColorWidget child(&parent, Qt::Widget, Qt::blue);
#ifndef Q_OS_WINCE
@ -5184,7 +5185,8 @@ void tst_QWidget::showAndMoveChild()
QSKIP("Wayland: This fails. Figure out why.");
QWidget parent(0, Qt::Window | Qt::WindowStaysOnTopHint);
// prevent custom styles
parent.setStyle(QStyleFactory::create(QLatin1String("Windows")));
const QScopedPointer<QStyle> style(QStyleFactory::create(QLatin1String("Windows")));
parent.setStyle(style.data());
QDesktopWidget desktop;
QRect desktopDimensions = desktop.availableGeometry(&parent);
@ -6680,7 +6682,9 @@ void tst_QWidget::renderWithPainter()
{
QWidget widget(0, Qt::Tool);
// prevent custom styles
widget.setStyle(QStyleFactory::create(QLatin1String("Windows")));
const QScopedPointer<QStyle> style(QStyleFactory::create(QLatin1String("Windows")));
widget.setStyle(style.data());
widget.show();
widget.resize(70, 50);
widget.setAutoFillBackground(true);