* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
G_IMPLEMENT_INTERFACE (GTK_TYPE_TREE_MODEL,
gtk_tree_model_ref_count_tree_model_init))
+static void
+row_removed (GtkTreeModelRefCount *ref_model,
+ GtkTreePath *path)
+{
+ GHashTableIter iter;
+ GtkTreeIter tree_iter;
+
+ if (!gtk_tree_model_get_iter_first (GTK_TREE_MODEL (ref_model), &tree_iter))
+ {
+ g_hash_table_remove_all (ref_model->priv->node_hash);
+ return;
+ }
+
+ g_hash_table_iter_init (&iter, ref_model->priv->node_hash);
+
+ while (g_hash_table_iter_next (&iter, &tree_iter.user_data, NULL))
+ {
+ if (!gtk_tree_store_iter_is_valid (GTK_TREE_STORE (ref_model), &tree_iter))
+ g_hash_table_iter_remove (&iter);
+ }
+}
+
static void
gtk_tree_model_ref_count_init (GtkTreeModelRefCount *ref_model)
{
g_direct_equal,
NULL,
(GDestroyNotify)node_info_free);
+
+ g_signal_connect (ref_model, "row-deleted", G_CALLBACK (row_removed), NULL);
}
static void
}
if (may_assert)
- g_assert_cmpint (expected_ref_count, ==, info->ref_count);
+ {
+ if (expected_ref_count == 0)
+ g_assert_cmpint (expected_ref_count, ==, info->ref_count);
+ else
+ g_assert_cmpint (expected_ref_count, <=, info->ref_count);
+ }
return expected_ref_count == info->ref_count;
}