5
0
mirror of https://github.com/wailsapp/wails.git synced 2025-05-09 23:41:09 +08:00

avoid deadlock on win

This commit is contained in:
popaprozac 2025-03-20 22:12:21 -07:00
parent 5dc7bd97f2
commit be1da68dbc
3 changed files with 6 additions and 5 deletions

View File

@ -16,6 +16,8 @@ import (
"context"
"fmt"
"sync"
"github.com/wailsapp/wails/v3/pkg/application"
)
type notificationImpl interface {
@ -133,7 +135,7 @@ func (ns *Service) handleNotificationResult(result NotificationResult) {
}
// ServiceStartup is called when the service is loaded
func (ns *Service) ServiceStartup(ctx context.Context, options interface{}) error {
func (ns *Service) ServiceStartup(ctx context.Context, options application.ServiceOptions) error {
return ns.impl.Startup(ctx)
}

View File

@ -78,6 +78,7 @@ func New() *Service {
impl: impl,
}
})
return NotificationService
}

View File

@ -209,8 +209,6 @@ func (wn *windowsNotifier) SendNotificationWithActions(options NotificationOptio
// Registering a category with the same name as a previously registered NotificationCategory will override it.
func (wn *windowsNotifier) RegisterNotificationCategory(category NotificationCategory) error {
wn.categoriesLock.Lock()
defer wn.categoriesLock.Unlock()
wn.categories[category.ID] = NotificationCategory{
ID: category.ID,
Actions: category.Actions,
@ -218,6 +216,7 @@ func (wn *windowsNotifier) RegisterNotificationCategory(category NotificationCat
ReplyPlaceholder: category.ReplyPlaceholder,
ReplyButtonTitle: category.ReplyButtonTitle,
}
wn.categoriesLock.Unlock()
return wn.saveCategoriesToRegistry()
}
@ -225,9 +224,8 @@ func (wn *windowsNotifier) RegisterNotificationCategory(category NotificationCat
// RemoveNotificationCategory removes a previously registered NotificationCategory.
func (wn *windowsNotifier) RemoveNotificationCategory(categoryId string) error {
wn.categoriesLock.Lock()
defer wn.categoriesLock.Unlock()
delete(wn.categories, categoryId)
wn.categoriesLock.Unlock()
return wn.saveCategoriesToRegistry()
}