Remove a boatload of "or %NULL" from nullable parameters
and return values. gi-docgen generates suitable text from
the annotation that we don't need to duplicate.
This adds a few missing nullable annotations too.
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.
Remove all the old 2.x and 3.x version annotations.
GTK+ 4 is a new start, and from the perspective of a
GTK+ 4 developer all these APIs have been around since
the beginning.
A "typo" led to using a wrong GtkTreePath when converting the path of the
virtual root to check the ancestors, which would lead to either no checks being
performed, or maybe segfaulting when using an invalid path as result.
https://bugzilla.gnome.org/show_bug.cgi?id=722058
Signed-off-by: Olivier Brunel <jjk@jjacky.com>
This means reffing the root in the set property implementation,
rather than in the constructor. We don't need to unref the root
on set, as it's a CONSTRUCT_ONLY property.
https://bugzilla.gnome.org/show_bug.cgi?id=680065
GSequence iterators point at the position between two elements so an
iterator pointing at the N tree model node is actually between the N-1
and N sequence elements. This means that asking for the previous
sequence iterator first and then checking if it is the begin iterator
would yeld true for an iterator pointing at the 2nd tree model node
and make us return FALSE mistakenly.
https://bugzilla.gnome.org/show_bug.cgi?id=679910
This bug is resolved by fixing two things in
gtk_tree_model_filter_row_deleted():
(1) It is possible for an elt to have elt->visible_siter == NULL, when
it is deleted. Only call g_sequence_remove() if this pointer is
non-NULL.
(2) For the case len (level->seq) > 1, free the elt->children level
if non-NULL. Failing to do this means the level will stick around.
If this child level was not referenced, it will still have a zero
ref count on its parent which cannot be removed!
For both bugs unit tests have been added in the preceding commit.
gtk_tree_model_filter_free_level() should always release ref on parent
unless the parent has been removed in the child model. The unit tests
added in the previous commit test this.
If the level to be reordered did not contain an elt with offset == 0
(for example if that node was hidden), the first reference was not
correctly transferred.
A unit test for this has been added in a previous commit.
This is due to the special handling for filter functions that depend
on child level state. If the parent level of a level is the root level,
the level cannot be removed from the cache. Any change in this level
can cause its parent in the root level to become visible again.
The most important change is that the function now properly releases
any external ref count and propagates these changes to the child model.
If a node is removed due to a filtering action, we now properly release
all external reference counts for its hierarchy of child nodes.
Apart from that, the function has been restructured to remove code
duplication.
Finally, there is still some doubt whether there are more calls to
gtk_tree_model_filter_free_level() which need unref_external set to TRUE.
Should be helpful when debugging this thing. Perhaps this needs to
be properly integrated in G_DEBUG/GTK_DEBUG, but currently I do not see
the need to.
There was still a discrepancy between the comments and the code about when
exactly a level was to be removed. The rule is now set on that for a level
to be removed its zero_ref_count as well as the zero_ref_count of its
parent has to be zero.