Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions src/ruisapp/glue/windows/application.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,11 @@ application_glue::application_glue(const utki::version_duplet& gl_version) :
),
ruis_style_provider( //
utki::make_shared<ruis::style_provider>(this->ruis_resource_loader)
)
),
// the glue is created on the UI thread (the thread running the main loop);
// post_to_ui_thread() uses this id to post procedures to the UI thread's
// message queue
ui_thread_id(::GetCurrentThreadId())
{}

void application_glue::render()
Expand All @@ -158,15 +162,15 @@ void application_glue::render()
void application_glue::post_to_ui_thread(std::function<void()> procedure)
{
if ( //
PostMessage( //
NULL, // post message to UI thread's message queue
PostThreadMessage( //
this->ui_thread_id, // post message to the UI thread's message queue
WM_USER,
0, // no wParam
// NOLINTNEXTLINE(cppcoreguidelines-owning-memory, cppcoreguidelines-pro-type-reinterpret-cast)
reinterpret_cast<LPARAM>(new std::function<void()>(std::move(procedure)))
) == 0)
{
throw std::runtime_error("PostMessage(): failed");
throw std::runtime_error("PostThreadMessage(): failed");
}
}

Expand Down
5 changes: 5 additions & 0 deletions src/ruisapp/glue/windows/application.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,11 @@ private:
public:
std::atomic_bool quit_flag = false;

// the id of the UI thread (the thread that created the glue and runs the
// main loop); post_to_ui_thread() uses it to post procedures to the UI
// thread's message queue
const DWORD ui_thread_id;

const utki::shared_ref<ruis::updater> updater = utki::make_shared<ruis::updater>();

std::vector<utki::shared_ref<app_window>> windows_to_destroy;
Expand Down
Loading