Bug 593530 - Don't leak the DeviceManagerD3D9 if initializing it fails. r=joe a=blocking2.0:beta6+

This commit is contained in:
Matt Woodrow 2010-09-03 23:21:26 -04:00
Родитель b63cc0ba47
Коммит 881a4c21e1
3 изменённых файлов: 15 добавлений и 6 удалений

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

@ -189,6 +189,9 @@ DeviceManagerD3D9::~DeviceManagerD3D9()
LayerManagerD3D9::OnDeviceManagerDestroy(this);
}
NS_IMPL_ADDREF(DeviceManagerD3D9)
NS_IMPL_RELEASE(DeviceManagerD3D9)
bool
DeviceManagerD3D9::Init()
{

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

@ -106,9 +106,13 @@ class THEBES_API DeviceManagerD3D9
{
public:
DeviceManagerD3D9();
NS_IMETHOD_(nsrefcnt) AddRef(void);
NS_IMETHOD_(nsrefcnt) Release(void);
protected:
nsAutoRefCnt mRefCnt;
NS_DECL_OWNINGTHREAD
NS_INLINE_DECL_REFCOUNTING(DeviceManagerD3D9)
public:
bool Init();
/**

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

@ -65,8 +65,8 @@ LayerManagerD3D9::~LayerManagerD3D9()
*/
mSwapChain = nsnull;
if (mDeviceManager) {
mDeviceManager->Release();
if (mDeviceManager && mDeviceManager->Release() == 0) {
mDeviceManager = nsnull;
}
}
@ -79,15 +79,17 @@ LayerManagerD3D9::Initialize()
if (!mDeviceManager) {
mDeviceManager = new DeviceManagerD3D9;
mDeviceManager->AddRef();
if (!mDeviceManager->Init()) {
mDeviceManager->Release();
mDeviceManager = nsnull;
return PR_FALSE;
}
} else {
mDeviceManager->AddRef();
}
mDeviceManager->AddRef();
mSwapChain = mDeviceManager->
CreateSwapChain((HWND)mWidget->GetNativeData(NS_NATIVE_WINDOW));