Esme Povirk (@madewokherd) commented about dlls/uiautomationcore/uia_event.c:
+void uia_event_thread_set_win_event_callback(UiaWineWinEventCallback *cback) +{
- if (cback && !uia_start_event_thread())
- {
WARN("Failed to start UIA event thread\n");
return;
- }
- EnterCriticalSection(&event_thread_cs);
- event_thread.win_event_callback = cback;
- LeaveCriticalSection(&event_thread_cs);
- if (!cback)
uia_stop_event_thread();
+}
This seems either broken or unnecessarily complicated to me.
If this will only ever be used for that one specific function in the com client code, it seems to me it'd be simpler to always call that function and let it return immediately if it has nothing to do.
In the case of multiple users: If this is ever changed from non-NULL to a different non-NULL value, or from NULL to NULL, the reference counting will be wrong. It's also not possible to two callbacks to exist simultaneously.