• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

fyne-io / fyne / 17185843058

24 Aug 2025 07:27AM UTC coverage: 62.326% (+0.02%) from 62.309%
17185843058

Pull #5912

github

Jacalz
Make dedup cleanup a bit safer without migrations
Pull Request #5912: Simplify freeing of dirty textures

56 of 78 new or added lines in 2 files covered. (71.79%)

3 existing lines in 1 file now uncovered.

25427 of 40797 relevant lines covered (62.33%)

711.81 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

80.85
/internal/driver/common/structures.go
1
package common
2

3
import (
4
        "fyne.io/fyne/v2"
5
        "fyne.io/fyne/v2/internal"
6
        "fyne.io/fyne/v2/internal/async"
7
        "fyne.io/fyne/v2/internal/build"
8
)
9

10
type deduplicatedObjectQueue struct {
11
        queue *async.CanvasObjectQueue
12
        dedup async.Map[fyne.CanvasObject, struct{}]
13
}
14

15
// In adds an object to the queue if it is not already present.
16
func (q *deduplicatedObjectQueue) In(obj fyne.CanvasObject) {
1,005✔
17
        _, exists := q.dedup.Load(obj)
1,005✔
18
        if exists {
1,007✔
19
                return
2✔
20
        }
2✔
21

22
        q.queue.In(obj)
1,003✔
23
        q.dedup.Store(obj, struct{}{})
1,003✔
24
}
25

26
// Out removes and returns the next object from the queue.
27
// It assumes that the whole queue is drained and defers clearing
28
// the deduplication map until it is empty.
29
func (q *deduplicatedObjectQueue) Out() fyne.CanvasObject {
1,005✔
30
        if q.queue.Len() == 0 {
1,008✔
31
                q.dedup.Clear()
3✔
32
                return nil
3✔
33
        }
3✔
34

35
        out := q.queue.Out()
1,002✔
36
        if !build.DisableThreadChecks {
2,004✔
37
                q.dedup.Delete(out)
1,002✔
38
        }
1,002✔
39
        return out
1,002✔
40
}
41

42
// Len returns the number of elements in the queue.
43
func (q *deduplicatedObjectQueue) Len() uint64 {
8✔
44
        return q.queue.Len()
8✔
45
}
8✔
46

47
type renderCacheTree struct {
48
        root *RenderCacheNode
49
}
50

51
// RenderCacheNode represents a node in a render cache tree.
52
type RenderCacheNode struct {
53
        // structural data
54
        firstChild  *RenderCacheNode
55
        nextSibling *RenderCacheNode
56
        obj         fyne.CanvasObject
57
        parent      *RenderCacheNode
58
        // cache data
59
        minSize fyne.Size
60
}
61

62
// Obj returns the node object.
NEW
63
func (r *RenderCacheNode) Obj() fyne.CanvasObject {
×
NEW
64
        return r.obj
×
NEW
65
}
×
66

67
type overlayStack struct {
68
        internal.OverlayStack
69

70
        renderCaches []*renderCacheTree
71
}
72

73
func (o *overlayStack) Add(overlay fyne.CanvasObject) {
3✔
74
        if overlay == nil {
3✔
NEW
75
                return
×
NEW
76
        }
×
77
        o.add(overlay)
3✔
78
}
79

80
func (o *overlayStack) Remove(overlay fyne.CanvasObject) {
2✔
81
        if overlay == nil || len(o.List()) == 0 {
2✔
NEW
82
                return
×
NEW
83
        }
×
84
        o.remove(overlay)
2✔
85
}
86

87
func (o *overlayStack) add(overlay fyne.CanvasObject) {
3✔
88
        o.renderCaches = append(o.renderCaches, &renderCacheTree{root: &RenderCacheNode{obj: overlay}})
3✔
89
        o.OverlayStack.Add(overlay)
3✔
90
}
3✔
91

92
func (o *overlayStack) remove(overlay fyne.CanvasObject) {
2✔
93
        o.OverlayStack.Remove(overlay)
2✔
94
        overlayCount := len(o.List())
2✔
95

2✔
96
        // it is possible that overlays are removed implicitly and render caches already cleared out
2✔
97
        if overlayCount >= len(o.renderCaches) {
2✔
NEW
98
                return
×
NEW
99
        }
×
100

101
        o.renderCaches[overlayCount] = nil // release memory reference to removed element
2✔
102
        o.renderCaches = o.renderCaches[:overlayCount]
2✔
103
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc