dee

Merge lp:~mhr3/dee/fix-seqnum-inheritance into lp:dee

Proposed by Michal Hruby
Status: Merged
Approved by: Paweł Stołowski
Approved revision: 399
Merged at revision: 398
Proposed branch: lp:~mhr3/dee/fix-seqnum-inheritance
Merge into: lp:dee
Diff against target: 291 lines (+66/-15)
5 files modified
configure.ac (+2/-2)
src/dee-filter-model.c (+20/-8)
src/dee-proxy-model.c (+27/-4)
tests/test-filter-model.c (+15/-1)
vapi/dee-1.0.vapi (+2/-0)
To merge this branch: bzr merge lp:~mhr3/dee/fix-seqnum-inheritance
Reviewer Review Type Date Requested Status
Paweł Stołowski (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+141961@code.launchpad.net

Commit message

Fix incorrect implementation of seqnum inheritance in DeeProxyModel

Description of the change

Fix incorrect implementation of seqnum inheritance in DeeProxyModel, and expose the inheritance as a public construct-only property (similar to the "proxy-signals" property).

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
lp:~mhr3/dee/fix-seqnum-inheritance updated
399. By Michal Hruby

Bump configure version

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Paweł Stołowski (stolowski) wrote :

Looks sane and tests pass. +1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'configure.ac'
2--- configure.ac 2012-12-13 20:30:25 +0000
3+++ configure.ac 2013-01-07 09:42:22 +0000
4@@ -4,8 +4,8 @@
5 # but also remember to bump the lib version as instructed below
6 # Don't forget to check also GIR_VERSION
7 m4_define([dee_major], [1])
8-m4_define([dee_minor], [1])
9-m4_define([dee_micro], [99])
10+m4_define([dee_minor], [2])
11+m4_define([dee_micro], [1])
12 m4_define([dee_api],
13 [dee_major.dee_minor])
14 m4_define([dee_version],
15
16=== modified file 'src/dee-filter-model.c'
17--- src/dee-filter-model.c 2012-08-10 10:56:44 +0000
18+++ src/dee-filter-model.c 2013-01-07 09:42:22 +0000
19@@ -83,7 +83,7 @@
20 {
21 DeeFilter *filter;
22 DeeModel *orig_model;
23-
24+
25 /* Map of orig_model iters to our own internal GSequenceIters for iter_list */
26 GHashTable *iter_map;
27
28@@ -373,6 +373,7 @@
29 "filter", filter,
30 "back-end", orig_model,
31 "proxy-signals", FALSE,
32+ "inherit-seqnums", FALSE,
33 NULL));
34
35 return self;
36@@ -430,7 +431,8 @@
37
38 seq_iter = g_sequence_append (priv->iter_list, iter);
39 g_hash_table_insert (priv->iter_map, iter, seq_iter);
40-
41+
42+ dee_serializable_model_inc_seqnum (DEE_MODEL (self));
43 g_signal_emit_by_name (self, "row-added", iter);
44
45 return iter;
46@@ -469,7 +471,8 @@
47
48 seq_iter = g_sequence_prepend (priv->iter_list, iter);
49 g_hash_table_insert (priv->iter_map, iter, seq_iter);
50-
51+
52+ dee_serializable_model_inc_seqnum (DEE_MODEL (self));
53 g_signal_emit_by_name (self, "row-added", iter);
54
55 return iter;
56@@ -546,7 +549,8 @@
57
58 seq_iter = g_sequence_insert_before (seq_iter, iter);
59 g_hash_table_insert (priv->iter_map, iter, seq_iter);
60-
61+
62+ dee_serializable_model_inc_seqnum (DEE_MODEL (self));
63 g_signal_emit_by_name (self, "row-added", iter);
64
65 return iter;
66@@ -652,6 +656,7 @@
67 if (seq_iter != NULL)
68 {
69 /* Emit signal before we delete it from our records */
70+ dee_serializable_model_inc_seqnum (DEE_MODEL (self));
71 g_signal_emit_by_name (self, "row-removed", iter);
72 g_hash_table_remove (priv->iter_map, iter);
73 g_sequence_remove (seq_iter);
74@@ -670,7 +675,10 @@
75 return;
76
77 if (dee_filter_model_contains (self, iter))
78- g_signal_emit_by_name (self, "row-changed", iter);
79+ {
80+ dee_serializable_model_inc_seqnum (DEE_MODEL (self));
81+ g_signal_emit_by_name (self, "row-changed", iter);
82+ }
83 }
84
85 /*
86@@ -741,7 +749,8 @@
87
88 seq_iter = g_sequence_prepend (priv->iter_list, iter);
89 g_hash_table_insert (priv->iter_map, iter, seq_iter);
90-
91+
92+ dee_serializable_model_inc_seqnum (self);
93 g_signal_emit_by_name (self, "row-added", iter);
94
95 return iter;
96@@ -777,7 +786,8 @@
97
98 seq_iter = g_sequence_append (priv->iter_list, iter);
99 g_hash_table_insert (priv->iter_map, iter, seq_iter);
100-
101+
102+ dee_serializable_model_inc_seqnum (self);
103 g_signal_emit_by_name (self, "row-added", iter);
104
105 return iter;
106@@ -811,7 +821,8 @@
107
108 seq_iter = g_sequence_insert_before (seq_iter, new_iter);
109 g_hash_table_insert (priv->iter_map, new_iter, seq_iter);
110-
111+
112+ dee_serializable_model_inc_seqnum (self);
113 g_signal_emit_by_name (self, "row-added", new_iter);
114
115 return iter;
116@@ -1075,3 +1086,4 @@
117
118 return (guint) ABS(g_sequence_iter_get_position (seq_iter));
119 }
120+
121
122=== modified file 'src/dee-proxy-model.c'
123--- src/dee-proxy-model.c 2012-12-17 16:26:36 +0000
124+++ src/dee-proxy-model.c 2013-01-07 09:42:22 +0000
125@@ -57,6 +57,7 @@
126 PROP_0,
127 PROP_BACK_END,
128 PROP_PROXY_SIGNALS,
129+ PROP_INHERIT_SEQNUMS
130 };
131
132 /**
133@@ -325,6 +326,9 @@
134 case PROP_PROXY_SIGNALS:
135 priv->proxy_signals = g_value_get_boolean (value);
136 break;
137+ case PROP_INHERIT_SEQNUMS:
138+ priv->inherit_seqnums = g_value_get_boolean (value);
139+ break;
140 default:
141 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, id, pspec);
142 break;
143@@ -345,6 +349,9 @@
144 case PROP_PROXY_SIGNALS:
145 g_value_set_boolean (value, DEE_PROXY_MODEL (object)->priv->proxy_signals);
146 break;
147+ case PROP_INHERIT_SEQNUMS:
148+ g_value_set_boolean (value, DEE_PROXY_MODEL (object)->priv->inherit_seqnums);
149+ break;
150 default:
151 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, id, pspec);
152 break;
153@@ -392,6 +399,22 @@
154 G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY
155 | G_PARAM_STATIC_STRINGS);
156 g_object_class_install_property (obj_class, PROP_PROXY_SIGNALS, pspec);
157+
158+ /**
159+ * DeeProxyModel:inherit-seqnums:
160+ *
161+ * Boolean property defining whether sequence numbers will be inherited
162+ * from the back end model.
163+ * You will most likely want to set this property to false
164+ * if the implementation manipulates with the rows in the model and keep
165+ * track of seqnums.
166+ **/
167+ pspec = g_param_spec_boolean ("inherit-seqnums", "Inherit seqnums",
168+ "Whether or not to inherit seqnums",
169+ TRUE,
170+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY
171+ | G_PARAM_STATIC_STRINGS);
172+ g_object_class_install_property (obj_class, PROP_INHERIT_SEQNUMS, pspec);
173
174 /* Add private data */
175 g_type_class_add_private (obj_class, sizeof (DeeProxyModelPrivate));
176@@ -451,7 +474,7 @@
177
178 priv = model->priv = DEE_PROXY_MODEL_GET_PRIVATE (model);
179 priv->back_end = NULL;
180- priv->inherit_seqnums = FALSE;
181+ priv->inherit_seqnums = TRUE;
182
183 priv->row_added_handler = 0;
184 priv->row_removed_handler = 0;
185@@ -908,7 +931,7 @@
186 if (priv->inherit_seqnums)
187 return dee_serializable_model_get_seqnum (priv->back_end);
188 else
189- return SUPER_CLASS->get_seqnum (priv->back_end);
190+ return SUPER_CLASS->get_seqnum (self);
191 }
192
193 static void
194@@ -924,7 +947,7 @@
195 if (priv->inherit_seqnums)
196 dee_serializable_model_set_seqnum (priv->back_end, seqnum);
197 else
198- return SUPER_CLASS->set_seqnum (priv->back_end, seqnum);
199+ return SUPER_CLASS->set_seqnum (self, seqnum);
200 }
201
202 static guint64
203@@ -939,5 +962,5 @@
204 if (priv->inherit_seqnums)
205 return dee_serializable_model_inc_seqnum (priv->back_end);
206 else
207- return SUPER_CLASS->inc_seqnum (priv->back_end);
208+ return SUPER_CLASS->inc_seqnum (self);
209 }
210
211=== modified file 'tests/test-filter-model.c'
212--- tests/test-filter-model.c 2011-12-19 14:27:29 +0000
213+++ tests/test-filter-model.c 2013-01-07 09:42:22 +0000
214@@ -171,6 +171,8 @@
215 DeeModelIter *iter = dee_model_get_first_iter (m);
216 g_assert (dee_model_is_first (m, iter));
217 g_assert (dee_model_is_last (m, iter));
218+
219+ g_assert_cmpuint (0, ==, dee_serializable_model_get_seqnum (m));
220 }
221
222 /* A filter model that is a complete copy of the orig */
223@@ -211,6 +213,9 @@
224 g_assert (dee_model_is_last (m, iter));
225
226 g_assert (dee_model_is_last (m, iter));
227+
228+ g_assert_cmpuint (dee_serializable_model_get_seqnum (fix->model), ==,
229+ dee_serializable_model_get_seqnum (m));
230 }
231
232 /* Test a filter that blocks everything */
233@@ -236,7 +241,10 @@
234 DeeModelIter *iter = dee_model_get_first_iter (m);
235 g_assert (dee_model_is_first (m, iter));
236 g_assert (dee_model_is_last (m, iter));
237-
238+
239+ /* Check that seqnum is still zero */
240+ g_assert_cmpuint (0, ==, dee_serializable_model_get_seqnum (m));
241+
242 guint filter_add_count = 0;
243 guint orig_add_count = 0;
244 g_signal_connect (m, "row-added", G_CALLBACK (signal_counter), &filter_add_count);
245@@ -250,6 +258,7 @@
246 g_assert_cmpint (2, ==, orig_add_count);
247 g_assert_cmpint (0, ==, dee_model_get_n_rows (m));
248 g_assert_cmpint (5, ==, dee_model_get_n_rows (fix->model));
249+ g_assert_cmpuint (0, ==, dee_serializable_model_get_seqnum (m));
250
251 /* Now add stuff to the filtered model directly. This should work,
252 * and should be written through to the orig model as well */
253@@ -258,6 +267,7 @@
254 g_assert_cmpint (3, ==, orig_add_count);
255 g_assert_cmpint (1, ==, dee_model_get_n_rows (m));
256 g_assert_cmpint (6, ==, dee_model_get_n_rows (fix->model));
257+ g_assert_cmpuint (1, ==, dee_serializable_model_get_seqnum (m));
258
259 /* The first (and only) row of 'm' should be at offset 5 in fix->model */
260 iter = dee_model_get_first_iter (m);
261@@ -283,6 +293,9 @@
262 &filter);
263
264 DeeModel *m = dee_filter_model_new (fix->model, &filter);
265+
266+ /* Nothing was added to the filter model, seqnum should be zero */
267+ g_assert_cmpuint (0, ==, dee_serializable_model_get_seqnum (m));
268
269 guint filter_add_count = 0;
270 guint orig_add_count = 0;
271@@ -297,6 +310,7 @@
272 g_assert_cmpint (2, ==, orig_add_count);
273 g_assert_cmpint (2, ==, dee_model_get_n_rows (m));
274 g_assert_cmpint (5, ==, dee_model_get_n_rows (fix->model));
275+ g_assert_cmpuint (2, ==, dee_serializable_model_get_seqnum (m));
276
277 /* The first row of 'm' should be at offset 3 in fix->model */
278 DeeModelIter *iter = dee_model_get_first_iter (m);
279
280=== modified file 'vapi/dee-1.0.vapi'
281--- vapi/dee-1.0.vapi 2013-01-04 15:46:35 +0000
282+++ vapi/dee-1.0.vapi 2013-01-07 09:42:22 +0000
283@@ -118,6 +118,8 @@
284 [NoAccessorMethod]
285 public Dee.Model back_end { owned get; construct; }
286 [NoAccessorMethod]
287+ public bool inherit_seqnums { get; construct; }
288+ [NoAccessorMethod]
289 public bool proxy_signals { get; construct; }
290 }
291 [CCode (cheader_filename = "dee.h", type_id = "dee_sequence_model_get_type ()")]

Subscribers

People subscribed via source and target branches

to all changes: