[v3] fix deadlock when quit (#2982)

* fix: dead lock when quit

* docs: update changelog
This commit is contained in:
5aaee9
2023-10-14 20:34:00 +11:00
committed by GitHub
parent 320fc20461
commit a8641672cd
2 changed files with 17 additions and 15 deletions
+2
View File
@@ -24,6 +24,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
- [darwin] Fixed application frozen when quit by @5aaee9 in
[#2982](https://github.com/wailsapp/wails/pull/2982)
- Fixed background colours of examples on Windows by
[mmgvh](https://github.com/mmghv) in
[#2750](https://github.com/wailsapp/wails/pull/2750).
+15 -15
View File
@@ -235,7 +235,7 @@ type App struct {
// Windows
windows map[uint]Window
windowsLock sync.Mutex
windowsLock sync.RWMutex
// System Trays
systemTrays map[uint]*SystemTray
@@ -301,8 +301,8 @@ func (a *App) getSystemTrayID() uint {
}
func (a *App) getWindowForID(id uint) Window {
a.windowsLock.Lock()
defer a.windowsLock.Unlock()
a.windowsLock.RLock()
defer a.windowsLock.RUnlock()
return a.windows[id]
}
@@ -539,9 +539,9 @@ func (a *App) handleDragAndDropMessage(event *dragAndDropMessage) {
func (a *App) handleWindowMessage(event *windowMessage) {
// Get window from window map
a.windowsLock.Lock()
a.windowsLock.RLock()
window, ok := a.windows[event.windowId]
a.windowsLock.Unlock()
a.windowsLock.RUnlock()
if !ok {
log.Printf("WebviewWindow #%d not found", event.windowId)
return
@@ -556,9 +556,9 @@ func (a *App) handleWebViewRequest(request *webViewAssetRequest) {
func (a *App) handleWindowEvent(event *windowEvent) {
// Get window from window map
a.windowsLock.Lock()
a.windowsLock.RLock()
window, ok := a.windows[event.WindowID]
a.windowsLock.Unlock()
a.windowsLock.RUnlock()
if !ok {
log.Printf("Window #%d not found", event.WindowID)
return
@@ -580,18 +580,18 @@ func (a *App) CurrentWindow() *WebviewWindow {
return nil
}
id := a.impl.getCurrentWindowID()
a.windowsLock.Lock()
defer a.windowsLock.Unlock()
a.windowsLock.RLock()
defer a.windowsLock.RUnlock()
return a.windows[id].(*WebviewWindow)
}
func (a *App) Quit() {
InvokeSync(func() {
a.windowsLock.Lock()
a.windowsLock.RLock()
for _, window := range a.windows {
window.Destroy()
}
a.windowsLock.Unlock()
a.windowsLock.RUnlock()
a.systemTraysLock.Lock()
for _, systray := range a.systemTrays {
systray.Destroy()
@@ -729,8 +729,8 @@ func (a *App) OnWindowCreation(callback func(window Window)) {
}
func (a *App) GetWindowByName(name string) Window {
a.windowsLock.Lock()
defer a.windowsLock.Unlock()
a.windowsLock.RLock()
defer a.windowsLock.RUnlock()
for _, window := range a.windows {
if window.Name() == name {
return window
@@ -772,9 +772,9 @@ func (a *App) processKeyBinding(acceleratorString string, window *WebviewWindow)
func (a *App) handleWindowKeyEvent(event *windowKeyEvent) {
// Get window from window map
a.windowsLock.Lock()
a.windowsLock.RLock()
window, ok := a.windows[event.windowId]
a.windowsLock.Unlock()
a.windowsLock.RUnlock()
if !ok {
log.Printf("WebviewWindow #%d not found", event.windowId)
return