From 4e9eda8e1fc791265d54dcd901d1fd39ae38c5d9 Mon Sep 17 00:00:00 2001 From: Lea Anthony Date: Tue, 19 Apr 2022 17:44:40 +1000 Subject: [PATCH] Fix bug in WindowSet*Theme --- .../frontend/desktop/windows/frontend.go | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/v2/internal/frontend/desktop/windows/frontend.go b/v2/internal/frontend/desktop/windows/frontend.go index 99b45910e..c6f83333f 100644 --- a/v2/internal/frontend/desktop/windows/frontend.go +++ b/v2/internal/frontend/desktop/windows/frontend.go @@ -104,18 +104,22 @@ func (f *Frontend) WindowSetSystemDefaultTheme() { func (f *Frontend) WindowSetLightTheme() { runtime.LockOSThread() - f.mainWindow.frontendOptions.Windows.Theme = windows.Light - f.mainWindow.Invoke(func() { - f.mainWindow.updateTheme() - }) + if f.mainWindow.frontendOptions != nil && f.mainWindow.frontendOptions.Windows != nil { + f.mainWindow.frontendOptions.Windows.Theme = windows.Light + f.mainWindow.Invoke(func() { + f.mainWindow.updateTheme() + }) + } } func (f *Frontend) WindowSetDarkTheme() { runtime.LockOSThread() - f.mainWindow.frontendOptions.Windows.Theme = windows.Dark - f.mainWindow.Invoke(func() { - f.mainWindow.updateTheme() - }) + if f.mainWindow.frontendOptions != nil && f.mainWindow.frontendOptions.Windows != nil { + f.mainWindow.frontendOptions.Windows.Theme = windows.Dark + f.mainWindow.Invoke(func() { + f.mainWindow.updateTheme() + }) + } } func (f *Frontend) Run(ctx context.Context) error {