Bug 610690 - Crash when printing many documents successively [@ nsCOMPtr_base::assign_from_qi | nsDocShell::SetTreeOwner ], r=mats, a=benjamin

This commit is contained in:
Olli Pettay 2010-11-10 23:15:21 +02:00
parent b0591e0b6d
commit 7e8cc37590
2 changed files with 6 additions and 4 deletions

View File

@ -43,7 +43,6 @@
#include "nsPIDOMWindow.h"
#include "nsGkAtoms.h"
#include "nsComponentManagerUtils.h"
#include "nsIDocShellTreeOwner.h"
#include "nsIDocShellTreeItem.h"
//---------------------------------------------------
@ -66,10 +65,11 @@ nsPrintObject::~nsPrintObject()
}
DestroyPresentation();
mDocShell = nsnull;
mTreeOwner = nsnull; // mTreeOwner must be released after mDocShell;
}
//------------------------------------------------------------------
// Resets PO by destroying the presentation
nsresult
nsPrintObject::Init(nsIDocShell* aDocShell, nsIDOMDocument* aDoc,
PRBool aPrintPreview)
@ -79,7 +79,7 @@ nsPrintObject::Init(nsIDocShell* aDocShell, nsIDOMDocument* aDoc,
if (mPrintPreview || mParent) {
mDocShell = aDocShell;
} else {
nsCOMPtr<nsIDocShellTreeOwner> owner = do_GetInterface(aDocShell);
mTreeOwner = do_GetInterface(aDocShell);
nsCOMPtr<nsIDocShellTreeItem> item = do_QueryInterface(aDocShell);
PRInt32 itemType = 0;
item->GetItemType(&itemType);
@ -88,7 +88,7 @@ nsPrintObject::Init(nsIDocShell* aDocShell, nsIDOMDocument* aDoc,
NS_ENSURE_TRUE(mDocShell, NS_ERROR_OUT_OF_MEMORY);
nsCOMPtr<nsIDocShellTreeItem> newItem = do_QueryInterface(mDocShell);
newItem->SetItemType(itemType);
newItem->SetTreeOwner(owner);
newItem->SetTreeOwner(mTreeOwner);
}
NS_ENSURE_TRUE(mDocShell, NS_ERROR_FAILURE);

View File

@ -45,6 +45,7 @@
#include "nsIViewManager.h"
#include "nsIDocShell.h"
#include "nsIDocument.h"
#include "nsIDocShellTreeOwner.h"
class nsPresContext;
@ -70,6 +71,7 @@ public:
// Data Members
nsCOMPtr<nsIDocShell> mDocShell;
nsCOMPtr<nsIDocShellTreeOwner> mTreeOwner;
nsCOMPtr<nsIDocument> mDocument;
nsRefPtr<nsPresContext> mPresContext;