testbench: ensure that assets are reloaded properly

Clear the view's model, otherwise it will keep the old items around
with the old assets, even after clearing the pixmap cache.

Change-Id: If27400c0940448b337d1a4cd3ce0d6c99e2d9ddd
Reviewed-by: J-P Nurmi <jpnurmi@qt.io>
This commit is contained in:
Mitch Curtis 2017-09-26 11:30:46 +02:00
parent e57d85368f
commit 85341c7c98
2 changed files with 22 additions and 6 deletions

View File

@ -515,6 +515,7 @@ void AssetFixer::clearImageCache()
// We can't seem to disable image caching on a per-Image basis (by the time the QQuickImages
// are available, the cache has already been filled), so we call this instead.
qCDebug(lcAssetFixer) << "Calling QQuickWindow::releaseResources() to clear pixmap cache";
window->releaseResources();
}

View File

@ -266,6 +266,10 @@ ApplicationWindow {
function reloadAssets() {
console.log(brief, "Reloading assets...")
// Clear the model, otherwise ListView will keep the old items around
// with the old assets, even after clearing the pixmap cache
listView.resettingModel = true
listView.model = null
window.Imagine.path = ""
assetReloadNextFrameTimer.start()
}
@ -297,9 +301,14 @@ ApplicationWindow {
window.Imagine.path = Qt.binding(function() {
return settings.useCustomImaginePath && settings.imaginePath.length > 0 ? settings.imaginePath : undefined
})
infoToolTip.text = "Reloaded assets"
infoToolTip.timeout = 1500
infoToolTip.open()
listView.model = controlFolderListModel
listView.resettingModel = false
console.log(brief, "... reloaded assets.")
}
}
@ -378,18 +387,24 @@ ApplicationWindow {
return paletteSettings.useCustomPalette && paletteColorString.length > 0 ? paletteColorString : undefined
}
FolderListModel {
id: controlFolderListModel
folder: "qrc:/controls"
showDirs: false
nameFilters: searchTextField.text.length > 0 ? ["*" + searchTextField.text + "*.qml"] : []
}
ListView {
id: listView
anchors.fill: parent
spacing: 30
visible: !busyIndicatorRow.visible
visible: !busyIndicatorRow.visible && !resettingModel
property bool resettingModel: false
ScrollBar.vertical: ScrollBar {}
model: FolderListModel {
folder: "qrc:/controls"
showDirs: false
nameFilters: searchTextField.text.length > 0 ? ["*" + searchTextField.text + "*.qml"] : []
}
model: controlFolderListModel
delegate: ColumnLayout {
id: rootDelegate
width: parent.width