[devhelp] KeywordModel: DhLink boxed type, not simple pointer, for the link column
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [devhelp] KeywordModel: DhLink boxed type, not simple pointer, for the link column
- Date: Sat, 20 Jan 2018 20:38:19 +0000 (UTC)
commit 1693f70b184d6279e42d4b41d1b32b8455e397bf
Author: Sébastien Wilmet <swilmet gnome org>
Date: Sat Jan 20 20:55:57 2018 +0100
KeywordModel: DhLink boxed type, not simple pointer, for the link column
To do the same as DhBookTree.
src/dh-keyword-model.c | 12 ++++--------
src/dh-sidebar.c | 4 ++++
2 files changed, 8 insertions(+), 8 deletions(-)
---
diff --git a/src/dh-keyword-model.c b/src/dh-keyword-model.c
index d4ca924..9fe3eb0 100644
--- a/src/dh-keyword-model.c
+++ b/src/dh-keyword-model.c
@@ -4,7 +4,7 @@
* Copyright (C) 2002 Mikael Hallendal <micke imendio com>
* Copyright (C) 2008 Imendio AB
* Copyright (C) 2010 Lanedo GmbH
- * Copyright (C) 2015 Sébastien Wilmet <swilmet gnome org>
+ * Copyright (C) 2015-2018 Sébastien Wilmet <swilmet gnome org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -134,11 +134,7 @@ dh_keyword_model_get_column_type (GtkTreeModel *tree_model,
return G_TYPE_STRING;
case DH_KEYWORD_MODEL_COL_LINK:
- /* FIXME: use DH_TYPE_LINK boxed type, to take advantage of ref
- * counting, to have safer code in case a DhLink is freed when
- * still stored in the GtkTreeModel.
- */
- return G_TYPE_POINTER;
+ return DH_TYPE_LINK;
case DH_KEYWORD_MODEL_COL_CURRENT_BOOK_FLAG:
return G_TYPE_BOOLEAN;
@@ -228,8 +224,8 @@ dh_keyword_model_get_value (GtkTreeModel *tree_model,
break;
case DH_KEYWORD_MODEL_COL_LINK:
- g_value_init (value, G_TYPE_POINTER);
- g_value_set_pointer (value, link);
+ g_value_init (value, DH_TYPE_LINK);
+ g_value_set_boxed (value, link);
break;
case DH_KEYWORD_MODEL_COL_CURRENT_BOOK_FLAG:
diff --git a/src/dh-sidebar.c b/src/dh-sidebar.c
index c4f795d..78cdce5 100644
--- a/src/dh-sidebar.c
+++ b/src/dh-sidebar.c
@@ -192,6 +192,7 @@ hitlist_selection_changed_cb (GtkTreeSelection *selection,
-1);
g_signal_emit (sidebar, signals[SIGNAL_LINK_SELECTED], 0, link);
+ dh_link_unref (link);
}
}
@@ -222,6 +223,7 @@ hitlist_button_press_cb (GtkTreeView *hitlist_view,
-1);
g_signal_emit (sidebar, signals[SIGNAL_LINK_SELECTED], 0, link);
+ dh_link_unref (link);
/* Always propagate the event so the tree view can update
* the selection etc.
@@ -282,6 +284,7 @@ entry_key_press_event_cb (GtkEntry *entry,
gtk_editable_set_position (GTK_EDITABLE (entry), -1);
g_signal_emit (sidebar, signals[SIGNAL_LINK_SELECTED], 0, link);
+ dh_link_unref (link);
return GDK_EVENT_STOP;
}
@@ -442,6 +445,7 @@ hitlist_cell_data_func (GtkTreeViewColumn *tree_column,
"weight", weight,
NULL);
+ dh_link_unref (link);
g_free (name);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]