Bug 595277 - Part 0: Clear out user data on destroy. r=roc

This commit is contained in:
Bas Schouten 2010-12-07 03:05:25 +01:00
parent 385f364b09
commit 604a3dd45e
5 changed files with 22 additions and 1 deletions

View File

@ -190,6 +190,15 @@ public:
return mKey == aKey ? mValue.get() : nsnull;
}
/**
* Clear out current user data.
*/
void Clear()
{
mKey = nsnull;
mValue = nsnull;
}
private:
void* mKey;
nsAutoPtr<LayerUserData> mValue;
@ -241,7 +250,7 @@ public:
* for its widget going away. After this call, only user data calls
* are valid on the layer manager.
*/
virtual void Destroy() { mDestroyed = PR_TRUE; }
virtual void Destroy() { mDestroyed = PR_TRUE; mUserData.Clear(); }
PRBool IsDestroyed() { return mDestroyed; }
/**

View File

@ -3196,6 +3196,7 @@ nsWindow::GetLayerManager(bool* aAllowRetaining)
if (layerManagerD3D10->device() !=
gfxWindowsPlatform::GetPlatform()->GetD3D10Device())
{
mLayerManager->Destroy();
mLayerManager = nsnull;
}
}

View File

@ -608,6 +608,7 @@ PRBool nsWindow::OnPaint(HDC aDC, PRUint32 aNestingLevel)
layerManagerD3D9->SetClippingRegion(event.region);
result = DispatchWindowEvent(&event, eventStatus);
if (layerManagerD3D9->DeviceWasRemoved()) {
mLayerManager->Destroy();
mLayerManager = nsnull;
// When our device was removed, we should have gfxWindowsPlatform
// check if its render mode is up to date!

View File

@ -154,6 +154,9 @@ PuppetWidget::Destroy()
Base::Destroy();
mPaintTask.Revoke();
mChild = nsnull;
if (mLayerManager) {
mLayerManager->Destroy();
}
mLayerManager = nsnull;
mTabChild = nsnull;
return NS_OK;

View File

@ -137,6 +137,10 @@ nsBaseWidget::~nsBaseWidget()
static_cast<BasicLayerManager*>(mLayerManager.get())->ClearRetainerWidget();
}
if (mLayerManager) {
mLayerManager->Destroy();
}
#ifdef NOISY_WIDGET_LEAKS
gNumWidgets--;
printf("WIDGETS- = %d\n", gNumWidgets);
@ -1027,6 +1031,9 @@ nsBaseWidget::SetAcceleratedRendering(PRBool aEnabled)
return NS_OK;
}
mUseAcceleratedRendering = aEnabled;
if (mLayerManager) {
mLayerManager->Destroy();
}
mLayerManager = NULL;
return NS_OK;
}