]> gitweb.stoutner.com Git - PrivacyBrowserPC.git/blobdiff - src/databases/CookiesDatabase.cpp
Replace the for loops in CookiesDialog with while loops. https://redmine.stoutner...
[PrivacyBrowserPC.git] / src / databases / CookiesDatabase.cpp
index a99290985cd7c5f28e971c3e50250f2567aa5aec..8464c0624a4f728c4532efa33eacb93f2bbda18e 100644 (file)
@@ -163,11 +163,18 @@ int CookiesDatabase::cookieCount()
     // Execute the query.
     countCookiesQuery.exec();
 
-    // Move to the last row.
-    countCookiesQuery.last();
+    // Initialize a number of cookies variable.
+    int numberOfCookies = 0;
 
-    // Get the number of rows (which is zero based).
-    int numberOfCookies = countCookiesQuery.at() + 1;
+    // Check to see if the query is valid (there is at least one cookie).
+    if (countCookiesQuery.isValid())
+    {
+        // Move to the last row.
+        countCookiesQuery.last();
+
+        // Get the number of rows (which is zero based) and add one to calculate the number of cookies.
+        numberOfCookies = countCookiesQuery.at() + 1;
+    }
 
     // Return the number of cookies.
     return numberOfCookies;
@@ -351,14 +358,14 @@ bool CookiesDatabase::isUpdate(const QNetworkCookie &cookie)
             (isUpdateQuery.value(2).toBool() != cookie.isSecure()) ||
             (isUpdateQuery.value(3).toString().toUtf8() != cookie.value()))  // The cookies data has changed.
         {
-            qDebug() << "The durable cookie data has changed.";
+            //qDebug() << "The durable cookie data has changed.";
 
             // Return true.
             return true;
         }
         else  // The cookie data has not changed.
         {
-            qDebug() << "The durable cookie data is unchanged.";
+            //qDebug() << "The durable cookie data is unchanged.";
 
             // Return false.
             return false;