Font release

Font release

Postby Richard Chidiak » Sat Sep 11, 2010 6:36 am

Antonio

We still have unrelased fonts when we use bgotfocus with xbrowse for instance, and i guess this happens with other controls also with gotfocus

This is a snapshot of my checkres.txt

My xbrowse in this particular program is using bgotfocus ..... , if i comment the line the fonts get released

Thanks for your help,

Richard

FONT,235542300,INITPLAN(457)->(b)PLANCHA00(407)->TCONTROL:GOTFOCUS(998)->(b)TXBROWSE:TXBROWSE(437)->TXBROWSE:GOTFOCUS(0)->TWINDOW:HANDLEEVENT(0)->TCONTROL:HANDLEEVENT(1499)->TXBROWSE:HANDLEEVENT(11063)->_FWH(3393)->SETFOCUS(0)->TWINDOW:GOTFOCUS(2596)->TWINDOW:HANDLEEVENT(0)->_FWH(3393)->SETFOCUS(0)->TWINDOW:SETFOCUS(2790)->FINPLANCH(354)->(b)PLANCHANT(253)->TBTNBMP:CLICK(463)->TBTNBMP:LBUTTONUP(658)->TBTNBMP:LBUTTONDOWN(598)->TCONTROL:HANDLEEVENT(1483)->TBTNBMP:HANDLEEVENT(1437)->_FWH(3393)->SYSREFRESH(0)->STOPUNTIL(60)->DFSAP(9538)->DEVPREP(6072)->MAJDET(1118)->DEVISCOR(61)->DEVFACMAJ(1373)->(b)DEVLIST(817)->TWINDOW:LDBLCLICK(1872)->TCONTROL:LDBLCLICK(1514)->TXBROWSE:LDBLCLICK(3470)->TWINDOW:HANDLEEVENT(0)->TCONTROL:HANDLEEVENT(1499)->TXBROWSE:HANDLEEVENT(11063)->_FWH(3393)->DIALOGBOX(0)->TDIALOG:ACTIVATE(279)->DEVLIST(922)->(b)MENUDEV(1196)->TMENU:COMMAND(437)->TWINDOW:COMMAND(1029)->TWINDOW:HANDLEEVENT(0)->_FWH(3393)->WINRUN(0)->TWINDOW:ACTIVATE(978)->MAIN(258)
http://www.cbati.com

Uestudio
Fwh 13.05 Harbour 3.2 MSVC 2013
User avatar
Richard Chidiak
 
Posts: 946
Joined: Thu Oct 06, 2005 7:05 pm
Location: France

Re: Font release

Postby nageswaragunupudi » Sat Sep 11, 2010 6:53 am

It is possible that a new font is created in the application program INITPLAN. If so the responsibility of finally releasing the font is that of the application program.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10335
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Font release

Postby Richard Chidiak » Sat Sep 11, 2010 7:06 am

Mr Rao

The font is released at the end of the program

If i remove the obrw:bgotfocus line, the checkres.txt does not show the font which means that the gotfocus is keeping the font

Hth

Richard
http://www.cbati.com

Uestudio
Fwh 13.05 Harbour 3.2 MSVC 2013
User avatar
Richard Chidiak
 
Posts: 946
Joined: Thu Oct 06, 2005 7:05 pm
Location: France

Re: Font release

Postby Antonio Linares » Sat Sep 11, 2010 7:23 am

Richard,

What actions does your app from such bGotFocus ?
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41469
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Font release

Postby Richard Chidiak » Sat Sep 11, 2010 7:36 am

Antonio

This is the line

oBrWPLC:bGotFocus := {|| (IF( FILE(TRANS[04] + ".DBF"),dbSelectArea(TRANS[04]), ) , IF(SELECT(TRANS[04]) = 0, INITPLAN(TRANS) , ) ) }

STATIC FUNCTION INITPLAN(TRANS)
FOR I = 1 TO LEN(TRANS[09]) // FONT
IF TRANS[09][I] # NIL
TRANS[09][I]:END() // FONT
ENDIF
NEXT

DEFINE FONT TRANS[09][1] NAME "ARIAL" SIZE 0,-16 BOLD
DEFINE FONT TRANS[09][2] NAME "ARIAL BLACK" SIZE 0,-14 UNDERLINE
DEFINE FONT TRANS[09][3] NAME "ARIAL BLACK" SIZE 0,-12
DEFINE FONT TRANS[09][4] NAME "ARIAL BLACK" SIZE 0,-10

...
http://www.cbati.com

Uestudio
Fwh 13.05 Harbour 3.2 MSVC 2013
User avatar
Richard Chidiak
 
Posts: 946
Joined: Thu Oct 06, 2005 7:05 pm
Location: France

Re: Font release

Postby Antonio Linares » Sat Sep 11, 2010 7:40 am

Richard,

Do you End() the fonts in TRANS[09][I] at the end of your app ?
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41469
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Font release

Postby Richard Chidiak » Sat Sep 11, 2010 7:41 am

Antonio

yes

this is the end routine

Code: Select all  Expand view


STATIC FUNCTION FINPLANCH(obrwplc,TRANS,TPAR)
IF TRANS[24] # NIL   // BRUSH
   TRANS[24]:END()
ENDIF

IF TRANS[15] # NIL   // BAR
   TRANS[15]:END()
ENDIF

IF obrwplc # NIL
   obrwplc:END()
   obrwplc := NIL
ENDIF

FOR I = 1 TO LEN(TRANS[09])  // FONT
   IF TRANS[09][I] # NIL
      TRANS[09][I]:END() // FONT
   ENDIF
NEXT

IF TRANS[04] # NIL   // FUSER
   IF FILE(TRANS[04] + ".DBF")
      CLOSEFIC(TRANS[04])
      ERASE (TRANS[04]) + ".DBF"
   ENDIF
ENDIF

IF wndpcmain # NIL
   wndpcmain:SetFocus()
   wndpcmain:PostMsg(WM_CLOSE)
   wndpcmain := NIL
ENDIF
RETURN .T.
 
http://www.cbati.com

Uestudio
Fwh 13.05 Harbour 3.2 MSVC 2013
User avatar
Richard Chidiak
 
Posts: 946
Joined: Thu Oct 06, 2005 7:05 pm
Location: France

Re: Font release

Postby Antonio Linares » Sat Sep 11, 2010 7:51 am

Richard,

Both the fonts and the brushes use a users counter to control shared owners. Please add this code:
Code: Select all  Expand view

      TRANS[09][I]:END() // FONT
      MsgInfo( TRANS[09][I]:nCount )
 

If there are no more (GDI object) users then nCount should be zero. This may help to locate where the font counter is not decreased or extra increased. Thanks! :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41469
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Font release

Postby Richard Chidiak » Sat Sep 11, 2010 7:58 am

Antonio

font1 = 4
font2 and 3 and 4 are 0

Richard
http://www.cbati.com

Uestudio
Fwh 13.05 Harbour 3.2 MSVC 2013
User avatar
Richard Chidiak
 
Posts: 946
Joined: Thu Oct 06, 2005 7:05 pm
Location: France

Re: Font release

Postby Richard Chidiak » Sat Sep 11, 2010 8:04 am

Antonio

This may help

the font is basically used this way

@ 15,70 SAY TRANS[28][1] PROMPT TRANS[26] OF TRANS[15] PIXEL SIZE 150,40 FONT TRANS[09][1] COLOR CLR_HBLUE CENTERED
@ 15,800 SAY TRANS[28][11] PROMPT TRANS[17] OF TRANS[15] PIXEL SIZE 150,40 FONT TRANS[09][1] COLOR CLR_HBLUE CENTERED UPDATE
obrwplc:aCols[X]:oheaderFont := TRANS[09][1]

Richard
http://www.cbati.com

Uestudio
Fwh 13.05 Harbour 3.2 MSVC 2013
User avatar
Richard Chidiak
 
Posts: 946
Joined: Thu Oct 06, 2005 7:05 pm
Location: France

Re: Font release

Postby nageswaragunupudi » Sat Sep 11, 2010 8:39 am

This posting of mine does not directly deal with the above problem, but .

It is always a safe practice to create fonts at the entry point and release them at the exit point and to avoid creation in a routine that is conditionally executed.

This practice greatly reduces the chance of obscure possibility of non-release of resources, which can be too difficult to debug.

Also assignment of fonts to a control/window should be by Obj:SetFont( oFont ) and not as obj:oFont := oFont.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10335
Joined: Sun Nov 19, 2006 5:22 am
Location: India


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: George, Google [Bot], Horizon, Otto and 152 guests