[tracker/async-queries] libtracker-db: Support empty result sets in async queries
- From: Jürg Billeter <juergbi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/async-queries] libtracker-db: Support empty result sets in async queries
- Date: Wed, 14 Apr 2010 08:26:04 +0000 (UTC)
commit 009551fab747faaa1ea4ca6768598dd120b8a8f8
Author: Jürg Billeter <j bitron ch>
Date: Wed Apr 14 10:24:32 2010 +0200
libtracker-db: Support empty result sets in async queries
src/libtracker-db/tracker-db-manager.c | 21 +++++++++++++++------
1 files changed, 15 insertions(+), 6 deletions(-)
---
diff --git a/src/libtracker-db/tracker-db-manager.c b/src/libtracker-db/tracker-db-manager.c
index 458bfa6..cccf6db 100644
--- a/src/libtracker-db/tracker-db-manager.c
+++ b/src/libtracker-db/tracker-db-manager.c
@@ -1366,15 +1366,18 @@ interface_pool_dispatch_cb (gpointer data,
g_simple_async_result_set_from_error (G_SIMPLE_ASYNC_RESULT (job->async_result), error);
g_error_free (error);
} else {
- TrackerDBResultSet *result_set;
+ TrackerDBResultSet *result_set = NULL;
guint n_columns;
n_columns = tracker_db_cursor_get_n_columns (cursor);
- result_set = _tracker_db_result_set_new (n_columns);
while (tracker_db_cursor_iter_next (cursor)) {
GValue val = { 0 };
+ if (G_UNLIKELY (!result_set)) {
+ result_set = _tracker_db_result_set_new (n_columns);
+ }
+
_tracker_db_result_set_append (result_set);
for (i = 0; i < n_columns; i++) {
@@ -1402,9 +1405,11 @@ interface_pool_dispatch_cb (gpointer data,
if (job->cancellable &&
g_cancellable_set_error_if_cancelled (job->cancellable, &error)) {
g_simple_async_result_set_from_error (G_SIMPLE_ASYNC_RESULT (job->async_result), error);
- g_object_unref (result_set);
+ if (result_set) {
+ g_object_unref (result_set);
+ }
g_error_free (error);
- } else {
+ } else if (result_set) {
g_simple_async_result_set_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (job->async_result),
result_set, (GDestroyNotify) g_object_unref);
}
@@ -1459,9 +1464,13 @@ tracker_db_interface_pool_execute_query_finish (TrackerDBInterfacePool *pool,
return NULL;
}
- result_set = TRACKER_DB_RESULT_SET (g_simple_async_result_get_op_res_gpointer (result));
+ result_set = g_simple_async_result_get_op_res_gpointer (result);
- return g_object_ref (result_set);
+ if (result_set) {
+ return g_object_ref (result_set);
+ } else {
+ return NULL;
+ }
}
void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]