Skip to content

Commit 7bacc4d

Browse files
committed
refactor(w3dview): replace custom MEMBER_ADD/MEMBER_RELEASE macros with core library REF_PTR_SET/REF_PTR_RELEASE
1 parent 7a6402b commit 7bacc4d

19 files changed

+88
-93
lines changed

Core/Tools/W3DView/AdvancedAnimSheet.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include "W3DView.h"
2424
#include "W3DViewDoc.h"
2525
#include "AdvancedAnimSheet.h"
26+
#include "refcount.h"
2627

2728
#include "assetmgr.h"
2829
#include "hanim.h"
@@ -77,7 +78,7 @@ CAdvancedAnimSheet::~CAdvancedAnimSheet()
7778
{
7879
for (int i = 0; i < AnimCount; i++)
7980
{
80-
MEMBER_RELEASE(Anims[i]);
81+
REF_PTR_RELEASE(Anims[i]);
8182
}
8283
AnimsValid = false;
8384
AnimCount = 0;
@@ -162,7 +163,7 @@ void CAdvancedAnimSheet::LoadAnims (void)
162163
// Add this Anims pointer to the array.
163164
if (AnimCount < MAX_REPORT_ANIMS)
164165
{
165-
MEMBER_ADD(Anims[AnimCount], pHierarchyAnim);
166+
REF_PTR_SET(Anims[AnimCount], pHierarchyAnim);
166167
AnimCount++;
167168
}
168169
else
@@ -176,7 +177,7 @@ void CAdvancedAnimSheet::LoadAnims (void)
176177
}
177178

178179
// Release our hold on this animation.
179-
MEMBER_RELEASE(pHierarchyAnim);
180+
REF_PTR_RELEASE(pHierarchyAnim);
180181
}
181182
}
182183

Core/Tools/W3DView/AssetInfo.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737

3838
#include "StdAfx.h"
3939
#include "AssetInfo.h"
40+
#include "refcount.h"
4041
//#include "HModel.h"
4142
#include "assetmgr.h"
4243
#include "htree.h"
@@ -53,7 +54,7 @@ AssetInfoClass::Initialize (void)
5354

5455
// Assume we are wrapping an instance as apposed to an asset 'name'.
5556
RenderObjClass *prender_obj = m_pRenderObj;
56-
SAFE_ADD_REF (prender_obj);
57+
if (prender_obj) 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: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "StdAfx.h"
2323
#include "W3DView.h"
2424
#include "BoneMgrDialog.h"
25+
#include "refcount.h"
2526
#include "htree.h"
2627
#include "assetmgr.h"
2728
#include "Utils.h"
@@ -222,15 +223,15 @@ BoneMgrDialogClass::Fill_Bone_Item
222223

223224
// Free our hold on the render objs in the original node list
224225
for (index = 0; index < orig_node_list.Count (); index ++) {
225-
MEMBER_RELEASE (orig_node_list[index]);
226+
REF_PTR_RELEASE (orig_node_list[index]);
226227
}
227228

228229
// Free our hold on the render objs in the node list
229230
for (index = 0; index < node_list.Count (); index ++) {
230-
MEMBER_RELEASE (node_list[index]);
231+
REF_PTR_RELEASE (node_list[index]);
231232
}
232233

233-
MEMBER_RELEASE (porig_model);
234+
REF_PTR_RELEASE (porig_model);
234235
return ;
235236
}
236237

@@ -405,7 +406,7 @@ void
405406
BoneMgrDialogClass::OnOK (void)
406407
{
407408
// Simply forget about the backup we made
408-
MEMBER_RELEASE (m_pBackupModel);
409+
REF_PTR_RELEASE (m_pBackupModel);
409410

410411
// Update the hierarchy's cached information to reflect the new settings
411412
CW3DViewDoc *pdoc = (CW3DViewDoc *)((CMainFrame *)::AfxGetMainWnd())->GetActiveDocument ();
@@ -459,7 +460,7 @@ BoneMgrDialogClass::OnAttachButton (void)
459460
if (prender_obj != NULL) {
460461
m_pBaseModel->Add_Sub_Object_To_Bone (prender_obj, m_BoneName);
461462
m_BoneTree.InsertItem (name, 1, 1, hbone_item);
462-
MEMBER_RELEASE (prender_obj);
463+
REF_PTR_RELEASE (prender_obj);
463464
}
464465

465466
} else {
@@ -481,7 +482,7 @@ BoneMgrDialogClass::OnAttachButton (void)
481482
}
482483

483484
// Release our hold on this pointer
484-
MEMBER_RELEASE (psub_obj);
485+
REF_PTR_RELEASE (psub_obj);
485486
}
486487

487488
// Remove the object from our UI

Core/Tools/W3DView/DataTreeView.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
#include "StdAfx.h"
3939
#include "W3DView.h"
4040
#include "DataTreeView.h"
41+
#include "refcount.h"
4142
#include "rendobj.h"
4243
#include "ViewerAssetMgr.h"
4344
#include "Globals.h"
@@ -521,7 +522,7 @@ CDataTreeView::LoadAnimationsIntoTree (void)
521522
}
522523

523524
// Release our hold on this animation...
524-
MEMBER_RELEASE (pHierarchyAnim);
525+
REF_PTR_RELEASE (pHierarchyAnim);
525526
}
526527
}
527528

@@ -583,7 +584,7 @@ CDataTreeView::LoadAnimationsIntoTree (HTREEITEM hItem)
583584
}
584585

585586
// Release our hold on the animation object
586-
MEMBER_RELEASE (pHierarchyAnim);
587+
REF_PTR_RELEASE (pHierarchyAnim);
587588
}
588589
}
589590

@@ -1009,7 +1010,7 @@ CDataTreeView::Display_Asset (HTREEITEM htree_item)
10091010
RenderObjClass *prender_obj = Create_Render_Obj_To_Display (hParentItem);
10101011
pdoc->PlayAnimation (prender_obj,
10111012
asset_info->Get_Name ());
1012-
MEMBER_RELEASE (prender_obj);
1013+
REF_PTR_RELEASE (prender_obj);
10131014
}
10141015
}
10151016
break;
@@ -1019,7 +1020,7 @@ CDataTreeView::Display_Asset (HTREEITEM htree_item)
10191020
// Ask the document to display this object
10201021
ParticleEmitterClass *emitter = (ParticleEmitterClass *)Create_Render_Obj_To_Display (htree_item);
10211022
pdoc->Display_Emitter (emitter);
1022-
MEMBER_RELEASE (emitter);
1023+
REF_PTR_RELEASE (emitter);
10231024
}
10241025
break;
10251026

@@ -1035,7 +1036,7 @@ CDataTreeView::Display_Asset (HTREEITEM htree_item)
10351036
// Ask the document to display this object
10361037
RenderObjClass *prender_obj = Create_Render_Obj_To_Display (htree_item);
10371038
pdoc->DisplayObject (prender_obj);
1038-
MEMBER_RELEASE (prender_obj);
1039+
REF_PTR_RELEASE (prender_obj);
10391040
}
10401041
break;
10411042
}
@@ -1478,7 +1479,7 @@ Set_Highest_LOD (RenderObjClass *render_obj)
14781479
if (sub_obj != NULL) {
14791480
Set_Highest_LOD (sub_obj);
14801481
}
1481-
MEMBER_RELEASE (sub_obj);
1482+
REF_PTR_RELEASE (sub_obj);
14821483
}
14831484

14841485
//

Core/Tools/W3DView/EditLODDialog.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "StdAfx.h"
2323
#include "W3DView.h"
2424
#include "EditLODDialog.h"
25+
#include "refcount.h"
2526
#include "distlod.h"
2627
#include "Utils.h"
2728
#include "rendobj.h"
@@ -119,7 +120,7 @@ CEditLODDialog::OnInitDialog (void)
119120
RenderObjClass *pfirst_subobj = pLOD->Get_Sub_Object (0);
120121
if (pfirst_subobj != NULL) {
121122
m_spinIncrement = pfirst_subobj->Get_Bounding_Sphere ().Radius / 5.0F;
122-
MEMBER_RELEASE (pfirst_subobj);
123+
REF_PTR_RELEASE (pfirst_subobj);
123124
}
124125

125126
// Loop through all the subobjects
@@ -142,7 +143,7 @@ CEditLODDialog::OnInitDialog (void)
142143
m_hierarchyListCtrl.SetItemText (iIndex, COL_SWITCH_DN, stringTemp);
143144

144145
// Free this object
145-
MEMBER_RELEASE (pCSubObject);
146+
REF_PTR_RELEASE (pCSubObject);
146147
}
147148
}
148149

Core/Tools/W3DView/EmitterInstanceList.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333

3434
#include "StdAfx.h"
3535
#include "EmitterInstanceList.h"
36+
#include "refcount.h"
3637
#include "Utils.h"
3738

3839
/////////////////////////////////////////////////////////////////////
@@ -59,7 +60,7 @@ EmitterInstanceListClass::Free_List (void)
5960
// Release our hold on each of the emitter pointers
6061
//
6162
for (int index = 0; index < m_List.Count (); index ++) {
62-
MEMBER_RELEASE (m_List[index]);
63+
REF_PTR_RELEASE (m_List[index]);
6364
}
6465

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

Core/Tools/W3DView/EmitterPropertySheet.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include "StdAfx.h"
3434
#include "W3DView.h"
3535
#include "EmitterPropertySheet.h"
36+
#include "refcount.h"
3637
#include "part_emt.h"
3738
#include "part_ldr.h"
3839
#include "assetmgr.h"
@@ -265,7 +266,7 @@ EmitterPropertySheetClass::Update_Emitter (void)
265266
//
266267
// Use this emitter as the edited emitter from here on out
267268
//
268-
MEMBER_RELEASE (m_pEmitter);
269+
REF_PTR_RELEASE (m_pEmitter);
269270
m_pEmitter = pemitter;*/
270271

271272
// Pass the emitter along to the pages
@@ -501,7 +502,7 @@ EmitterPropertySheetClass::Create_New_Emitter (void)
501502
// Display the new emitter
502503
//
503504
::GetCurrentDocument ()->Display_Emitter (emitter);
504-
MEMBER_RELEASE (emitter);
505+
REF_PTR_RELEASE (emitter);
505506

506507
/*SAFE_DELETE_ARRAY (color.Values);
507508
SAFE_DELETE_ARRAY (color.KeyTimes);

Core/Tools/W3DView/GraphicView.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "StdAfx.h"
2323
#include "W3DView.h"
2424
#include "GraphicView.h"
25+
#include "refcount.h"
2526
#include "ww3d.h"
2627
#include "Globals.h"
2728
#include "W3DViewDoc.h"
@@ -329,8 +330,8 @@ CGraphicView::OnDestroy (void)
329330
//
330331
// Free the camera object
331332
//
332-
MEMBER_RELEASE (m_pCamera);
333-
MEMBER_RELEASE (m_pLightMesh);
333+
REF_PTR_RELEASE (m_pCamera);
334+
REF_PTR_RELEASE (m_pLightMesh);
334335

335336
// Is there an update thread running?
336337
if (m_TimerID == 0) {
@@ -388,7 +389,7 @@ Set_Lowest_LOD (RenderObjClass *render_obj)
388389
if (psub_obj != NULL) {
389390
Set_Lowest_LOD (psub_obj);
390391
}
391-
MEMBER_RELEASE (psub_obj);
392+
REF_PTR_RELEASE (psub_obj);
392393
}
393394

394395
//

Core/Tools/W3DView/PlaySoundDialog.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
#include "StdAfx.h"
2323
#include "PlaySoundDialog.h"
24+
#include "refcount.h"
2425
#include "Utils.h"
2526
#include "AudibleSound.h"
2627

@@ -100,7 +101,7 @@ void
100101
PlaySoundDialogClass::OnCancel (void)
101102
{
102103
SoundObj->Stop ();
103-
MEMBER_RELEASE (SoundObj);
104+
REF_PTR_RELEASE (SoundObj);
104105

105106
CDialog::OnCancel ();
106107
return ;

0 commit comments

Comments
 (0)