summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Ohly <patrick.ohly@intel.com>2013-04-02 06:59:12 -0700
committerPatrick Ohly <patrick.ohly@intel.com>2013-04-02 16:18:48 +0200
commit7c826e0e74ececc3d1fff74e9eb5d0e66d38c20a (patch)
tree69b5dd9980174b1aa788e3c17d7a4dd3ed534354
parent62fd3b55564d412874e3ca2fcd300ddfd39c4dbc (diff)
downloadevolution-data-server-openismus-work-pohly.tar.gz
ebook DRA: partial fix for openingopenismus-work-pohly
Opening in DRA mode synchronously completely skipped opening the backend on the server side. Opening asynchronously got the order wrong and opened in the client before letting the server complete its work. As a result, the client randomly ran into database errors when accessing the database too early. For unknown reasons this started to happen a lot after merging with the changes made between (roughly) EDS 3.6.3 and 3.6.4. This fix is not a proper solution because it involves synchronous local calls in cases where asynchronous calls should be used. See https://bugzilla.gnome.org/show_bug.cgi?id=697106
-rw-r--r--addressbook/libebook/e-book-client.c87
1 files changed, 32 insertions, 55 deletions
diff --git a/addressbook/libebook/e-book-client.c b/addressbook/libebook/e-book-client.c
index 7c66828f0..00d52e515 100644
--- a/addressbook/libebook/e-book-client.c
+++ b/addressbook/libebook/e-book-client.c
@@ -1025,67 +1025,15 @@ static void book_client_open (EClient *client,
gpointer user_data);
static void
-direct_book_async_opened (GObject *source_object,
- GAsyncResult *res,
- gpointer user_data)
-{
- PropagateReadyData *data = (PropagateReadyData *)user_data;
- GError *error = NULL;
-
- if (e_data_book_open_finish (E_DATA_BOOK (source_object), res, &error)) {
-
- /* Open direct book succeeded, now proceed to open the real book over D-Bus */
- e_client_proxy_call_boolean (E_CLIENT (data->client), data->only_if_exists,
- data->cancellable, data->callback, data->user_data, book_client_open,
- e_gdbus_book_call_open, e_gdbus_book_call_open_finish,
- NULL, NULL, NULL, NULL);
- } else {
- /* Open failed, report error right away */
- GSimpleAsyncResult *result;
-
- result = g_simple_async_result_new_take_error (G_OBJECT (data->client),
- data->callback,
- data->user_data,
- error);
- g_simple_async_result_complete (result);
- g_object_unref (result);
- }
-
- propagate_ready_data_free (data);
-}
-
-static void
book_client_open (EClient *client,
gboolean only_if_exists,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
{
- EBookClient *book_client;
- PropagateReadyData *data;
-
- g_return_if_fail (E_IS_BOOK_CLIENT (client));
-
- book_client = E_BOOK_CLIENT (client);
-
- if (book_client->priv->direct_book) {
- data = propagate_ready_data_new (book_client,
- callback,
- user_data,
- book_client_open,
- cancellable);
- data->only_if_exists = only_if_exists;
-
- e_data_book_open (book_client->priv->direct_book,
- only_if_exists,
- cancellable,
- direct_book_async_opened,
- data);
- } else {
- e_client_proxy_call_boolean (client, only_if_exists, cancellable, callback, user_data, book_client_open,
+ e_client_proxy_call_boolean (client, only_if_exists, cancellable, callback, user_data, book_client_open,
e_gdbus_book_call_open,
e_gdbus_book_call_open_finish, NULL, NULL, NULL, NULL);
- }
}
static gboolean
@@ -1093,7 +1041,33 @@ book_client_open_finish (EClient *client,
GAsyncResult *result,
GError **error)
{
- return e_client_proxy_call_finish_void (client, result, error, book_client_open);
+ EBookClient *book_client;
+
+ g_return_val_if_fail (E_IS_BOOK_CLIENT (client), FALSE);
+
+ book_client = E_BOOK_CLIENT (client);
+
+ if (!e_client_proxy_call_finish_void (client, result, error, book_client_open))
+ return FALSE;
+
+ /**
+ * This is cheating, for two reasons:
+ * - We should avoid the synchronous call here and instead
+ * hook into the asynchronous processing of the opening.
+ * - only_if_exists is assumed to always be FALSE (as safe bet,
+ * because setting the parameter to TRUE does not make sense,
+ * as discussed on #evolution a while back).
+ * - This operation cannot be cancelled.
+ *
+ * This is a quick fix for openismus-work. A better solution must
+ * land in master.
+ */
+ if (book_client->priv->direct_book &&
+ !e_data_book_open_sync (book_client->priv->direct_book,
+ FALSE /* only_if_exists */, NULL /* cancellable */, error))
+ return FALSE;
+
+ return TRUE;
}
static gboolean
@@ -1113,12 +1087,15 @@ book_client_open_sync (EClient *client,
return FALSE;
}
+ if (!e_client_proxy_call_sync_boolean__void (client, only_if_exists, cancellable, error, e_gdbus_book_call_open_sync))
+ return FALSE;
+
if (book_client->priv->direct_book &&
!e_data_book_open_sync (book_client->priv->direct_book,
only_if_exists, cancellable, error))
return FALSE;
- return e_client_proxy_call_sync_boolean__void (client, only_if_exists, cancellable, error, e_gdbus_book_call_open_sync);
+ return TRUE;
}
static void