Page 1 of 1

OFnt:END() generating logfile

PostPosted: Fri Mar 10, 2017 3:48 pm
by aferra
I create the font object in this way:

DEFINE FONT cFontBot NAME "Ms Sans Serif" SIZE 0, -08 BOLD

And when I finish the dialog, after the active dialog, I destroy the source object in this way:

CFontBot: END ()

But this is creating a log with this message:

10/03/2017 11:57:02: EXCESS RELEASE OF FONT Ms Sans Serif [hFont: 0] (nCount: 61)
<-TFONT: END (284) <-TWINDOW: DESTROY (2145) <- (b) TDIALOG: TDIALOG (91) <-TDIALOG: DESTROY (0) <-TWINDOW: HANDLEEVENT (0) <-TDIALOG: HANDLEEVENT (914 ) <-DIALOGBOX (0) <-TDIALOG: ACTIVATE (296) <-CHK_MESSAGE (553)

What is the solution to not creating this log?

thanks in advance

Re: OFnt:END() generating logfile

PostPosted: Fri Mar 10, 2017 5:00 pm
by vilian
Aferra,

Don't do things like oDlg:oFont := oFontBot AND
Remove, CFontBot: END(). I believe it's not necessary anymore.

Re: OFnt:END() generating logfile

PostPosted: Fri Mar 10, 2017 5:24 pm
by nageswaragunupudi
Remove, CFontBot: END(). I believe it's not necessary anymore.

This is necessary.

Re: OFnt:END() generating logfile

PostPosted: Fri Mar 10, 2017 5:25 pm
by nageswaragunupudi
As Mr Vilian said, please look for code like
oObj:oFont := oFont

You should always assign a font either by using FONT clause in the command creating DIALOG/CONTROL or use oObj:SetFont( oFont )

Re: OFnt:END() generating logfile

PostPosted: Fri Mar 10, 2017 5:56 pm
by aferra
Okay, I'll check and return.

Re: oFnt:END() generating logfile

PostPosted: Tue May 23, 2017 9:17 am
by dutch
I've got the same problem with this topic
The problem is occurred on oFnt:End() that assign for DIALOG only. The :End() method of other assignment has not any problem.
Code: Select all  Expand view
oFnt := TFont():New( MEMVAR->aFonts[14],, -16, .F., .F., 0, 0, 400, .F., .F., .F., 222, 3, 2, 1, , 34 )
oFnt1:= TFont():New( MEMVAR->aFonts[14],, -14, .F., .F., 0, 0, 400, .F., .F., .F., 222, 3, 2, 1, , 34 )
oFnt2:= TFont():New( MEMVAR->aFonts[14],, -22, .F., .F., 0, 0, 700, .F., .F., .F., 222, 3, 2, 1, , 34 )

DEFINE DIALOG oDlg RESOURCE 'REPORT' ;
         COLOR CLR_BLACK, THEME2007 ;
         FONT oFnt
   
   oDlg:lHelpIcon := .F.

   REDEFINE TITLE oHeader ID 100 OF oDlg ;
            SHADOW BOTTOMLEFT SHADOWSIZE 2
       
            oHeader:AddText( 8, 15, cRptTitle , , , , "BOTTOMLEFT" , oFnt2 , CLR_WHITE )
 
    REDEFINE LISTBOX oLbx ;
            FIELDS REP->REP_NR, REP->REP_NAME ;
            FIELDSIZES 50, 100 ;
            FONT oFnt ;
            HEADER 'No.', 'Report Name' ;
            ID 101 OF oDlg ;
            COLORS RGB(  0 ,   0 ,   0 ),RGB( 192 , 192 , 192 ) ;
            ON DBLCLICK if(empty(REP->REP_SECRET).or.(REP->REP_SECRET='Y'.and.UserRights(13)) , RPTPROMPT() ,  )

   oLbx:bRClicked = { | nRow, nCol, nFlags | (oLbx:SetFocus(), oLbx:lButtonDown(nRow,nCol),if(UserRights(14,.T.),ShowPopup( nRow, nCol, oDlg, oLbx ), ) ) }

    WbrStyles( oLbx )  

    oLbx:bChange    := {|| (oSays:settext( MEMVAR->FindKey ) , oSays:refresh())  }      

   oLbx:lMChange   := .F.
   oLbx:lAdjLastCol:= .T.
   oLbx:nLineStyle  := 10
   oLbx:nLineHeight := 28
   oLbx:nHeaderHeight:= 29
   oLbx:aHJustify       := { 2, 2 }
   oLbx:aJustify        := { 2, 0 }

   oLbx:bKeyChar = { | nKey | IIF(nKey = VK_RETURN , (iif((REP->REP_SECRET='Y'.and.UserRights(13)).or.REP->REP_SECRET<>'Y',RPTPROMPT(),MsgStop(' You can not print this report ')) , oLbx:SetFocus() ), ;
                                    (FindRpt(nKey,oLbx),oSays:Refresh()) ) }

   oLbx:bKeyDown = { | nKey |(IIF(nKey = VK_INSERT.and.UserRights(14,.F.), RptSet(.T.,oLbx,.F.) , ;
                                    IIF(nKey = VK_ADD   .and.UserRights(14,.F.), RptSet(.F.,oLbx,.F.) , ;
                                    IIF(nKey = VK_DELETE.and.UserRights(14,.F.), DelRpt(oLbx) , ) ) ) , oLbx:Refresh()) }


    REDEFINE SAY oSay PROMPT 'Search :' ID 202 OF oDlg  FONT oFnt1
   
    REDEFINE SAY oSays PROMPT FindKey ID 102 OF oDlg PICTURE '@!' FONT oFnt1 ;
                COLORS CLR_BLUE, CLR_WHITE
               
                oSays:lTransparent := .F.

    REDEFINE SAY oSay PROMPT 'DOUBLE CLICK OR ENTER TO SELECT OPTION' ID 201 OF oDlg ;
                FONT oFnt

ACTIVATE DIALOG oDlg CENTER RESIZE16

oFnt1:End()
oFnt2:End()
oFnt:End() <- Line 84

23/05/17 14:27:54: EXCESS RELEASE OF FONT Tahoma[ hFont : 0] ( nCount : 0 )
<-TFONT:END(285) <-REPORT(84) <-(b)MAIN(266) <-TWINDOW:ACTIVATE(1022) <-MAIN(266)
------------------------------------------------------------
23/05/17 14:39:13: EXCESS RELEASE OF FONT Tahoma[ hFont : 0] ( nCount : 0 )
<-TFONT:END(285) <-REPORT(84) <-(b)MAIN(266) <-TWINDOW:ACTIVATE(1022) <-MAIN(266)
------------------------------------------------------------
23/05/17 16:09:34: EXCESS RELEASE OF FONT Tahoma[ hFont : 0] ( nCount : 0 )
<-TFONT:END(285) <-REPORT(84) <-(b)MAIN(267) <-TWINDOW:ACTIVATE(1022) <-MAIN(267)
------------------------------------------------------------
23/05/17 16:10:24: EXCESS RELEASE OF FONT Tahoma[ hFont : 0] ( nCount : 0 )
<-TFONT:END(285) <-REPORT(84) <-(b)MAIN(267) <-TWINDOW:ACTIVATE(1022) <-MAIN(267)
------------------------------------------------------------

Re: OFnt:END() generating logfile

PostPosted: Tue May 23, 2017 9:28 am
by Enrico Maria Giordano
You don't have to explicitly release a font assigned to a control using FONT clause. That control takes the ownership and therefore the responsibility to release it.

EMG

Re: OFnt:END() generating logfile

PostPosted: Tue May 23, 2017 9:34 am
by dutch
Enrico Maria Giordano wrote:You don't have to explicitly release a font assigned to a control using FONT clause. That control takes the ownership and therefore the responsibility to release it.

EMG

Dear EMG,

It means End dialog will be ended font also, doesn't it?

Thanks

Re: OFnt:END() generating logfile

PostPosted: Tue May 23, 2017 9:41 am
by nageswaragunupudi
Dutch

The excess release must be happening elsewhere.
Otherwise the part of the code you published looks ok.

For testing change the size of oFnt from -16 and -17 and see

Re: OFnt:END() generating logfile

PostPosted: Tue May 23, 2017 9:58 am
by cnavarro
As Mr Rao says, the problem may be elsewhere in your program
As stated Enrico, control has to destroy the resources that are used for control, but also if you want to be sure to destroy the fonts, you can try
Code: Select all  Expand view

   Do While oFont:nCount > 0
      oFont:End()
   Enddo
 

Re: OFnt:END() generating logfile

PostPosted: Tue May 23, 2017 11:26 am
by dutch
It shows the same error in the same line.
23/05/17 17:53:04: EXCESS RELEASE OF FONT Tahoma[ hFont : 0] ( nCount : 0 )
<-TFONT:END(285) <-REPORT(86) <-(b)MAIN(267) <-TWINDOW:ACTIVATE(1022) <-MAIN(267)

Re: OFnt:END() generating logfile

PostPosted: Tue May 23, 2017 1:13 pm
by nageswaragunupudi
cnavarro wrote:As Mr Rao says, the problem may be elsewhere in your program
As stated Enrico, control has to destroy the resources that are used for control, but also if you want to be sure to destroy the fonts, you can try
Code: Select all  Expand view

   Do While oFont:nCount > 0
      oFont:End()
   Enddo
 

Mr Cristobal
This is not a case of under release of fonts.
This is a case where a font is released more than it is incremented.