[ Show ]
Support VoyForums
[ Shrink ]
VoyForums Announcement: Programming and providing support for this service has been a labor of love since 1997. We are one of the few services online who values our users' privacy, and have never sold your information. We have even fought hard to defend your privacy in legal cases; however, we've done it with almost no financial support -- paying out of pocket to continue providing the service. Due to the issues imposed on us by advertisers, we also stopped hosting most ads on the forums many years ago. We hope you appreciate our efforts.

Show your support by donating any amount. (Note: We are still technically a for-profit company, so your contribution is not tax-deductible.) PayPal Acct: Feedback:

Donate to VoyForums (PayPal):

Login ] [ Contact Forum Admin ] [ Main index ] [ Post a new message ] [ Search | Check update time | Archives: 12345[6]78910 ]

[ Next Thread | Previous Thread | Next Message | Previous Message ]

Date Posted: 19:27:46 03/18/02 Mon
Author: Michel
Subject: Re: memory leak in TRubberBandMouseHandler
In reply to: Mark Chambers 's message, "memory leak in TRubberBandMouseHandler" on 11:07:10 03/17/02 Sun

Hi Mark,

I would check to make sure you have version 1.1. In version 1.1, the method TRubberBandMouseHandler.MouseUp is,

procedure TRubberbandMouseHandler.MouseUp(
const Button : TMouseButton;
const Shift : TShiftState;
const X, Y : Integer );
if FMouseIsDown then
if SelectionActive then
if FX2 < FX1 then
SwapIntegers(FX2, FX1);

if FY2 < FY1 then
SwapIntegers(FY2, FY1);

if FBandVisible and
(FX1 = FX2) and
(FY1 = FY2) then
FBandVisible := False;

FMouseIsDown := False;

I don't quite recall when this was changed. I think in version 1.1 there were major changes to the rubber band mouse handler.

Best regards,


>Hi - the method TRubberBandMouseHandler.MouseUp
>allocates a DibGraphic object in order to pass it to
>the callback method. It is then up to the callback
>method to delete it. (This isn't generally a good
>idea - responsibilty for destruction should rest with
>the creator) Unfortunately, MouseUp creates the
>DibGraphic regardless of whether or not there is a
>callback method - and if there isn't, then it never
>gets cleanedup. My suggested fix follows.
>Mark Chambers
>procedure TRubberBandMouseHandler.MouseUp(const
>Button: TMouseButton;
> const Shift: TShiftState; const X, Y: Integer);
> DibGraphic: TDibGraphic;
> Temp: integer;
> inherited;
> FBottom:= Y;
> FRight:= X;
> if (FTop <> FBottom) and (FLeft <> FRight) then begin
> if FTop > FBottom then begin
> Temp:= FTop;
> FTop:= FBottom;
> FBottom:= Temp;
> end;
> if FLeft > FRight then begin
> Temp:= FLeft;
> FLeft:= FRight;
> FRight:= Temp;
> end;
> if Assigned(FCallback) then begin
> DibGraphic:= TDibGraphic.Create;
> try
> DibGraphic.NewImage(
> FRight - FLeft, FBottom - FTop,
> (FImageScrollBox.FImage.Picture.Graphic as
> @(FImageScrollBox.FImage.Picture.Graphic
>as TDibGraphic).Palette,
> (FImageScrollBox.FImage.Picture.Graphic as
> (FImageScrollBox.FImage.Picture.Graphic as
> );
> DibGraphic.Canvas.CopyRect(
> Rect(0, 0, FRight - FLeft - 1, FBottom -
>FTop - 1),
> (FImageScrollBox.FImage.Picture.Graphic as
> Rect(FLeft, FTop, FRight, FBottom)
> );
> FCallback(FTop, FLeft, FBottom, FRight,
> finally
> // DibGraphic.Free;
> // not freed as it might be kept by the
>callback routine.
> // this is not a good practice! We should free
>it ourselves (and
> // expect the CallBack method to copy it, or
>just pass the
> // FImageScrollBox.FImage.Picture.Graphic (or
>just FImageScrollBox)
> // and let the callback do what it wants.
> // I think this should be changed to at least
>free the
> // DibGraphic, but the I don't have to manage
> // the complaints that will ensue!
> end;
> end;
> end;
> DrawRubberBand;
> Screen.Cursor:= FScreenCursor;

[ Next Thread | Previous Thread | Next Message | Previous Message ]

[ Contact Forum Admin ]

Forum timezone: GMT-5
VF Version: 3.00b, ConfDB:
Before posting please read our privacy policy.
VoyForums(tm) is a Free Service from Voyager Info-Systems.
Copyright © 1998-2019 Voyager Info-Systems. All Rights Reserved.