Skip to content

Commit 15d0fbe

Browse files
authored
refactor(w3dview): Replace duplicate reference count macros with core library equivalents (#1784)
1 parent 615aca6 commit 15d0fbe

19 files changed

+74
-93
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/AssetInfo.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ AssetInfoClass::Initialize (void)
5353

5454
// Assume we are wrapping an instance as apposed to an asset 'name'.
5555
RenderObjClass *prender_obj = m_pRenderObj;
56-
SAFE_ADD_REF (prender_obj);
56+
if (prender_obj)
57+
prender_obj->Add_Ref();
5758

5859
// If we are wrapping an asset name, then create an instance of it.
5960
if (prender_obj == NULL) {
@@ -72,7 +73,7 @@ AssetInfoClass::Initialize (void)
7273
}
7374

7475
// Release our hold on the temporary object
75-
MEMBER_RELEASE (prender_obj);
76+
REF_PTR_RELEASE (prender_obj);
7677
}
7778

7879
return ;

Core/Tools/W3DView/AssetInfo.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,9 @@ class AssetInfoClass
6565
: m_Name (passet_name),
6666
m_AssetType (type),
6767
m_dwUserData (user_data),
68-
m_pRenderObj (NULL) { MEMBER_ADD (m_pRenderObj, prender_obj); Initialize (); }
68+
m_pRenderObj (NULL) { REF_PTR_SET (m_pRenderObj, prender_obj); Initialize (); }
6969

70-
virtual ~AssetInfoClass (void) { MEMBER_RELEASE (m_pRenderObj); }
70+
virtual ~AssetInfoClass (void) { REF_PTR_RELEASE (m_pRenderObj); }
7171

7272
//////////////////////////////////////////////////////////////
7373
//
@@ -83,14 +83,14 @@ class AssetInfoClass
8383
ASSET_TYPE Get_Type (void) const { return m_AssetType; }
8484
DWORD Get_User_Number (void) const { return m_dwUserData; }
8585
const CString & Get_User_String (void) const { return m_UserString; }
86-
RenderObjClass * Get_Render_Obj (void) const { SAFE_ADD_REF (m_pRenderObj); return m_pRenderObj; }
86+
RenderObjClass * Get_Render_Obj (void) const { if (m_pRenderObj) m_pRenderObj->Add_Ref(); return m_pRenderObj; }
8787
RenderObjClass * Peek_Render_Obj (void) const { return m_pRenderObj; }
8888
void Set_Name (LPCTSTR pname) { m_Name = pname; }
8989
void Set_Hierarchy_Name (LPCTSTR pname) { m_HierarchyName = pname; }
9090
void Set_Type (ASSET_TYPE type) { m_AssetType = type; }
9191
void Set_User_Number (DWORD user_data) { m_dwUserData = user_data; }
9292
void Set_User_String (LPCTSTR string) { m_UserString = string; }
93-
void Set_Render_Obj (RenderObjClass *pobj) { MEMBER_ADD (m_pRenderObj, pobj); }
93+
void Set_Render_Obj (RenderObjClass *pobj) { REF_PTR_SET (m_pRenderObj, pobj); }
9494

9595
//
9696
// Information methods

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/EmitterInstanceList.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ EmitterInstanceListClass::Free_List (void)
5959
// Release our hold on each of the emitter pointers
6060
//
6161
for (int index = 0; index < m_List.Count (); index ++) {
62-
MEMBER_RELEASE (m_List[index]);
62+
REF_PTR_RELEASE (m_List[index]);
6363
}
6464

6565
m_List.Delete_All ();
@@ -93,7 +93,8 @@ EmitterInstanceListClass::Add_Emitter (ParticleEmitterClass *emitter)
9393
//
9494
// Add this emitter to the list and put a hold on its reference
9595
//
96-
SAFE_ADD_REF (emitter);
96+
if (emitter)
97+
emitter->Add_Ref();
9798
m_List.Add (emitter);
9899
}
99100

Core/Tools/W3DView/EmitterPropertySheet.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ EmitterPropertySheetClass::Update_Emitter (void)
265265
//
266266
// Use this emitter as the edited emitter from here on out
267267
//
268-
MEMBER_RELEASE (m_pEmitter);
268+
REF_PTR_RELEASE (m_pEmitter);
269269
m_pEmitter = pemitter;*/
270270

271271
// Pass the emitter along to the pages
@@ -501,7 +501,7 @@ EmitterPropertySheetClass::Create_New_Emitter (void)
501501
// Display the new emitter
502502
//
503503
::GetCurrentDocument ()->Display_Emitter (emitter);
504-
MEMBER_RELEASE (emitter);
504+
REF_PTR_RELEASE (emitter);
505505

506506
/*SAFE_DELETE_ARRAY (color.Values);
507507
SAFE_DELETE_ARRAY (color.KeyTimes);

Core/Tools/W3DView/GraphicView.cpp

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

335335
// Is there an update thread running?
336336
if (m_TimerID == 0) {
@@ -388,7 +388,7 @@ Set_Lowest_LOD (RenderObjClass *render_obj)
388388
if (psub_obj != NULL) {
389389
Set_Lowest_LOD (psub_obj);
390390
}
391-
MEMBER_RELEASE (psub_obj);
391+
REF_PTR_RELEASE (psub_obj);
392392
}
393393

394394
//

Core/Tools/W3DView/PlaySoundDialog.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ void
100100
PlaySoundDialogClass::OnCancel (void)
101101
{
102102
SoundObj->Stop ();
103-
MEMBER_RELEASE (SoundObj);
103+
REF_PTR_RELEASE (SoundObj);
104104

105105
CDialog::OnCancel ();
106106
return ;

0 commit comments

Comments
 (0)