From b6ffbe257e34c62eedf61be9c6de48be945e03b9 Mon Sep 17 00:00:00 2001 From: Kai O'Reilly Date: Thu, 7 Nov 2024 07:48:22 -0800 Subject: [PATCH] fix data race condition when closing the main window using the system close window button --- system/driver/base/app_multi.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/system/driver/base/app_multi.go b/system/driver/base/app_multi.go index 32a47b59a8..48e73ef878 100644 --- a/system/driver/base/app_multi.go +++ b/system/driver/base/app_multi.go @@ -108,12 +108,16 @@ func (a *AppMulti[W]) ContextWindow() system.Window { // RemoveWindow removes the given Window from the app's list of windows. // It does not actually close it; see [Window.Close] for that. func (a *AppMulti[W]) RemoveWindow(w system.Window) { + a.Mu.Lock() + defer a.Mu.Unlock() a.Windows = slices.DeleteFunc(a.Windows, func(ew W) bool { return system.Window(ew) == w }) } func (a *AppMulti[W]) QuitClean() bool { + a.Mu.Lock() + defer a.Mu.Unlock() for _, qf := range a.QuitCleanFuncs { qf() }