From d26577ca1de0d00cde39dd6a81f2e0d7da4cc9e0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Efe=20=C3=87iftci?= Date: Fri, 16 May 2025 20:50:21 +0300 Subject: [PATCH] [PATCH] Fix incorrect usage percentage in Properties dialog for virtual filesystems The Properties dialog for filesystems such as `/proc/` or `/sys/` shows an incorrect usage percentage (i.e., "-2,147,483,648% used"). This commit fixes that issue by avoiding a divbyzero: if the `size` variable is `0`, the `percentUsed` variable is set to `0`. Gbp-Pq: Name upstream_81ca0e2c_Fix-incorrect-usage-percentage-in-Properties-dialog-for-virtual-filesystems.patch --- src/widgets/kpropertiesdialogbuiltin_p.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/widgets/kpropertiesdialogbuiltin_p.cpp b/src/widgets/kpropertiesdialogbuiltin_p.cpp index 25e146d..910ab16 100644 --- a/src/widgets/kpropertiesdialogbuiltin_p.cpp +++ b/src/widgets/kpropertiesdialogbuiltin_p.cpp @@ -664,7 +664,7 @@ void KFilePropsPlugin::slotFreeSpaceResult(KJob *_job) const qint64 size = job->size(); const qint64 available = job->availableSize(); const quint64 used = size - available; - const int percentUsed = qRound(100.0 * qreal(used) / qreal(size)); + const int percentUsed = (size == 0) ? 0 : qRound(100.0 * qreal(used) / qreal(size)); d->m_ui->capacityBar->setText(i18nc("Available space out of total partition size (percent used)", "%1 free of %2 (%3% used)", -- 2.30.2