From 9938167a9079c7a67ef3a592f5bf86cae995517f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Fri, 11 Oct 2013 18:09:37 +0200 Subject: [PATCH] fixed json loading in VolumesModel --- YACReaderLibrary/comic_vine/model/volumes_model.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/YACReaderLibrary/comic_vine/model/volumes_model.cpp b/YACReaderLibrary/comic_vine/model/volumes_model.cpp index 774d3148..44f5db52 100644 --- a/YACReaderLibrary/comic_vine/model/volumes_model.cpp +++ b/YACReaderLibrary/comic_vine/model/volumes_model.cpp @@ -27,7 +27,8 @@ void VolumesModel::load(const QString &json) { int numResults = sc.property("number_of_total_results").toString().toInt(); //fix to weird behaviour using hasNext QScriptValueIterator it(sc.property("results")); - while (numResults > 0) { + bool test; + while (it.hasNext()) { it.next(); QString numIssues = it.value().property("count_of_issues").toString(); QString year = it.value().property("start_year").toString(); @@ -36,7 +37,9 @@ void VolumesModel::load(const QString &json) QString url = it.value().property("image").property("screen_url").toString(); QStringList & l = *(new QStringList); l << name << year << numIssues << publisher << url; - _data.push_back(&l); + test = name.isEmpty() && year.isEmpty() && numIssues.isEmpty() && url.isEmpty(); + if(numResults>0 && !test) + _data.push_back(&l); numResults--; } }