[devhelp] KeywordModel: check GtkTreePath depth in get_iter()
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [devhelp] KeywordModel: check GtkTreePath depth in get_iter()
- Date: Sat, 20 Jan 2018 20:38:34 +0000 (UTC)
commit ba96930f2ee33c515786413c45d424e2a7b98902
Author: Sébastien Wilmet <swilmet gnome org>
Date: Sat Jan 20 20:59:11 2018 +0100
KeywordModel: check GtkTreePath depth in get_iter()
And have an implementation similar to iter_nth_child().
g_queue_peek_nth_link() already checks the length.
src/dh-keyword-model.c | 19 +++++++++++--------
1 files changed, 11 insertions(+), 8 deletions(-)
---
diff --git a/src/dh-keyword-model.c b/src/dh-keyword-model.c
index 6ff06e4..15a8fe5 100644
--- a/src/dh-keyword-model.c
+++ b/src/dh-keyword-model.c
@@ -149,27 +149,30 @@ dh_keyword_model_get_iter (GtkTreeModel *tree_model,
GtkTreePath *path)
{
DhKeywordModelPrivate *priv;
- GList *node;
const gint *indices;
+ GList *node;
priv = dh_keyword_model_get_instance_private (DH_KEYWORD_MODEL (tree_model));
- indices = gtk_tree_path_get_indices (path);
-
- if (indices == NULL) {
+ if (gtk_tree_path_get_depth (path) > 1) {
return FALSE;
}
- if (indices[0] >= (gint)priv->links.length) {
+ indices = gtk_tree_path_get_indices (path);
+
+ if (indices == NULL) {
return FALSE;
}
node = g_queue_peek_nth_link (&priv->links, indices[0]);
- iter->stamp = priv->stamp;
- iter->user_data = node;
+ if (node != NULL) {
+ iter->stamp = priv->stamp;
+ iter->user_data = node;
+ return TRUE;
+ }
- return TRUE;
+ return FALSE;
}
static GtkTreePath *
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]