The Release method was used (HMG3) with window "object"!
There are other problems that I do not know which require the use? We must use Release for any control?
The Release method was used (HMG3) with window "object"!
There are other problems that I do not know which require the use? We must use Release for any control?
Many thanks in advance.
Me too.
Not really sure, but if an object isn't "released" doesn't it retains some memory ?
METHOD Release() CLASS BASIC
// Some QT classes do not have close()
IF !( ::cClass = "MENUITEM" .OR.;
::cClass = "SOUND" .OR.;
::cClass = "TIMER" .OR.;
::cClass = "LAYOUTBOX" .OR.;
::cClass = "LAYOUTFORM".OR.;
::cClass = "LAYOUTGRID" )
::oQTObject:close()
ENDIF
RETURN Self
Hi Luigi, that was me.
This is because the QT related objects don't have the Close() method.
Ok, so the best to do in a OOP world is to override METHOD Release in MENUITEM SOUND LAYOUTBOX etc to do the close() and keep an "empty" METHOD Release in basic.prg
what do you think ?
and I find (ie within samples\mainmenu\demo_1.prg) this:
The Release method was used (HMG3) with window "object"!
There are other problems that I do not know which require the use? We must use Release for any control?
Many thanks in advance.
Me too.
Not really sure, but if an object isn't "released" doesn't it retains some memory ?
Objects are "fully released" when the harbour object is released. It is not necessary to do the :release() stuff just to free memory. If it is necessary aka an error happens if you don't release() there is an error somewhere so please report.
mrduck wrote:Objects are "fully released" when the harbour object is released
it's better to remove the code within examples else like me other can take a bad idea.
On the other hand, If we want close an object (this it's not HMG3 compliant, but...) we can preserve the idea, but with
mrduck wrote:Ok, so the best to do in a OOP world is to override METHOD Release in MENUITEM SOUND LAYOUTBOX etc to do the close() and keep an "empty" METHOD Release in basic.prg
Ok, so the best to do in a OOP world is to override METHOD Release in MENUITEM SOUND LAYOUTBOX etc to do the close() and keep an "empty" METHOD Release in basic.prg
mrduck wrote:Objects are "fully released" when the harbour object is released.
This is a little bit gray to me... I do not really know this in deep.
Could you please explain when a harbour object is released ? Or point where can I find this info ?
mrduck wrote:Objects are "fully released" when the harbour object is released.
This is a little bit gray to me... I do not really know this in deep.
Could you please explain when a harbour object is released ? Or point where can I find this info ?
How many hours do you have available ?
Standard harbour objects are released when:
- they go out of scope
- they are set := NIL
You can check this by adding a destructor to the class
Out of scope means that the variable is no longer visible. PUBLICs are never released.
Harbour objects that are linked to low-level external structures handled by different libraries like in hbQt case and a couple of others cases are instead freed in a very different way: harbour object is no more usable from a prg level program but the variable is put on a special list and from time to time the garbage collector call a routine specified durint object creation and this routine reports if the object can be finally destroyed or not. Sorry, it's a very basic explanation, if you want I can send you a couple of messages from Przemek...
Hi
I've made this change to this code some time ago, if someone want to test it, replace in basic.prg and remove release method in control.prg
Is recursive and clean the array ::aControls. No need to release each control in code.
/*----------------------------------------------------------------------*/
METHOD Release() CLASS BASIC
LOCAL i
// Some QT classes do not have close()
IF ! ( ::cClass == "MENUITEM" .OR. ;
::cClass == "SOUND" .OR. ;
::cClass == "TIMER" .OR. ;
::cClass == "LAYOUTBOX" .OR. ;
::cClass == "LAYOUTFORM" .OR. ;
::cClass == "LAYOUTGRID" )
// release QT object
::oQTObject:close()
ENDIF
// Release all child objects in it.
// Recursive !
FOR i := 1 TO Len( ::aControls )
IF hb_IsObject( ::aControls[ i ] )
::aControls[ i ]:Release()
ENDIF
NEXT
// Remove from the parent pool control
FOR i := 1 TO Len( ::oParent:aControls )
IF hb_IsObject( ::oParent:aControls[ i ] )
IF ::oParent:aControls[ i ]:Name == ::Name
::oParent:aControls[ i ] := Nil
ENDIF
ENDIF
NEXT
RETURN Self