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 147 TemplateList templates;
148 148 while ((templates.size() < readBlockSize) && !gallery.atEnd()) {
149 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 155 // Special case for pipes where we want to process data as soon as it is available
156 156 if (gallery.isSequential())
... ... @@ -350,7 +350,9 @@ class jsonGallery : public BinaryGallery
350 350 Template readTemplate()
351 351 {
352 352 QJsonParseError error;
353   - const QByteArray line = gallery.readLine();
  353 + const QByteArray line = gallery.readLine().simplified();
  354 + if (line.isEmpty())
  355 + return Template();
354 356 File file = QJsonDocument::fromJson(line, &error).object().toVariantMap();
355 357 if (error.error != QJsonParseError::NoError) {
356 358 qWarning("Couldn't parse: %s\n", line.data());
... ...