Problem with Tree using bimaps from resources

Problem with Tree using bimaps from resources

Postby Marco Turco » Sat Mar 01, 2014 2: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
User avatar
Marco Turco
 
Posts: 858
Joined: Fri Oct 07, 2005 12:00 pm
Location: London

Re: Problem with Tree using bimaps from resources

Postby Marco Turco » Mon Mar 03, 2014 8:07 am

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

Marco Turco
SOFTWARE XP LLP
User avatar
Marco Turco
 
Posts: 858
Joined: Fri Oct 07, 2005 12:00 pm
Location: London

Re: Problem with Tree using bimaps from resources

Postby James Bott » Tue Mar 04, 2014 5: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
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 75 guests