(x)harbour class - destroy method

(x)harbour class - destroy method

Postby nageswaragunupudi » Tue Jan 01, 2008 7: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
User avatar
nageswaragunupudi
 
Posts: 10313
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Postby Antonio Linares » Tue Jan 01, 2008 8: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
User avatar
Antonio Linares
Site Admin
 
Posts: 41414
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby nageswaragunupudi » Tue Jan 01, 2008 9: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
Code: Select all  Expand view
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
nageswaragunupudi
 
Posts: 10313
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Postby Enrico Maria Giordano » 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:

Code: Select all  Expand view
#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
Enrico Maria Giordano
 
Posts: 8379
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby Antonio Linares » Tue Jan 01, 2008 5: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
User avatar
Antonio Linares
Site Admin
 
Posts: 41414
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 26 guests

cron