Commit 93b7a3cdc9523c29316ecb57d1b8e43b643206f9

Authored by Charles Otto
1 parent 1bf9c77c

Modify dbGallery to actually give deterministic output

Make a call to qSort prior to shuffling the records received by a dbGallery
this makes the output of a dbGallery deterministic for a given query (as long
as the seed is set).
Showing 1 changed file with 2 additions and 2 deletions
sdk/plugins/gallery.cpp
@@ -590,10 +590,10 @@ class dbGallery : public Gallery @@ -590,10 +590,10 @@ class dbGallery : public Gallery
590 } 590 }
591 591
592 QStringList labels = entries.keys(); 592 QStringList labels = entries.keys();
  593 + qSort(labels);
  594 +
593 if (hasFilter && ((labels.size() > numSubjects) || (numSubjects == std::numeric_limits<int>::max()))) 595 if (hasFilter && ((labels.size() > numSubjects) || (numSubjects == std::numeric_limits<int>::max())))
594 std::random_shuffle(labels.begin(), labels.end()); 596 std::random_shuffle(labels.begin(), labels.end());
595 - else  
596 - qSort(labels);  
597 597
598 foreach (const QString &label, labels) { 598 foreach (const QString &label, labels) {
599 QList<Entry> entryList = entries[label]; 599 QList<Entry> entryList = entries[label];