mono / gtk-sharp

Gtk# is a Mono/.NET binding to the cross platform Gtk+ GUI toolkit and the foundation of most GUI apps built with Mono
http://www.mono-project.com/GtkSharp
Other
428 stars 140 forks source link

Fix cairo context memory leak #176

Closed marvinkopf closed 7 years ago

marvinkopf commented 7 years ago

CairoHelper.Create would pass "owner=false" to the ctor of Cairo.Context, which would then wrongfully increment its reference counter. Thus making it impossible to free the context or any resource it is holding with Dispose().

This adds the metadata attribute to correctly generate CairoHelper.Create with "owner=true".

Test: Make a new Gtk#3.0 app and add this to the constructor of your window.

Maximize ();
Drawn += (o, args) => Gdk.CairoHelper.Create ((o as Window).Window).Dispose ();
System.Threading.Tasks.Task.Run (() => { 
    while (true) { 
        System.Threading.Thread.Sleep (100);
        Gtk.Application.Invoke ((sender, e) => QueueDraw ());
    }
});
monojenkins commented 7 years ago

Hello! I'm the build bot for the Mono project.

I need approval from a Mono team member to build this pull request. A team member should reply with "approve" to approve a build of this pull request, "whitelist" to whitelist this and all future pull requests from this contributor, or "build" to explicitly request a build, even if one has already been done.

Contributors can ignore this message.