Skip to content

Commit

Permalink
Better error handling for background load errors
Browse files Browse the repository at this point in the history
  • Loading branch information
andydotxyz committed Mar 18, 2024
1 parent 7bc2c75 commit 2133ce0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion internal/ui/background.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func (b *background) loadModules() []fyne.CanvasObject {

func (b *background) updateBackground(path string) {
_, err := os.Stat(path)
if path == "" || os.IsNotExist(err) {
if path == "" || err != nil {
set := fyne.CurrentApp().Settings()
src := &builtin.Builtin{}
b.wallpaper.Objects[0] = src.Load(set.Theme(), set.ThemeVariant())
Expand Down
15 changes: 8 additions & 7 deletions internal/x11/wm/desk.go
Original file line number Diff line number Diff line change
Expand Up @@ -850,14 +850,15 @@ func (x *x11WM) updatedBackgroundImage(w, h int) image.Image {
file, err := os.Open(path)
if err != nil {
fyne.LogError("Failed to open background image", err)
} else {
img, _, err := image.Decode(file)
if err != nil {
fyne.LogError("Failed to read background image", err)
} else {
_ = file.Close()
return resize.Resize(uint(w), uint(h), img, resize.Lanczos3)
}
}
img, _, err := image.Decode(file)
if err != nil {
fyne.LogError("Failed to read background image", err)
}
_ = file.Close()

return resize.Resize(uint(w), uint(h), img, resize.Lanczos3)
}

set := fyne.CurrentApp().Settings()
Expand Down

0 comments on commit 2133ce0

Please sign in to comment.