[tracker/wip/carlosg/fixes-for-music] libtracker-bus: Make error clearer
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/wip/carlosg/fixes-for-music] libtracker-bus: Make error clearer
- Date: Sat, 17 Nov 2018 14:30:57 +0000 (UTC)
commit f81c4cd057ec3caf6bde242d7885f9561297d587
Author: Carlos Garnacho <carlosg gnome org>
Date: Sat Nov 17 11:39:50 2018 +0100
libtracker-bus: Make error clearer
The data != null check in get_string() really happens because of
fetching values on a finished or not yet started cursor, so make
it clearer to reason about.
This is of course a programming error.
src/libtracker-bus/tracker-bus-fd-cursor.vala | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
---
diff --git a/src/libtracker-bus/tracker-bus-fd-cursor.vala b/src/libtracker-bus/tracker-bus-fd-cursor.vala
index d42a6133f..751c65349 100644
--- a/src/libtracker-bus/tracker-bus-fd-cursor.vala
+++ b/src/libtracker-bus/tracker-bus-fd-cursor.vala
@@ -27,11 +27,13 @@ class Tracker.Bus.FDCursor : Tracker.Sparql.Cursor {
internal int* types;
internal char* data;
internal string[] variable_names;
+ internal bool cursor_finished;
public FDCursor (char* buffer, ulong buffer_size, string[] variable_names) {
this.buffer = buffer;
this.buffer_size = buffer_size;
this.variable_names = variable_names;
+ this.cursor_finished = true;
_n_columns = variable_names.length;
}
@@ -63,7 +65,7 @@ class Tracker.Bus.FDCursor : Tracker.Sparql.Cursor {
}
public override unowned string? get_string (int column, out long length = null)
- requires (data != null) {
+ requires (cursor_finished == false) {
unowned string str = null;
if (column >= n_columns) {
@@ -96,6 +98,8 @@ class Tracker.Bus.FDCursor : Tracker.Sparql.Cursor {
}
if (buffer_index >= buffer_size) {
+ cursor_finished = true;
+ data = null;
return false;
}
@@ -118,6 +122,7 @@ class Tracker.Bus.FDCursor : Tracker.Sparql.Cursor {
last_offset = buffer_read_int ();
data = buffer + buffer_index;
+ cursor_finished = false;
buffer_index += last_offset + 1;
@@ -132,5 +137,6 @@ class Tracker.Bus.FDCursor : Tracker.Sparql.Cursor {
public override void rewind () {
buffer_index = 0;
data = buffer;
+ cursor_finished = false;
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]