Skip to content

Commit

Permalink
Use scoped pointer
Browse files Browse the repository at this point in the history
  • Loading branch information
res2002 committed Nov 15, 2011
1 parent 6b3ee23 commit 355cbfb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
15 changes: 5 additions & 10 deletions plugins/video/render3d/opengl/gl_txtmgr_basictex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ csGLBasicTextureHandle::csGLBasicTextureHandle (int width,
textureClass (txtmgr->GetTextureClassID ("default")),
alphaType (csAlphaMode::alphaNone), Handle (0), pbo (0),
orig_width (width), orig_height (height), orig_d (depth),
uploadData(0), G3D (iG3D), texFormat((TextureBlitDataFormat)-1)
G3D (iG3D), texFormat((TextureBlitDataFormat)-1)
{
switch (imagetype)
{
Expand Down Expand Up @@ -127,7 +127,6 @@ csGLBasicTextureHandle::csGLBasicTextureHandle (
orig_width (0),
orig_height (0),
orig_d (0),
uploadData (0),
G3D (iG3D),
texType (texType),
texFormat ((TextureBlitDataFormat)-1)
Expand Down Expand Up @@ -256,11 +255,7 @@ bool csGLBasicTextureHandle::SynthesizeUploadData (

void csGLBasicTextureHandle::Clear()
{
if (uploadData != 0)
{
delete uploadData;
uploadData = 0;
}
uploadData.Reset();
Unload ();
}

Expand Down Expand Up @@ -348,10 +343,10 @@ void csGLBasicTextureHandle::ComputeNewPo2ImageSize (int texFlags,

void csGLBasicTextureHandle::FreshUploadData ()
{
if (uploadData != 0)
if (uploadData.IsValid())
uploadData->DeleteAll();
else
uploadData = new csArray<csGLUploadData>;
uploadData.Reset (new csArray<csGLUploadData>);
}

void csGLBasicTextureHandle::AdjustSizePo2 ()
Expand Down Expand Up @@ -664,7 +659,7 @@ void csGLBasicTextureHandle::Load ()
}
}

delete uploadData; uploadData = 0;
uploadData.Reset();
SetUploaded (true);
}

Expand Down
3 changes: 2 additions & 1 deletion plugins/video/render3d/opengl/gl_txtmgr_basictex.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include "csutil/ref.h"
#include "csutil/scf.h"
#include "csutil/scf_implementation.h"
#include "csutil/scopedpointer.h"
#include "csutil/weakref.h"

#include "igraphic/image.h"
Expand Down Expand Up @@ -239,7 +240,7 @@ class csGLBasicTextureHandle :
int orig_width, orig_height, orig_d;
/// The dimensions actually used
int actual_width, actual_height, actual_d;
csArray<csGLUploadData>* uploadData;
CS::Utility::ScopedPointer<csArray<csGLUploadData> > uploadData;
csWeakRef<csGLGraphics3D> G3D;
TextureType texType;

Expand Down

0 comments on commit 355cbfb

Please sign in to comment.