From d1ae506e4084ba3f8ec923a61e91a4d6f9d9ddc3 Mon Sep 17 00:00:00 2001 From: Hans Leidekker Date: Thu, 23 Jun 2011 09:07:48 +0200 Subject: [PATCH] msi: Don't subscribe more than once to the same control event. --- dlls/msi/events.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/dlls/msi/events.c b/dlls/msi/events.c index 88b84ff6a7c..3047d1df8aa 100644 --- a/dlls/msi/events.c +++ b/dlls/msi/events.c @@ -254,9 +254,19 @@ VOID ControlEvent_SubscribeToEvent( MSIPACKAGE *package, msi_dialog *dialog, { struct subscriber *sub; - sub = msi_alloc(sizeof (*sub)); - if( !sub ) - return; + TRACE("event %s control %s attribute %s\n", debugstr_w(event), debugstr_w(control), debugstr_w(attribute)); + + LIST_FOR_EACH_ENTRY( sub, &package->subscriptions, struct subscriber, entry ) + { + if (!strcmpiW( sub->event, event ) && + !strcmpiW( sub->control, control ) && + !strcmpiW( sub->attribute, attribute )) + { + TRACE("already subscribed\n"); + return; + }; + } + if (!(sub = msi_alloc( sizeof(*sub) ))) return; sub->dialog = dialog; sub->event = strdupW(event); sub->control = strdupW(control); @@ -264,17 +274,15 @@ VOID ControlEvent_SubscribeToEvent( MSIPACKAGE *package, msi_dialog *dialog, list_add_tail( &package->subscriptions, &sub->entry ); } -VOID ControlEvent_FireSubscribedEvent( MSIPACKAGE *package, LPCWSTR event, - MSIRECORD *rec ) +VOID ControlEvent_FireSubscribedEvent( MSIPACKAGE *package, LPCWSTR event, MSIRECORD *rec ) { struct subscriber *sub; - TRACE("Firing Event %s\n",debugstr_w(event)); + TRACE("Firing event %s\n", debugstr_w(event)); LIST_FOR_EACH_ENTRY( sub, &package->subscriptions, struct subscriber, entry ) { - if (strcmpiW( sub->event, event )) - continue; + if (strcmpiW( sub->event, event )) continue; msi_dialog_handle_event( sub->dialog, sub->control, sub->attribute, rec ); } }