diff --git a/autotests/tst_pagerow.qml b/autotests/tst_pagerow.qml --- a/autotests/tst_pagerow.qml +++ b/autotests/tst_pagerow.qml @@ -105,25 +105,35 @@ compare(mainWindow.pageStack.depth, 1) } - readonly property int destructions: 0 + property int destructions: 0 Component { id: destroyedPage Kirigami.Page { + id: page Rectangle { anchors.fill: parent color: "blue" - Component.onDestruction: testCase.destructions++ + Component.onDestruction: { + console.log("ko", page) + testCase.destructions++ + } } } } - function test_cleanup() { + SignalSpy { + id: spyDestructions + target: testCase + signalName: "destructionsChanged" + } + function test_clearPages() { mainWindow.pageStack.push(destroyedPage) mainWindow.pageStack.push(destroyedPage) mainWindow.pageStack.push(destroyedPage) compare(mainWindow.pageStack.depth, 3) mainWindow.pageStack.clear() compare(mainWindow.pageStack.depth, 0) + console.log(spyDestructions.wait()) compare(testCase.destructions, 3) } } diff --git a/src/controls/PageRow.qml b/src/controls/PageRow.qml --- a/src/controls/PageRow.qml +++ b/src/controls/PageRow.qml @@ -250,6 +250,9 @@ //is destroy just an async deleteLater() that isn't executed immediately or it actually leaks? pagesLogic.remove(id); item.parent = root; + if (item.page.parent==item) { + item.page.destroy(1) + } item.destroy(); } function clearPages () {