FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour font release in dialogs
Posts: 946
Joined: Thu Oct 06, 2005 07:05 PM
font release in dialogs
Posted: Wed Sep 01, 2010 02:58 PM

Antonio

i need to understand how fonts are released in dialogs :?

ex

define dialog odlg...
define font afont ....

redefine button id 01 action ...,odlg:end() // here

activate dialog odlg

afont:end() // this should release the font

it is not, in order to release the font i need to code this way

redefine button id 01 action ..afont:end(),odlg:end()

This is what is consuming memory

making the change like above is releasing properly the font....

Am i missing something ?

http://www.cbati.com

Uestudio
Fwh 13.05 Harbour 3.2 MSVC 2013
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: font release in dialogs
Posted: Wed Sep 01, 2010 03:20 PM

It is the correct way to release a font, as far as I know.

EMG

Posts: 946
Joined: Thu Oct 06, 2005 07:05 PM
Re: font release in dialogs
Posted: Wed Sep 01, 2010 03:44 PM

Maybe i did not explain it correctly

in the sample below

ACTIVATE DIALOG ODLG CENTERED
AFONT:END() // this line not executed
ASIZE := {} // this line OK
OBRW:GetDisplayColsWidth(@ASIZE) // this line ok

Another question , the font is a local variable in my case, why isn't it destroyed automatically at the end of the program ?

Antonio , is there a change in releasing fonts in fwh 10.7 ?

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 in dialogs
Posted: Wed Sep 01, 2010 06:15 PM

Richard,

We have not changed fonts management recently (I have just checked our private SVN). Maybe another change is related with the fonts.

How do you use aFont in your code ? You create it but I don't see where you use it and how, thanks :-)

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Re: font release in dialogs
Posted: Wed Sep 01, 2010 07:04 PM
A Test, shows Font undefined, activated / deactivated

Code (fw): Select all Collapse
#include "FiveWin.ch"

FUNCTION MAIN()
LOCAL oDlg, oFont, oFont1, oSay, lFontEnd := .F.

// Undefined Fonts are shown with Default-Values( no Error-Message ! )

DEFINE DIALOG oDlg FROM 5, 5 TO 240, 400  TITLE "Fonttest"    PIXEL  FONT oFont

// Font < oFont > is UNDEFINED, Default-values are used !!!

@ 40, 30 SAY oSay PROMPT "Main-Dialog with UNDEFINED Font" OF oDlg ;
PIXEL FONT oFont ;
SIZE 100, 25 COLOR 0

@ 80,120 BUTTON "&Exit" size 50, 20 FONT oFont OF oDlg PIXEL ;
ACTION oDlg:End()

ACTIVATE DIALOG oDlg CENTERED ;

lFontEnd := .F.
// 1. Dialog-Test with UNDEFINED Font
TEST_FONT(lFontEnd, oFont1)

lFontEnd := .T.
// 2. Dialog-Test with DEFINED Font
TEST_FONT(lFontEnd, oFont1)

lFontEnd := .F.
// 3. Dialog-Test with ENDED Font in 2.Dialog-Test
TEST_FONT(lFontEnd, oFont1)

RETURN( NIL )

// -----------------

FUNCTION TEST_FONT(lFontEnd, oFont1)
LOCAL oDlg1, oSay1

IF lFontEnd = .T.
      oFont1 := TFont():New("Arial",0,-16,.F.,.T.,0,0,0,.T. )
ENDIF

DEFINE DIALOG oDlg1 FROM 5, 5 TO 240, 400  TITLE "Fonttest" PIXEL  FONT oFont1 

IF lFontEnd = .T. 
      @ 40, 30 SAY oSay1 PROMPT "Test-Dialog with DEFINED Font" OF oDlg1 ;
      PIXEL FONT oFont1 ;
      SIZE 150, 25 COLOR 0
ELSE
      @ 40, 30 SAY oSay1 PROMPT "Test-Dialog with UNDEFINED Font ( oFont1 )" OF oDlg1 ;
      PIXEL FONT oFont1 ;
      SIZE 150, 25 COLOR 0
ENDIF

@ 80,120 BUTTON "&Exit Test" size 50,20  OF oDlg1 FONT oFont1 PIXEL ;
ACTION oDlg1:End()

ACTIVATE DIALOG oDlg1 CENTERED ;

IF lFontEnd = .T. 

      oFont1:End() // !!!!!!!!

      MsgAlert( "Next Test will show oFont1 " + CRLF + ;
          "UNDEFINED !!!" + CRLF + ;
          "with oFont1:End()", "Attention" )
ENDIF

RETURN( NIL )




Best Regards
Uwe :-)
Since 1995 ( the first release of FW 1.9 )

i work with FW.

If you have any questions about special functions, maybe i can help.
Posts: 946
Joined: Thu Oct 06, 2005 07:05 PM
Re: font release in dialogs
Posted: Thu Sep 02, 2010 03:59 AM

Antonio

I use fonts essentially with xbrowse and gets in my dialogs

My concern is the end of the dialog , this is where some change has happened

I will publish a small test this morning to show the problem, i have identified it

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 in dialogs
Posted: Thu Sep 02, 2010 08:43 AM
Antonio

this is a sample that demonstrates the problem, add rescheck.prg for the project
you will see that the font is still present and it should not

Code (fw): Select all Collapse
#include "FiveWin.ch"

function Main()
LOCAL ATAB   := {}, ;
      LSAVE  := .F., ;
      ODLG,OBRW,AFONT

AADD(ATAB,{"NUM1","NUM2","NUM3"})

SetResDebug()

DEFINE DIALOG ODLG RESOURCE "TESTFONT" TITLE "TEST FONTS"
DEFINE FONT aFONT NAME "Arial" SIZE 0,-12

REDEFINE XBROWSE oBrw ID 201 OF ODLG ;
   FONT aFont ;
   COLORS {|| { CLR_BLUE, CLR_WHITE } } ;
   array ATAB AUTOCOLS AUTOSORT

oBrw:nMarqueeStyle       := MARQSTYLE_HIGHLROW
oBrw:lColDividerComplete := .t.
oBrw:nColDividerStyle    := LINESTYLE_LIGHTGRAY
oBrw:nRowDividerStyle    := LINESTYLE_LIGHTGRAY

oBrw:bClrheader := {|| { CLR_HBLUE, CLR_WHITE } }

REDEFINE BUTTON ID 01 OF ODLG ACTION (LSAVE := .T., ODLG:END())
REDEFINE BUTTON ID 02 OF ODLG ACTION (LSAVE := .F., ODLG:END())

ACTIVATE DIALOG ODLG CENTERED
AFONT:END()

CHECKRES()
return nil

#include <windows.h>
#include <commctrl.h>
#include <richedit.h>

LANGUAGE LANG_ENGLISH,SUBLANG_ENGLISH_US

TESTFONT DIALOG DISCARDABLE 21, 13, 283, 183
STYLE WS_POPUP|DS_MODALFRAME|WS_CAPTION|WS_SYSMENU|WS_VISIBLE
FONT 10, "Tahoma"
{
  CONTROL "", 201, "tXbrowse", 0x00b00000, 0, 1, 276, 151
  CONTROL "OK", IDOK, "Button", BS_DEFPUSHBUTTON|WS_TABSTOP, 0, 160, 42, 21
  CONTROL "Annuler", IDCANCEL, "Button", WS_TABSTOP, 240, 160, 42, 21
}



if you modify the tst program this way

Code (fw): Select all Collapse
REDEFINE BUTTON ID 01 OF ODLG ACTION LSAVE := .T. , AFONT:END(), ODLG:END()
REDEFINE BUTTON ID 02 OF ODLG ACTION LSAVE := .F. , AFONT:END(), ODLG:END()


the font is released ...
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 in dialogs
Posted: Thu Sep 02, 2010 08:45 AM
Richard,

Please comment out the xbrowse code section:
Code (fw): Select all Collapse
/*


REDEFINE XBROWSE oBrw ID 201 OF ODLG ;
   FONT aFont ;
   COLORS {|| { CLR_BLUE, CLR_WHITE } } ;
   array ATAB AUTOCOLS AUTOSORT

oBrw:nMarqueeStyle       := MARQSTYLE_HIGHLROW
oBrw:lColDividerComplete := .t.
oBrw:nColDividerStyle    := LINESTYLE_LIGHTGRAY
oBrw:nRowDividerStyle    := LINESTYLE_LIGHTGRAY

oBrw:bClrheader := {|| { CLR_HBLUE, CLR_WHITE } }

*/

and see if the font problem persists, thanks :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 946
Joined: Thu Oct 06, 2005 07:05 PM
Re: font release in dialogs
Posted: Thu Sep 02, 2010 08:54 AM

Antonio

without xbrowse, the font is released correct at the end of the dialog

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 in dialogs
Posted: Thu Sep 02, 2010 09:25 AM

Richard,

We are checking it. We will provide you an answer in a few minutes... :-)

Thanks,

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: font release in dialogs
Posted: Thu Sep 02, 2010 09:28 AM
Richard,

Please remove this code from Class TXBrowse Method Initiate():
Code (fw): Select all Collapse
   /*
   if ::oFont != nil
      ::SetFont( ::oFont )
   else
      ::GetFont()
   endif
   */

as the font was already assigned from:
Code (fw): Select all Collapse
   if hDlg != nil
      Super:Initiate( hDlg )
   ...

some lines above, so the font was assigned an extra time.

With such fix, your code is working fine and the font gets properly released :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 946
Joined: Thu Oct 06, 2005 07:05 PM
Re: font release in dialogs
Posted: Thu Sep 02, 2010 02:40 PM

Antonio

Thanks , it works ok now

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 in dialogs
Posted: Fri Sep 03, 2010 04:51 AM

Antonio

A similar problem exists with Gets but only when Memo is specified, in this case fonts are not released , when no memo clause is specified fonts get released

Ex : redefine get id xxx of odlg memo font afont

activate dialog odlg

afont:end() // has no effect in this case

Thanks for your help

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 in dialogs
Posted: Fri Sep 03, 2010 11:42 AM
Richard,

In Class TMultiGet (source\classes\mget.prg) this code has to be removed:
Code (fw): Select all Collapse
METHOD Default() CLASS TMultiGet

   /*
   if ::oFont != nil
      ::SetFont( ::oFont )
   else
      ::SetFont( ::oFont )
   endif
   */

return nil

Many thanks for your feedback :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com

Continue the discussion