FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour (x)harbour class - destroy method
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
(x)harbour class - destroy method
Posted: Tue Jan 01, 2008 07:03 AM

I see some classes in FWH have a method by name Destroy(). If we name a method as Destroy, will it be called automatically, when the object goes out of reference ?

xharbour documentation mentions about DESTROYER method. Does it also called automatically?

Can any one clarify please?

Regards



G. N. Rao.

Hyderabad, India
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
(x)harbour class - destroy method
Posted: Tue Jan 01, 2008 08:33 AM

Nageswararao,

>
I see some classes in FWH have a method by name Destroy(). If we name a method as Destroy, will it be called automatically, when the object goes out of reference ?
>

FWH automatically calls method Destroy() when a windows msg WM_DESTROY arrives:

http://msdn2.microsoft.com/en-us/library/ms632620.aspx

>
xharbour documentation mentions about DESTROYER method. Does it also called automatically?
>

FWH does not uses those methods, in order to have full control of what it is happening in the application

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
(x)harbour class - destroy method
Posted: Tue Jan 01, 2008 09:33 AM
I have some related doubts about releasing objects like fonts, brushes etc. Normally I place the commands release fonts and other objects after the main (mdi) window's activate command. Example
func main()

define window ownd MDI ....
.........
activate window ownd
release font ...
release brush ...
return 0



1) IF somewhere in one of the modules if we call WndMain():End(), does the control go to the statements after the main window's activate command and execute all release commands?
2) If somewhere in one of the modules if we issue the statement QUIT, is there the danger that the resources are not destroyed/ released?
if so, is it good to keep the release statements in the EXIT PROCEDURE ?

Or is it desirable that all FWH classes for the resources have a destroy method, so that all the resources are destryoyed / released when the program terminates?
Regards



G. N. Rao.

Hyderabad, India
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
(x)harbour class - destroy method
Posted: Tue Jan 01, 2008 10:59 AM
nageswaragunupudi wrote:1) IF somewhere in one of the modules if we call WndMain():End(), does the control go to the statements after the main window's activate command and execute all release commands?


Yes.

nageswaragunupudi wrote:2) If somewhere in one of the modules if we issue the statement QUIT, is there the danger that the resources are not destroyed/ released?


Yes. Example:

#include "Fivewin.ch"


FUNCTION MAIN()

    LOCAL oWnd

    DEFINE WINDOW oWnd

    @ 1, 1 BUTTON "Test";
           SIZE 100, 20;
           ACTION oWnd:End() //MYQUIT()

    ACTIVATE WINDOW oWnd

    ? "Exiting"

    RETURN NIL


STATIC FUNCTION MYQUIT()

    QUIT

    RETURN NIL


nageswaragunupudi wrote:if so, is it good to keep the release statements in the EXIT PROCEDURE ?


How an EXIT PROCEDURE could see all the variables used in the app for keeping reference of font, brush, etc.? It seem a bad idea.

Maybe the easier solution is to not use QUIT at all.

EMG
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
(x)harbour class - destroy method
Posted: Tue Jan 01, 2008 05:07 PM

Nageswararao, Enrico,

> Maybe the easier solution is to not use QUIT at all.

Right. QUIT should not be used at all.

regards, saludos

Antonio Linares
www.fivetechsoft.com

Continue the discussion