File 2001-smaps.patch of Package libksysguard6

diff --git a/formatter/Formatter.cpp b/formatter/Formatter.cpp
index 104d218a038f03e18334cfe7df92343e44b3af92..989acadda97bec58a902e15da3ea7f215eddd3cb 100644
--- a/formatter/Formatter.cpp
+++ b/formatter/Formatter.cpp
@@ -458,6 +458,10 @@ QString Formatter::formatValue(const QVariant &value, Unit unit, MetricPrefix ta
     case UnitGigaByte:
     case UnitTeraByte:
     case UnitPetaByte:
+        if (value.toDouble() < 0) {
+            return i18nc("Not available", "N/A");
+        }
+        Q_FALLTHROUGH();
     case UnitByteRate:
     case UnitKiloByteRate:
     case UnitMegaByteRate:
diff --git a/processcore/read_procsmaps_runnable.cpp b/processcore/read_procsmaps_runnable.cpp
index b2a3bfcb2f47be7e3f643a37a6ae99fa2483da2d..68500c9694708b0329d2902ca44763eb6e7c2e91 100644
--- a/processcore/read_procsmaps_runnable.cpp
+++ b/processcore/read_procsmaps_runnable.cpp
@@ -19,21 +19,19 @@ ReadProcSmapsRunnable::ReadProcSmapsRunnable(const QString &dir)
 
 void ReadProcSmapsRunnable::run()
 {
-    QFile file{m_dir + QStringLiteral("smaps_rollup")};
-    if (!file.open(QIODevice::ReadOnly)) {
-        return;
-    }
+    qlonglong pss = -1;
 
-    qulonglong pss = 0LL;
-    auto buffer = QByteArray{1024, '\0'};
-    while (file.readLine(buffer.data(), buffer.size()) > 0) {
-        if (buffer.startsWith("Pss:")) {
-            pss += std::stoll(buffer.mid(sizeof("Pss:")).toStdString());
-            break;
+    QFile file{m_dir + QStringLiteral("smaps_rollup")};
+    if (file.open(QIODevice::ReadOnly)) {
+        auto buffer = QByteArray{1024, '\0'};
+        while (file.readLine(buffer.data(), buffer.size()) > 0) {
+            if (buffer.startsWith("Pss:")) {
+                pss += std::stoll(buffer.mid(sizeof("Pss:")).toStdString());
+                break;
+            }
         }
+        file.close();
     }
 
-    file.close();
-
     Q_EMIT finished(pss);
 }
openSUSE Build Service is sponsored by