Skip to content

Commit 4636f25

Browse files
committed
fix: create separate material.Theme per window to prevent concurrent map crash in text.Shaper
1 parent 4b639fd commit 4636f25

3 files changed

Lines changed: 12 additions & 4 deletions

File tree

internal/app/desktop/console_window.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ type ConsoleWindow struct {
8787
func NewConsoleWindow(parent *Window, onClose func()) *ConsoleWindow {
8888
window := &ConsoleWindow{
8989
parent: parent,
90-
theme: parent.theme,
90+
theme: newAppTheme(),
9191
onClose: onClose,
9292
closed: make(chan struct{}),
9393
peerList: widget.List{

internal/app/desktop/window.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,20 @@ const (
6767
languageMenuHeight = 316
6868
)
6969

70-
func NewWindow(client *service.DesktopClient, router *service.DMRouter, cmdTable *rpc.CommandTable, runtime *NodeRuntime, prefs *Preferences) *Window {
70+
// newAppTheme creates a fresh material.Theme with the application colour scheme.
71+
// Each window must own its own Theme because the embedded text.Shaper uses an
72+
// unsynchronised map cache and is therefore not safe for concurrent use.
73+
func newAppTheme() *material.Theme {
7174
theme := material.NewTheme()
7275
theme.Bg = color.NRGBA{R: 18, G: 21, B: 26, A: 255}
7376
theme.Fg = color.NRGBA{R: 235, G: 239, B: 244, A: 255}
7477
theme.ContrastBg = color.NRGBA{R: 36, G: 67, B: 126, A: 255}
7578
theme.ContrastFg = color.NRGBA{R: 255, G: 255, B: 255, A: 255}
79+
return theme
80+
}
81+
82+
func NewWindow(client *service.DesktopClient, router *service.DMRouter, cmdTable *rpc.CommandTable, runtime *NodeRuntime, prefs *Preferences) *Window {
83+
theme := newAppTheme()
7684

7785
language := normalizeLanguage(client.Language())
7886
if prefs != nil && prefs.Language != "" {

internal/core/config/config.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ type Config struct {
6060
}
6161

6262
const (
63-
CorsaVersion = "0.16 alpha"
64-
CorsaWireVersion = "0.16-alpha"
63+
CorsaVersion = "0.17 alpha"
64+
CorsaWireVersion = "0.17-alpha"
6565
ProtocolVersion = 2
6666
MinimumProtocolVersion = 2
6767
DefaultOutgoingPeers = 8

0 commit comments

Comments
 (0)