Commit e82920f726af10db91ad949340c0584dfc66b611

Authored by Josh Klontz
1 parent 7cfd26b4

BinaryGallery and jsonGallery logic cleanup

Showing 1 changed file with 7 additions and 5 deletions
openbr/plugins/gallery.cpp
@@ -147,10 +147,10 @@ class BinaryGallery : public Gallery @@ -147,10 +147,10 @@ class BinaryGallery : public Gallery
147 TemplateList templates; 147 TemplateList templates;
148 while ((templates.size() < readBlockSize) && !gallery.atEnd()) { 148 while ((templates.size() < readBlockSize) && !gallery.atEnd()) {
149 const Template t = readTemplate(); 149 const Template t = readTemplate();
150 - if (t.isEmpty() && t.file.isNull())  
151 - continue;  
152 - templates.append(t);  
153 - templates.last().file.set("progress", position()); 150 + if (!t.isEmpty() || !t.file.isNull()) {
  151 + templates.append(t);
  152 + templates.last().file.set("progress", position());
  153 + }
154 154
155 // Special case for pipes where we want to process data as soon as it is available 155 // Special case for pipes where we want to process data as soon as it is available
156 if (gallery.isSequential()) 156 if (gallery.isSequential())
@@ -350,7 +350,9 @@ class jsonGallery : public BinaryGallery @@ -350,7 +350,9 @@ class jsonGallery : public BinaryGallery
350 Template readTemplate() 350 Template readTemplate()
351 { 351 {
352 QJsonParseError error; 352 QJsonParseError error;
353 - const QByteArray line = gallery.readLine(); 353 + const QByteArray line = gallery.readLine().simplified();
  354 + if (line.isEmpty())
  355 + return Template();
354 File file = QJsonDocument::fromJson(line, &error).object().toVariantMap(); 356 File file = QJsonDocument::fromJson(line, &error).object().toVariantMap();
355 if (error.error != QJsonParseError::NoError) { 357 if (error.error != QJsonParseError::NoError) {
356 qWarning("Couldn't parse: %s\n", line.data()); 358 qWarning("Couldn't parse: %s\n", line.data());