summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2016-09-27 10:22:46 +0200
committerMarc Mutz <marc.mutz@kdab.com>2016-09-28 04:56:48 +0000
commitda2c73ad2b84ef9d58a23fa880c05ca33a0053e5 (patch)
tree3a49bf37d7c54d2e71a61452abce89fbd18d0a31 /tests/auto
parent24314c73ae711fb9bd16626c41a09ddeee0a7001 (diff)
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>
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
index 50d7b258bc..e00e575c36 100644
--- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
+++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
@@ -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);