Properly destroying components created with set_ref
Posted: Thu Jun 01, 2017 12:06 am
Is there a "proper" way to destroy components that were created with set_ref?
I am managing the lifetime of objects that inherit from CMGRPTReportList where the object is defined like:
uTerminate and uInitialize are mthroutines defined in CMGRPTReportList that provides the object a place to get initialized and clean up before getting killed.
When I create a new object and kill the current object I am doing this: (STD_TEXT contains the identifier of the object to be created)
Is setting the object to *NULL the correct way to handle destroying the object?
I am managing the lifetime of objects that inherit from CMGRPTReportList where the object is defined like:
Code: Select all
define_com class(#CMGRPTReportList) name(#ReportList) reference(*DYNAMIC)
When I create a new object and kill the current object I am doing this: (STD_TEXT contains the identifier of the object to be created)
Code: Select all
#STD_TEXT := #ReportListMap<#reportId>
if (#ReportList *IsNot *NULL)
#ReportList.uTerminate
set_ref com(#ReportList) to(*NULL)
endif
set_ref com(#ReportList) to(*CREATE_FROM #STD_TEXT)
if (#ReportList *IsNot *NULL)
#ListLayoutItem.Manage <= #ReportList
#ListLayoutItem.Sizing := FitBoth
#ReportList.Parent <= #ListPanel
#ReportList.uInitialize
endif