Bug 29920 - Make a copy of listeners array before dispatching an event
Summary: Make a copy of listeners array before dispatching an event
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Inspector (Deprecated) (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Yury Semikhatsky
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-09-30 05:56 PDT by Yury Semikhatsky
Modified: 2009-10-01 06:17 PDT (History)
3 users (show)

See Also:


Attachments
patch (1.60 KB, patch)
2009-09-30 06:05 PDT, Yury Semikhatsky
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Yury Semikhatsky 2009-09-30 05:56:19 PDT
Make a copy of listeners array before dispatching an event in WebInspector.Object.prototype.dispatchEventToListeners. Otherwise if current listener removes itself from the array next listener will be skipped.
Comment 1 Yury Semikhatsky 2009-09-30 06:05:24 PDT
Created attachment 40366 [details]
patch
Comment 2 Timothy Hatcher 2009-09-30 09:18:45 PDT
Comment on attachment 40366 [details]
patch

Why did you remove the bind calls?

Those are needed to pass the event as the this object.
Comment 3 Patrick Mueller 2009-09-30 11:43:23 PDT
Looks like the bind() should be on preventDefault, but not on stopPropagation.  Not harmful on stopPropagation, but it's not needed, and otherwise creates a new function closure for no good reason.
Comment 4 Yury Semikhatsky 2009-09-30 23:48:07 PDT
(In reply to comment #2)
> (From update of attachment 40366 [details])
> Why did you remove the bind calls?
> 
> Those are needed to pass the event as the this object.

There is no need to bind the functions to event since 'this' variable will be resolved dynamically and as long as preventDefault and stopPropagation are invoked on 'event' 'this' object will be === 'event'. Please tell me if you still want me to revert the changes.
Comment 5 WebKit Commit Bot 2009-10-01 06:17:12 PDT
Comment on attachment 40366 [details]
patch

Clearing flags on attachment: 40366

Committed r48970: <http://trac.webkit.org/changeset/48970>
Comment 6 WebKit Commit Bot 2009-10-01 06:17:16 PDT
All reviewed patches have been landed.  Closing bug.