From b8ce924ad83cb679795b3ad0a667cb50d9705068 Mon Sep 17 00:00:00 2001 From: AmirHossein Abdolmotallebi Date: Mon, 6 Jan 2025 04:58:32 +0330 Subject: [PATCH] fix crash when changing theme in linux (#348) --- .../desktop/window/custom/CustomWindow.kt | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/desktop/app-utils/src/main/kotlin/com/abdownloadmanager/desktop/window/custom/CustomWindow.kt b/desktop/app-utils/src/main/kotlin/com/abdownloadmanager/desktop/window/custom/CustomWindow.kt index b299896..8460817 100644 --- a/desktop/app-utils/src/main/kotlin/com/abdownloadmanager/desktop/window/custom/CustomWindow.kt +++ b/desktop/app-utils/src/main/kotlin/com/abdownloadmanager/desktop/window/custom/CustomWindow.kt @@ -39,6 +39,8 @@ import ir.amirab.util.customwindow.HitSpots import ir.amirab.util.customwindow.util.CustomWindowDecorationAccessing import ir.amirab.util.customwindow.windowFrameItem import ir.amirab.util.ifThen +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.withContext // a window frame which totally rendered with compose @@ -318,11 +320,13 @@ fun CustomWindow( val isLight = myColors.isLight val background = myColors.background LaunchedEffect(background) { - //I set window background fix window edge flickering on window resize - window.background = background.takeOrElse { - if (isLight) Color.White - else Color.Black - }.toWindowColorType() + withContext(Dispatchers.Main) { + //I set window background fix window edge flickering on window resize + window.background = background.takeOrElse { + if (isLight) Color.White + else Color.Black + }.toWindowColorType() + } } UiScaledContent { CompositionLocalProvider(