Skip to content

Commit

Permalink
switch from recursion to loop
Browse files Browse the repository at this point in the history
  • Loading branch information
dweymouth committed Jan 27, 2024
1 parent f8d1e90 commit fd7d135
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions theme/icons.go
Original file line number Diff line number Diff line change
Expand Up @@ -1305,18 +1305,20 @@ func safeIconLookup(n fyne.ThemeIconName) fyne.Resource {
// the "base" resource - to avoid recolorizing SVG multiple times
// if we for example have a ThemedResource wrapped in an ErrorThemedResource
func unwrapResource(res fyne.Resource) fyne.Resource {
switch res := res.(type) {
case *DisabledResource:
return unwrapResource(res.source)
case *ErrorThemedResource:
return unwrapResource(res.source)
case *InvertedThemedResource:
return unwrapResource(res.source)
case *PrimaryThemedResource:
return unwrapResource(res.source)
case *ThemedResource:
return unwrapResource(res.source)
default:
return res
for {
switch typedRes := res.(type) {
case *DisabledResource:
res = typedRes.source
case *ErrorThemedResource:
res = typedRes.source
case *InvertedThemedResource:
res = typedRes.source
case *PrimaryThemedResource:
res = typedRes.source
case *ThemedResource:
res = typedRes.source
default:
return res
}
}
}

0 comments on commit fd7d135

Please sign in to comment.