Skip to content

Commit

Permalink
Merge pull request fyne-io#1125 from Jacalz/staticcheck-fixes
Browse files Browse the repository at this point in the history
Fix a lot of recommendations from staticcheck
  • Loading branch information
Jacalz committed Jun 25, 2020
2 parents 33c346c + 6acbcd1 commit 3d6571a
Show file tree
Hide file tree
Showing 27 changed files with 30 additions and 66 deletions.
3 changes: 0 additions & 3 deletions app/app_test.go
Expand Up @@ -46,8 +46,5 @@ func TestFyneApp_OpenURL(t *testing.T) {
return // when running in CI mode we don't actually open URLs...
}

// wait for the command to execute then check the URL we loaded
for opened == "" {
}
assert.Equal(t, urlStr, opened)
}
6 changes: 3 additions & 3 deletions app/settings_desktop_test.go
Expand Up @@ -37,7 +37,7 @@ func TestWatchSettings(t *testing.T) {
settings.fileChanged() // simulate the settings file changing

select {
case _ = <-listener:
case <-listener:
case <-time.After(100 * time.Millisecond):
t.Error("Settings listener was not called")
}
Expand All @@ -58,7 +58,7 @@ func TestWatchFile(t *testing.T) {
file.Close()

select {
case _ = <-called:
case <-called:
case <-time.After(100 * time.Millisecond):
t.Error("File watcher callback was not called")
}
Expand All @@ -84,7 +84,7 @@ func TestFileWatcher_FileDeleted(t *testing.T) {
f, _ = os.Create(path)

select {
case _ = <-called:
case <-called:
case <-time.After(100 * time.Millisecond):
t.Error("File watcher callback was not called")
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/fyne/vendor.go
Expand Up @@ -65,15 +65,15 @@ func cacheModPath(r io.Reader) (string, string, error) {
}

if err := scanner.Err(); err != nil {
return "", "", fmt.Errorf("Cannot read content: %v", err)
return "", "", fmt.Errorf("cannot read content: %v", err)
}
return "", "", nil
}

func recursiveCopy(src, target string) error {
files, err := ioutil.ReadDir(src)
if err != nil {
return fmt.Errorf("Cannot read dir %s: %v", src, err)
return fmt.Errorf("cannot read dir %s: %v", src, err)
}
err = ensureDir(target)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion cmd/fyne/version.go
Expand Up @@ -43,7 +43,7 @@ func (v *version) run(args []string) {
func (v *version) get() (string, error) {
info, ok := debug.ReadBuildInfo()
if !ok {
return "", fmt.Errorf("Could not retrieve version information. Please ensure module support is activated and build again")
return "", fmt.Errorf("could not retrieve version information (ensure module support is activated and build again)")
}
return info.Main.Version, nil
}
2 changes: 1 addition & 1 deletion cmd/fyne_demo/screens/window.go
Expand Up @@ -100,7 +100,7 @@ func loadDialogGroup(win fyne.Window) *widget.Group {
dialog.ShowInformation("Information", "You should know this thing...", win)
}),
widget.NewButton("Error", func() {
err := errors.New("A dummy error message")
err := errors.New("a dummy error message")
dialog.ShowError(err, win)
}),
widget.NewButton("Confirm", func() {
Expand Down
2 changes: 1 addition & 1 deletion cmd/fyne_settings/data/gen.go
Expand Up @@ -38,7 +38,7 @@ func openFile(filename string) *os.File {
return nil
}

_, err = f.WriteString("// **** THIS FILE IS AUTO-GENERATED, PLEASE DO NOT EDIT IT **** //\n\npackage main\n\nimport \"fyne.io/fyne\"\n\n")
_, err = f.WriteString("// **** THIS FILE IS AUTO-GENERATED, PLEASE DO NOT EDIT IT **** //\n\npackage settings\n\nimport \"fyne.io/fyne\"\n\n")
if err != nil {
fyne.LogError("Unable to write file "+filename, err)
return nil
Expand Down
2 changes: 1 addition & 1 deletion cmd/fyne_settings/data/language.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion cmd/fyne_settings/settings/bundled.go
Expand Up @@ -19,4 +19,4 @@ var appearanceIcon = &fyne.StaticResource{
var languageIcon = &fyne.StaticResource{
StaticName: "language.svg",
StaticContent: []byte{
60, 115, 118, 103, 32, 120, 109, 108, 110, 115, 61, 34, 104, 116, 116, 112, 58, 47, 47, 119, 119, 119, 46, 119, 51, 46, 111, 114, 103, 47, 50, 48, 48, 48, 47, 115, 118, 103, 34, 32, 119, 105, 100, 116, 104, 61, 34, 50, 52, 34, 32, 104, 101, 105, 103, 104, 116, 61, 34, 50, 52, 34, 32, 118, 105, 101, 119, 66, 111, 120, 61, 34, 48, 32, 48, 32, 50, 52, 32, 50, 52, 34, 62, 60, 112, 97, 116, 104, 32, 100, 61, 34, 77, 48, 32, 48, 104, 50, 52, 118, 50, 52, 72, 48, 122, 34, 32, 102, 105, 108, 108, 61, 34, 110, 111, 110, 101, 34, 47, 62, 60, 112, 97, 116, 104, 32, 100, 61, 34, 77, 49, 49, 46, 57, 57, 32, 50, 67, 54, 46, 52, 55, 32, 50, 32, 50, 32, 54, 46, 52, 56, 32, 50, 32, 49, 50, 115, 52, 46, 52, 55, 32, 49, 48, 32, 57, 46, 57, 57, 32, 49, 48, 67, 49, 55, 46, 53, 50, 32, 50, 50, 32, 50, 50, 32, 49, 55, 46, 53, 50, 32, 50, 50, 32, 49, 50, 83, 49, 55, 46, 53, 50, 32, 50, 32, 49, 49, 46, 57, 57, 32, 50, 122, 109, 54, 46, 57, 51, 32, 54, 104, 45, 50, 46, 57, 53, 99, 45, 46, 51, 50, 45, 49, 46, 50, 53, 45, 46, 55, 56, 45, 50, 46, 52, 53, 45, 49, 46, 51, 56, 45, 51, 46, 53, 54, 32, 49, 46, 56, 52, 46, 54, 51, 32, 51, 46, 51, 55, 32, 49, 46, 57, 49, 32, 52, 46, 51, 51, 32, 51, 46, 53, 54, 122, 77, 49, 50, 32, 52, 46, 48, 52, 99, 46, 56, 51, 32, 49, 46, 50, 32, 49, 46, 52, 56, 32, 50, 46, 53, 51, 32, 49, 46, 57, 49, 32, 51, 46, 57, 54, 104, 45, 51, 46, 56, 50, 99, 46, 52, 51, 45, 49, 46, 52, 51, 32, 49, 46, 48, 56, 45, 50, 46, 55, 54, 32, 49, 46, 57, 49, 45, 51, 46, 57, 54, 122, 77, 52, 46, 50, 54, 32, 49, 52, 67, 52, 46, 49, 32, 49, 51, 46, 51, 54, 32, 52, 32, 49, 50, 46, 54, 57, 32, 52, 32, 49, 50, 115, 46, 49, 45, 49, 46, 51, 54, 46, 50, 54, 45, 50, 104, 51, 46, 51, 56, 99, 45, 46, 48, 56, 46, 54, 54, 45, 46, 49, 52, 32, 49, 46, 51, 50, 45, 46, 49, 52, 32, 50, 32, 48, 32, 46, 54, 56, 46, 48, 54, 32, 49, 46, 51, 52, 46, 49, 52, 32, 50, 72, 52, 46, 50, 54, 122, 109, 46, 56, 50, 32, 50, 104, 50, 46, 57, 53, 99, 46, 51, 50, 32, 49, 46, 50, 53, 46, 55, 56, 32, 50, 46, 52, 53, 32, 49, 46, 51, 56, 32, 51, 46, 53, 54, 45, 49, 46, 56, 52, 45, 46, 54, 51, 45, 51, 46, 51, 55, 45, 49, 46, 57, 45, 52, 46, 51, 51, 45, 51, 46, 53, 54, 122, 109, 50, 46, 57, 53, 45, 56, 72, 53, 46, 48, 56, 99, 46, 57, 54, 45, 49, 46, 54, 54, 32, 50, 46, 52, 57, 45, 50, 46, 57, 51, 32, 52, 46, 51, 51, 45, 51, 46, 53, 54, 67, 56, 46, 56, 49, 32, 53, 46, 53, 53, 32, 56, 46, 51, 53, 32, 54, 46, 55, 53, 32, 56, 46, 48, 51, 32, 56, 122, 77, 49, 50, 32, 49, 57, 46, 57, 54, 99, 45, 46, 56, 51, 45, 49, 46, 50, 45, 49, 46, 52, 56, 45, 50, 46, 53, 51, 45, 49, 46, 57, 49, 45, 51, 46, 57, 54, 104, 51, 46, 56, 50, 99, 45, 46, 52, 51, 32, 49, 46, 52, 51, 45, 49, 46, 48, 56, 32, 50, 46, 55, 54, 45, 49, 46, 57, 49, 32, 51, 46, 57, 54, 122, 77, 49, 52, 46, 51, 52, 32, 49, 52, 72, 57, 46, 54, 54, 99, 45, 46, 48, 57, 45, 46, 54, 54, 45, 46, 49, 54, 45, 49, 46, 51, 50, 45, 46, 49, 54, 45, 50, 32, 48, 45, 46, 54, 56, 46, 48, 55, 45, 49, 46, 51, 53, 46, 49, 54, 45, 50, 104, 52, 46, 54, 56, 99, 46, 48, 57, 46, 54, 53, 46, 49, 54, 32, 49, 46, 51, 50, 46, 49, 54, 32, 50, 32, 48, 32, 46, 54, 56, 45, 46, 48, 55, 32, 49, 46, 51, 52, 45, 46, 49, 54, 32, 50, 122, 109, 46, 50, 53, 32, 53, 46, 53, 54, 99, 46, 54, 45, 49, 46, 49, 49, 32, 49, 46, 48, 54, 45, 50, 46, 51, 49, 32, 49, 46, 51, 56, 45, 51, 46, 53, 54, 104, 50, 46, 57, 53, 99, 45, 46, 57, 54, 32, 49, 46, 54, 53, 45, 50, 46, 52, 57, 32, 50, 46, 57, 51, 45, 52, 46, 51, 51, 32, 51, 46, 53, 54, 122, 77, 49, 54, 46, 51, 54, 32, 49, 52, 99, 46, 48, 56, 45, 46, 54, 54, 46, 49, 52, 45, 49, 46, 51, 50, 46, 49, 52, 45, 50, 32, 48, 45, 46, 54, 56, 45, 46, 48, 54, 45, 49, 46, 51, 52, 45, 46, 49, 52, 45, 50, 104, 51, 46, 51, 56, 99, 46, 49, 54, 46, 54, 52, 46, 50, 54, 32, 49, 46, 51, 49, 46, 50, 54, 32, 50, 115, 45, 46, 49, 32, 49, 46, 51, 54, 45, 46, 50, 54, 32, 50, 104, 45, 51, 46, 51, 56, 122, 34, 47, 62, 60, 47, 115, 118, 103, 62}}
60, 115, 118, 103, 32, 120, 109, 108, 110, 115, 61, 34, 104, 116, 116, 112, 58, 47, 47, 119, 119, 119, 46, 119, 51, 46, 111, 114, 103, 47, 50, 48, 48, 48, 47, 115, 118, 103, 34, 32, 119, 105, 100, 116, 104, 61, 34, 50, 52, 34, 32, 104, 101, 105, 103, 104, 116, 61, 34, 50, 52, 34, 32, 118, 105, 101, 119, 66, 111, 120, 61, 34, 48, 32, 48, 32, 50, 52, 32, 50, 52, 34, 62, 60, 112, 97, 116, 104, 32, 100, 61, 34, 77, 48, 32, 48, 104, 50, 52, 118, 50, 52, 72, 48, 122, 34, 32, 102, 105, 108, 108, 61, 34, 110, 111, 110, 101, 34, 47, 62, 60, 112, 97, 116, 104, 32, 100, 61, 34, 77, 49, 49, 46, 57, 57, 32, 50, 67, 54, 46, 52, 55, 32, 50, 32, 50, 32, 54, 46, 52, 56, 32, 50, 32, 49, 50, 115, 52, 46, 52, 55, 32, 49, 48, 32, 57, 46, 57, 57, 32, 49, 48, 67, 49, 55, 46, 53, 50, 32, 50, 50, 32, 50, 50, 32, 49, 55, 46, 53, 50, 32, 50, 50, 32, 49, 50, 83, 49, 55, 46, 53, 50, 32, 50, 32, 49, 49, 46, 57, 57, 32, 50, 122, 109, 54, 46, 57, 51, 32, 54, 104, 45, 50, 46, 57, 53, 99, 45, 46, 51, 50, 45, 49, 46, 50, 53, 45, 46, 55, 56, 45, 50, 46, 52, 53, 45, 49, 46, 51, 56, 45, 51, 46, 53, 54, 32, 49, 46, 56, 52, 46, 54, 51, 32, 51, 46, 51, 55, 32, 49, 46, 57, 49, 32, 52, 46, 51, 51, 32, 51, 46, 53, 54, 122, 77, 49, 50, 32, 52, 46, 48, 52, 99, 46, 56, 51, 32, 49, 46, 50, 32, 49, 46, 52, 56, 32, 50, 46, 53, 51, 32, 49, 46, 57, 49, 32, 51, 46, 57, 54, 104, 45, 51, 46, 56, 50, 99, 46, 52, 51, 45, 49, 46, 52, 51, 32, 49, 46, 48, 56, 45, 50, 46, 55, 54, 32, 49, 46, 57, 49, 45, 51, 46, 57, 54, 122, 77, 52, 46, 50, 54, 32, 49, 52, 67, 52, 46, 49, 32, 49, 51, 46, 51, 54, 32, 52, 32, 49, 50, 46, 54, 57, 32, 52, 32, 49, 50, 115, 46, 49, 45, 49, 46, 51, 54, 46, 50, 54, 45, 50, 104, 51, 46, 51, 56, 99, 45, 46, 48, 56, 46, 54, 54, 45, 46, 49, 52, 32, 49, 46, 51, 50, 45, 46, 49, 52, 32, 50, 32, 48, 32, 46, 54, 56, 46, 48, 54, 32, 49, 46, 51, 52, 46, 49, 52, 32, 50, 72, 52, 46, 50, 54, 122, 109, 46, 56, 50, 32, 50, 104, 50, 46, 57, 53, 99, 46, 51, 50, 32, 49, 46, 50, 53, 46, 55, 56, 32, 50, 46, 52, 53, 32, 49, 46, 51, 56, 32, 51, 46, 53, 54, 45, 49, 46, 56, 52, 45, 46, 54, 51, 45, 51, 46, 51, 55, 45, 49, 46, 57, 45, 52, 46, 51, 51, 45, 51, 46, 53, 54, 122, 109, 50, 46, 57, 53, 45, 56, 72, 53, 46, 48, 56, 99, 46, 57, 54, 45, 49, 46, 54, 54, 32, 50, 46, 52, 57, 45, 50, 46, 57, 51, 32, 52, 46, 51, 51, 45, 51, 46, 53, 54, 67, 56, 46, 56, 49, 32, 53, 46, 53, 53, 32, 56, 46, 51, 53, 32, 54, 46, 55, 53, 32, 56, 46, 48, 51, 32, 56, 122, 77, 49, 50, 32, 49, 57, 46, 57, 54, 99, 45, 46, 56, 51, 45, 49, 46, 50, 45, 49, 46, 52, 56, 45, 50, 46, 53, 51, 45, 49, 46, 57, 49, 45, 51, 46, 57, 54, 104, 51, 46, 56, 50, 99, 45, 46, 52, 51, 32, 49, 46, 52, 51, 45, 49, 46, 48, 56, 32, 50, 46, 55, 54, 45, 49, 46, 57, 49, 32, 51, 46, 57, 54, 122, 77, 49, 52, 46, 51, 52, 32, 49, 52, 72, 57, 46, 54, 54, 99, 45, 46, 48, 57, 45, 46, 54, 54, 45, 46, 49, 54, 45, 49, 46, 51, 50, 45, 46, 49, 54, 45, 50, 32, 48, 45, 46, 54, 56, 46, 48, 55, 45, 49, 46, 51, 53, 46, 49, 54, 45, 50, 104, 52, 46, 54, 56, 99, 46, 48, 57, 46, 54, 53, 46, 49, 54, 32, 49, 46, 51, 50, 46, 49, 54, 32, 50, 32, 48, 32, 46, 54, 56, 45, 46, 48, 55, 32, 49, 46, 51, 52, 45, 46, 49, 54, 32, 50, 122, 109, 46, 50, 53, 32, 53, 46, 53, 54, 99, 46, 54, 45, 49, 46, 49, 49, 32, 49, 46, 48, 54, 45, 50, 46, 51, 49, 32, 49, 46, 51, 56, 45, 51, 46, 53, 54, 104, 50, 46, 57, 53, 99, 45, 46, 57, 54, 32, 49, 46, 54, 53, 45, 50, 46, 52, 57, 32, 50, 46, 57, 51, 45, 52, 46, 51, 51, 32, 51, 46, 53, 54, 122, 77, 49, 54, 46, 51, 54, 32, 49, 52, 99, 46, 48, 56, 45, 46, 54, 54, 46, 49, 52, 45, 49, 46, 51, 50, 46, 49, 52, 45, 50, 32, 48, 45, 46, 54, 56, 45, 46, 48, 54, 45, 49, 46, 51, 52, 45, 46, 49, 52, 45, 50, 104, 51, 46, 51, 56, 99, 46, 49, 54, 46, 54, 52, 46, 50, 54, 32, 49, 46, 51, 49, 46, 50, 54, 32, 50, 115, 45, 46, 49, 32, 49, 46, 51, 54, 45, 46, 50, 54, 32, 50, 104, 45, 51, 46, 51, 56, 122, 34, 47, 62, 60, 47, 115, 118, 103, 62, 10}}
2 changes: 0 additions & 2 deletions driver/desktop/shortcut_test.go
Expand Up @@ -47,8 +47,6 @@ func TestCustomShortcut_Shortcut(t *testing.T) {
}

func Test_modifierToString(t *testing.T) {
type args struct {
}
tests := []struct {
name string
mods Modifier
Expand Down
1 change: 0 additions & 1 deletion internal/driver/glfw/canvas_test.go
Expand Up @@ -429,7 +429,6 @@ func Test_glCanvas_walkTree(t *testing.T) {
// test that first walk calls the hooks correctly
//
type beforeCall struct {
node *renderCacheNode
obj fyne.CanvasObject
parent fyne.CanvasObject
pos fyne.Position
Expand Down
13 changes: 0 additions & 13 deletions internal/driver/glfw/file.go
Expand Up @@ -26,23 +26,10 @@ func (f *file) URI() fyne.URI {
return storage.NewURI("file://" + f.path)
}

type fileWriter struct {
*os.File
path string
}

func (d *gLDriver) FileWriterForURI(uri fyne.URI) (fyne.URIWriteCloser, error) {
return openFile(uri, true)
}

func (f *fileWriter) Name() string {
return filepath.Base(f.path)
}

func (f *fileWriter) URI() fyne.URI {
return storage.NewURI("file://" + f.path)
}

func openFile(uri fyne.URI, create bool) (*file, error) {
if uri.Scheme() != "file" {
return nil, fmt.Errorf("invalid URI for file: %s", uri)
Expand Down
3 changes: 1 addition & 2 deletions internal/driver/glfw/window.go
Expand Up @@ -51,7 +51,6 @@ type window struct {
fixedSize bool

cursor *glfw.Cursor
painted int // part of the macOS GL fix, updated GLFW should fix this
canvas *glCanvas
title string
icon fyne.Resource
Expand Down Expand Up @@ -658,7 +657,7 @@ func (w *window) mouseClicked(_ *glfw.Window, btn glfw.MouseButton, action glfw.
_, tap := co.(fyne.Tappable)
_, altTap := co.(fyne.SecondaryTappable)
// Prevent Tapped from triggering if DoubleTapped has been sent
if (tap || altTap) && doubleTapped == false {
if (tap || altTap) && !doubleTapped {
if action == glfw.Press {
w.mousePressed = co
} else if action == glfw.Release {
Expand Down
2 changes: 1 addition & 1 deletion internal/painter/gl/gl_core.go
Expand Up @@ -74,7 +74,7 @@ func (p *glPainter) imgToTexture(img image.Image, textureFilter canvas.ImageScal
return texture
default:
rgba := image.NewRGBA(image.Rect(0, 0, img.Bounds().Dx(), img.Bounds().Dy()))
draw.Draw(rgba, rgba.Rect, img, image.ZP, draw.Over)
draw.Draw(rgba, rgba.Rect, img, image.Point{}, draw.Over)
return p.imgToTexture(rgba, textureFilter)
}
}
Expand Down
2 changes: 1 addition & 1 deletion internal/painter/image.go
Expand Up @@ -125,7 +125,7 @@ func drawSVGSafely(icon *oksvg.SvgIcon, raster *rasterx.Dasher) error {
var err error
defer func() {
if r := recover(); r != nil {
err = errors.New("Crash when rendering SVG")
err = errors.New("crash when rendering svg")
}
}()
icon.Draw(raster, 1)
Expand Down
4 changes: 2 additions & 2 deletions internal/painter/software/draw.go
Expand Up @@ -121,13 +121,13 @@ func drawRectangle(c fyne.Canvas, rect *canvas.Rectangle, pos fyne.Position, bas
scaledHeight := internal.ScaleInt(c, rect.Size().Height)
scaledX, scaledY := internal.ScaleInt(c, pos.X), internal.ScaleInt(c, pos.Y)
bounds := clip.Intersect(image.Rect(scaledX, scaledY, scaledX+scaledWidth, scaledY+scaledHeight))
draw.Draw(base, bounds, image.NewUniform(rect.FillColor), image.ZP, draw.Over)
draw.Draw(base, bounds, image.NewUniform(rect.FillColor), image.Point{}, draw.Over)
}

func drawWidget(c fyne.Canvas, wid fyne.Widget, pos fyne.Position, base *image.NRGBA, clip image.Rectangle) {
scaledWidth := internal.ScaleInt(c, wid.Size().Width)
scaledHeight := internal.ScaleInt(c, wid.Size().Height)
scaledX, scaledY := internal.ScaleInt(c, pos.X), internal.ScaleInt(c, pos.Y)
bounds := clip.Intersect(image.Rect(scaledX, scaledY, scaledX+scaledWidth, scaledY+scaledHeight))
draw.Draw(base, bounds, image.NewUniform(cache.Renderer(wid).BackgroundColor()), image.ZP, draw.Over)
draw.Draw(base, bounds, image.NewUniform(cache.Renderer(wid).BackgroundColor()), image.Point{}, draw.Over)
}
2 changes: 1 addition & 1 deletion internal/painter/software/painter.go
Expand Up @@ -28,7 +28,7 @@ func (*Painter) Paint(c fyne.Canvas) image.Image {
size := c.Size().Max(c.Content().MinSize())
bounds := image.Rect(0, 0, internal.ScaleInt(c, size.Width), internal.ScaleInt(c, size.Height))
base := image.NewNRGBA(bounds)
draw.Draw(base, bounds, image.NewUniform(theme.BackgroundColor()), image.ZP, draw.Src)
draw.Draw(base, bounds, image.NewUniform(theme.BackgroundColor()), image.Point{}, draw.Src)

paint := func(obj fyne.CanvasObject, pos, clipPos fyne.Position, clipSize fyne.Size) bool {
clip := image.Rect(
Expand Down
9 changes: 1 addition & 8 deletions test/testapp.go
Expand Up @@ -83,13 +83,6 @@ func (a *testApp) lastAppliedTheme() fyne.Theme {
return a.appliedTheme
}

func (a *testApp) lastNotificationSent() *fyne.Notification {
a.propertyLock.Lock()
defer a.propertyLock.Unlock()

return a.lastNotification
}

// NewApp returns a new dummy app used for testing.
// It loads a test driver which creates a virtual window in memory for testing.
func NewApp() fyne.App {
Expand All @@ -102,7 +95,7 @@ func NewApp() fyne.App {
test.Settings().AddChangeListener(listener)
go func() {
for {
_ = <-listener
<-listener
painter.SvgCacheReset()
app.ApplySettings(test.Settings(), test)

Expand Down
2 changes: 1 addition & 1 deletion test/testcanvas.go
Expand Up @@ -224,7 +224,7 @@ func (c *testCanvas) Capture() image.Image {

bounds := image.Rect(0, 0, internal.ScaleInt(c, c.Size().Width), internal.ScaleInt(c, c.Size().Height))
img := image.NewNRGBA(bounds)
draw.Draw(img, bounds, image.NewUniform(theme.BackgroundColor()), image.ZP, draw.Src)
draw.Draw(img, bounds, image.NewUniform(theme.BackgroundColor()), image.Point{}, draw.Src)

return img
}
Expand Down
4 changes: 2 additions & 2 deletions test/util_test.go
Expand Up @@ -39,7 +39,7 @@ func TestAssertCanvasTappableAt(t *testing.T) {
func TestAssertImageMatches(t *testing.T) {
bounds := image.Rect(0, 0, 100, 50)
img := image.NewNRGBA(bounds)
draw.Draw(img, bounds, image.NewUniform(color.White), image.ZP, draw.Src)
draw.Draw(img, bounds, image.NewUniform(color.White), image.Point{}, draw.Src)

txtImg := image.NewNRGBA(bounds)
opts := truetype.Options{Size: 20, DPI: 96}
Expand All @@ -52,7 +52,7 @@ func TestAssertImageMatches(t *testing.T) {
Dot: freetype.Pt(0, 50-face.Metrics().Descent.Ceil()),
}
d.DrawString("Hello!")
draw.Draw(img, bounds, txtImg, image.ZP, draw.Over)
draw.Draw(img, bounds, txtImg, image.Point{}, draw.Over)

tt := &testing.T{}
assert.False(t, test.AssertImageMatches(tt, "non_existing_master.png", img), "non existing master is not equal a given image")
Expand Down
2 changes: 1 addition & 1 deletion theme/theme.go
Expand Up @@ -136,7 +136,7 @@ func (t *builtinTheme) TextSize() int {
}

func loadCustomFont(env, variant string, fallback fyne.Resource) fyne.Resource {
variantPath := strings.Replace(env, "Regular", variant, 0)
variantPath := strings.Replace(env, "Regular", variant, -1)

res, err := fyne.LoadResourceFromPath(variantPath)
if err != nil {
Expand Down
4 changes: 0 additions & 4 deletions widget/box.go
Expand Up @@ -62,10 +62,6 @@ func (b *Box) CreateRenderer() fyne.WidgetRenderer {
return &boxRenderer{BaseRenderer: widget.NewBaseRenderer(b.Children), layout: lay, box: b}
}

func (b *Box) setBackgroundColor(bg color.Color) {
b.background = bg
}

// NewHBox creates a new horizontally aligned box widget with the specified list of child objects
func NewHBox(children ...fyne.CanvasObject) *Box {
return &Box{BaseWidget: BaseWidget{}, Horizontal: true, Children: children}
Expand Down

0 comments on commit 3d6571a

Please sign in to comment.