From 811d29f643bdfabeaccc54c3a2281e86026175a4 Mon Sep 17 00:00:00 2001
From: Martin Rotter <rotter@praktik.cz>
Date: Thu, 13 Aug 2020 14:39:17 +0200
Subject: [PATCH] Fix error when gmail feed has no messages.

---
 .../gmail/network/gmailnetworkfactory.cpp     | 26 ++++++++++---------
 1 file changed, 14 insertions(+), 12 deletions(-)

diff --git a/src/librssguard/services/gmail/network/gmailnetworkfactory.cpp b/src/librssguard/services/gmail/network/gmailnetworkfactory.cpp
index fffaab1f4..a305a0dae 100644
--- a/src/librssguard/services/gmail/network/gmailnetworkfactory.cpp
+++ b/src/librssguard/services/gmail/network/gmailnetworkfactory.cpp
@@ -191,22 +191,24 @@ QList<Message> GmailNetworkFactory::messages(const QString& stream_id, Feed::Sta
       QList<Message> more_messages = decodeLiteMessages(messages_data, stream_id, next_page_token);
       QList<Message> full_messages;
 
-      // Now, we via batch HTTP request obtain full data for each message.
-      bool obtained = obtainAndDecodeFullMessages(more_messages, stream_id, full_messages);
+      if (!more_messages.isEmpty()) {
+        // Now, we via batch HTTP request obtain full data for each message.
+        bool obtained = obtainAndDecodeFullMessages(more_messages, stream_id, full_messages);
 
-      if (obtained) {
-        messages.append(full_messages);
+        if (obtained) {
+          messages.append(full_messages);
 
-        // New batch of messages was obtained, check if we have enough.
-        if (batchSize() > 0 && batchSize() <= messages.size()) {
-          // We have enough messages.
-          break;
+          // New batch of messages was obtained, check if we have enough.
+          if (batchSize() > 0 && batchSize() <= messages.size()) {
+            // We have enough messages.
+            break;
+          }
         }
-      }
-      else {
+        else {
 
-        error = Feed::Status::NetworkError;
-        return messages;
+          error = Feed::Status::NetworkError;
+          return messages;
+        }
       }
     }
     else {