Skip to content

Calling obj.MinSize() in software.Render() breaks TestRender #6235

@MaxGyver83

Description

@MaxGyver83

Checklist

  • I have searched the issue tracker for open issues that relate to the same problem, before opening a new one.
  • This issue only relates to a single bug. I will open new issues for any other problems.

Describe the bug

While trying to fix my pull request #6234, I noticed that a call to obj.MinSize() breaks TestRender (in driver/software/render_test.go:17). This isn't an issue in any real app but it surprises me and might be an indicator that something is broken. (Or maybe the test is wrong.)

How to reproduce

  1. Apply this patch:
diff --git a/driver/software/render.go b/driver/software/render.go
index 2a22d43db..3fb6d3f57 100644
--- a/driver/software/render.go
+++ b/driver/software/render.go
@@ -27,5 +27,6 @@ func Render(obj fyne.CanvasObject, t fyne.Theme) image.Image {
        c.SetContent(obj)

        app.ApplyThemeTo(obj, c)
+       obj.MinSize() // this breaks TestRender
        return c.Capture()
 }
  1. Run: go test -v -test.run 'TestRender$' ./driver/software

Output:

=== RUN   TestRender
    util_helper.go:61:
        	Error Trace:	/home/max/repos/my-fyne/internal/test/util_helper.go:61
        	            				/home/max/repos/my-fyne/test/test_helper.go:78
        	            				/home/max/repos/my-fyne/driver/software/render_test.go:21
        	Error:      	Images not equal.
        	Test:       	TestRender
        	Messages:   	Image did not match master. Actual image written to file:///home/max/repos/my-fyne/driver/software/testdata/failed/label_ugly_theme.png.
--- FAIL: TestRender (0.06s)
FAIL
FAIL	fyne.io/fyne/v2/driver/software	0.071s
FAIL

Update: It turns out, this wasn't an issue before my own PR #6231 was merged. Maybe there is just a Refresh call missing somewhere.
Update 2: When I call obj.Refresh() after obj.MinSize() the test passes. I'm not sure if a Refresh call should be required here.

Screenshots

Expected image:
Image

Actual image:
Image

Example code

develop branch plus patch above.

Fyne version

develop

Go compiler version

1.26.1

Operating system and version

Arch Linux

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    unverifiedA bug that has been reported but not verified

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions