[Lazarus] Gtk2 missed try-finally

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[Lazarus] Gtk2 missed try-finally

Free Pascal - Lazarus mailing list
gtk2proc.inc, procedure DrawImageListIconOnWidget: it allocates Bitmap +
DC. Pls add try-finally for Bitmap; and (not sure) try-finally for DC:

     finally
       ReleaseDC(HDC({%H-}PtrUInt(DestWidget)),DestDC);
     end;
   finally
     Bitmap.Free;
   end;

--
Regards,
Alexey

--
_______________________________________________
Lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [Lazarus] Gtk2 missed try-finally

Free Pascal - Lazarus mailing list
On Tue, 25 Jul 2017 13:16:50 +0300
Alexey via Lazarus <[hidden email]> wrote:

> gtk2proc.inc, procedure DrawImageListIconOnWidget: it allocates Bitmap +
> DC. Pls add try-finally for Bitmap; and (not sure) try-finally for DC:

How did you manage to create a mem leak there?

 
>      finally
>        ReleaseDC(HDC({%H-}PtrUInt(DestWidget)),DestDC);
>      end;
>    finally
>      Bitmap.Free;
>    end;


Mattias
 
--
_______________________________________________
Lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [Lazarus] Gtk2 missed try-finally

Free Pascal - Lazarus mailing list

>How did you manage to create a mem leak there?

If not using try-finally, and exception, Bitmap will not be freed.

--
Regards,
Alexey

--
_______________________________________________
Lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [Lazarus] Gtk2 missed try-finally

Free Pascal - Lazarus mailing list
How do you get an exception there ?

Marc

On July 25, 2017 4:35:50 PM GMT+02:00, Alexey via Lazarus <[hidden email]> wrote:

>
>>How did you manage to create a mem leak there?
>
>If not using try-finally, and exception, Bitmap will not be freed.
>
>--
>Regards,
>Alexey
>
>--
>_______________________________________________
>Lazarus mailing list
>[hidden email]
>https://lists.lazarus-ide.org/listinfo/lazarus
--
_______________________________________________
Lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus
Loading...