[Gtk-sharp-list] Pango.FontDescription exception

pinggi at centrum.cz pinggi at centrum.cz
Sun Apr 22 17:35:01 UTC 2012


Hi,

I render text into DrawingArea with double buffering on using Cairo+Pango, like this:

			using (Pango.Layout layout = PangoCairoHelper.CreateLayout(c)) {
				layout.SetText(text);
				layout.FontDescription = Pango.FontDescription.FromString("Sans 9");
				PangoCairoHelper.LayoutPath(c, layout, true);
			}

If I increase window size, background becomes black and following text appears in the application log:


Cairo.Context: called from finalization thread, programmer is missing a call to Dispose
**
GLib:ERROR:gmain.c:2443:g_main_dispatch: assertion failed: (current->dispatching_sources == &current_source_link)

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.


If I write it like this...

			using (Pango.Layout layout = PangoCairoHelper.CreateLayout(c)) {
				layout.SetText(text);
				using (var fontDesc = Pango.FontDescription.FromString("Sans 9"))
				{
					layout.FontDescription = fontDesc;
				}
				layout.Alignment = Pango.Alignment.Left;
				PangoCairoHelper.LayoutPath(c, layout, true);
			}

...window resizing works ok. Why I need to dispose newly created object? Isn't that bad desing of Pango wrapper?


More information about the Gtk-sharp-list mailing list