Skip to content

windows: fix post_to_ui_thread() posting to the calling thread's queue - #40

Merged
igagis merged 1 commit into
cppfw:mainfrom
igagis-bot:fix-windows-post-to-ui-thread
Nov 26, 2026
Merged

igagis merged 1 commit into
cppfw:mainfrom
igagis-bot:fix-windows-post-to-ui-thread

Conversation

@igagis-bot

Copy link
Copy Markdown
Contributor

Fixes #39.

application_glue::post_to_ui_thread() used PostMessage(NULL, WM_USER, ...). With a NULL window handle, PostMessage() posts to the message queue of the calling thread, so procedures posted from other threads (e.g. ruisapp::probe_server::push_commands() calling ruisapp::inst().poke() from the probe server's connection thread) were never executed on the UI thread.

The fix captures the UI thread id in the application_glue constructor (the glue is created on the UI thread, in winmain) and uses PostThreadMessage(ui_thread_id, WM_USER, ...) instead.

Verified locally on Windows (ruisapp-opengl-test with probe server, app sitting idle with no input):

  • run{get_windows} now returns response{get_windows{windows_count{1}}} (previously no response at all)
  • run{quit} returns response{quit{ok}} and the app exits cleanly (previously the batch sat in the probe server's exec_list until a real input event arrived, and a second connection in the meantime tripped the exec_list.empty() assert)

@igagis
igagis merged commit 71c8bbc into cppfw:main Nov 26, 2026
21 checks passed
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.

windows: post_to_ui_thread() posts the message to the calling thread's queue, not the UI thread's

2 participants