effective leak of nsDOMWindowController due to cycle with pref observer

RESOLVED WORKSFORME

Status

()

Core
Disability Access APIs
RESOLVED WORKSFORME
15 years ago
15 years ago

People

(Reporter: John Morrison, Assigned: Christopher Aillon (sabbatical, not receiving bugmail))

Tracking

({mlk})

Trunk
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(URL)

(Reporter)

Description

15 years ago
I think this is effectively a leak. [I say effectively, because the destructor
is eventually called at shutdown. However, this object should go away when its
owning window is destroyed.] The use of AddObserver for |this| in the ctor now
extends the life of the nsDOMWindowController to the life of the observer 
service which holds the pref branch. 

Are am I drinking too much coffee? Again.

6078
6079  nsDOMWindowController::nsDOMWindowController(
                                               nsIDOMWindowInternal *aWindow)
6080  {
6081    mWindow = aWindow;
6082  
6083    // Set mBrowseWithCaret so we don't need to check pref every time
6084    mBrowseWithCaret = PR_FALSE;
6085    nsCOMPtr<nsIEventStateManager> esm;
6086    if (NS_SUCCEEDED(GetEventStateManager(getter_AddRefs(esm))))
6087      esm->ResetBrowseWithCaret(&mBrowseWithCaret);
6088  
6089    nsCOMPtr<nsIPrefBranchInternal> pbi(do_QueryInterface(gPrefBranch));
6090    if (pbi) {
6091      pbi->AddObserver("accessibility.browsewithcaret", this, PR_FALSE);
6092    }
6093  }
6094  
6095  nsDOMWindowController::~nsDOMWindowController()
6096  {
6097    nsCOMPtr<nsIPrefBranchInternal> pbi(do_QueryInterface(gPrefBranch));
6098    if (pbi) {
6099      pbi->RemoveObserver("accessibility.browsewithcaret", this);
6100    }
6101  }
6102
Yeah, that's a leak....
Attachment 108171 [details] [diff] (from bug 183069) should fix this I think.  It already has
r=timeless, sr=bzbarsky.
(Reporter)

Comment 3

15 years ago
-> caillon, per request.
Assignee: aaronl → caillon
I don't believe this is any longer an issue due to the checkins from bug 201560.
Closing.  If this still seems to be a problem, then re-open it.
Status: NEW → RESOLVED
Last Resolved: 15 years ago
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.