[tracker/wip/carlosg/unbreak-writeback: 1/2] libtracker-data: Ensure triples cursor is entirely reset on filter()
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/wip/carlosg/unbreak-writeback: 1/2] libtracker-data: Ensure triples cursor is entirely reset on filter()
- Date: Wed, 12 Jun 2019 13:05:58 +0000 (UTC)
commit 1cac469c7f916bd36945a7187f8a29f25112e3bf
Author: Carlos Garnacho <carlosg gnome org>
Date: Sat Jun 8 15:59:17 2019 +0200
libtracker-data: Ensure triples cursor is entirely reset on filter()
The cursor may actually be reused multiple times for different values,
in which case we'd get filter() called again on it. Ensure the cursor
is properly reset so it can handle later items as if brand new.
src/libtracker-data/tracker-vtab-triples.c | 23 ++++++++++++++++-------
1 file changed, 16 insertions(+), 7 deletions(-)
---
diff --git a/src/libtracker-data/tracker-vtab-triples.c b/src/libtracker-data/tracker-vtab-triples.c
index 92a5ff86c..78cae40cb 100644
--- a/src/libtracker-data/tracker-vtab-triples.c
+++ b/src/libtracker-data/tracker-vtab-triples.c
@@ -98,17 +98,24 @@ tracker_triples_vtab_free (gpointer data)
}
static void
-tracker_triples_cursor_free (gpointer data)
+tracker_triples_cursor_reset (TrackerTriplesCursor *cursor)
{
- TrackerTriplesCursor *cursor = data;
-
- if (cursor->stmt)
- sqlite3_finalize (cursor->stmt);
-
+ g_clear_pointer (&cursor->stmt, sqlite3_finalize);
g_clear_pointer (&cursor->match.graph, sqlite3_value_free);
g_clear_pointer (&cursor->match.subject, sqlite3_value_free);
g_clear_pointer (&cursor->match.predicate, sqlite3_value_free);
- g_list_free (cursor->properties);
+ g_clear_pointer (&cursor->properties, g_list_free);
+ cursor->match.idxFlags = 0;
+ cursor->rowid = 0;
+ cursor->finished = FALSE;
+}
+
+static void
+tracker_triples_cursor_free (gpointer data)
+{
+ TrackerTriplesCursor *cursor = data;
+
+ tracker_triples_cursor_reset (cursor);
g_free (cursor);
}
@@ -414,6 +421,8 @@ triples_filter (sqlite3_vtab_cursor *vtab_cursor,
TrackerTriplesCursor *cursor = (TrackerTriplesCursor *) vtab_cursor;
int rc;
+ tracker_triples_cursor_reset (cursor);
+
if (idx & IDX_COL_GRAPH) {
int idx = idx_str[COL_GRAPH];
cursor->match.graph = sqlite3_value_dup (argv[idx]);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]