your idea it's good but I have some doubt:
1) about QT objects: when I close (release) a form every child it's released. For this reason, looking to your code: before I close a form and then I have a loop for every child (good), but it's already closed. I repeat: about QT
Attention: it's an idea, I don't test it
1) the release method cant' be in a unique place. Every object must have a release method ( as MrDuck write). I think this for other things, anyway.
2) Well, I change the order: before I execute the loop and then close the object:
Code: Select all
METHOD Release() CLASS WINDOW or BUTTON or ....
LOCAL i
LOCAL cCurrentObj := ::cName //<<---- to clear current object
// Release all child objects in it.
// Recursive !
FOR i := 1 TO Len( ::aControls )
IF hb_IsObject( ::aControls[ i ] )
::aControls[ i ]:Release()
ENDIF
NEXT
// Some QT classes do not have close()
::oQTObject:close() //<=== this must be inserted if the QT object has the close method
// I remember to you: the release method must by overwrite for every object
::oParent:&cCurrentObj := NIL //<=== remove my self Harbour/HMG4
RETURN NIL
In this moment I don't have a clear idea. I'm working to extend ONRELEASE to every object.
On the other hand, I'm working to find a good way to connect and handle events and signals. Thanks to MrDuck for inspiration!
This is a little real example that I'm using on my experimental HMG4, within every object class
Code: Select all
::oQtObject:connect( QEvent_WindowStateChange, { |e| ::ZonChangeDo( e ) } ) <=== this only for window
::oQtObject:connect( QEvent_Close, { || ::ZonCloseDo() } )
::oQTObject:connect( QEvent_FocusIn, { || ::ZonFocusInDo() } )
etc., etc.
Cheers