Closed Bug 232854 Opened 21 years ago Closed 21 years ago

XULDocument.RemoveBroadcastListenerFor does not remove the observer

Categories

(Core :: XUL, defect)

x86
Windows XP
defect
Not set
major

Tracking

()

RESOLVED FIXED

People

(Reporter: phnixwxz1, Assigned: tingley)

Details

Attachments

(1 file)

User-Agent: Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.4) Gecko/20030624 Whenver XULDocument.RemoveBroadcastListenerFor is called with correct arguments, it will return NS_OK, but the observer is not removed. 964 for (PRInt32 i = entry->mListeners.Count() - 1; i >= 0; --i) { 965 BroadcastListener* bl = 966 NS_STATIC_CAST(BroadcastListener*, entry->mListeners[i]); 967 968 if ((bl->mListener == aListener) && (bl->mAttribute == attr)) { 969 entry->mListeners.RemoveElement(aListener); 970 971 if (entry->mListeners.Count() == 0) 972 PL_DHashTableOperate(mBroadcasterMap, aBroadcaster, 973 PL_DHASH_REMOVE); 974 975 SynchronizeBroadcastListener(aBroadcaster, aListener, aAttr); 976 977 break; 978 } 979 } The problem is caused by line 969, because the entries in entry->mListeners are of type BroadcastListener. '...RemoveElement(aListener)' does nothing. This may cause crash if the listener element is removed from the document, and GC'ed by Javascript. Reproducible: Always Steps to Reproduce:
Summary: XULDocument.RemoveBroadcastListenerFor doesnot remove the observer → XULDocument.RemoveBroadcastListenerFor does not remove the observer
Yup, this should be |RemoveElement(bl)| -> XUL
Assignee: general → hyatt
Status: UNCONFIRMED → NEW
Component: DOM: Mozilla Extensions → XP Toolkit/Widgets: XUL
Ever confirmed: true
QA Contact: ian → shrir
Post a patch? hyatt is not likely to....
Attached patch patchSplinter Review
Actually, RemoveElement(i) would be even better...
Assignee: hyatt → tingley
Status: NEW → ASSIGNED
Attachment #140475 - Flags: review?(varga)
Comment on attachment 140475 [details] [diff] [review] patch r=varga
Attachment #140475 - Flags: review?(varga) → review+
Comment on attachment 140475 [details] [diff] [review] patch sr=bzbarsky
Attachment #140475 - Flags: superreview+
Fix checked in.
Status: ASSIGNED → RESOLVED
Closed: 21 years ago
Resolution: --- → FIXED
Component: XP Toolkit/Widgets: XUL → XUL
QA Contact: shrir → xptoolkit.widgets
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: