Commit Graph

150 Commits

Author SHA1 Message Date
Alexander Larsson
1c46a02bcb TreeModelFilter: Fix uninitialized memory read.
We were copying an iterator that sometimes was not initialized,
which caused debugger warnings in VS2015.
2015-11-05 16:52:51 +01:00
Matthias Clasen
bed26edfd1 tree model filter: Fix compiler warnings
Fix warnings due to -Wdeclaration-after-statement and -Wshadow.
2015-06-02 09:08:16 -04:00
Matthias Clasen
8c5eb9a0d6 GtkTreeModelFilter: Documentation improvement
Clarify in the docs that some functions can only be called
once for a given filter model.

https://bugzilla.gnome.org/show_bug.cgi?id=346886
2014-08-30 01:59:05 -04:00
Olivier Brunel
5c019bde15 treemodelfilter: Fix using wrong path on row-deleted
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>
2014-03-26 20:40:50 -04:00
William Jon McCann
469d333aa2 docs: use Returns: consistently
Instead of Return value:
2014-02-19 18:56:05 -05:00
Matthias Clasen
c779b42476 Docs: use // for comments in examples
Without sgml mode, we can't escape /* as /&ast; anymore,
so just switch to // for comments in examples.
2014-02-14 23:34:22 -05:00
Matthias Clasen
7f6a964c47 Docs: Remove all entities and turn off sgml mode
With all element markup gone, it is time to turn off
sgml mode, and get rid of entities as well.
2014-02-09 17:58:07 -05:00
William Jon McCann
e34bd4137d docs: use apostrophes in *n't 2014-02-07 13:32:47 -05:00
William Jon McCann
7a208fbbf3 docs: use proper apostrophe
https://wiki.gnome.org/Design/OS/Typography
2014-02-07 13:06:10 -05:00
William Jon McCann
2a45418b67 docs: use proper quotes 2014-02-05 15:08:42 -05:00
Matthias Clasen
30cc1512e6 Docs: Use markdown for lists
This greatly reduces the amount of xml in the docs.
2014-02-02 01:07:39 -05:00
William Jon McCann
4c8bd8e7cf docs: Identify examples that are C code
https://bugzilla.gnome.org/show_bug.cgi?id=723119
2014-01-29 12:45:49 -05:00
William Jon McCann
768bc44081 docs: use |[ ]| instead of <programlisting></programlisting>
https://bugzilla.gnome.org/show_bug.cgi?id=723119
2014-01-29 12:45:49 -05:00
William Jon McCann
2d003553e8 docs: don't use <emphasis>
It is a little heavy handed. The text can speak for itself.
2014-01-28 02:02:05 -05:00
Bastien Nocera
587f993444 treemodelfilter: Fix typo in API docs 2014-01-14 15:02:59 +01:00
Emmanuele Bassi
0899ef7cc9 gtk: Use new macros for defining private data
https://bugzilla.gnome.org/show_bug.cgi?id=702996
2013-07-09 09:30:02 +01:00
Jasper St. Pierre
7ee5e7af70 treemodelfilter: Make the constructor binding friendly
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
2012-12-05 13:43:19 -05:00
Rui Matos
eaddf70a43 GtkTreeModelFilter: Fix _iter_previous() when iter points at 2nd node
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
2012-07-17 10:50:48 +02:00
Benjamin Otte
754bf5e3d8 treemodelfilter: Don't unref deleted rows
When we're fudging with child nodes of a deleted node, we don't want to
have them delete their parent - which is the deleted row.
2012-03-19 02:26:16 +01:00
Javier Jardón
9d0febc9a6 Change FSF Address 2012-02-27 17:06:11 +00:00
Javier Jardón
0853ce3077 Use G_VALUE_INIT
Instead of an explicit { 0, } when declaring the variable.
2011-10-15 16:45:16 +01:00
Kristian Rietveld
bbc1e883a8 Bug 659022 - gtk_tree_model_filter_clear_cache_helper: assertion failed
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.
2011-10-03 22:59:40 +02:00
Kristian Rietveld
f646ed6f76 Fix first part of bug 659022
Push creation of path into if clause, the path cannot be created anyway
(and would be meaningless otherwise) if the parent is not visible.
2011-10-03 22:59:40 +02:00
Xavier Claessens
0561c7a68d GtkTreeModelFilter: Fix build warnings
https://bugzilla.gnome.org/show_bug.cgi?id=659441
2011-09-20 09:06:54 +02:00
Kristian Rietveld
e1ede022f8 treemodelfilter: add additional asserts to MODEL_FILTER_DEBUG mode 2011-09-17 06:09:35 +02:00
Kristian Rietveld
7c0526e9b2 treemodelfilter: bring if-condition in sync
Bring the if-condition in sync with the other if-conditions in the
function where the "path" variable is used.
2011-09-11 20:19:56 +02:00
Kristian Rietveld
3db7344f33 treemodelfilter: correct forgotten unref of parent on level destroy
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.
2011-09-11 16:53:27 +02:00
Sébastien Granjoux
35eb92138a treemodelfilter: bgo#658696- Crash when inserting new node 2011-09-11 12:13:54 +02:00
Kristian Rietveld
a43f2ba010 gtktreemodelfilter: fix small bug in prune level
gtk_tree_model_filter_prune_level() should drop all internal reference
counts as well for nodes which are going to be removed from the
sequence.
2011-09-11 12:13:54 +02:00
Kristian Rietveld
9ed76387fa gtktreemodelfilter: fix corner case in rows-reordered handling
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.
2011-09-11 12:13:54 +02:00
Kristian Rietveld
022327c408 gtktreemodelfilter: child levels of the root level must remain cached
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.
2011-09-07 22:25:29 +02:00
Kristian Rietveld
ae2b2e7cfc gtktreemodelfilter: rework gtk_tree_model_filter_remove_elt_from_level
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.
2011-09-07 22:25:29 +02:00
Kristian Rietveld
767b2e2604 gtktreemodelfilter: add a debug define and more assertions
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.
2011-09-07 22:25:29 +02:00
Kristian Rietveld
f317dd3831 gtktreemodelfilter: make rule used for level caching consistent
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.
2011-09-07 22:25:29 +02:00
Kristian Rietveld
584ff7c29a treemodelfilter: eliminate unread variable assigments
Courtesy of scan-build/clang.
2011-08-22 21:30:35 +02:00
Kristian Rietveld
089edcf765 Fix bad typo in gtk_tree_model_filter_build_level() ... 2011-08-22 21:30:34 +02:00
Kristian Rietveld
6cd134d39e gtktreemodelfilter: only maintain cache at 1 level depth instead of 2 2011-08-22 21:30:34 +02:00
Kristian Rietveld
aa9151a6ee Extend public and internal documentation about GtkTreeModelFilter 2011-08-22 21:30:34 +02:00
Xavier Claessens
bee3d5f143 Replace GArray with GSequence in GtkTreeModelFilter
Significantly improves performance when e.g. removing (filtering) a lot
of rows from the filter model.  Fixes bug 616871.

This commit includes changes by Kristian Rietveld to make the patch apply
on top of the treemodel-fix branch and pass all newly written unit tests.
2011-08-22 21:30:33 +02:00
Xavier Claessens
eb594da2f2 Revert usage of parent_elt_index back to parent_elt pointers
This was introduced in commit a59c39f370.
The revert is part of bug 616871.  Adaption to recent GtkTreeModelFilter
changes by Kristian Rietveld.
2011-08-22 21:30:33 +02:00
Kristian Rietveld
510d84f682 Do not emit rows-reordered for levels with no visible rows 2011-08-22 21:30:33 +02:00
Kristian Rietveld
3b7aed050d Correct ref transfer in GtkTreeModelFilter rows-reordered handling 2011-08-22 21:30:33 +02:00
Kristian Rietveld
88dd6372b0 treemodelfilter: rework reference counting
- Before we kept a reference on all nodes in non-root levels.  This has
   been changed, now we keep a reference on the first node of each level.
   If, due to changes in the model, another node becomes the first node in
   the level, the reference is transferred to this new first node.
 - All non-root levels keep a reference on their parent.
 - By making use of the external ref count, the filter model now emits less
   unnecessary signals.
 - GtkTreeModelFilter does support filter functions which decide visibility
   of a given node based on the number of or visibility of children.
   To accomplish this, a child level of a node is cached when its
   parent has an external ref count > 0, because changes to the node might
   affect this parent.
 - An optimization for not building the root level in case the inserted
   node is not visible in gtk_tree_model_filter_row_inserted() has been
   removed.  In this case, we still need to build the root level and
   possibly a child level to monitor for signals which might make
   this row visible.
2011-08-22 21:30:32 +02:00
Kristian Rietveld
2984e22ef0 treemodelfilter: handle another case in check_ancestors
In gtk_tree_model_filter_check_ancestors(), also handle the case when
a node is already in the cache, but invisible, in the root level.
With the upcoming changes to GtkTreeModelFilter's ref counting this
case can occur.
2011-08-22 21:30:32 +02:00
Kristian Rietveld
52de413d43 treemodelfilter: guard for building already existing levels 2011-08-22 21:30:32 +02:00
Kristian Rietveld
dc15124c6f treemodelfilter: Introduce notion of external ref count
We need to distinguish between the ref count objects have on us versus
the ref count we have on our child model.  To keep track of the former,
we introduce the "external ref count" in this commit.  The zero_ref_count
needs to be determined from the external ref count, because objects that
have a ref count on us have say in which levels must be cached and which
can be released.

Before the caching in GtkTreeModelFilter was essentially broken and
levels were never released.  This was caused because the zero_ref_count
was connected to the ref count the filter model had on its child model.
Now that this depends on the external ref count, this is working fine and
as to be expected.
2011-08-22 21:30:32 +02:00
Kristian Rietveld
058a9090c2 treemodelfilter: Move more missions of row-deleted down
The row-deleted signal should be emitted after the internal data
structures have been updated.  In gtk_tree_model_filter_remove_elt_from_level
and gtk_tree_model_filter_virtual_root_deleted the signal was still being
emitted before the updates were carried out.
2011-08-22 21:30:32 +02:00
Kristian Rietveld
a485334c37 Add some comments to gtk_tree_model_filter_remove_elt_from_level 2011-08-22 21:30:31 +02:00
Kristian Rietveld
76cfd8bfac Bug 621076 - GtkTreeModelFilter does not emit all signals in some ...
The bulk of the fix is to walk the chain of ancestors, starting at the
root level, and check if the visibility of any of the ancestors has
changed.  If yes, the necessary signals are emitted so that this change
is propagated properly.  This walk is done after a node has been
inserted, changed or deleted, see function
gtk_tree_model_filter_check_ancestors().

Bug reported, and initial debugging and analysis, by Xavier Claessens.
2011-08-22 21:30:31 +02:00
Kristian Rietveld
c8783d3339 Decrease code duplication in _remove_elt_from_level take two 2011-08-22 21:30:31 +02:00