controlcenter: lazyload cleanup confirmed
This commit is contained in:
parent
ff03760675
commit
9bd3d57ff5
1 changed files with 52 additions and 1 deletions
|
|
@ -1891,6 +1891,20 @@ RowLayout {
|
||||||
console.error("[AppearancePane] Wallpaper loader error!");
|
console.error("[AppearancePane] Wallpaper loader error!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Stop lazy loading when loader becomes inactive
|
||||||
|
onActiveChanged: {
|
||||||
|
if (!active && wallpaperLoader.item) {
|
||||||
|
const container = wallpaperLoader.item;
|
||||||
|
// Access timer through wallpaperGrid
|
||||||
|
if (container && container.wallpaperGrid) {
|
||||||
|
if (container.wallpaperGrid.scrollCheckTimer) {
|
||||||
|
container.wallpaperGrid.scrollCheckTimer.stop();
|
||||||
|
}
|
||||||
|
container.wallpaperGrid._expansionInProgress = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
sourceComponent: Item {
|
sourceComponent: Item {
|
||||||
id: wallpaperGridContainer
|
id: wallpaperGridContainer
|
||||||
|
|
@ -1908,6 +1922,16 @@ RowLayout {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Cleanup when component is destroyed
|
||||||
|
Component.onDestruction: {
|
||||||
|
if (wallpaperGrid) {
|
||||||
|
if (wallpaperGrid.scrollCheckTimer) {
|
||||||
|
wallpaperGrid.scrollCheckTimer.stop();
|
||||||
|
}
|
||||||
|
wallpaperGrid._expansionInProgress = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Lazy loading model: loads one image at a time, only when touching bottom
|
// Lazy loading model: loads one image at a time, only when touching bottom
|
||||||
// This prevents GridView from creating all delegates at once
|
// This prevents GridView from creating all delegates at once
|
||||||
QtObject {
|
QtObject {
|
||||||
|
|
@ -2030,6 +2054,19 @@ RowLayout {
|
||||||
target: root.session
|
target: root.session
|
||||||
function onActiveIndexChanged(): void {
|
function onActiveIndexChanged(): void {
|
||||||
const isActive = root.session.activeIndex === 3;
|
const isActive = root.session.activeIndex === 3;
|
||||||
|
|
||||||
|
// Stop lazy loading when switching away from appearance pane
|
||||||
|
if (!isActive) {
|
||||||
|
if (scrollCheckTimer) {
|
||||||
|
scrollCheckTimer.stop();
|
||||||
|
}
|
||||||
|
if (wallpaperGrid) {
|
||||||
|
wallpaperGrid._expansionInProgress = false;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Initialize if needed when switching to appearance pane
|
||||||
if (isActive && width > 0 && !lazyModel.sourceList && parent && parent.visible && Wallpapers.list) {
|
if (isActive && width > 0 && !lazyModel.sourceList && parent && parent.visible && Wallpapers.list) {
|
||||||
lazyModel.initialize(Wallpapers.list);
|
lazyModel.initialize(Wallpapers.list);
|
||||||
wallpaperListModel.clear();
|
wallpaperListModel.clear();
|
||||||
|
|
@ -2062,6 +2099,10 @@ RowLayout {
|
||||||
Connections {
|
Connections {
|
||||||
target: wallpaperGridContainer.parentFlickable
|
target: wallpaperGridContainer.parentFlickable
|
||||||
function onContentYChanged(): void {
|
function onContentYChanged(): void {
|
||||||
|
// Don't process scroll events if appearance pane is not active
|
||||||
|
const isActive = root.session.activeIndex === 3;
|
||||||
|
if (!isActive) return;
|
||||||
|
|
||||||
if (!lazyModel || !lazyModel.sourceList || lazyModel.loadedCount >= lazyModel.totalCount || wallpaperGrid._expansionInProgress) {
|
if (!lazyModel || !lazyModel.sourceList || lazyModel.loadedCount >= lazyModel.totalCount || wallpaperGrid._expansionInProgress) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -2107,9 +2148,19 @@ RowLayout {
|
||||||
Timer {
|
Timer {
|
||||||
id: scrollCheckTimer
|
id: scrollCheckTimer
|
||||||
interval: 100
|
interval: 100
|
||||||
running: lazyModel && lazyModel.sourceList && lazyModel.loadedCount < lazyModel.totalCount
|
running: {
|
||||||
|
const isActive = root.session.activeIndex === 3;
|
||||||
|
return isActive && lazyModel && lazyModel.sourceList && lazyModel.loadedCount < lazyModel.totalCount;
|
||||||
|
}
|
||||||
repeat: true
|
repeat: true
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
|
// Double-check that appearance pane is still active
|
||||||
|
const isActive = root.session.activeIndex === 3;
|
||||||
|
if (!isActive) {
|
||||||
|
stop();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const flickable = wallpaperGridContainer.parentFlickable;
|
const flickable = wallpaperGridContainer.parentFlickable;
|
||||||
if (!flickable || !lazyModel || !lazyModel.sourceList) return;
|
if (!flickable || !lazyModel || !lazyModel.sourceList) return;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue