Closed Bug 265289 Opened 20 years ago Closed 20 years ago

nsDocLoader comparing weakrefs

Categories

(Core :: DOM: Navigation, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: jhpedemonte, Assigned: adamlock)

Details

Attachments

(1 file)

The function nsDocLoaderImpl::GetListenerInfo compares its parameter (an
nsIWeakReference*) to a saved nsWeakPtr.  But this seems wrong to me.  The two
weakref instances come from different calls to |do_GetWeakReference|, so how
does it work if we compare them to each other?  Should we not be comparing the
referent?

For me, at least, it is causing a failure, since the weakrefs never match up,
and nsWebBrowser::RemoveWebBrowserListener() returns an error (since
nsDocLoaderImpl::RemoveProgressListener() failed).  I was able to work around
this by getting the referent for each weakref and comparing those, but I'm not
sure if that is the right solution.
That is the correct solution. Be sure that you get the referent as nsISupports*,
not any other interface*, since only nsISupports* is guaranteed to have
pointer->object identity per the COM rules.
> That is the correct solution. Be sure that you get the referent as nsISupports*,
> not any other interface*, since only nsISupports* is guaranteed to have
> pointer->object identity per the COM rules.

nsIWebProgressListener should be just as good... there cannot be two different
nsIWebProgressListener pointers to the same object.  IOW, it should be enough to
take aListener passed to Add/RemoveProgressListener and compare that to the
result of QueryReferent(NS_GET_IID(nsIWebProgressListener)) on the list of
stored progress listeners weak refs.
I stand corrected.  A tearoff could be used to implement nsIWebProgressListener,
so it is necessary to compare nsISupports instances as bsmedberg said.  My bad.
Attached patch patchSplinter Review
Attachment #162745 - Flags: review?(bsmedberg)
Attachment #162745 - Flags: review?(bsmedberg) → review+
Comment on attachment 162745 [details] [diff] [review]
patch

sr=darin
Attachment #162745 - Flags: superreview+
(In reply to comment #3)
> I stand corrected.  A tearoff could be used to implement nsIWebProgressListener,

or code could implement two interfaces which both derive from nsIWPL - then you
could also have different nsIWPL pointers for the same object.

> or code could implement two interfaces which both derive from nsIWPL - then you
> could also have different nsIWPL pointers for the same object.

true true!
Checked into trunk.
Status: NEW → RESOLVED
Closed: 20 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: