Don't clear the root view manager pointer when the root view is destroyed. Bug

269402, r+sr=roc, a=asa
This commit is contained in:
bzbarsky%mit.edu 2004-11-22 03:06:14 +00:00
parent 7028f44696
commit a36ab5b06d
2 changed files with 10 additions and 3 deletions

View File

@ -499,6 +499,9 @@ nsViewManager::~nsViewManager()
getter_AddRefs(eventQueue));
NS_ASSERTION(nsnull != eventQueue, "Event queue is null");
eventQueue->RevokeEvents(this);
} else {
// We have a strong ref to mRootViewManager
NS_IF_RELEASE(mRootViewManager);
}
mInvalidateEventQueue = nsnull;
@ -646,19 +649,22 @@ NS_IMETHODIMP nsViewManager::SetRootView(nsIView *aView)
mRootView = view;
if (mRootView) {
if (mRootViewManager && mRootViewManager != this) {
NS_RELEASE(mRootViewManager);
}
nsView* parent = mRootView->GetParent();
if (parent) {
parent->InsertChild(mRootView, nsnull);
mRootViewManager = parent->GetViewManager()->RootViewManager();
NS_ASSERTION(mRootViewManager != this, "Something's wrong");
NS_ADDREF(mRootViewManager);
} else {
mRootViewManager = this;
}
mRootView->SetZIndex(PR_FALSE, 0, PR_FALSE);
} else {
// XXXbz not really needed, probably
mRootViewManager = this;
}
// Else don't touch mRootViewManager
return NS_OK;
}

View File

@ -489,6 +489,7 @@ private:
nsISupportsArray *mCompositeListeners;
nsCOMPtr<nsIFactory> mRegionFactory;
nsView *mRootView;
// mRootViewManager is a strong ref unless it equals |this|
nsViewManager *mRootViewManager;
nsCOMPtr<nsIEventQueueService> mEventQueueService;
nsCOMPtr<nsIEventQueue> mSynthMouseMoveEventQueue;