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
Родитель 5a57702df9
Коммит e95f123c37
5 изменённых файлов: 22 добавлений и 1 удалений

Просмотреть файл

@ -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; }
/**

Просмотреть файл

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

Просмотреть файл

@ -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!

Просмотреть файл

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

Просмотреть файл

@ -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;
}