(x)harbour class - destroy method

Post Reply
User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

(x)harbour class - destroy method

Post by nageswaragunupudi »

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
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

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
User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Post by nageswaragunupudi »

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

Code: Select all

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
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Post by Enrico Maria Giordano »

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:

Code: Select all

#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
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

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
Post Reply