Skip to content

fix: preserve shortcut and window hook callback lifetimes - #82

Merged
lijy91 merged 1 commit into
libnativeapi:mainfrom
szymonmazanik:fix-callback-lifetimes
Sep 25, 2026
Merged

lijy91 merged 1 commit into
libnativeapi:mainfrom
szymonmazanik:fix-callback-lifetimes

Conversation

@szymonmazanik

@szymonmazanik szymonmazanik commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Unregistering a shortcut leaves its callback attached to retained handles. Callbacks and window hooks can also destroy their own captured state when they replace or clear themselves during invocation.

Clear shortcut callbacks after successful unregister, outside the manager mutex, and invoke a local copy of shortcut callbacks and desktop window hooks. The C ABI is unchanged.

Added regression tests for callback replacement, hook removal, and retained shortcuts after unregister.

Clear shortcut callbacks after successful unregistration, outside the
manager mutex. Retained handles can no longer invoke stale callbacks.

Keep a local copy while invoking shortcuts and desktop window hooks so
self-replacement or removal does not destroy executing captures.

Add CTest coverage for self-replacement, hook removal, and retained handles.
@lijy91
lijy91 merged commit e723f31 into libnativeapi:main Sep 25, 2026
lijy91 added a commit to libnativeapi/nativeapi that referenced this pull request Sep 25, 2026
…ters global shortcuts

Merges libnativeapi/nativeapi-core#82 and the follow-ups: shortcut callbacks are guarded across threads, and Windows registers hotkeys on the thread that owns its message window, so global shortcuts work there at all.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants