mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-10 12:39:58 +08:00
avoid deadlock on win
This commit is contained in:
parent
5dc7bd97f2
commit
be1da68dbc
@ -16,6 +16,8 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
|
"github.com/wailsapp/wails/v3/pkg/application"
|
||||||
)
|
)
|
||||||
|
|
||||||
type notificationImpl interface {
|
type notificationImpl interface {
|
||||||
@ -133,7 +135,7 @@ func (ns *Service) handleNotificationResult(result NotificationResult) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ServiceStartup is called when the service is loaded
|
// 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)
|
return ns.impl.Startup(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,6 +78,7 @@ func New() *Service {
|
|||||||
impl: impl,
|
impl: impl,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
return NotificationService
|
return NotificationService
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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.
|
// Registering a category with the same name as a previously registered NotificationCategory will override it.
|
||||||
func (wn *windowsNotifier) RegisterNotificationCategory(category NotificationCategory) error {
|
func (wn *windowsNotifier) RegisterNotificationCategory(category NotificationCategory) error {
|
||||||
wn.categoriesLock.Lock()
|
wn.categoriesLock.Lock()
|
||||||
defer wn.categoriesLock.Unlock()
|
|
||||||
|
|
||||||
wn.categories[category.ID] = NotificationCategory{
|
wn.categories[category.ID] = NotificationCategory{
|
||||||
ID: category.ID,
|
ID: category.ID,
|
||||||
Actions: category.Actions,
|
Actions: category.Actions,
|
||||||
@ -218,6 +216,7 @@ func (wn *windowsNotifier) RegisterNotificationCategory(category NotificationCat
|
|||||||
ReplyPlaceholder: category.ReplyPlaceholder,
|
ReplyPlaceholder: category.ReplyPlaceholder,
|
||||||
ReplyButtonTitle: category.ReplyButtonTitle,
|
ReplyButtonTitle: category.ReplyButtonTitle,
|
||||||
}
|
}
|
||||||
|
wn.categoriesLock.Unlock()
|
||||||
|
|
||||||
return wn.saveCategoriesToRegistry()
|
return wn.saveCategoriesToRegistry()
|
||||||
}
|
}
|
||||||
@ -225,9 +224,8 @@ func (wn *windowsNotifier) RegisterNotificationCategory(category NotificationCat
|
|||||||
// RemoveNotificationCategory removes a previously registered NotificationCategory.
|
// RemoveNotificationCategory removes a previously registered NotificationCategory.
|
||||||
func (wn *windowsNotifier) RemoveNotificationCategory(categoryId string) error {
|
func (wn *windowsNotifier) RemoveNotificationCategory(categoryId string) error {
|
||||||
wn.categoriesLock.Lock()
|
wn.categoriesLock.Lock()
|
||||||
defer wn.categoriesLock.Unlock()
|
|
||||||
|
|
||||||
delete(wn.categories, categoryId)
|
delete(wn.categories, categoryId)
|
||||||
|
wn.categoriesLock.Unlock()
|
||||||
|
|
||||||
return wn.saveCategoriesToRegistry()
|
return wn.saveCategoriesToRegistry()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user