From 6b910dcbb51f0e03143dd1fc10b17fb396898df9 Mon Sep 17 00:00:00 2001
From: Caroline Chao <caroline.chao@digia.com>
Date: Tue, 9 Apr 2013 08:26:46 +0200
Subject: [PATCH] Tests: Destroy created components at the end of the tests
 functions
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

To ensure the components don't interfere with other functions.

Change-Id: Ie22311471021175d23ae47c9e3a1ec603e803f2c
Reviewed-by: Jan Arve Sæther <jan-arve.saether@digia.com>
---
 tests/auto/controls/data/tst_button.qml       |  5 ++++
 tests/auto/controls/data/tst_checkbox.qml     |  3 +++
 tests/auto/controls/data/tst_combobox.qml     |  9 +++++++
 tests/auto/controls/data/tst_groupbox.qml     |  5 ++++
 tests/auto/controls/data/tst_label.qml        |  1 +
 tests/auto/controls/data/tst_menu.qml         |  3 ++-
 tests/auto/controls/data/tst_menubar.qml      |  1 +
 tests/auto/controls/data/tst_progressbar.qml  | 24 ++++++++++++-------
 tests/auto/controls/data/tst_radiobutton.qml  |  4 ++++
 tests/auto/controls/data/tst_rangemodel.qml   |  4 ++--
 tests/auto/controls/data/tst_rowlayout.qml    |  5 ++++
 tests/auto/controls/data/tst_scrollview.qml   |  2 ++
 tests/auto/controls/data/tst_shortcuts.qml    |  5 ++++
 tests/auto/controls/data/tst_slider.qml       |  7 +++++-
 tests/auto/controls/data/tst_spinbox.qml      | 19 +++++++++++++--
 tests/auto/controls/data/tst_splitview.qml    |  1 +
 tests/auto/controls/data/tst_statusbar.qml    |  1 +
 tests/auto/controls/data/tst_tab.qml          |  1 +
 .../controls/data/tst_tableviewcolumn.qml     |  1 +
 tests/auto/controls/data/tst_tabview.qml      |  4 ++++
 tests/auto/controls/data/tst_textarea.qml     |  2 ++
 tests/auto/controls/data/tst_textfield.qml    | 17 +++++++++++++
 tests/auto/controls/data/tst_toolbar.qml      |  1 +
 tests/auto/controls/data/tst_toolbutton.qml   |  2 ++
 24 files changed, 113 insertions(+), 14 deletions(-)

diff --git a/tests/auto/controls/data/tst_button.qml b/tests/auto/controls/data/tst_button.qml
index a49a45797..2ac5cea2c 100644
--- a/tests/auto/controls/data/tst_button.qml
+++ b/tests/auto/controls/data/tst_button.qml
@@ -56,6 +56,7 @@ TestCase {
     function test_isDefault() {
         var tmp = Qt.createQmlObject('import QtQuick.Controls 1.0; Button {id: button1}', testCase, '');
         compare(tmp.isDefault, false);
+        tmp.destroy()
     }
 
     function test_text() {
@@ -66,6 +67,8 @@ TestCase {
 
         var tmp2 = Qt.createQmlObject('import QtQuick.Controls 1.0; Button {id: button2_2; text: "Hello"}', testCase, '');
         compare(tmp2.text, "Hello");
+        tmp1.destroy()
+        tmp2.destroy()
     }
 
     SignalSpy {
@@ -102,6 +105,7 @@ TestCase {
         clickSpy.target = tmp.button
         tmp.testAction.trigger()
         compare(clickSpy.count, 1)
+        tmp.destroy()
     }
 
     function test_activeFocusOnPress(){
@@ -114,6 +118,7 @@ TestCase {
         verify(!control.activeFocus)
         mouseClick(control, 30, 30)
         verify(control.activeFocus)
+        control.destroy()
     }
 }
 }
diff --git a/tests/auto/controls/data/tst_checkbox.qml b/tests/auto/controls/data/tst_checkbox.qml
index ca12da3cf..1c9162a88 100644
--- a/tests/auto/controls/data/tst_checkbox.qml
+++ b/tests/auto/controls/data/tst_checkbox.qml
@@ -64,6 +64,9 @@ Item {
         }
 
         function cleanup() {
+            if (checkBox !== null) {
+                checkBox.destroy()
+            }
             signalSpy.clear();
         }
 
diff --git a/tests/auto/controls/data/tst_combobox.qml b/tests/auto/controls/data/tst_combobox.qml
index 2cd60278a..7609c51d7 100644
--- a/tests/auto/controls/data/tst_combobox.qml
+++ b/tests/auto/controls/data/tst_combobox.qml
@@ -56,6 +56,11 @@ TestCase {
         model.append({ text: "Coconut", color: "Brown" })
     }
 
+    function cleanup() {
+        if (model !== 0)
+            model.destroy()
+    }
+
     function test_keyupdown() {
         var comboBox = Qt.createQmlObject('import QtQuick.Controls 1.0 ; ComboBox { model: 4 }', testCase, '');
 
@@ -69,6 +74,7 @@ TestCase {
         compare(comboBox.currentIndex, 2)
         keyPress(Qt.Key_Up)
         compare(comboBox.currentIndex, 1)
+        comboBox.destroy()
     }
 
     function test_textrole() {
@@ -79,6 +85,7 @@ TestCase {
         compare(comboBox.currentText, "Banana")
         comboBox.textRole = "color"
         compare(comboBox.currentText, "Yellow")
+        comboBox.destroy()
     }
 
     function test_arraymodel() {
@@ -92,6 +99,7 @@ TestCase {
         comboBox.model = arrayModel
         compare(comboBox.currentIndex, 0)
         compare(comboBox.currentText, "Banana")
+        comboBox.destroy()
     }
 
     function test_arraymodelwithtextrole() {
@@ -108,5 +116,6 @@ TestCase {
         compare(comboBox.currentText, "Banana")
         comboBox.textRole = "color"
         compare(comboBox.currentText, "Yellow")
+        comboBox.destroy()
     }
 }
diff --git a/tests/auto/controls/data/tst_groupbox.qml b/tests/auto/controls/data/tst_groupbox.qml
index 1c62dc501..81a8580e8 100644
--- a/tests/auto/controls/data/tst_groupbox.qml
+++ b/tests/auto/controls/data/tst_groupbox.qml
@@ -73,6 +73,11 @@ TestCase {
         groupBox = groupboxComponent.createObject(testCase)
     }
 
+    function cleanup() {
+        if (groupBox !== 0)
+            groupBox.destroy()
+    }
+
     function test_checkable() {
         compare(groupBox.checkable, false)
         compare(groupBox.child1.enabled, true)
diff --git a/tests/auto/controls/data/tst_label.qml b/tests/auto/controls/data/tst_label.qml
index 2f2591f85..c904d8bed 100644
--- a/tests/auto/controls/data/tst_label.qml
+++ b/tests/auto/controls/data/tst_label.qml
@@ -50,5 +50,6 @@ TestCase {
 
     function test_createLabel() {
         var label = Qt.createQmlObject('import QtQuick.Controls 1.0; Label {}', testCase, '');
+        label.destroy()
     }
 }
diff --git a/tests/auto/controls/data/tst_menu.qml b/tests/auto/controls/data/tst_menu.qml
index 3c109347f..11e92969b 100644
--- a/tests/auto/controls/data/tst_menu.qml
+++ b/tests/auto/controls/data/tst_menu.qml
@@ -82,7 +82,8 @@ TestCase {
     function cleanup() {
         menuSpy.clear()
         menuItemSpy.clear()
-        menu.destroy()
+        if (menu !== 0)
+            menu.destroy()
     }
 
     function test_creation() {
diff --git a/tests/auto/controls/data/tst_menubar.qml b/tests/auto/controls/data/tst_menubar.qml
index 80699d336..aa25917aa 100644
--- a/tests/auto/controls/data/tst_menubar.qml
+++ b/tests/auto/controls/data/tst_menubar.qml
@@ -50,5 +50,6 @@ TestCase {
 
     function test_createMenuBar() {
         var menuBar = Qt.createQmlObject('import QtQuick.Controls 1.0; MenuBar {}', testCase, '');
+        menuBar.destroy()
     }
 }
diff --git a/tests/auto/controls/data/tst_progressbar.qml b/tests/auto/controls/data/tst_progressbar.qml
index b68a592a6..02b96ac36 100644
--- a/tests/auto/controls/data/tst_progressbar.qml
+++ b/tests/auto/controls/data/tst_progressbar.qml
@@ -59,6 +59,7 @@ TestCase {
 
         progressBar.minimumValue = 7
         compare(progressBar.value, 7)
+        progressBar.destroy()
     }
 
     function test_maximumvalue() {
@@ -72,6 +73,7 @@ TestCase {
 
         progressBar.maximumValue = 8
         compare(progressBar.value, 8)
+        progressBar.destroy()
     }
 
     function test_invalidMinMax() {
@@ -94,25 +96,31 @@ TestCase {
 
         var progressBar2 = Qt.createQmlObject('import QtQuick.Controls 1.0; ProgressBar {minimumValue: 10; maximumValue: 4; value: 5}', testCase, '');
         compare(progressBar.value, progressBar.minimumValue)
+        progressBar.destroy()
+        progressBar2.destroy()
     }
 
     function test_initialization_order()
     {
-        var spinbox = Qt.createQmlObject("import QtQuick.Controls 1.0; ProgressBar {maximumValue: 100; value: 50}",
+        var progressBar = Qt.createQmlObject("import QtQuick.Controls 1.0; ProgressBar {maximumValue: 100; value: 50}",
                                          testCase, '')
-        compare(spinbox.value, 50);
+        compare(progressBar.value, 50);
 
-        spinbox = Qt.createQmlObject("import QtQuick.Controls 1.0; ProgressBar {" +
+        var progressBar2 = Qt.createQmlObject("import QtQuick.Controls 1.0; ProgressBar {" +
                                          "value: 50; maximumValue: 100}",
                                          testCase, '')
-        compare(spinbox.value, 50);
+        compare(progressBar2.value, 50);
 
-        spinbox = Qt.createQmlObject("import QtQuick.Controls 1.0; ProgressBar { minimumValue: -50 ; value:-10}",
+        var progressBar3 = Qt.createQmlObject("import QtQuick.Controls 1.0; ProgressBar { minimumValue: -50 ; value:-10}",
                                          testCase, '')
-        compare(spinbox.value, -10);
+        compare(progressBar3.value, -10);
 
-        spinbox = Qt.createQmlObject("import QtQuick.Controls 1.0; ProgressBar { value:-10; minimumValue: -50}",
+        var progressBar4 = Qt.createQmlObject("import QtQuick.Controls 1.0; ProgressBar { value:-10; minimumValue: -50}",
                                          testCase, '')
-        compare(spinbox.value, -10);
+        compare(progressBar4.value, -10);
+        progressBar.destroy()
+        progressBar2.destroy()
+        progressBar3.destroy()
+        progressBar4.destroy()
     }
 }
diff --git a/tests/auto/controls/data/tst_radiobutton.qml b/tests/auto/controls/data/tst_radiobutton.qml
index 4b036d8de..1bdb1c937 100644
--- a/tests/auto/controls/data/tst_radiobutton.qml
+++ b/tests/auto/controls/data/tst_radiobutton.qml
@@ -64,6 +64,9 @@ Item {
         }
 
         function cleanup() {
+            if (radioButton !== null) {
+                radioButton.destroy()
+            }
             signalSpy.clear();
         }
 
@@ -170,6 +173,7 @@ Item {
             compare(signalSpy.count, 1);
             compare(root.radioButton1.checked, true);
             compare(root.radioButton2.checked, false);
+            root.destroy()
         }
 
         function test_activeFocusOnPress(){
diff --git a/tests/auto/controls/data/tst_rangemodel.qml b/tests/auto/controls/data/tst_rangemodel.qml
index 526971400..2ba049263 100644
--- a/tests/auto/controls/data/tst_rangemodel.qml
+++ b/tests/auto/controls/data/tst_rangemodel.qml
@@ -56,8 +56,6 @@ TestCase {
     }
 
     function init() {
-        if (range !== undefined)
-            range.destroy()
         var component = Qt.createComponent("rangemodel/rangemodel.qml");
         compare(component.status, Component.Ready)
         range =  component.createObject(testCase);
@@ -65,6 +63,8 @@ TestCase {
     }
 
     function cleanup() {
+        if (range !== 0)
+            range.destroy()
         spy.clear()
     }
 
diff --git a/tests/auto/controls/data/tst_rowlayout.qml b/tests/auto/controls/data/tst_rowlayout.qml
index e1d9f1bf9..c99d01248 100644
--- a/tests/auto/controls/data/tst_rowlayout.qml
+++ b/tests/auto/controls/data/tst_rowlayout.qml
@@ -87,6 +87,7 @@ Item {
             compare(lay.r1.width, 5);
             compare(lay.r2.x, 5);
             compare(lay.r2.width, 25);
+            lay.destroy()
         }
 
         function test_allExpanding() {
@@ -122,6 +123,7 @@ Item {
             tmp.width = 30
             compare(tmp.r1.width, 10);
             compare(tmp.r2.width, 20);
+            tmp.destroy()
         }
 
         function test_initialNestedLayouts() {
@@ -159,6 +161,7 @@ Item {
             tryCompare(col.row, 'width', 200);
             tryCompare(col.row.r1, 'width', 50);
             tryCompare(col.row.r2, 'width', 150);
+            col.destroy()
         }
 
         function test_implicitSize() {
@@ -191,6 +194,7 @@ Item {
             var row = Qt.createQmlObject(test_layoutStr, container, '');
             compare(row.implicitWidth, 50 + 10 + 40);
             compare(row.implicitHeight, 6);
+            row.destroy()
         }
 
         function test_countGeometryChanges() {
@@ -238,6 +242,7 @@ Item {
             compare(col.row.r1.counter, 1);
             compare(col.row.r2.counter, 1);
             verify(col.row.counter <= 2);
+            col.destroy()
         }
     }
 }
diff --git a/tests/auto/controls/data/tst_scrollview.qml b/tests/auto/controls/data/tst_scrollview.qml
index ee66939e8..a9e73d1ef 100644
--- a/tests/auto/controls/data/tst_scrollview.qml
+++ b/tests/auto/controls/data/tst_scrollview.qml
@@ -81,6 +81,7 @@ TestCase {
 
         scrollView.flickableItem.contentX = 300
         verify(scrollView.flickableItem.contentX === 300, "ContentX not set")
+        scrollView.destroy()
     }
 
     function test_viewport() {
@@ -104,5 +105,6 @@ TestCase {
         scrollView.frameVisible = true
         verify(scrollView.frameVisible, "Frame should be true")
         verify(scrollView.viewport.width < prevViewportWidth, "Viewport should be smaller with frame")
+        scrollView.destroy()
     }
 }
diff --git a/tests/auto/controls/data/tst_shortcuts.qml b/tests/auto/controls/data/tst_shortcuts.qml
index 30c234a0b..c0a668d4c 100644
--- a/tests/auto/controls/data/tst_shortcuts.qml
+++ b/tests/auto/controls/data/tst_shortcuts.qml
@@ -60,6 +60,11 @@ TestCase {
         rootObject.forceActiveFocus();
     }
 
+    function cleanup() {
+        if (rootObject !== null)
+            rootObject.destroy()
+    }
+
     function test_shortcut_data() {
         return [
             { key: Qt.Key_A, modifier: Qt.NoModifier, expected: "a pressed" },
diff --git a/tests/auto/controls/data/tst_slider.qml b/tests/auto/controls/data/tst_slider.qml
index b6f60c558..88171da5a 100644
--- a/tests/auto/controls/data/tst_slider.qml
+++ b/tests/auto/controls/data/tst_slider.qml
@@ -59,6 +59,7 @@ Item {
 
             slider.orientation = Qt.Vertical;
             verify(slider.height > slider.width)
+            slider.destroy()
         }
 
         function test_minimumvalue() {
@@ -69,6 +70,7 @@ Item {
             slider.value = 2
             compare(slider.minimumValue, 5)
             compare(slider.value, 5)
+            slider.destroy()
         }
 
         function test_maximumvalue() {
@@ -79,6 +81,7 @@ Item {
             slider.value = 15
             compare(slider.maximumValue, 10)
             compare(slider.value, 10)
+            slider.destroy()
         }
 
         function test_rightLeftKeyPressed() {
@@ -94,6 +97,7 @@ Item {
             compare(slider.value, 1 + keyStep * 2)
             keyPress(Qt.Key_Left)
             compare(slider.value, 1 + keyStep)
+            slider.destroy()
         }
 
         function test_mouseWheel() {
@@ -136,7 +140,7 @@ Item {
             slider.value = 0
             mouseWheel(slider, 5, 5, 40 * ratio, 0)
             compare(slider.value, slider.maximumValue)
-
+            slider.destroy()
         }
 
         function test_activeFocusOnPress(){
@@ -149,6 +153,7 @@ Item {
             verify(!control.activeFocus)
             mousePress(control, 30, 30)
             verify(control.activeFocus)
+            control.destroy()
         }
     }
 }
diff --git a/tests/auto/controls/data/tst_spinbox.qml b/tests/auto/controls/data/tst_spinbox.qml
index 53615c711..e8b0b5b96 100644
--- a/tests/auto/controls/data/tst_spinbox.qml
+++ b/tests/auto/controls/data/tst_spinbox.qml
@@ -68,6 +68,7 @@ Item {
             compare(spinbox.value, spinbox.maximumValue)
             keyPress(Qt.Key_Up)
             compare(spinbox.value, spinbox.maximumValue)
+            spinbox.destroy()
         }
 
         function test_decrement_key() {
@@ -83,6 +84,7 @@ Item {
             compare(spinbox.value, spinbox.minimumValue)
             keyPress(Qt.Key_Down)
             compare(spinbox.value, spinbox.minimumValue)
+            spinbox.destroy()
         }
 
         function test_increment_mouse() {
@@ -98,6 +100,7 @@ Item {
             compare(spinbox.value, spinbox.maximumValue)
             mouseClick(spinbox, upCoord.x, upCoord.y, Qt.LeftButton)
             compare(spinbox.value, spinbox.maximumValue)
+            spinbox.destroy()
         }
 
         function test_decrement_mouse() {
@@ -113,6 +116,7 @@ Item {
             compare(spinbox.value, spinbox.minimumValue)
             mouseClick(spinbox, downCoord.x, downCoord.y, Qt.LeftButton)
             compare(spinbox.value, spinbox.minimumValue)
+            spinbox.destroy()
         }
 
         function test_move_mouse() {
@@ -137,6 +141,7 @@ Item {
             compare(spinbox.__containsMouse, false)
             compare(spinbox.__upHovered, false)
             compare(spinbox.__downHovered, false)
+            spinbox.destroy()
         }
 
         function test_maxvalue() {
@@ -153,6 +158,7 @@ Item {
             spinbox.minimumValue = 0;
             spinbox.value = 10;
             compare(spinbox.value, 5)
+            spinbox.destroy()
         }
 
         function test_minvalue() {
@@ -169,6 +175,7 @@ Item {
             spinbox.minimumValue = 6;
             spinbox.value = 0;
             compare(spinbox.value, 6)
+            spinbox.destroy()
         }
 
         function test_nanvalue() {
@@ -178,6 +185,7 @@ Item {
             spinbox.value = NaN
             compare(spinbox.value, NaN)
             compare(spinbox.__text, "nan")
+            spinbox.destroy()
         }
 
         function test_decimals() {
@@ -204,6 +212,7 @@ Item {
             spinbox.decimals = 6
             compare(spinbox.value, 1.00001)
             compare(spinbox.__text, "1.000010")
+            spinbox.destroy()
         }
 
         function test_stepsize()
@@ -222,6 +231,7 @@ Item {
             var previousValue = spinbox.value
             keyPress(Qt.Key_Down)
             compare(spinbox.value, previousValue - spinbox.stepSize)
+            spinbox.destroy()
         }
 
         function test_negativeStepSize()
@@ -253,6 +263,7 @@ Item {
             spinbox.value = 49
             keyPress(Qt.Key_Down)
             compare(spinbox.value, spinbox.maximumValue)
+            spinbox.destroy()
         }
 
         function test_initialization_order()
@@ -262,9 +273,11 @@ Item {
                                              container, '')
             compare(spinbox.value, 1000);
 
-            spinbox = Qt.createQmlObject('import QtQuick.Controls 1.0; SpinBox { minimumValue: -1000 ; value:-1000}',
+            var spinbox2 = Qt.createQmlObject('import QtQuick.Controls 1.0; SpinBox { minimumValue: -1000 ; value:-1000}',
                                              container, '')
-            compare(spinbox.value, -1000);
+            compare(spinbox2.value, -1000);
+            spinbox.destroy()
+            spinbox2.destroy()
         }
 
         function test_activeFocusOnPress(){
@@ -277,6 +290,7 @@ Item {
             verify(!spinbox.activeFocus)
             mouseClick(spinbox, 30, 30)
             verify(spinbox.activeFocus)
+            spinbox.destroy()
         }
 
         function test_ImplicitSize() // Verify if we correctly grow and shrink depending on contents
@@ -312,6 +326,7 @@ Item {
             oldSize = spinbox.implicitWidth
             spinbox.decimals = 4
             verify(oldSize < spinbox.implicitWidth)
+            spinbox.destroy()
         }
 
         function setCoordinates(item)
diff --git a/tests/auto/controls/data/tst_splitview.qml b/tests/auto/controls/data/tst_splitview.qml
index fee25f3e0..ebbcef459 100644
--- a/tests/auto/controls/data/tst_splitview.qml
+++ b/tests/auto/controls/data/tst_splitview.qml
@@ -61,6 +61,7 @@ TestCase {
         verify (view !== null, "splitview created is null")
         verify (view.orientation === Qt.Horizontal)
         verify (view.__items.length === 2)
+        view.destroy()
     }
 
 }
diff --git a/tests/auto/controls/data/tst_statusbar.qml b/tests/auto/controls/data/tst_statusbar.qml
index f85195bd9..df0a768c5 100644
--- a/tests/auto/controls/data/tst_statusbar.qml
+++ b/tests/auto/controls/data/tst_statusbar.qml
@@ -50,6 +50,7 @@ TestCase {
 
     function test_createStatusBar() {
         var statusBar = Qt.createQmlObject('import QtQuick.Controls 1.0; StatusBar {}', testCase, '');
+        statusBar.destroy()
     }
 }
 
diff --git a/tests/auto/controls/data/tst_tab.qml b/tests/auto/controls/data/tst_tab.qml
index d839ff41b..939ede7e3 100644
--- a/tests/auto/controls/data/tst_tab.qml
+++ b/tests/auto/controls/data/tst_tab.qml
@@ -50,6 +50,7 @@ TestCase {
 
     function test_createTab() {
         var tab = Qt.createQmlObject('import QtQuick.Controls 1.0; Tab {}', testCase, '');
+        tab.destroy()
     }
 }
 
diff --git a/tests/auto/controls/data/tst_tableviewcolumn.qml b/tests/auto/controls/data/tst_tableviewcolumn.qml
index 37468af48..16eadf538 100644
--- a/tests/auto/controls/data/tst_tableviewcolumn.qml
+++ b/tests/auto/controls/data/tst_tableviewcolumn.qml
@@ -50,6 +50,7 @@ TestCase {
 
     function test_createTableViewColumn() {
         var tableViewColumn = Qt.createQmlObject('import QtQuick.Controls 1.0; TableViewColumn {}', testCase, '');
+        tableViewColumn.destroy()
     }
 }
 
diff --git a/tests/auto/controls/data/tst_tabview.qml b/tests/auto/controls/data/tst_tabview.qml
index 7bf9a00ff..897565f19 100644
--- a/tests/auto/controls/data/tst_tabview.qml
+++ b/tests/auto/controls/data/tst_tabview.qml
@@ -50,11 +50,13 @@ TestCase {
 
     function test_createTabView() {
         var tabView = Qt.createQmlObject('import QtQuick.Controls 1.0; TabView {}', testCase, '');
+        tabView.destroy()
     }
 
     function test_repeater() {
         var tabView = Qt.createQmlObject('import QtQuick 2.1; import QtQuick.Controls 1.0; TabView { Repeater { model: 3; Tab { } } }', testCase, '');
         compare(tabView.count, 3)
+        tabView.destroy()
     }
 
     Component {
@@ -71,6 +73,7 @@ TestCase {
         verify(tabView.tabAt(2).item == undefined)
         tabView.currentIndex = 1
         verify(tabView.tabAt(2).item !== undefined)
+        tabView.destroy()
     }
 
 
@@ -114,6 +117,7 @@ TestCase {
 
         tabView.removeTab(0)
         compare(tabView.count, 0)
+        tabView.destroy()
     }
 }
 
diff --git a/tests/auto/controls/data/tst_textarea.qml b/tests/auto/controls/data/tst_textarea.qml
index 945b8aa48..0756e4c24 100644
--- a/tests/auto/controls/data/tst_textarea.qml
+++ b/tests/auto/controls/data/tst_textarea.qml
@@ -63,6 +63,7 @@ TestCase {
 
         textarea.append("name");
         compare(textarea.text, "my\nname")
+        textarea.destroy()
     }
 
     function test_activeFocusOnPress(){
@@ -75,6 +76,7 @@ TestCase {
         verify(!control.activeFocus)
         mouseClick(control, 30, 30)
         verify(control.activeFocus)
+        control.destroy()
     }
 }
 }
diff --git a/tests/auto/controls/data/tst_textfield.qml b/tests/auto/controls/data/tst_textfield.qml
index ed2d5401a..14a18b0e5 100644
--- a/tests/auto/controls/data/tst_textfield.qml
+++ b/tests/auto/controls/data/tst_textfield.qml
@@ -58,6 +58,7 @@ TestCase {
         compare(textfield.text, "")
         textfield.text = "hello world"
         compare(textfield.text, "hello world")
+        textfield.destroy()
     }
 
     function test_maximumLength() {
@@ -66,6 +67,7 @@ TestCase {
         textfield.text = "hello world"
         textfield.maximumLength = 5
         compare(textfield.text, "hello")
+        textfield.destroy()
     }
 
     function test_length() {
@@ -73,6 +75,7 @@ TestCase {
 
         textfield.text = "hello world"
         compare(textfield.length, 11)
+        textfield.destroy()
     }
 
 
@@ -85,6 +88,7 @@ TestCase {
         textfield.readOnly = true
         keyPress(Qt.Key_9)
         compare(textfield.text,"hello")
+        textfield.destroy()
     }
 
     function test_inputMask() {
@@ -123,6 +127,7 @@ TestCase {
         keyPress(Qt.Key_3)
         compare(textfield.acceptableInput, false)
         compare(textfield.text,"-93")
+        textfield.destroy()
     }
 
     function test_validator() {
@@ -136,6 +141,7 @@ TestCase {
 
         textfield.text = "bluee"
         compare(textfield.acceptableInput, false)
+        textfield.destroy()
     }
 
     function test_selectAll() {
@@ -147,6 +153,7 @@ TestCase {
 
         keyPress(Qt.Key_Delete)
         compare(textfield.text, "")
+        textfield.destroy()
     }
 
     function test_select() {
@@ -161,6 +168,7 @@ TestCase {
         compare(textfield.selectedText, "is ")
         keyPress(Qt.Key_Delete)
         compare(textfield.text, "this my text")
+        textfield.destroy()
     }
 
     function test_cursorPosition() {
@@ -176,6 +184,7 @@ TestCase {
         textfield.cursorPosition = 1
         keyPress(Qt.Key_A)
         compare(textfield.text, "may")
+        textfield.destroy()
     }
 
     function test_selectWord() {
@@ -188,6 +197,7 @@ TestCase {
         textfield.cursorPosition = 2
         textfield.selectWord();
         compare(textfield.selectedText, "this")
+        textfield.destroy()
     }
 
     function copy() {
@@ -195,6 +205,7 @@ TestCase {
         textfield.text = "this is my text"
         textfield.select(0, 5)
         textfield.copy()
+        textfield.destroy()
     }
 
     function test_getText() {
@@ -204,6 +215,7 @@ TestCase {
         textfield.text = "this is my text"
         var gettext = textfield.getText(0, 4)
         compare(gettext, "this")
+        textfield.destroy()
     }
 
     function test_insert() {
@@ -213,6 +225,7 @@ TestCase {
         textfield.text = "this is my text"
         textfield.insert(8, "not ")
         compare(textfield.text, "this is not my text")
+        textfield.destroy()
     }
 
     function test_deselect() {
@@ -223,6 +236,7 @@ TestCase {
         textfield.selectWord();
         textfield.deselect()
         compare(textfield.selectedText, "")
+        textfield.destroy()
     }
 
     function test_undo() {
@@ -234,6 +248,7 @@ TestCase {
         compare(textfield.canUndo, true)
         textfield.undo()
         compare(textfield.text, "this is my text")
+        textfield.destroy()
     }
 
     function test_redo() {
@@ -246,6 +261,7 @@ TestCase {
         compare(textfield.canRedo, true)
         textfield.redo()
         compare(textfield.text, "this is not my text")
+        textfield.destroy()
     }
 
     function test_activeFocusOnPress(){
@@ -258,6 +274,7 @@ TestCase {
         verify(!control.activeFocus)
         mouseClick(control, 30, 30)
         verify(control.activeFocus)
+        control.destroy()
     }
 }
 }
diff --git a/tests/auto/controls/data/tst_toolbar.qml b/tests/auto/controls/data/tst_toolbar.qml
index 68765b0d3..75cacf93b 100644
--- a/tests/auto/controls/data/tst_toolbar.qml
+++ b/tests/auto/controls/data/tst_toolbar.qml
@@ -50,6 +50,7 @@ TestCase {
 
     function test_createToolBar() {
         var toolBar = Qt.createQmlObject('import QtQuick.Controls 1.0; ToolBar {}', testCase, '');
+        toolBar.destroy()
     }
 }
 
diff --git a/tests/auto/controls/data/tst_toolbutton.qml b/tests/auto/controls/data/tst_toolbutton.qml
index 8400b552f..af33cd5a6 100644
--- a/tests/auto/controls/data/tst_toolbutton.qml
+++ b/tests/auto/controls/data/tst_toolbutton.qml
@@ -55,6 +55,7 @@ TestCase {
 
     function test_createToolButton() {
         var toolButton = Qt.createQmlObject('import QtQuick.Controls 1.0; ToolButton {}', testCase, '');
+        toolButton.destroy()
     }
 
     function test_activeFocusOnPress(){
@@ -67,6 +68,7 @@ TestCase {
         verify(!control.activeFocus)
         mouseClick(control, 30, 30)
         verify(control.activeFocus)
+        control.destroy()
     }
 }
 }
-- 
GitLab