FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Problem with Tree using bimaps from resources
Posts: 858
Joined: Fri Oct 07, 2005 12:00 PM
Problem with Tree using bimaps from resources
Posted: Sat Mar 01, 2014 02:58 PM

Hi, I made an xbrowse with tree and I'm using bitmaps from resources.
It seems there is a memory leak. The bitmaps appears the first time the dialog is displayed but not if I close and recall the dialog.
Any ideas ?

b_FolderOpened:=LoadBitMap( GetResources(), "16open")
b_Folder:=LoadBitMap( GetResources(), "16folder")
b_mptydoc:=LoadBitMap( GetResources(), "16mptydoc")

DEFINE DIALOG oDlg FONT oGenFont RESOURCE "XP_034" TITLE CTITLE

  redefine XBROWSE oBrw id 102 FONT oGenFont OF oDlg NOBORDER

oBrw:SetTree( oTree, { b_FolderOpened, ;
                      b_Folder, ;
                      b_mptydoc } )

WITH OBJECT oBrw:aCols[ 1 ]

    :AddResource( "16hdrive" )
    :nWidth     := 340
    :cHeader    := 'Cartella'
    b           := :bLDClickData

    :bLDClickData  := { |r,c,f,o| ToggleFolder( r,c,f,o,b ) }

    :bBmpData   := { || If( ':' $ oBrw:oTreeItem:cPrompt, 4, ;
                      If( 'D' $ oBrw:oTreeItem:Cargo[ 5 ], ;
                      If( oBrw:oTreeItem:lOpened, 1, 2 ), 3 ) ) }

END

ACTIVATE DIALOG oDlg CENTER
Best Regards,



Marco Turco

SOFTWARE XP LLP
Posts: 858
Joined: Fri Oct 07, 2005 12:00 PM
Re: Problem with Tree using bimaps from resources
Posted: Mon Mar 03, 2014 08:07 AM

The problem seems to be solved with a local definition of these variables.

Best Regards,



Marco Turco

SOFTWARE XP LLP
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: Problem with Tree using bimaps from resources
Posted: Tue Mar 04, 2014 05:35 PM

Marco,

Thanks for reporting the solution.

This is another reason why I always declare all my variables as LOCAL with the rare exception of a STATIC. I never use PUBLIC or PRIVATE. And I set the compiler to report any undeclared variables. This has really helped reduce bugs.

James

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10

Continue the discussion