Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: fyne-io/fyne
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v2.2.2
Choose a base ref
...
head repository: fyne-io/fyne
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v2.2.3
Choose a head ref
  • 18 commits
  • 10 files changed
  • 3 contributors

Commits on Jun 28, 2022

  1. Copy the full SHA
    72a1ec6 View commit details
  2. Fix format

    andydotxyz committed Jun 28, 2022
    Copy the full SHA
    d84c943 View commit details

Commits on Jun 30, 2022

  1. Remove unneeded set

    andydotxyz committed Jun 30, 2022
    Copy the full SHA
    d65feb8 View commit details
  2. Copy the full SHA
    4922b9a View commit details

Commits on Jul 6, 2022

  1. Somehow this code got commented out?

    Add a test to make sure it doesn't happen again.
    Fixes #3125
    andydotxyz committed Jul 6, 2022
    Copy the full SHA
    db463a5 View commit details
  2. Fix more broken tests

    andydotxyz committed Jul 6, 2022
    Copy the full SHA
    da29681 View commit details
  3. Copy the full SHA
    d7a1036 View commit details
  4. Inject metadata for iOS and Android

    This had been missed as it's a different compile path
    Fixes #3109
    andydotxyz committed Jul 6, 2022
    Copy the full SHA
    76c40ae View commit details
  5. Format error snuck in

    andydotxyz committed Jul 6, 2022
    Copy the full SHA
    e3a38c1 View commit details
  6. Copy the full SHA
    77d8a96 View commit details
  7. Copy the full SHA
    968357b View commit details
  8. prepping notes

    andydotxyz committed Jul 6, 2022
    Copy the full SHA
    937991b View commit details
  9. Copy the full SHA
    2a54f83 View commit details
  10. Merge pull request #3111 from fyne-io/fix/3003

    Fix crash with richtext that is too narrow
    andydotxyz authored Jul 6, 2022
    Copy the full SHA
    232fbdb View commit details
  11. Copy the full SHA
    3fbe84b View commit details
  12. Copy the full SHA
    7a3ae4d View commit details

Commits on Jul 8, 2022

  1. Date to changelog

    andydotxyz committed Jul 8, 2022
    Copy the full SHA
    70b4ad9 View commit details
  2. Copy the full SHA
    ac41869 View commit details
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -3,6 +3,15 @@
This file lists the main changes with each version of the Fyne toolkit.
More detailed release notes can be found on the [releases page](https://github.com/fyne-io/fyne/releases).

## 2.2.3 - 8 July 2022

### Fixed

* Regression: Preferences are not parsed at program start (#3125)
* Wrappable RichText in a Split container causes crash (#3003, #2961)
* meta.Version is always 1.0.0 on android & ios (#3109)


## 2.2.2 - 30 June 2022

### Fixed
8 changes: 4 additions & 4 deletions app/preferences.go
Original file line number Diff line number Diff line change
@@ -79,10 +79,10 @@ func (p *preferences) saveToFile(path string) error {
}

func (p *preferences) load() {
// err := p.loadFromFile(p.storagePath())
// if err != nil {
// fyne.LogError("Preferences load error:", err)
// }
err := p.loadFromFile(p.storagePath())
if err != nil {
fyne.LogError("Preferences load error:", err)
}
}

func (p *preferences) loadFromFile(path string) (err error) {
4 changes: 4 additions & 0 deletions app/preferences_test.go
Original file line number Diff line number Diff line change
@@ -38,6 +38,10 @@ func TestPreferences_Save(t *testing.T) {
assert.Fail(t, "Failed to load, %v", err)
}
assert.JSONEq(t, string(expected), string(content))

// check it reads the saved output
p = loadPreferences("dummy")
assert.Equal(t, "value", p.String("keyString"))
}

func TestPreferences_Save_OverwriteFast(t *testing.T) {
79 changes: 40 additions & 39 deletions cmd/fyne/internal/commands/build.go
Original file line number Diff line number Diff line change
@@ -165,44 +165,6 @@ func getFyneGoModVersion(runner runner) (string, error) {
return "", fmt.Errorf("fyne version not found")
}

func (b *Builder) createMetadataInitFile() (func(), error) {
data, err := metadata.LoadStandard(b.srcdir)
if err == nil {
mergeMetadata(b.appData, data)
}

metadataInitFilePath := filepath.Join(b.srcdir, "fyne_metadata_init.go")
metadataInitFile, err := os.Create(metadataInitFilePath)
if err != nil {
return func() {}, err
}
defer metadataInitFile.Close()

err = templates.FyneMetadataInit.Execute(metadataInitFile, b.appData)
if err == nil {
if b.icon != "" {
writeResource(b.icon, "fyneMetadataIcon", metadataInitFile)
}
}

return func() { os.Remove(metadataInitFilePath) }, err
}

func (b *Builder) injectMetadataIfPossible(runner runner, createMetadataInitFile func() (func(), error)) (func(), error) {
fyneGoModVersion, err := getFyneGoModVersion(runner)
if err != nil {
return nil, err
}

fyneGoModVersionNormalized := version.Normalize(fyneGoModVersion)
fyneGoModVersionConstraint := version.NewConstrainGroupFromString(">=2.2")
if fyneGoModVersion != "master" && !fyneGoModVersionConstraint.Match(fyneGoModVersionNormalized) {
return nil, nil
}

return createMetadataInitFile()
}

func (b *Builder) build() error {
var versionConstraint *version.ConstraintGroup

@@ -221,7 +183,7 @@ func (b *Builder) build() error {
}
}

close, err := b.injectMetadataIfPossible(fyneGoModRunner, b.createMetadataInitFile)
close, err := injectMetadataIfPossible(fyneGoModRunner, b.srcdir, b.appData, b.icon, createMetadataInitFile)
if err != nil {
fyne.LogError("Failed to inject metadata init file, omitting metadata", err)
} else if close != nil {
@@ -298,6 +260,45 @@ func (b *Builder) build() error {
return err
}

func createMetadataInitFile(srcdir string, app *appData, icon string) (func(), error) {
data, err := metadata.LoadStandard(srcdir)
if err == nil {
mergeMetadata(app, data)
}

metadataInitFilePath := filepath.Join(srcdir, "fyne_metadata_init.go")
metadataInitFile, err := os.Create(metadataInitFilePath)
if err != nil {
return func() {}, err
}
defer metadataInitFile.Close()

err = templates.FyneMetadataInit.Execute(metadataInitFile, app)
if err == nil {
if icon != "" {
writeResource(icon, "fyneMetadataIcon", metadataInitFile)
}
}

return func() { os.Remove(metadataInitFilePath) }, err
}

func injectMetadataIfPossible(runner runner, srcdir string, app *appData, icon string,
createMetadataInitFile func(srcdir string, app *appData, icon string) (func(), error)) (func(), error) {
fyneGoModVersion, err := getFyneGoModVersion(runner)
if err != nil {
return nil, err
}

fyneGoModVersionNormalized := version.Normalize(fyneGoModVersion)
fyneGoModVersionConstraint := version.NewConstrainGroupFromString(">=2.2")
if fyneGoModVersion != "master" && !fyneGoModVersionConstraint.Match(fyneGoModVersionNormalized) {
return nil, nil
}

return createMetadataInitFile(srcdir, app, icon)
}

func targetOS() string {
osEnv, ok := os.LookupEnv("GOOS")
if ok {
10 changes: 5 additions & 5 deletions cmd/fyne/internal/commands/build_test.go
Original file line number Diff line number Diff line change
@@ -244,11 +244,11 @@ func Test_FyneGoMod(t *testing.T) {
called := false

fyneGoModTest := &testCommandRuns{runs: expected, t: t}
b := &Builder{appData: &appData{}, os: "wasm", srcdir: "myTest", runner: fyneGoModTest}
b.injectMetadataIfPossible(fyneGoModTest, func() (func(), error) {
called = true
return func() {}, nil
})
injectMetadataIfPossible(fyneGoModTest, "myTest", &appData{}, "",
func(string, *appData, string) (func(), error) {
called = true
return func() {}, nil
})

assert.Equal(t, j.expected, called)
}
11 changes: 10 additions & 1 deletion cmd/fyne/internal/commands/package.go
Original file line number Diff line number Diff line change
@@ -14,6 +14,7 @@ import (
"strconv"
"strings"

"fyne.io/fyne/v2"
_ "github.com/fyne-io/image/ico" // import image encodings
"github.com/urfave/cli/v2"
"golang.org/x/mod/modfile"
@@ -24,7 +25,7 @@ import (

const (
defaultAppBuild = 1
defaultAppVersion = "1.0.0"
defaultAppVersion = "0.0.1"
)

type appData struct {
@@ -274,6 +275,14 @@ func (p *Packager) doPackage(runner runner) error {
defer p.removeBuild(files)
}
}
if util.IsMobile(p.os) { // we don't use the normal build command for mobile so inject before gomobile...
close, err := injectMetadataIfPossible(newCommand("go"), p.dir, p.appData, p.icon, createMetadataInitFile)
if err != nil {
fyne.LogError("Failed to inject metadata init file, omitting metadata", err)
} else if close != nil {
defer close()
}
}

switch p.os {
case "darwin":
2 changes: 1 addition & 1 deletion cmd/fyne/internal/mobile/binres/binres_test.go
Original file line number Diff line number Diff line change
@@ -445,7 +445,7 @@ func TestTableMarshal(t *testing.T) {
err = xtbl.UnmarshalBinary(bin)
r.NoError(err)

r.Equal(len(tbl.pool.strings), xtbl.pool.strings)
r.Equal(len(tbl.pool.strings), len(xtbl.pool.strings))
r.Equal(len(tbl.pkgs), len(xtbl.pkgs))

pkg, xpkg := tbl.pkgs[0], xtbl.pkgs[0]
6 changes: 3 additions & 3 deletions internal/driver/glfw/driver_test.go
Original file line number Diff line number Diff line change
@@ -126,7 +126,7 @@ func init() {
}

func TestGoroutineID(t *testing.T) {
assert.Equal(t, 1, mainRoutineID)
assert.Equal(t, uint64(1), mainRoutineID)

var childID1, childID2 uint64
testID1 := goroutineID()
@@ -144,8 +144,8 @@ func TestGoroutineID(t *testing.T) {
testID2 := goroutineID()

assert.Equal(t, testID1, testID2)
assert.Greater(t, childID1, 0)
assert.Greater(t, childID1, uint64(0))
assert.NotEqual(t, testID1, childID1)
assert.Greater(t, childID2, 0)
assert.Greater(t, childID2, uint64(0))
assert.NotEqual(t, childID1, childID2)
}
16 changes: 15 additions & 1 deletion widget/entry_test.go
Original file line number Diff line number Diff line change
@@ -533,7 +533,6 @@ func TestEntry_OnKeyDown_Backspace(t *testing.T) {
assert.Equal(t, 1, entry.CursorColumn)

entry = widget.NewMultiLineEntry()
entry.Wrapping = fyne.TextWrapWord
entry.SetText("Line\n2b\n")
down := &fyne.KeyEvent{Name: fyne.KeyDown}
entry.TypedKey(down)
@@ -545,6 +544,21 @@ func TestEntry_OnKeyDown_Backspace(t *testing.T) {
assert.Equal(t, "Line\nb\n", entry.Text)
assert.Equal(t, 1, entry.CursorRow)
assert.Equal(t, 0, entry.CursorColumn)

entry.CursorRow = 0
entry.CursorColumn = 0
entry.Wrapping = fyne.TextWrapWord
entry.SetText("Line 2b")
entry.Resize(fyne.NewSize(50, 50))
entry.TypedKey(down)
entry.TypedKey(right)
assert.Equal(t, 1, entry.CursorRow)
assert.Equal(t, 1, entry.CursorColumn)

entry.TypedKey(backspace)
assert.Equal(t, "Line b", entry.Text)
assert.Equal(t, 1, entry.CursorRow)
assert.Equal(t, 0, entry.CursorColumn)
}

func TestEntry_OnKeyDown_BackspaceBeyondText(t *testing.T) {
30 changes: 25 additions & 5 deletions widget/richtext.go
Original file line number Diff line number Diff line change
@@ -756,7 +756,7 @@ func findSpaceIndex(text []rune, fallback int) int {
// lineBounds returns a slice containing the boundary metadata of each line with the given wrapping applied.
func lineBounds(seg *TextSegment, wrap fyne.TextWrap, firstWidth, maxWidth float32, measurer func([]rune) float32) []rowBoundary {
lines := splitLines(seg)
if maxWidth <= 0 || wrap == fyne.TextWrapOff {
if wrap == fyne.TextWrapOff {
return lines
}

@@ -791,13 +791,21 @@ func lineBounds(seg *TextSegment, wrap fyne.TextWrap, firstWidth, maxWidth float
high = l.end
measureWidth = maxWidth
} else {
high = binarySearch(checker, low, high)
newHigh := binarySearch(checker, low, high)
if newHigh <= low {
bounds = append(bounds, rowBoundary{[]RichTextSegment{seg}, reuse, low, low + 1})
reuse++
low++
} else {
high = newHigh
}
}
}
case fyne.TextWrapWord:
for low < high {
sub := text[low:high]
if measurer(sub) <= measureWidth {
subWidth := measurer(sub)
if subWidth <= measureWidth {
bounds = append(bounds, rowBoundary{[]RichTextSegment{seg}, reuse, low, high})
reuse++
low = high
@@ -810,8 +818,20 @@ func lineBounds(seg *TextSegment, wrap fyne.TextWrap, firstWidth, maxWidth float
oldHigh := high
last := low + len(sub) - 1
fallback := binarySearch(checker, low, last) - low
high = low + findSpaceIndex(sub, fallback)
if high == fallback && measurer(sub) <= maxWidth { // add a newline as there is more space on next

if fallback < 1 { // even a character won't fit
bounds = append(bounds, rowBoundary{[]RichTextSegment{seg}, reuse, low, low + 1})
low++
high = low + 1
reuse++

if high > l.end {
return bounds
}
} else {
high = low + findSpaceIndex(sub, fallback)
}
if high == fallback && subWidth <= maxWidth { // add a newline as there is more space on next
bounds = append(bounds, rowBoundary{[]RichTextSegment{seg}, reuse, low, low})
reuse++
high = oldHigh