Changed raw pointers to RefCountObject to BindingPointers.
I suspect there is a bug whereby an owning reference to a RefCountObject is temporarily assigned to a BindingPointer, causing it to be destroyed and making the owning raw pointer go dangling.
Making this change for mColorbufferProxy seemed to fix a crash in Chrome with canvas 2D.
This was previously landed in r417 and r418.
Review URL: http://codereview.appspot.com/2108047
git-svn-id: https://angleproject.googlecode.com/svn/trunk@423 736b8ea6-26fd-11df-bfd4-992fa37f6226
diff --git a/src/libGLESv2/Texture.cpp b/src/libGLESv2/Texture.cpp
index 2feb7e4..d5825cf 100644
--- a/src/libGLESv2/Texture.cpp
+++ b/src/libGLESv2/Texture.cpp
@@ -923,12 +923,11 @@
Texture2D::Texture2D(GLuint id) : Texture(id)
{
mTexture = NULL;
- mColorbufferProxy = NULL;
}
Texture2D::~Texture2D()
{
- delete mColorbufferProxy;
+ mColorbufferProxy.set(NULL);
if (mTexture)
{
@@ -1400,13 +1399,12 @@
return error(GL_INVALID_OPERATION, (Renderbuffer *)NULL);
}
- if (mColorbufferProxy == NULL)
+ if (mColorbufferProxy.get() == NULL)
{
- mColorbufferProxy = new Renderbuffer(id(), new TextureColorbufferProxy(this, target));
- mColorbufferProxy->addRef();
+ mColorbufferProxy.set(new Renderbuffer(id(), new TextureColorbufferProxy(this, target)));
}
- return mColorbufferProxy;
+ return mColorbufferProxy.get();
}
IDirect3DSurface9 *Texture2D::getRenderTarget(GLenum target)
@@ -1424,18 +1422,13 @@
TextureCubeMap::TextureCubeMap(GLuint id) : Texture(id)
{
mTexture = NULL;
-
- for (int i = 0; i < 6; i++)
- {
- mFaceProxies[i] = NULL;
- }
}
TextureCubeMap::~TextureCubeMap()
{
for (int i = 0; i < 6; i++)
{
- delete mFaceProxies[i];
+ mFaceProxies[i].set(NULL);
}
if (mTexture)
@@ -2012,13 +2005,12 @@
unsigned int face = faceIndex(target);
- if (mFaceProxies[face] == NULL)
+ if (mFaceProxies[face].get() == NULL)
{
- mFaceProxies[face] = new Renderbuffer(id(), new TextureColorbufferProxy(this, target));
- mFaceProxies[face]->addRef();
+ mFaceProxies[face].set(new Renderbuffer(id(), new TextureColorbufferProxy(this, target)));
}
- return mFaceProxies[face];
+ return mFaceProxies[face].get();
}
IDirect3DSurface9 *TextureCubeMap::getRenderTarget(GLenum target)