>>
oDlg:SetBrush( TBrush():New( ,,,, hBmp ) )
>>
TBrush():new() creates a brush object and sets the count to 1. oWnd/oDlg:SetBrush( oBrush ) increments count to 2. When the window/dialog is closed, the count of oBrush is decremented to 1. The program that first creates the brush is responsible to finally release the brush. In the above usage the brush is never released.
Therefore it is not desirable to create brush inline while setting brush.
What is to be done is :
Create brush ( count : 1 )
setbrush --> count 2
close window --> count 1
brush:end --> count 0 and released
Examining the code for SetBrush makes it clear:
- Code: Select all Expand view
METHOD SetBrush( oBrush ) INLINE If( ::oBrush != nil, ::oBrush:End(),),;
::oBrush := oBrush,;
If( oBrush:nCount == nil, oBrush:nCount := 1, oBrush:nCount++),;
::Refresh()