Skip to content

Commit d2d68a2

Browse files
committed
refactor(w3dview): migrate W3DViewDoc and GraphicView to RefCountPtr<T>
Replace MEMBER_ADD/MEMBER_RELEASE macros with RefCountPtr<T> and REF_PTR_RELEASE. - W3DViewDoc: m_pCRenderObj, m_pCAnimation, m_pCursorScene, m_pCursor now RefCountPtr - GraphicView: m_pCamera and m_pLightMesh now RefCountPtr - Local variables in Utils, DataTreeView, BoneMgrDialog, etc. use REF_PTR_RELEASE
1 parent 245c97e commit d2d68a2

File tree

9 files changed

+54
-67
lines changed

9 files changed

+54
-67
lines changed

Core/Tools/W3DView/AdvancedAnimSheet.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ CAdvancedAnimSheet::~CAdvancedAnimSheet()
7777
{
7878
for (int i = 0; i < AnimCount; i++)
7979
{
80-
MEMBER_RELEASE(Anims[i]);
80+
REF_PTR_RELEASE(Anims[i]);
8181
}
8282
AnimsValid = false;
8383
AnimCount = 0;
@@ -162,7 +162,7 @@ void CAdvancedAnimSheet::LoadAnims (void)
162162
// Add this Anims pointer to the array.
163163
if (AnimCount < MAX_REPORT_ANIMS)
164164
{
165-
MEMBER_ADD(Anims[AnimCount], pHierarchyAnim);
165+
REF_PTR_SET(Anims[AnimCount], pHierarchyAnim);
166166
AnimCount++;
167167
}
168168
else
@@ -176,7 +176,7 @@ void CAdvancedAnimSheet::LoadAnims (void)
176176
}
177177

178178
// Release our hold on this animation.
179-
MEMBER_RELEASE(pHierarchyAnim);
179+
REF_PTR_RELEASE(pHierarchyAnim);
180180
}
181181
}
182182

Core/Tools/W3DView/BoneMgrDialog.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -222,15 +222,15 @@ BoneMgrDialogClass::Fill_Bone_Item
222222

223223
// Free our hold on the render objs in the original node list
224224
for (index = 0; index < orig_node_list.Count (); index ++) {
225-
MEMBER_RELEASE (orig_node_list[index]);
225+
REF_PTR_RELEASE (orig_node_list[index]);
226226
}
227227

228228
// Free our hold on the render objs in the node list
229229
for (index = 0; index < node_list.Count (); index ++) {
230-
MEMBER_RELEASE (node_list[index]);
230+
REF_PTR_RELEASE (node_list[index]);
231231
}
232232

233-
MEMBER_RELEASE (porig_model);
233+
REF_PTR_RELEASE (porig_model);
234234
return ;
235235
}
236236

@@ -405,7 +405,7 @@ void
405405
BoneMgrDialogClass::OnOK (void)
406406
{
407407
// Simply forget about the backup we made
408-
MEMBER_RELEASE (m_pBackupModel);
408+
REF_PTR_RELEASE (m_pBackupModel);
409409

410410
// Update the hierarchy's cached information to reflect the new settings
411411
CW3DViewDoc *pdoc = (CW3DViewDoc *)((CMainFrame *)::AfxGetMainWnd())->GetActiveDocument ();
@@ -459,7 +459,7 @@ BoneMgrDialogClass::OnAttachButton (void)
459459
if (prender_obj != NULL) {
460460
m_pBaseModel->Add_Sub_Object_To_Bone (prender_obj, m_BoneName);
461461
m_BoneTree.InsertItem (name, 1, 1, hbone_item);
462-
MEMBER_RELEASE (prender_obj);
462+
REF_PTR_RELEASE (prender_obj);
463463
}
464464

465465
} else {
@@ -481,7 +481,7 @@ BoneMgrDialogClass::OnAttachButton (void)
481481
}
482482

483483
// Release our hold on this pointer
484-
MEMBER_RELEASE (psub_obj);
484+
REF_PTR_RELEASE (psub_obj);
485485
}
486486

487487
// Remove the object from our UI

Core/Tools/W3DView/DataTreeView.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,7 @@ CDataTreeView::LoadAnimationsIntoTree (void)
521521
}
522522

523523
// Release our hold on this animation...
524-
MEMBER_RELEASE (pHierarchyAnim);
524+
REF_PTR_RELEASE (pHierarchyAnim);
525525
}
526526
}
527527

@@ -583,7 +583,7 @@ CDataTreeView::LoadAnimationsIntoTree (HTREEITEM hItem)
583583
}
584584

585585
// Release our hold on the animation object
586-
MEMBER_RELEASE (pHierarchyAnim);
586+
REF_PTR_RELEASE (pHierarchyAnim);
587587
}
588588
}
589589

@@ -1009,7 +1009,7 @@ CDataTreeView::Display_Asset (HTREEITEM htree_item)
10091009
RenderObjClass *prender_obj = Create_Render_Obj_To_Display (hParentItem);
10101010
pdoc->PlayAnimation (prender_obj,
10111011
asset_info->Get_Name ());
1012-
MEMBER_RELEASE (prender_obj);
1012+
REF_PTR_RELEASE (prender_obj);
10131013
}
10141014
}
10151015
break;
@@ -1019,7 +1019,7 @@ CDataTreeView::Display_Asset (HTREEITEM htree_item)
10191019
// Ask the document to display this object
10201020
ParticleEmitterClass *emitter = (ParticleEmitterClass *)Create_Render_Obj_To_Display (htree_item);
10211021
pdoc->Display_Emitter (emitter);
1022-
MEMBER_RELEASE (emitter);
1022+
REF_PTR_RELEASE (emitter);
10231023
}
10241024
break;
10251025

@@ -1035,7 +1035,7 @@ CDataTreeView::Display_Asset (HTREEITEM htree_item)
10351035
// Ask the document to display this object
10361036
RenderObjClass *prender_obj = Create_Render_Obj_To_Display (htree_item);
10371037
pdoc->DisplayObject (prender_obj);
1038-
MEMBER_RELEASE (prender_obj);
1038+
REF_PTR_RELEASE (prender_obj);
10391039
}
10401040
break;
10411041
}
@@ -1478,7 +1478,7 @@ Set_Highest_LOD (RenderObjClass *render_obj)
14781478
if (sub_obj != NULL) {
14791479
Set_Highest_LOD (sub_obj);
14801480
}
1481-
MEMBER_RELEASE (sub_obj);
1481+
REF_PTR_RELEASE (sub_obj);
14821482
}
14831483

14841484
//

Core/Tools/W3DView/EditLODDialog.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ CEditLODDialog::OnInitDialog (void)
119119
RenderObjClass *pfirst_subobj = pLOD->Get_Sub_Object (0);
120120
if (pfirst_subobj != NULL) {
121121
m_spinIncrement = pfirst_subobj->Get_Bounding_Sphere ().Radius / 5.0F;
122-
MEMBER_RELEASE (pfirst_subobj);
122+
REF_PTR_RELEASE (pfirst_subobj);
123123
}
124124

125125
// Loop through all the subobjects
@@ -142,7 +142,7 @@ CEditLODDialog::OnInitDialog (void)
142142
m_hierarchyListCtrl.SetItemText (iIndex, COL_SWITCH_DN, stringTemp);
143143

144144
// Free this object
145-
MEMBER_RELEASE (pCSubObject);
145+
REF_PTR_RELEASE (pCSubObject);
146146
}
147147
}
148148

Core/Tools/W3DView/GraphicView.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -329,8 +329,6 @@ CGraphicView::OnDestroy (void)
329329
//
330330
// Free the camera object
331331
//
332-
MEMBER_RELEASE (m_pCamera);
333-
MEMBER_RELEASE (m_pLightMesh);
334332

335333
// Is there an update thread running?
336334
if (m_TimerID == 0) {
@@ -388,7 +386,7 @@ Set_Lowest_LOD (RenderObjClass *render_obj)
388386
if (psub_obj != NULL) {
389387
Set_Lowest_LOD (psub_obj);
390388
}
391-
MEMBER_RELEASE (psub_obj);
389+
REF_PTR_RELEASE (psub_obj);
392390
}
393391

394392
//

Core/Tools/W3DView/GraphicView.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ class ParticleEmitterClass;
4141
// CGraphicView view
4242

4343
#include "camera.h"
44+
#include "ref_ptr.h"
4445

4546
class CGraphicView : public CView
4647
{
@@ -170,7 +171,7 @@ class CGraphicView : public CView
170171
void SetAllowedCameraRotation (CAMERA_ROTATION cameraRotation);
171172
CAMERA_ROTATION GetAllowedCameraRotation () const { return m_allowedCameraRotation; }
172173
void SetCameraPos (CAMERA_POS cameraPos);
173-
class CameraClass *GetCamera (void) const { return m_pCamera; }
174+
class CameraClass *GetCamera (void) const { return m_pCamera.Peek(); }
174175

175176
float Get_Camera_Distance (void) const { return m_CameraDistance; }
176177
void Set_Camera_Distance (float dist);
@@ -227,8 +228,8 @@ class CGraphicView : public CView
227228
BOOL m_bInitialized;
228229
BOOL m_bActive;
229230
UINT m_TimerID;
230-
CameraClass * m_pCamera;
231-
RenderObjClass * m_pLightMesh;
231+
RefCountPtr<CameraClass> m_pCamera;
232+
RefCountPtr<RenderObjClass> m_pLightMesh;
232233
bool m_bLightMeshInScene;
233234
Vector3 m_ObjectCenter;
234235
SphereClass m_ViewedSphere;

Core/Tools/W3DView/Utils.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,7 @@ Build_Emitter_List
559559

560560
// Recursivly add emitters to the list
561561
Build_Emitter_List (*psub_obj, list);
562-
MEMBER_RELEASE (psub_obj);
562+
REF_PTR_RELEASE (psub_obj);
563563
}
564564
}
565565

@@ -586,7 +586,7 @@ Is_Aggregate (const char *asset_name)
586586
}
587587

588588
// Free our hold on the temporary render object
589-
MEMBER_RELEASE (prender_obj);
589+
REF_PTR_RELEASE (prender_obj);
590590

591591
// Return the true/false result code
592592
return retval;
@@ -649,7 +649,7 @@ Is_Real_LOD (const char *asset_name)
649649
}
650650

651651
// Free our hold on the temporary render object
652-
MEMBER_RELEASE (prender_obj);
652+
REF_PTR_RELEASE (prender_obj);
653653

654654
// Return the true/false result code
655655
return retval;

0 commit comments

Comments
 (0)