[rygel] core: Fix simple search for offset > 0
- From: Jens Georg <jensgeorg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rygel] core: Fix simple search for offset > 0
- Date: Sun, 29 Jan 2012 11:33:28 +0000 (UTC)
commit e8cdb95008b6d71557f6fa53d26b89d866de1cd8
Author: Jens Georg <mail jensge org>
Date: Sat Jan 28 15:19:06 2012 +0100
core: Fix simple search for offset > 0
On a search request where offset was > 0 and limit was 0 due to
limiting the result set to offset the result was always a set of one.
Also total_matches was set to 0 in this case although we know the
number of total matches since using a start offset doesn't limit the
results.
https://bugzilla.gnome.org/show_bug.cgi?id=653120
src/rygel/rygel-searchable-container.vala | 35 +++++++++++++++-------------
1 files changed, 19 insertions(+), 16 deletions(-)
---
diff --git a/src/rygel/rygel-searchable-container.vala b/src/rygel/rygel-searchable-container.vala
index 10f9713..8334c42 100644
--- a/src/rygel/rygel-searchable-container.vala
+++ b/src/rygel/rygel-searchable-container.vala
@@ -82,7 +82,7 @@ public interface Rygel.SearchableContainer : MediaContainer {
// The maximum number of results we need to be able to slice-out
// the needed portion from it.
uint limit;
- if (offset > 0 || max_count > 0) {
+ if (max_count > 0) {
limit = offset + max_count;
} else {
limit = 0; // No limits on searches
@@ -110,29 +110,32 @@ public interface Rygel.SearchableContainer : MediaContainer {
result.add_all (child_results);
}
+ // Since we limited our search, we don't know how many objects
+ // actually satisfy the give search expression
+ if (max_count > 0) {
+ total_matches = 0;
+ } else {
+ total_matches = result.size;
+ }
+
+ if (offset >= result.size) {
+ return new MediaObjects ();
+ }
+
// See if we need to slice the results
- if (result.size > 0 && limit > 0) {
- uint start;
+ if (result.size > 0 && (max_count > 0 || offset > 0)) {
uint stop;
- start = offset.clamp (0, result.size - 1);
-
- if (max_count != 0 && start + max_count <= result.size) {
- stop = start + max_count;
+ if (max_count != 0 && offset + max_count <= result.size) {
+ stop = offset + max_count;
} else {
stop = result.size;
}
- // Since we limited our search, we don't know how many objects
- // actually satisfy the give search expression
- total_matches = 0;
-
- return result.slice ((int) start, (int) stop) as MediaObjects;
- } else {
- total_matches = result.size;
-
- return result;
+ return result.slice ((int) offset, (int) stop) as MediaObjects;
}
+
+ return result;
}
/**
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]