From: <ah...@us...> - 2008-06-22 20:37:13
|
Revision: 11816 http://jvcl.svn.sourceforge.net/jvcl/?rev=11816&view=rev Author: ahuser Date: 2008-06-22 13:37:12 -0700 (Sun, 22 Jun 2008) Log Message: ----------- Mantis #4372 Memory Leak in TJvTransparentButton Modified Paths: -------------- trunk/jvcl/run/JvTransparentButton.pas Modified: trunk/jvcl/run/JvTransparentButton.pas =================================================================== --- trunk/jvcl/run/JvTransparentButton.pas 2008-06-21 10:59:03 UTC (rev 11815) +++ trunk/jvcl/run/JvTransparentButton.pas 2008-06-22 20:37:12 UTC (rev 11816) @@ -125,19 +125,15 @@ FOutline: TJvFrameStyle; FWordWrap: Boolean; - { former TJvTransparentButton } FGlyph: TBitmap; FGrayGlyph: TBitmap; FDisabledGlyph: TBitmap; FNumGlyphs: TNumGlyphs; - { former TJvTransparentButton2 } FKeepMouseLeavePressed: Boolean; FImages: TJvTransparentButtonImages; - { former TJvTransparentButton } procedure SetGlyph(Bmp: TBitmap); procedure SetNumGlyphs(Value: TNumGlyphs); procedure CalcGlyphCount; - { former TJvTransparentButton2 } procedure SetImages(Value: TJvTransparentButtonImages); procedure SetWordWrap(Value: Boolean); @@ -156,11 +152,9 @@ function GetActionLinkClass: TControlActionLinkClass; override; procedure GlyphChanged(Sender: TObject); - { former TJvTransparentButton } procedure AddGlyphGlyphs(AGlyph: TBitmap; AColor: TColor; Value: Integer); procedure ActionChange(Sender: TObject; CheckDefaults: Boolean); override; - { former TJvTransparentButton2 } procedure Notification(AComponent: TComponent; Operation: TOperation); override; procedure AddImageGlyphs; public @@ -217,10 +211,8 @@ property OnParentColorChange; property OnStartDrag; - { former TJvTransparentButton } property Glyph: TBitmap read FGlyph write SetGlyph; property NumGlyphs: TNumGlyphs read FNumGlyphs write SetNumGlyphs default 1; - { former TJvTransparentButton2 } property KeepMouseLeavePressed: Boolean read FKeepMouseLeavePressed write FKeepMouseLeavePressed default False; property Images: TJvTransparentButtonImages read FImages write SetImages; end; @@ -296,7 +288,7 @@ end; { create a disabled bitmap from a regular one, works best when bitmap has been -reduced to a few colors. Used by BWBitmap } + reduced to a few colors. Used by BWBitmap } procedure DisabledBitmap(Bmp: TBitmap); var @@ -412,9 +404,7 @@ Result := False; end; - {$IFDEF COMPILER6_UP} - function TJvTransparentButtonActionLink.IsGroupIndexLinked: Boolean; begin Result := False; @@ -423,10 +413,8 @@ procedure TJvTransparentButtonActionLink.SetGroupIndex(Value: Integer); begin end; - {$ENDIF COMPILER6_UP} - procedure TJvTransparentButtonActionLink.SetChecked(Value: Boolean); begin if IsCheckedLinked and (FClient is TJvTransparentButton) then @@ -455,14 +443,19 @@ FGrayLink := TChangeLink.Create; FGrayLink.OnChange := AButton.GlyphChanged; + FActiveLink := TChangeLink.Create; FActiveLink.OnChange := AButton.GlyphChanged; + FDisabledLink := TChangeLink.Create; FDisabledLink.OnChange := AButton.GlyphChanged; + FDownLink := TChangeLink.Create; FDownLink.OnChange := AButton.GlyphChanged; + FHotLink := TChangeLink.Create; FHotLink.OnChange := AButton.GlyphChanged; + FActiveIndex := -1; FDisabledIndex := -1; FDownIndex := -1; @@ -610,10 +603,8 @@ FWordWrap := False; FOutline := fsExplorer; - { former TJvTransparentButton2 } FImages := TJvTransparentButtonImages.Create(Self); - { former TJvTransparentButton } FNumGlyphs := 1; FGlyph := TBitmap.Create; FGrayGlyph := TBitmap.Create; @@ -629,21 +620,18 @@ destructor TJvTransparentButton.Destroy; begin - { former TJvTransparentButton } FGlyph.Free; FGrayGlyph.Free; FDisabledGlyph.Free; - { former TJvTransparentButton2 } - FImages.Free; - - FImList.Free; + // FImages.Free; // owner-destroyed + // FImList.Free; // owner-destroyed inherited Destroy; end; procedure TJvTransparentButton.Notification(AComponent: TComponent; Operation: TOperation); begin inherited Notification(AComponent, Operation); - if Operation = opRemove then + if (Operation = opRemove) and (FImages <> nil) then begin if AComponent = FImages.FGrayList then FImages.GrayImage := nil; @@ -1186,7 +1174,6 @@ Self.Canvas.FillRect(HelpRect); end; - // Use a TIcon instead of FImList.Draw to avoid triggering Mantis 3851 Icon := TIcon.Create; try This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |