diff --git a/channels/rdpgfx/client/rdpgfx_main.c b/channels/rdpgfx/client/rdpgfx_main.c index 26b29d1b2..0c42b5932 100644 --- a/channels/rdpgfx/client/rdpgfx_main.c +++ b/channels/rdpgfx/client/rdpgfx_main.c @@ -592,12 +592,14 @@ static UINT rdpgfx_recv_reset_graphics_pdu(GENERIC_CHANNEL_CALLBACK* callback, w error); } + free(pdu.monitorDefArray); + /* some listeners may be interested (namely the display channel) */ EventArgsInit(&graphicsReset, "libfreerdp"); graphicsReset.width = pdu.width; graphicsReset.height = pdu.height; - PubSub_OnGraphicsReset(gfx->rdpcontext->pubSub, gfx->rdpcontext, &graphicsReset); - free(pdu.monitorDefArray); + if (PubSub_OnGraphicsReset(gfx->rdpcontext->pubSub, gfx->rdpcontext, &graphicsReset) < 0) + return ERROR_INTERNAL_ERROR; return error; } diff --git a/client/Mac/MRDPView.m b/client/Mac/MRDPView.m index 2d9a20d5c..e82f50b9c 100644 --- a/client/Mac/MRDPView.m +++ b/client/Mac/MRDPView.m @@ -91,7 +91,9 @@ static CGContextRef mac_create_bitmap_context(rdpContext *context); EventArgsInit(&e, "mfreerdp"); e.embed = TRUE; e.handle = (void *)self; - PubSub_OnEmbedWindow(context->pubSub, context, &e); + if (PubSub_OnEmbedWindow(context->pubSub, context, &e) < 0) + return -1; + NSScreen *screen = [[NSScreen screens] objectAtIndex:0]; NSRect screenFrame = [screen frame]; @@ -1495,7 +1497,8 @@ BOOL mac_desktop_resize(rdpContext *context) EventArgsInit(&e, "mfreerdp"); e.width = freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth); e.height = freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight); - PubSub_OnResizeWindow(context->pubSub, context, &e); + if (PubSub_OnResizeWindow(context->pubSub, context, &e) < 0) + return FALSE; return TRUE; } diff --git a/client/Windows/wf_client.c b/client/Windows/wf_client.c index e2459b9d6..6ea87c84b 100644 --- a/client/Windows/wf_client.c +++ b/client/Windows/wf_client.c @@ -477,7 +477,9 @@ static BOOL wf_post_connect(freerdp* instance) EventArgsInit(&e, "wfreerdp"); e.embed = FALSE; e.handle = (void*)wfc->hwnd; - PubSub_OnEmbedWindow(context->pubSub, context, &e); + if (PubSub_OnEmbedWindow(context->pubSub, context, &e) < 0) + return FALSE; + #ifdef WITH_PROGRESS_BAR if (wfc->taskBarList) { diff --git a/client/Windows/wf_event.c b/client/Windows/wf_event.c index ed0fc3840..0bda81c38 100644 --- a/client/Windows/wf_event.c +++ b/client/Windows/wf_event.c @@ -927,8 +927,7 @@ static BOOL wf_pub_mouse_event(wfContext* wfc, UINT16 flags, UINT16 x, UINT16 y) eventArgs.flags = flags; eventArgs.x = x; eventArgs.y = y; - PubSub_OnMouseEvent(wfc->common.context.pubSub, &wfc->common.context, &eventArgs); - return TRUE; + return PubSub_OnMouseEvent(wfc->common.context.pubSub, &wfc->common.context, &eventArgs) >= 0; } static BOOL wf_scale_mouse_event(wfContext* wfc, UINT16 flags, INT32 x, INT32 y) diff --git a/client/X11/xf_client.c b/client/X11/xf_client.c index 17d4e21ce..e4cf2be68 100644 --- a/client/X11/xf_client.c +++ b/client/X11/xf_client.c @@ -826,7 +826,10 @@ void xf_toggle_fullscreen(xfContext* xfc) xf_SetWindowFullscreen(xfc, xfc->window, xfc->fullscreen); EventArgsInit(&e, "xfreerdp"); e.state = xfc->fullscreen ? FREERDP_WINDOW_STATE_FULLSCREEN : 0; - PubSub_OnWindowStateChange(context->pubSub, context, &e); + if (PubSub_OnWindowStateChange(context->pubSub, context, &e) < 0) + { + WLog_Print(xfc->log, WLOG_ERROR, "PubSub_OnWindowStateChange failed"); + } } void xf_minimize(xfContext* xfc) @@ -845,7 +848,10 @@ void xf_minimize(xfContext* xfc) xf_SetWindowMinimized(xfc, xfc->window); e.state = xfc->fullscreen ? FREERDP_WINDOW_STATE_FULLSCREEN : 0; - PubSub_OnWindowStateChange(context->pubSub, context, &e); + if (PubSub_OnWindowStateChange(context->pubSub, context, &e) < 0) + { + WLog_Print(xfc->log, WLOG_ERROR, "PubSub_OnWindowStateChange failed"); + } } void xf_lock_x11_(xfContext* xfc, WINPR_ATTR_UNUSED const char* fkt) @@ -1471,8 +1477,7 @@ static BOOL xf_post_connect(freerdp* instance) WINPR_ASSERTING_INT_CAST(int, freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth)); e.height = WINPR_ASSERTING_INT_CAST(int, freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight)); - PubSub_OnResizeWindow(context->pubSub, xfc, &e); - return TRUE; + return PubSub_OnResizeWindow(context->pubSub, xfc, &e) >= 0; } static void xf_post_disconnect(freerdp* instance) diff --git a/client/X11/xf_event.c b/client/X11/xf_event.c index 1a05b42a9..833b07cb9 100644 --- a/client/X11/xf_event.c +++ b/client/X11/xf_event.c @@ -1369,7 +1369,10 @@ BOOL xf_event_process(freerdp* instance, const XEvent* event) xf_cliprdr_handle_xevent(xfc, event); if (!xf_floatbar_check_event(floatbar, event) && !xf_floatbar_is_locked(floatbar)) - xf_input_handle_event(xfc, event); + { + if (xf_input_handle_event(xfc, event) < 0) + return FALSE; + } LogDynAndXSync(xfc->log, xfc->display, FALSE); return status; diff --git a/client/X11/xf_input.c b/client/X11/xf_input.c index dba6e0f5f..297b9ecd9 100644 --- a/client/X11/xf_input.c +++ b/client/X11/xf_input.c @@ -321,7 +321,8 @@ static void xf_input_save_last_event(xfContext* xfc, const XGenericEventCookie* xfc->lastEvent.event_y = event->event_y; } -static void xf_input_detect_pan(xfContext* xfc) +WINPR_ATTR_NODISCARD +static BOOL xf_input_detect_pan(xfContext* xfc) { WINPR_ASSERT(xfc); rdpContext* ctx = &xfc->common.context; @@ -329,7 +330,7 @@ static void xf_input_detect_pan(xfContext* xfc) if (xfc->active_contacts != 2) { - return; + return TRUE; } const double dx[] = { xfc->contacts[0].pos_x - xfc->contacts[0].last_x, @@ -352,7 +353,8 @@ static void xf_input_detect_pan(xfContext* xfc) EventArgsInit(&e, "xfreerdp"); e.dx = 5; e.dy = 0; - PubSub_OnPanningChange(ctx->pubSub, xfc, &e); + if (PubSub_OnPanningChange(ctx->pubSub, xfc, &e) < 0) + return FALSE; } xfc->px_vector = 0; xfc->py_vector = 0; @@ -365,7 +367,8 @@ static void xf_input_detect_pan(xfContext* xfc) EventArgsInit(&e, "xfreerdp"); e.dx = -5; e.dy = 0; - PubSub_OnPanningChange(ctx->pubSub, xfc, &e); + if (PubSub_OnPanningChange(ctx->pubSub, xfc, &e) < 0) + return FALSE; } xfc->px_vector = 0; xfc->py_vector = 0; @@ -382,7 +385,8 @@ static void xf_input_detect_pan(xfContext* xfc) EventArgsInit(&e, "xfreerdp"); e.dx = 0; e.dy = 5; - PubSub_OnPanningChange(ctx->pubSub, xfc, &e); + if (PubSub_OnPanningChange(ctx->pubSub, xfc, &e) < 0) + return FALSE; } xfc->py_vector = 0; xfc->px_vector = 0; @@ -395,16 +399,19 @@ static void xf_input_detect_pan(xfContext* xfc) EventArgsInit(&e, "xfreerdp"); e.dx = 0; e.dy = -5; - PubSub_OnPanningChange(ctx->pubSub, xfc, &e); + if (PubSub_OnPanningChange(ctx->pubSub, xfc, &e) < 0) + return FALSE; } xfc->py_vector = 0; xfc->px_vector = 0; xfc->z_vector = 0; } } + return TRUE; } -static void xf_input_detect_pinch(xfContext* xfc) +WINPR_ATTR_NODISCARD +static BOOL xf_input_detect_pinch(xfContext* xfc) { ZoomingChangeEventArgs e = WINPR_C_ARRAY_INIT; @@ -415,7 +422,7 @@ static void xf_input_detect_pinch(xfContext* xfc) if (xfc->active_contacts != 2) { xfc->firstDist = -1.0; - return; + return TRUE; } /* first calculate the distance */ @@ -449,7 +456,8 @@ static void xf_input_detect_pinch(xfContext* xfc) { EventArgsInit(&e, "xfreerdp"); e.dx = e.dy = -10; - PubSub_OnZoomingChange(ctx->pubSub, xfc, &e); + if (PubSub_OnZoomingChange(ctx->pubSub, xfc, &e) < 0) + return FALSE; xfc->z_vector = 0; xfc->px_vector = 0; xfc->py_vector = 0; @@ -459,12 +467,14 @@ static void xf_input_detect_pinch(xfContext* xfc) { EventArgsInit(&e, "xfreerdp"); e.dx = e.dy = 10; - PubSub_OnZoomingChange(ctx->pubSub, xfc, &e); + if (PubSub_OnZoomingChange(ctx->pubSub, xfc, &e) < 0) + return FALSE; xfc->z_vector = 0; xfc->px_vector = 0; xfc->py_vector = 0; } } + return TRUE; } static void xf_input_touch_begin(xfContext* xfc, const XIDeviceEvent* event) @@ -484,7 +494,8 @@ static void xf_input_touch_begin(xfContext* xfc, const XIDeviceEvent* event) } } -static void xf_input_touch_update(xfContext* xfc, const XIDeviceEvent* event) +WINPR_ATTR_NODISCARD +static BOOL xf_input_touch_update(xfContext* xfc, const XIDeviceEvent* event) { WINPR_ASSERT(xfc); WINPR_ASSERT(event); @@ -498,11 +509,15 @@ static void xf_input_touch_update(xfContext* xfc, const XIDeviceEvent* event) xfc->contacts[i].last_y = xfc->contacts[i].pos_y; xfc->contacts[i].pos_x = event->event_x; xfc->contacts[i].pos_y = event->event_y; - xf_input_detect_pinch(xfc); - xf_input_detect_pan(xfc); + if (!xf_input_detect_pinch(xfc)) + return FALSE; + if (!xf_input_detect_pan(xfc)) + return FALSE; break; } } + + return TRUE; } static void xf_input_touch_end(xfContext* xfc, const XIDeviceEvent* event) @@ -543,7 +558,10 @@ static int xf_input_handle_event_local(xfContext* xfc, const XEvent* event) case XI_TouchUpdate: if (xf_input_is_duplicate(xfc, cookie.cc) == FALSE) - xf_input_touch_update(xfc, cookie.cc->data); + { + if (!xf_input_touch_update(xfc, cookie.cc->data)) + return -1; + } xf_input_save_last_event(xfc, cookie.cc); break; diff --git a/client/X11/xf_input.h b/client/X11/xf_input.h index 49a8e1959..1b342a2b6 100644 --- a/client/X11/xf_input.h +++ b/client/X11/xf_input.h @@ -27,8 +27,13 @@ #include #endif +WINPR_ATTR_NODISCARD int xf_input_init(xfContext* xfc, Window window); + +WINPR_ATTR_NODISCARD int xf_input_handle_event(xfContext* xfc, const XEvent* event); + +WINPR_ATTR_NODISCARD bool xf_use_rel_mouse(xfContext* xfc); #endif /* FREERDP_CLIENT_X11_INPUT_H */ diff --git a/client/X11/xf_keyboard.c b/client/X11/xf_keyboard.c index e88c6ab58..86a21c221 100644 --- a/client/X11/xf_keyboard.c +++ b/client/X11/xf_keyboard.c @@ -1466,7 +1466,8 @@ BOOL xf_keyboard_handle_special_keys(xfContext* xfc, KeySym keysym) EventArgsInit(&e, "xfreerdp"); e.dx = pdx; e.dy = pdy; - PubSub_OnPanningChange(ctx->pubSub, xfc, &e); + if (PubSub_OnPanningChange(ctx->pubSub, xfc, &e)<0) + return FALSE; return TRUE; } @@ -1476,7 +1477,8 @@ BOOL xf_keyboard_handle_special_keys(xfContext* xfc, KeySym keysym) EventArgsInit(&e, "xfreerdp"); e.dx = zdx; e.dy = zdy; - PubSub_OnZoomingChange(ctx->pubSub, xfc, &e); + if (PubSub_OnZoomingChange(ctx->pubSub, xfc, &e)<0) + return FALSE; return TRUE; } } diff --git a/libfreerdp/core/client.c b/libfreerdp/core/client.c index 1dfacd460..0e695f5fe 100644 --- a/libfreerdp/core/client.c +++ b/libfreerdp/core/client.c @@ -223,12 +223,21 @@ static UINT freerdp_drdynvc_on_channel_connected(DrdynvcClientContext* context, { UINT status = CHANNEL_RC_OK; ChannelConnectedEventArgs e = WINPR_C_ARRAY_INIT; + + WINPR_ASSERT(context); + rdpChannels* channels = (rdpChannels*)context->custom; + WINPR_ASSERT(channels); + freerdp* instance = channels->instance; + WINPR_ASSERT(instance); + WINPR_ASSERT(instance->context); + EventArgsInit(&e, "freerdp"); e.name = name; e.pInterface = pInterface; - PubSub_OnChannelConnected(instance->context->pubSub, instance->context, &e); + if (PubSub_OnChannelConnected(instance->context->pubSub, instance->context, &e) < 0) + return ERROR_INTERNAL_ERROR; return status; } @@ -242,12 +251,20 @@ static UINT freerdp_drdynvc_on_channel_disconnected(DrdynvcClientContext* contex { UINT status = CHANNEL_RC_OK; ChannelDisconnectedEventArgs e = WINPR_C_ARRAY_INIT; + + WINPR_ASSERT(context); rdpChannels* channels = (rdpChannels*)context->custom; + WINPR_ASSERT(channels); + freerdp* instance = channels->instance; + WINPR_ASSERT(instance); + WINPR_ASSERT(instance->context); + EventArgsInit(&e, "freerdp"); e.name = name; e.pInterface = pInterface; - PubSub_OnChannelDisconnected(instance->context->pubSub, instance->context, &e); + if (PubSub_OnChannelDisconnected(instance->context->pubSub, instance->context, &e) < 0) + return ERROR_INTERNAL_ERROR; return status; } @@ -256,12 +273,20 @@ static UINT freerdp_drdynvc_on_channel_attached(DrdynvcClientContext* context, c { UINT status = CHANNEL_RC_OK; ChannelAttachedEventArgs e = WINPR_C_ARRAY_INIT; + + WINPR_ASSERT(context); rdpChannels* channels = (rdpChannels*)context->custom; + WINPR_ASSERT(channels); + freerdp* instance = channels->instance; + WINPR_ASSERT(instance); + WINPR_ASSERT(instance->context); + EventArgsInit(&e, "freerdp"); e.name = name; e.pInterface = pInterface; - PubSub_OnChannelAttached(instance->context->pubSub, instance->context, &e); + if (PubSub_OnChannelAttached(instance->context->pubSub, instance->context, &e) < 0) + return ERROR_INTERNAL_ERROR; return status; } @@ -270,12 +295,20 @@ static UINT freerdp_drdynvc_on_channel_detached(DrdynvcClientContext* context, c { UINT status = CHANNEL_RC_OK; ChannelDetachedEventArgs e = WINPR_C_ARRAY_INIT; + + WINPR_ASSERT(context); rdpChannels* channels = (rdpChannels*)context->custom; + WINPR_ASSERT(channels); + freerdp* instance = channels->instance; + WINPR_ASSERT(instance); + WINPR_ASSERT(instance->context); + EventArgsInit(&e, "freerdp"); e.name = name; e.pInterface = pInterface; - PubSub_OnChannelDetached(instance->context->pubSub, instance->context, &e); + if (PubSub_OnChannelDetached(instance->context->pubSub, instance->context, &e) < 0) + return ERROR_INTERNAL_ERROR; return status; } @@ -363,14 +396,19 @@ UINT freerdp_channels_attach(freerdp* instance) CHANNEL_EVENT_ATTACHED, cnv.pv, (UINT)hostnameLength); } - if (getChannelError(instance->context) != CHANNEL_RC_OK) + error = getChannelError(instance->context); + if (error != CHANNEL_RC_OK) goto fail; pChannelOpenData = &channels->openDataList[index]; EventArgsInit(&e, "freerdp"); e.name = pChannelOpenData->name; e.pInterface = pChannelOpenData->pInterface; - PubSub_OnChannelAttached(instance->context->pubSub, instance->context, &e); + if (PubSub_OnChannelAttached(instance->context->pubSub, instance->context, &e) < 0) + { + error = ERROR_INTERNAL_ERROR; + goto fail; + } } fail: @@ -426,14 +464,19 @@ UINT freerdp_channels_detach(freerdp* instance) CHANNEL_EVENT_DETACHED, cnv.pv, (UINT)hostnameLength); } - if (getChannelError(context) != CHANNEL_RC_OK) + error = getChannelError(context); + if (error != CHANNEL_RC_OK) goto fail; pChannelOpenData = &channels->openDataList[index]; EventArgsInit(&e, "freerdp"); e.name = pChannelOpenData->name; e.pInterface = pChannelOpenData->pInterface; - PubSub_OnChannelDetached(context->pubSub, context, &e); + if (PubSub_OnChannelDetached(context->pubSub, context, &e) < 0) + { + error = ERROR_INTERNAL_ERROR; + goto fail; + } } fail: @@ -495,7 +538,11 @@ UINT freerdp_channels_post_connect(rdpChannels* channels, freerdp* instance) EventArgsInit(&e, "freerdp"); e.name = pChannelOpenData->name; e.pInterface = pChannelOpenData->pInterface; - PubSub_OnChannelConnected(instance->context->pubSub, instance->context, &e); + if (PubSub_OnChannelConnected(instance->context->pubSub, instance->context, &e) < 0) + { + error = ERROR_INTERNAL_ERROR; + goto fail; + } } channels->drdynvc = (DrdynvcClientContext*)freerdp_channels_get_static_channel_interface( @@ -889,7 +936,8 @@ UINT freerdp_channels_disconnect(rdpChannels* channels, freerdp* instance) EventArgsInit(&e, "freerdp"); e.name = pChannelOpenData->name; e.pInterface = pChannelOpenData->pInterface; - PubSub_OnChannelDisconnected(instance->context->pubSub, instance->context, &e); + if (PubSub_OnChannelDisconnected(instance->context->pubSub, instance->context, &e) < 0) + error = ERROR_INTERNAL_ERROR; } channels->connected = FALSE; diff --git a/libfreerdp/core/connection.c b/libfreerdp/core/connection.c index 3a8032e49..c71325017 100644 --- a/libfreerdp/core/connection.c +++ b/libfreerdp/core/connection.c @@ -1419,7 +1419,8 @@ BOOL rdp_client_transition_to_state(rdpRdp* rdp, CONNECTION_STATE state) EventArgsInit(&activatedEvent, "libfreerdp"); activatedEvent.firstActivation = !rdp_finalize_is_flag_set(rdp, FINALIZE_DEACTIVATE_REACTIVATE); - PubSub_OnActivated(rdp->pubSub, context, &activatedEvent); + if (PubSub_OnActivated(rdp->pubSub, context, &activatedEvent) < 0) + return FALSE; } break; @@ -1434,7 +1435,8 @@ BOOL rdp_client_transition_to_state(rdpRdp* rdp, CONNECTION_STATE state) EventArgsInit(&stateEvent, "libfreerdp"); stateEvent.state = WINPR_ASSERTING_INT_CAST(int32_t, rdp_get_state(rdp)); stateEvent.active = rdp_is_active_state(rdp); - PubSub_OnConnectionStateChange(rdp->pubSub, context, &stateEvent); + if (PubSub_OnConnectionStateChange(rdp->pubSub, context, &stateEvent) < 0) + return FALSE; } return TRUE; diff --git a/libfreerdp/core/freerdp.c b/libfreerdp/core/freerdp.c index 2e4fe80b8..7367e8e5f 100644 --- a/libfreerdp/core/freerdp.c +++ b/libfreerdp/core/freerdp.c @@ -303,7 +303,8 @@ BOOL freerdp_connect(freerdp* instance) freerdp_connect_finally: EventArgsInit(&e, "freerdp"); e.result = status ? 0 : -1; - PubSub_OnConnectionResult(rdp->pubSub, instance->context, &e); + if (PubSub_OnConnectionResult(rdp->pubSub, instance->context, &e) < 0) + return FALSE; if (!status) freerdp_disconnect(instance); @@ -373,7 +374,8 @@ BOOL freerdp_check_fds(freerdp* instance) WLog_Print(context->log, WLOG_DEBUG, "rdp_check_fds() - %i", status); EventArgsInit(&e, "freerdp"); e.code = 0; - PubSub_OnTerminate(rdp->pubSub, context, &e); + if (PubSub_OnTerminate(rdp->pubSub, context, &e) < 0) + return FALSE; return FALSE; } diff --git a/libfreerdp/core/gateway/rpc_client.c b/libfreerdp/core/gateway/rpc_client.c index bb807e250..27f3614f1 100644 --- a/libfreerdp/core/gateway/rpc_client.c +++ b/libfreerdp/core/gateway/rpc_client.c @@ -432,8 +432,7 @@ static int rpc_client_recv_fragment(rdpRpc* rpc, wStream* fragment) tsg_set_state(tsg, TSG_STATE_TUNNEL_CLOSE_PENDING); EventArgsInit(&e, "freerdp"); e.code = 0; - PubSub_OnTerminate(context->rdp->pubSub, context, &e); - rc = 0; + rc = PubSub_OnTerminate(context->rdp->pubSub, context, &e) >= 0 ? 0 : -1; goto success; } diff --git a/libfreerdp/core/rdp.c b/libfreerdp/core/rdp.c index 98213985f..9f8591dd4 100644 --- a/libfreerdp/core/rdp.c +++ b/libfreerdp/core/rdp.c @@ -641,8 +641,7 @@ BOOL rdp_read_header(rdpRdp* rdp, wStream* s, UINT16* length, UINT16* channelId) utils_abort_connect(rdp); EventArgsInit(&e, "freerdp"); e.code = 0; - PubSub_OnTerminate(rdp->pubSub, context, &e); - return TRUE; + return PubSub_OnTerminate(rdp->pubSub, context, &e) >= 0; } if (!Stream_CheckAndLogRequiredLengthWLog(rdp->log, s, 5)) diff --git a/winpr/libwinpr/utils/collections/PubSub.c b/winpr/libwinpr/utils/collections/PubSub.c index d96b0b21a..8934a166c 100644 --- a/winpr/libwinpr/utils/collections/PubSub.c +++ b/winpr/libwinpr/utils/collections/PubSub.c @@ -23,6 +23,9 @@ #include +#include "../log.h" +#define TAG WINPR_TAG("pubsub") + /** * Events (C# Programming Guide) * http://msdn.microsoft.com/en-us/library/awbftdfh.aspx @@ -196,25 +199,23 @@ int PubSub_Unsubscribe(wPubSub* pubSub, const char* EventName, ...) int PubSub_OnEvent(wPubSub* pubSub, const char* EventName, void* context, const wEventArgs* e) { - wEventType* event = nullptr; - int status = -1; + WINPR_ASSERT(pubSub); + WINPR_ASSERT(EventName); + WINPR_ASSERT(e); if (!pubSub) + { + WLog_ERR(TAG, "pubSub(%s)=nullptr!", EventName); return -1; - WINPR_ASSERT(e); + } if (pubSub->synchronized) PubSub_Lock(pubSub); - event = PubSub_FindEventType(pubSub, EventName); - - if (pubSub->synchronized) - PubSub_Unlock(pubSub); - + int status = 0; + wEventType* event = PubSub_FindEventType(pubSub, EventName); if (event) { - status = 0; - for (size_t index = 0; index < event->EventHandlerCount; index++) { if (event->EventHandlers[index]) @@ -224,6 +225,8 @@ int PubSub_OnEvent(wPubSub* pubSub, const char* EventName, void* context, const } } } + if (pubSub->synchronized) + PubSub_Unlock(pubSub); return status; } diff --git a/winpr/libwinpr/utils/test/TestPubSub.c b/winpr/libwinpr/utils/test/TestPubSub.c index 39ef0e01f..2ff327a26 100644 --- a/winpr/libwinpr/utils/test/TestPubSub.c +++ b/winpr/libwinpr/utils/test/TestPubSub.c @@ -55,7 +55,8 @@ int TestPubSub(int argc, char* argv[]) e.x = 64; e.y = 128; - PubSub_OnMouseMotion(node, nullptr, &e); + if (PubSub_OnMouseMotion(node, nullptr, &e) < 0) + return -1; } { @@ -66,7 +67,8 @@ int TestPubSub(int argc, char* argv[]) e.flags = 7; e.button = 1; - PubSub_OnMouseButton(node, nullptr, &e); + if (PubSub_OnMouseButton(node, nullptr, &e) < 0) + return -1; } PubSub_Free(node);