FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Font release
Posts: 946
Joined: Thu Oct 06, 2005 07:05 PM
Font release
Posted: Sat Sep 11, 2010 06: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
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Font release
Posted: Sat Sep 11, 2010 06: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
Posts: 946
Joined: Thu Oct 06, 2005 07:05 PM
Re: Font release
Posted: Sat Sep 11, 2010 07: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
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Font release
Posted: Sat Sep 11, 2010 07:23 AM

Richard,

What actions does your app from such bGotFocus ?

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 946
Joined: Thu Oct 06, 2005 07:05 PM
Re: Font release
Posted: Sat Sep 11, 2010 07: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
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Font release
Posted: Sat Sep 11, 2010 07: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
Posts: 946
Joined: Thu Oct 06, 2005 07:05 PM
Re: Font release
Posted: Sat Sep 11, 2010 07:41 AM
Antonio

yes

this is the end routine

Code (fw): Select all Collapse
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
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Font release
Posted: Sat Sep 11, 2010 07:51 AM
Richard,

Both the fonts and the brushes use a users counter to control shared owners. Please add this code:
Code (fw): Select all Collapse
      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
Posts: 946
Joined: Thu Oct 06, 2005 07:05 PM
Re: Font release
Posted: Sat Sep 11, 2010 07: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
Posts: 946
Joined: Thu Oct 06, 2005 07:05 PM
Re: Font release
Posted: Sat Sep 11, 2010 08: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
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Font release
Posted: Sat Sep 11, 2010 08: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

Continue the discussion