diff --git a/Modules/Background/Background.qml b/Modules/Background/Background.qml index d5023fab4..8c01040df 100644 --- a/Modules/Background/Background.qml +++ b/Modules/Background/Background.qml @@ -306,37 +306,20 @@ Variants { duration: transitionType == "stripes" ? Settings.data.wallpaper.transitionDuration * 1.6 : Settings.data.wallpaper.transitionDuration easing.type: Easing.InOutCubic onFinished: { - // Strategy: Keep transitionProgress at 1.0 (showing nextWallpaper) - // until currentWallpaper finishes loading asynchronously + // Assign new image to current BEFORE clearing to prevent flicker const tempSource = nextWallpaper.source - const tempSourceSize = nextWallpaper.sourceSize - - // Enable async loading to prevent blocking - currentWallpaper.asynchronous = true - - // Create one-time connection to wait for async load to complete - const onCurrentLoaded = function () { - if (currentWallpaper.status === Image.Ready || currentWallpaper.status === Image.Error) { - // Disconnect this handler - currentWallpaper.statusChanged.disconnect(onCurrentLoaded) - - // Now it's safe to reset progress and cleanup - transitionProgress = 0.0 - - // Force complete cleanup to free texture memory (~18-25MB per monitor) - Qt.callLater(() => { - nextWallpaper.source = "" - nextWallpaper.sourceSize = undefined - }) - } - } - - // Connect the handler BEFORE changing source - currentWallpaper.statusChanged.connect(onCurrentLoaded) - - // Trigger async load (keeps nextWallpaper visible via progress=1.0) - currentWallpaper.sourceSize = tempSourceSize currentWallpaper.source = tempSource + transitionProgress = 0.0 + + // Now clear nextWallpaper after currentWallpaper has the new source + // Force complete cleanup to free texture memory (~18-25MB per monitor) + Qt.callLater(() => { + nextWallpaper.source = "" + nextWallpaper.sourceSize = undefined + Qt.callLater(() => { + currentWallpaper.asynchronous = true + }) + }) } }