We're using the tag contents array to count the number of invisible tags
set but we always increase it without being initialized.
This may lead to unexpected behavior when traversing them and it's
causing a reliable failure in the textiter tests under s390x.
So, memset that area content to 0 once allocated. It's not needed to do
the same for the tags themselves as we always assign them.
Conditional jump or move depends on uninitialised value(s)
at 0x4CFAA00: _gtk_text_btree_char_is_invisible (gtktextbtree.c:2569)
by 0x4B8A1BB: find_visible_by_log_attrs (gtktextiter.c:3244)
by 0x10E93D: check_backward_visible_word_start (textiter.c:484)
by 0x10E93D: test_visible_word_boundaries (textiter.c:523)
by 0x533288F: g_test_run_suite (in /usr/lib/s390x-linux-gnu/libglib-2.0.so.0)
by 0x53328E7: g_test_run (in /usr/lib/s390x-linux-gnu/libglib-2.0.so.0)
by 0x109CC1: main (textiter.c:807)
If we have never seen a GtkTextTag in the GtkTextTagTable with the
invisible bit set, then we do not need to go through the process of
checking the accumulated tags.
Not using invisible tags is overwhelmingly the common case.
Sprinkle various g_assert() around the code where gcc cannot figure out
on its own that a variable is not NULL and too much refactoring would be
needed to make it do that.
Also fix usage of g_assert_nonnull(x) to use g_assert(x) because the
first is not marked as G_GNUC_NORETURN because of course GTester
supports not aborting on aborts.
This changes gtk_text_buffer_insert_texture() to
gtk_text_buffer_insert_paintable() which is strictly more useful
(as textures are paintables). It also fixes the code to actually
support drawing the paintables (as well as tracking changes
to the paintables.
This affects a few apis, such as gtk_text_iter_get_pixbuf,
gtk_text_buffer_insert_pixbuf and GtkTextBuffer::insert-pixbuf,
which have all been replaced by texture equivalents.
Update all callers.
Use GSlice to allocate all types of segments:
- char
- toggle
- mark
- pixbuf
- child widget
Char segments are a bit more complicated because the length of the text
is determined at run time and stored in the 'byte_count' field. If the
text is long, GSlice will call the system malloc() anyway, so it's
better to always use GSlice for GtkTextLineSegment.
Toggle segments are also freed in gtktextbtree.c, hence the function
_gtk_toggle_segment_free() (for a later commit it would be nice to
rename those functions with the _gtk_text prefix).
https://bugzilla.gnome.org/show_bug.cgi?id=727908
Especially the gtk_*_type ones in gtktexttypes.h were mentioned in
gtk.symbols presumably by accident. That header isn't even installed,
so no way can they be supposed to be public.
gtk_text_attr_appearance_type is from the installed but "semi-private"
gtktextlayout.h, so drop that one too from gtk.symbols for now.
The use of gtk_text_unknown_char_utf8 is bit of a mess. Code in a few
files knew implicitly that it is three bytes. Define a symbolic name
for the length of it instead. Add an exported function
gtk_text_unknown_char_utf8_gtk_tests_only() that returns a pointer to
it just for the sake of gtk/tests/textbuffer.c. Prefix the variable
with an underscore.
I doubt the usefulness of the test_utf8() in textbuffer.c. If it could
be dropped, gtk_text_unknown_char_utf8_gtk_tests_only() could be
dropped, too.
Preferrably should be made just into a local variable for libgtk like
_gdk_debug_flags for libgdk. But for now used by
gtk/tests/textbuffer.c and modules/printbackends/cups/gtkprintbackendcups.c.