go-toast

Send toast notifications in Windows
Log | Files | Refs | README | LICENSE

commit d5f241d934b73b6fd4b2175d144a22fcc6f86782
parent 9ca375ab4b2f8269b4990567941508883863ed09
Author: Jack Mordaunt <jackmordaunt.dev@gmail.com>
Date:   Fri,  4 Oct 2024 04:05:45 -0400

wintoast.pushCOM: release all COM objects

Diffstat:
Mwintoast/bind_windows.go | 10++++++++++
1 file changed, 10 insertions(+), 0 deletions(-)

diff --git a/wintoast/bind_windows.go b/wintoast/bind_windows.go @@ -10,6 +10,8 @@ import ( "os/exec" "sync/atomic" "syscall" + "unicode/utf16" + "unicode/utf8" "unsafe" "git.sr.ht/~jackmordaunt/go-toast/internal/winrt/data/xml/dom" @@ -72,6 +74,8 @@ func pushCOM(xml string) error { return fmt.Errorf("dom.NewXmlDocument(): %w", err) } + defer doc.Release() + if err := doc.LoadXml(xml); err != nil { return fmt.Errorf("doc.LoadXml(tmpl): %w", err) } @@ -81,16 +85,22 @@ func pushCOM(xml string) error { return fmt.Errorf("notifications.GetDefault(): %w", err) } + defer manager.Release() + notifier, err := manager.CreateToastNotifierWithId(appData.AppID) if err != nil { return fmt.Errorf("manager.CreateToastNotifier(%q): %w", appData.AppID, err) } + defer notifier.Release() + toast, err := notifications.CreateToastNotification(doc) if err != nil { return fmt.Errorf("notifications.CreateToastNotification(doc): %w", err) } + defer toast.Release() + if err := notifier.Show(toast); err != nil { return fmt.Errorf("notifier.Show(): %w", err) }