Merge lp:~ted/hud/dee-sync into lp:hud/13.10

Proposed by Ted Gould
Status: Rejected
Rejected by: Ted Gould
Proposed branch: lp:~ted/hud/dee-sync
Merge into: lp:hud/13.10
Diff against target: 231 lines (+122/-5)
2 files modified
libhud-client/query.c (+86/-5)
tests/test-hud-client-query.c (+36/-0)
To merge this branch: bzr merge lp:~ted/hud/dee-sync
Reviewer Review Type Date Requested Status
Michal Hruby (community) Disapprove
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+166819@code.launchpad.net

Commit message

Waiting for Dee Models to be synchronized before reporting they're ready

Description of the change

Makes it so that the HUD client waits until the DeeModels report that they are synchronized before saying that the models are ready. This should make it so that QtDee gets appropriate data when initialized.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

PASSED: Continuous integration, rev:263
http://jenkins.qa.ubuntu.com/job/hud-ci/27/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/hud-raring-amd64-ci/31
    SUCCESS: http://jenkins.qa.ubuntu.com/job/hud-raring-i386-ci/16

Click here to trigger a rebuild:
http://s-jenkins:8080/job/hud-ci/27/rebuild

review: Approve (continuous-integration)
Revision history for this message
Michal Hruby (mhr3) wrote :

As discussed on IRC, this should be done on the server side (where the shared model is created before its name passed over dbus), once it's there this isn't needed.

Moreover without that change this doesn't fix anything, cause the synchronized notification will be emitted if the client becomes leader of the swarm.

review: Disapprove
Revision history for this message
Ted Gould (ted) wrote :

While I understand that it doesn't fix this bug, my question would be whether this is an overall improvement. It seems like informing the client that we have models before they're sync'd isn't really useful for the client.

Revision history for this message
Michal Hruby (mhr3) wrote :

> While I understand that it doesn't fix this bug, my question would be whether
> this is an overall improvement. It seems like informing the client that we
> have models before they're sync'd isn't really useful for the client.

Only partially, if you only wait for the synchronization, this client can still become leader of the swarm (if the server crashes in between) which means it'll be considered synchronized and an empty model with uninitialized schema will be still passed to the client. Therefore it's not really protecting the client from uninitialized models.

Unmerged revisions

263. By Ted Gould

Attaching bug

262. By Ted Gould

Temp workaround for Dee bug

261. By Ted Gould

Connect to voice signals before playing with possible emitions and callbacks

260. By Ted Gould

Don't emit the connection changed signal until after we know both models are synchronized

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'libhud-client/query.c'
2--- libhud-client/query.c 2013-05-29 13:56:50 +0000
3+++ libhud-client/query.c 2013-05-31 15:06:37 +0000
4@@ -35,8 +35,15 @@
5 HudClientConnection * connection;
6 guint connection_changed_sig;
7 gchar * query;
8+
9 DeeModel * results;
10 DeeModel * appstack;
11+
12+ gulong results_sync_signal;
13+ gulong appstack_sync_signal;
14+
15+ gboolean results_initial_sync;
16+ gboolean appstack_initial_sync;
17 };
18
19 #define HUD_CLIENT_QUERY_GET_PRIVATE(o) \
20@@ -261,8 +268,22 @@
21 static void
22 connection_status (HudClientConnection * connection, gboolean connected, HudClientQuery * cquery)
23 {
24+ /* Clear results */
25+ if (cquery->priv->results_sync_signal != 0) {
26+ g_signal_handler_disconnect(cquery->priv->results, cquery->priv->results_sync_signal);
27+ cquery->priv->results_sync_signal = 0;
28+ }
29 g_clear_object(&cquery->priv->results);
30+ cquery->priv->results_initial_sync = FALSE;
31+
32+ /* Clear appstack */
33+ if (cquery->priv->appstack_sync_signal != 0) {
34+ g_signal_handler_disconnect(cquery->priv->appstack, cquery->priv->appstack_sync_signal);
35+ cquery->priv->appstack_sync_signal = 0;
36+ }
37 g_clear_object(&cquery->priv->appstack);
38+ cquery->priv->appstack_initial_sync = FALSE;
39+
40 g_clear_object(&cquery->priv->proxy);
41
42 g_signal_emit(G_OBJECT(cquery), hud_client_query_signal_models_changed, 0);
43@@ -275,6 +296,46 @@
44 return;
45 }
46
47+/* Called initially to check for sync and then called again when
48+ the models update their synchronized property. Hopefully we'll
49+ get to a state where we've got nice data. */
50+static void
51+model_initial_sync_check (G_GNUC_UNUSED GObject * model, G_GNUC_UNUSED GParamSpec * spec, gpointer user_data)
52+{
53+ HudClientQuery * cquery = HUD_CLIENT_QUERY(user_data);
54+
55+ /* Since we only want to track the initial value, we only want
56+ to update if it's not sync'd yet */
57+ if (!cquery->priv->results_initial_sync) {
58+ cquery->priv->results_initial_sync = dee_shared_model_is_synchronized(DEE_SHARED_MODEL(cquery->priv->results));
59+ }
60+
61+ if (!cquery->priv->appstack_initial_sync) {
62+ cquery->priv->appstack_initial_sync = dee_shared_model_is_synchronized(DEE_SHARED_MODEL(cquery->priv->appstack));
63+ }
64+
65+ /* If we've gotten sync'd on one of them we can stop watching the
66+ signal so hopeful we won't waste time with updates */
67+ if (cquery->priv->results_initial_sync && cquery->priv->results_sync_signal != 0) {
68+ g_signal_handler_disconnect(cquery->priv->results, cquery->priv->results_sync_signal);
69+ cquery->priv->results_sync_signal = 0;
70+ }
71+
72+ if (cquery->priv->appstack_initial_sync && cquery->priv->appstack_sync_signal != 0) {
73+ g_signal_handler_disconnect(cquery->priv->appstack, cquery->priv->appstack_sync_signal);
74+ cquery->priv->appstack_sync_signal = 0;
75+ }
76+
77+ /* If we don't have one of these, we're done for now, wait some more. */
78+ if (!cquery->priv->appstack_initial_sync || !cquery->priv->results_initial_sync) {
79+ return;
80+ }
81+
82+ g_signal_emit(G_OBJECT(cquery), hud_client_query_signal_models_changed, 0);
83+ return;
84+}
85+
86+/* Called when we have a new query constructed */
87 static void
88 new_query_cb (HudClientConnection * connection, const gchar * path, const gchar * results, const gchar * appstack, gpointer user_data)
89 {
90@@ -302,10 +363,6 @@
91 return;
92 }
93
94- /* Set up our models */
95- cquery->priv->results = dee_shared_model_new(results);
96- cquery->priv->appstack = dee_shared_model_new(appstack);
97-
98 /* Watch for voice signals */
99 g_signal_connect_object (cquery->priv->proxy, "voice-query-loading",
100 G_CALLBACK (hud_client_query_voice_query_loading), G_OBJECT(cquery), 0);
101@@ -314,7 +371,19 @@
102 g_signal_connect_object (cquery->priv->proxy, "voice-query-heard-something",
103 G_CALLBACK (hud_client_query_voice_query_heard_something), G_OBJECT(cquery), 0);
104
105- g_signal_emit(G_OBJECT(cquery), hud_client_query_signal_models_changed, 0);
106+ /* Set up our models */
107+ cquery->priv->results = dee_shared_model_new(results);
108+ cquery->priv->appstack = dee_shared_model_new(appstack);
109+
110+ model_initial_sync_check(NULL, NULL, cquery);
111+
112+ if (!cquery->priv->results_initial_sync) {
113+ cquery->priv->results_sync_signal = g_signal_connect(G_OBJECT(cquery->priv->results), "notify::synchronized", G_CALLBACK(model_initial_sync_check), cquery);
114+ }
115+
116+ if (!cquery->priv->appstack_initial_sync) {
117+ cquery->priv->appstack_sync_signal = g_signal_connect(G_OBJECT(cquery->priv->appstack), "notify::synchronized", G_CALLBACK(model_initial_sync_check), cquery);
118+ }
119
120 g_object_unref(cquery);
121
122@@ -336,8 +405,20 @@
123 _hud_query_com_canonical_hud_query_call_close_query_sync(self->priv->proxy, NULL, NULL);
124 }
125
126+ /* Clear results */
127+ if (self->priv->results_sync_signal != 0) {
128+ g_signal_handler_disconnect(self->priv->results, self->priv->results_sync_signal);
129+ self->priv->results_sync_signal = 0;
130+ }
131 g_clear_object(&self->priv->results);
132+
133+ /* Clear appstack */
134+ if (self->priv->appstack_sync_signal != 0) {
135+ g_signal_handler_disconnect(self->priv->appstack, self->priv->appstack_sync_signal);
136+ self->priv->appstack_sync_signal = 0;
137+ }
138 g_clear_object(&self->priv->appstack);
139+
140 g_clear_object(&self->priv->proxy);
141 g_clear_object(&self->priv->connection);
142
143
144=== modified file 'tests/test-hud-client-query.c'
145--- tests/test-hud-client-query.c 2013-05-14 14:50:59 +0000
146+++ tests/test-hud-client-query.c 2013-05-31 15:06:37 +0000
147@@ -69,6 +69,11 @@
148
149 g_free(search);
150
151+ /* FIXME: This is required because Dee doesn't cancel and
152+ clean up it's handlers on dispose:
153+ https://code.launchpad.net/~ted/dee/errors-fix/+merge/166811
154+ */
155+ hud_test_utils_process_mainloop (100);
156 g_object_unref(query);
157
158 g_object_unref(client_connection);
159@@ -126,6 +131,11 @@
160 g_object_unref(testcon);
161
162 /* Clean up */
163+ /* FIXME: This is required because Dee doesn't cancel and
164+ clean up it's handlers on dispose:
165+ https://code.launchpad.net/~ted/dee/errors-fix/+merge/166811
166+ */
167+ hud_test_utils_process_mainloop (100);
168 g_object_unref(query);
169 g_object_unref(client_connection);
170
171@@ -167,6 +177,11 @@
172 dbus_mock_assert_method_call_results (connection, DBUS_NAME, QUERY_PATH,
173 "UpdateQuery", "\\(\\[\\(\\d+, \\[<'test2'>\\]\\)\\],\\)");
174
175+ /* FIXME: This is required because Dee doesn't cancel and
176+ clean up it's handlers on dispose:
177+ https://code.launchpad.net/~ted/dee/errors-fix/+merge/166811
178+ */
179+ hud_test_utils_process_mainloop (100);
180 g_object_unref(query);
181
182 hud_test_utils_stop_hud_service (service, connection, results_model,
183@@ -263,6 +278,11 @@
184 dbus_mock_assert_method_call_results (connection, DBUS_NAME, QUERY_PATH,
185 "UpdateApp", "\\(\\[\\(\\d+, \\[<'application-id'>\\]\\)\\],\\)");
186
187+ /* FIXME: This is required because Dee doesn't cancel and
188+ clean up it's handlers on dispose:
189+ https://code.launchpad.net/~ted/dee/errors-fix/+merge/166811
190+ */
191+ hud_test_utils_process_mainloop (100);
192 g_object_unref(query);
193
194 hud_test_utils_stop_hud_service (service, connection, results_model,
195@@ -304,6 +324,11 @@
196 dbus_mock_assert_method_call_results (connection, DBUS_NAME, QUERY_PATH,
197 "ExecuteCommand", "\\(\\[\\(\\d+, \\[<uint64 4321>, <uint32 1234>\\]\\)\\],\\)");
198
199+ /* FIXME: This is required because Dee doesn't cancel and
200+ clean up it's handlers on dispose:
201+ https://code.launchpad.net/~ted/dee/errors-fix/+merge/166811
202+ */
203+ hud_test_utils_process_mainloop (100);
204 g_object_unref(query);
205
206 hud_test_utils_stop_hud_service (service, connection, results_model,
207@@ -346,6 +371,12 @@
208 "ExecuteParameterized", "\\(\\[\\(\\d+, \\[<uint64 4321>, <uint32 1234>\\]\\)\\],\\)");
209
210 g_object_unref(param);
211+
212+ /* FIXME: This is required because Dee doesn't cancel and
213+ clean up it's handlers on dispose:
214+ https://code.launchpad.net/~ted/dee/errors-fix/+merge/166811
215+ */
216+ hud_test_utils_process_mainloop (100);
217 g_object_unref(query);
218
219 hud_test_utils_stop_hud_service (service, connection, results_model,
220@@ -416,6 +447,11 @@
221 "\\(\\[\\(\\d+, \\[<'undo'>, <uint32 53312>\\]\\)\\],\\)");
222 dbus_mock_clear_method_calls (connection, DBUS_NAME, QUERY_PATH);
223
224+ /* FIXME: This is required because Dee doesn't cancel and
225+ clean up it's handlers on dispose:
226+ https://code.launchpad.net/~ted/dee/errors-fix/+merge/166811
227+ */
228+ hud_test_utils_process_mainloop (100);
229 g_object_unref(query);
230
231 hud_test_utils_stop_hud_service (service, connection, results_model,

Subscribers

People subscribed via source and target branches