diff --git a/layout/xul/base/src/nsSplitterFrame.cpp b/layout/xul/base/src/nsSplitterFrame.cpp index 781fa88753b..fcff7caf5dd 100644 --- a/layout/xul/base/src/nsSplitterFrame.cpp +++ b/layout/xul/base/src/nsSplitterFrame.cpp @@ -106,6 +106,8 @@ public: } virtual ~nsSplitterFrameInner(); + void Disconnect() { mOuter = nsnull; } + // mouse listener NS_IMETHOD MouseDown(nsIDOMEvent* aMouseEvent); NS_IMETHOD MouseUp(nsIDOMEvent* aMouseEvent); @@ -254,12 +256,16 @@ nsSplitterFrame::nsSplitterFrame(nsIPresShell* aPresShell, nsStyleContext* aCont { } -nsSplitterFrame::~nsSplitterFrame() +void +nsSplitterFrame::Destroy() { if (mInner) { mInner->RemoveListener(); + mInner->Disconnect(); mInner->Release(); + mInner = nsnull; } + nsBoxFrame::Destroy(); } @@ -484,7 +490,7 @@ nsSplitterFrame::HandleEvent(nsPresContext* aPresContext, void nsSplitterFrameInner::MouseUp(nsPresContext* aPresContext, nsGUIEvent* aEvent) { - if (mDragging) { + if (mDragging && mOuter) { AdjustChildren(aPresContext); AddListener(aPresContext); mOuter->CaptureMouse(aPresContext, PR_FALSE); @@ -514,7 +520,7 @@ nsSplitterFrameInner::MouseUp(nsPresContext* aPresContext, nsGUIEvent* aEvent) void nsSplitterFrameInner::MouseDrag(nsPresContext* aPresContext, nsGUIEvent* aEvent) { - if (mDragging) { + if (mDragging && mOuter) { //printf("Dragging\n"); @@ -634,6 +640,7 @@ nsSplitterFrameInner::AddListener(nsPresContext* aPresContext) void nsSplitterFrameInner::RemoveListener() { + ENSURE_TRUE(mOuter); mOuter->GetContent()-> RemoveEventListenerByIID(NS_STATIC_CAST(nsIDOMMouseListener*,this), NS_GET_IID(nsIDOMMouseListener)); @@ -694,6 +701,7 @@ nsSplitterFrameInner :: IsMouseCaptured(nsPresContext* aPresContext) nsresult nsSplitterFrameInner::MouseUp(nsIDOMEvent* aMouseEvent) { + NS_ENSURE_TRUE(mOuter, NS_OK); mPressed = PR_FALSE; mOuter->CaptureMouse(mOuter->PresContext(), PR_FALSE); @@ -704,6 +712,7 @@ nsSplitterFrameInner::MouseUp(nsIDOMEvent* aMouseEvent) nsresult nsSplitterFrameInner::MouseDown(nsIDOMEvent* aMouseEvent) { + NS_ENSURE_TRUE(mOuter, NS_OK); nsCOMPtr mouseEvent(do_QueryInterface(aMouseEvent)); PRUint16 button = 0; @@ -878,14 +887,14 @@ nsSplitterFrameInner::MouseDown(nsIDOMEvent* aMouseEvent) nsresult nsSplitterFrameInner::MouseMove(nsIDOMEvent* aMouseEvent) { - //printf("Mouse move\n"); - + NS_ENSURE_TRUE(mOuter, NS_OK); if (!mPressed) return NS_OK; if (mDragging) return NS_OK; + nsCOMPtr kungfuDeathGrip(this); mOuter->mContent->SetAttr(kNameSpaceID_None, nsGkAtoms::state, NS_LITERAL_STRING("dragging"), PR_TRUE); RemoveListener(); diff --git a/layout/xul/base/src/nsSplitterFrame.h b/layout/xul/base/src/nsSplitterFrame.h index 75e87e5acb5..58cbe36f185 100644 --- a/layout/xul/base/src/nsSplitterFrame.h +++ b/layout/xul/base/src/nsSplitterFrame.h @@ -54,7 +54,7 @@ class nsSplitterFrame : public nsBoxFrame { public: nsSplitterFrame(nsIPresShell* aPresShell, nsStyleContext* aContext); - virtual ~nsSplitterFrame(); + virtual void Destroy(); #ifdef DEBUG NS_IMETHOD GetFrameName(nsAString& aResult) const {