Closed
Bug 232035
Opened 21 years ago
Closed 21 years ago
nsPrintEngine::FindPrintObjectByDOMWin() leaks window ?
Categories
(Core :: Printing: Output, defect)
Tracking
()
RESOLVED
FIXED
People
(Reporter: keeda, Assigned: keeda)
References
()
Details
(Keywords: memory-leak)
Attachments
(3 files, 2 obsolete files)
41.19 KB,
patch
|
dbaron
:
review+
|
Details | Diff | Splinter Review |
45.03 KB,
patch
|
Details | Diff | Splinter Review | |
42.36 KB,
patch
|
jst
:
review+
jst
:
superreview+
|
Details | Diff | Splinter Review |
nsCOMPtr<nsIDOMWindowInternal> domWin(GetDOMWinForWebShell(aPO->mWebShell));
This leaks since GetDOMWinForWebShell() returns an addrefed pointer.
(Found during code inspection. I am not even entirely sure when this code is hit.)
Assignee | ||
Comment 1•21 years ago
|
||
This should fix it.
I initially thought about making it return already_addrefed etc. But we seem to
be moving more towards not returning refs when not required, so this patch does
that.
Assignee | ||
Updated•21 years ago
|
Attachment #139795 -
Flags: review?(dbaron)
Assignee | ||
Comment 2•21 years ago
|
||
dbaron's window counting stuff makes it very easy to prove that this is
indeed a real leak.
Steps to reproduce (in a windows debug build):
1) Start mozilla. Go to any frameset page.
(say http://www.mozilla.org/quality/browser/standards/html/frame_name.html )
2) Click on the content area of any of the frames to focus it.(select some text)
3) Go to Print preview.
4) Close Print priview. Shutdown mozilla. Note window count at shutdown.
> --DOMWINDOW == 4
> --DOMWINDOW == 3
I leaked three window instances in the above test.
Assignee: core.printing → keeda
Assignee | ||
Updated•21 years ago
|
Status: NEW → ASSIGNED
Attachment #139795 -
Flags: review?(dbaron) → review+
Comment 3•21 years ago
|
||
> nsIDOMWindowInternal *
> nsPrintEngine::GetDOMWinForWebShell(nsIWebShell* aWebShell)
> {
> NS_ASSERTION(aWebShell, "Pointer is null!");
>
> nsCOMPtr<nsIDOMWindow> domWin = do_GetInterface(aWebShell);
>
> nsCOMPtr<nsIDOMWindowInternal> domWinInt(do_QueryInterface(domWin));
> - if (!domWinInt) return nsnull;
>
> - nsIDOMWindowInternal * dw = domWinInt.get();
> - NS_ADDREF(dw);
> -
> - return dw;
> + return domWinInt;
> }
This is actually equivalent to
NS_ASSERTION(aWebShell, "Pointer is null!");
nsCOMPtr<nsIDOMWindowInternal> domWinInt = do_GetInterface(aWebShell);
Maybe we could just do away with the function?
Assignee | ||
Comment 4•21 years ago
|
||
This does what peterv said. Just replaces the function with do_GetInterface()
everywhere.
This also includes a cleanup from a patch that jst mailed me. It makes this
code use nsIDOMWindow instead of nsIDOMWindowInternal unless necessary, and
also makes another potentially leaky fucntion return alredy_AddRefed<>
Assignee | ||
Updated•21 years ago
|
Attachment #139795 -
Attachment is obsolete: true
Assignee | ||
Comment 5•21 years ago
|
||
Assignee | ||
Updated•21 years ago
|
Attachment #139845 -
Flags: superreview?(peterv)
Attachment #139845 -
Flags: review?(dbaron)
Comment on attachment 139845 [details] [diff] [review]
-w version of the above. It may be (slightly) more easy to review in places
Rename FindFocusedDOMWindowInternal to FindFocusedDOMWindow
Fix indentation in the definitions of
nsPrintEngine::IsThereAnIFrameSelected and
nsPrintEngine::SetupToPrintContent and the definition of the latter.
In FindFocusedDOMWindowInternal, it seems a little dodgy to cast
nsIDOMWindowInteral* to nsIDOMWindow* (since it looks like this is used for
equality comparisons). Ask jst or peterv if they want to let this code
depend on that continuing to work.
With those, r=dbaron.
Attachment #139845 -
Flags: review?(dbaron) → review+
Assignee | ||
Comment 7•21 years ago
|
||
> In FindFocusedDOMWindowInternal, it seems a little dodgy to cast
> nsIDOMWindowInteral* to nsIDOMWindow* (since it looks like this is used for
> equality comparisons). Ask jst or peterv if they want to let this code
> depend on that continuing to work.
Actually, that part of the patch came from jst, so he should be ok with that.
But I can change it back to a QI if anyone asks me to. Let me know.
I've fixed the rest of the stuff you pointed out.
Assignee | ||
Updated•21 years ago
|
Attachment #139844 -
Attachment is obsolete: true
Assignee | ||
Comment 8•21 years ago
|
||
Assignee | ||
Updated•21 years ago
|
Attachment #139845 -
Flags: superreview?(peterv)
Assignee | ||
Updated•21 years ago
|
Attachment #139886 -
Flags: superreview?(peterv)
Comment 9•21 years ago
|
||
Comment on attachment 139886 [details] [diff] [review]
diff -w of above
r=jst
Attachment #139886 -
Flags: review+
Comment 10•21 years ago
|
||
Comment on attachment 139886 [details] [diff] [review]
diff -w of above
sr=jst, that is (since dbaron already reviewed).
Attachment #139886 -
Flags: superreview?(peterv) → superreview+
Assignee | ||
Comment 11•21 years ago
|
||
Checked in.
Surprisingly (at least it surprised me), this caused a 428 byte increase in mZ
on linux. Windows didnt change much at all. Looks like do_GetInterface() expands
to quite a bit of code?
+428 (+3976/-3548) text (DATA)
+428 (+3976/-3548) UNDEF:libgklayout.so:text
+1356 nsPrintEngine::SetupToPrintContent(nsIDeviceContext*, nsIDOMWindow*)
+595 nsPrintEngine::IsWindowsInOurSubTree(nsIDOMWindow*)
+558 nsPrintEngine::EnablePOsForPrinting()
+416 nsPrintEngine::IsThereARangeSelection(nsIDOMWindow*)
+353 nsPrintEngine::FindFocusedDOMWindow()
+353 nsPrintEngine::FindPrintObjectByDOMWin(nsPrintObject*, nsIDOMWindow*)
+274 nsPrintEngine::IsThereAnIFrameSelected(nsIWebShell*, nsIDOMWindow*,
unsigned char&)
+42 nsPrintEngine::Print(nsIPrintSettings*, nsIWebProgressListener*)
+10 nsPrintEngine::PrintPreview(nsIPrintSettings*, nsIDOMWindow*,
nsIWebProgressListener*)
+6 nsPrintEngine::GetIsIFrameSelected(int*)
+6 nsPrintEngine::GetIsRangeSelection(int*)
+5 nsPrintEngine::GetIsFramesetFrameSelected(int*)
+2 .nosyms.text
-2 nsPrintEngine::ShowPrintErrorDialog(unsigned, int)
-112 nsPrintEngine::ReflowPrintObject(nsPrintObject*, int)
-170 nsPrintEngine::IsThereAnIFrameSelected(nsIWebShell*, nsIDOMWindowInternal*,
unsigned char&)
-257 nsPrintEngine::GetDOMWinForWebShell(nsIWebShell*)
-273 nsPrintEngine::FindPrintObjectByDOMWin(nsPrintObject*, nsIDOMWindowInternal*)
-352 nsPrintEngine::FindFocusedDOMWindowInternal()
-416 nsPrintEngine::IsThereARangeSelection(nsIDOMWindowInternal*)
-610 nsPrintEngine::IsWindowsInOurSubTree(nsIDOMWindowInternal*)
-1356 nsPrintEngine::SetupToPrintContent(nsIDeviceContext*, nsIDOMWindowInternal*)
Status: ASSIGNED → RESOLVED
Closed: 21 years ago
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•