mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2025-01-14 06:10:21 +00:00
gtk-demo: Plug a memory leak
This commit is contained in:
parent
b622745501
commit
b81463e7d3
@ -337,8 +337,8 @@ display_text (const char *format,
|
|||||||
|
|
||||||
bytes = g_resources_lookup_data (resource, 0, NULL);
|
bytes = g_resources_lookup_data (resource, 0, NULL);
|
||||||
g_assert (bytes);
|
g_assert (bytes);
|
||||||
|
text = g_bytes_get_data (bytes, &len);
|
||||||
g_assert (g_utf8_validate (g_bytes_get_data (bytes, NULL), g_bytes_get_size (bytes), NULL));
|
g_assert (g_utf8_validate (text, len, NULL));
|
||||||
|
|
||||||
textview = gtk_text_view_new ();
|
textview = gtk_text_view_new ();
|
||||||
gtk_text_view_set_left_margin (GTK_TEXT_VIEW (textview), 20);
|
gtk_text_view_set_left_margin (GTK_TEXT_VIEW (textview), 20);
|
||||||
@ -354,9 +354,8 @@ display_text (const char *format,
|
|||||||
gtk_text_view_set_monospace (GTK_TEXT_VIEW (textview), TRUE);
|
gtk_text_view_set_monospace (GTK_TEXT_VIEW (textview), TRUE);
|
||||||
|
|
||||||
buffer = gtk_text_buffer_new (NULL);
|
buffer = gtk_text_buffer_new (NULL);
|
||||||
|
|
||||||
text = g_bytes_unref_to_data (bytes, &len);
|
|
||||||
gtk_text_buffer_set_text (buffer, text, len);
|
gtk_text_buffer_set_text (buffer, text, len);
|
||||||
|
g_bytes_unref (bytes);
|
||||||
|
|
||||||
if (format)
|
if (format)
|
||||||
fontify (format, buffer);
|
fontify (format, buffer);
|
||||||
|
Loading…
Reference in New Issue
Block a user