Download raw body.
Patch: kf6/kcoreaddons
On Sat Nov 01, 2025 at 12:01:03PM -0700, Kristaps Dzonsons wrote:
> Hi, enclosed is a source patch that provides the available physical memory
> (previously listed as a TODO) and refactors the total physical memory to
> qt6's core addons. It should be added to the "patches" directory to enable.
>
> This is because the available physical memory is used by digikam when
> deciding how to export "large" (not by today's standards, but whatever)
> photos with resizing. Without this patch, digikam would fail to export.
>
> I haven't tested this elsewhere, however: digikam is the only qt6
> application that I use.
>
> Best,
>
> Kristaps
Thanks Kristaps, I tested your diff in my KDE Plasma setup, so far
no issues. If no one has any objections, I'd like to commit it
and push it upstream.
Rafael
Index: Makefile
===================================================================
RCS file: /cvs/ports/devel/kf6/kcoreaddons/Makefile,v
diff -u -p -r1.9 Makefile
--- Makefile 13 Sep 2025 16:02:45 -0000 1.9
+++ Makefile 2 Nov 2025 06:46:21 -0000
@@ -1,5 +1,6 @@
COMMENT = core KDE extensions to Qt classes
DISTNAME = kcoreaddons-${VERSION}
+REVISION = 0
SHARED_LIBS += KF6CoreAddons 1.2 # 0.0
Index: patches/patch-src_lib_util_kmemoryinfo_cpp
===================================================================
RCS file: patches/patch-src_lib_util_kmemoryinfo_cpp
diff -N patches/patch-src_lib_util_kmemoryinfo_cpp
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_lib_util_kmemoryinfo_cpp 2 Nov 2025 06:46:21 -0000
@@ -0,0 +1,56 @@
+Index: src/lib/util/kmemoryinfo.cpp
+--- src/lib/util/kmemoryinfo.cpp.orig
++++ src/lib/util/kmemoryinfo.cpp
+@@ -467,14 +467,23 @@ static int swap_usage(int *used, int *total)
+
+ bool KMemoryInfo::update()
+ {
+- // TODO: compute m_availablePhysical on OpenBSD
++ int64_t memSize = 0;
++ size_t sz = 0;
+
+- // tota phsycial memory
+- const long phys_pages = sysconf(_SC_PHYS_PAGES);
+- const long pagesize = sysconf(_SC_PAGESIZE);
+- if (phys_pages != -1 && pagesize != -1)
+- d->m_totalPhysical = ((uint64_t)phys_pages * (uint64_t)pagesize / 1024);
++ int usermem_mib[] = {CTL_HW, HW_USERMEM64};
++ sz = sizeof(memSize);
++ if (sysctl(usermem_mib, 2, &memSize, &sz, NULL, 0) != 0) {
++ return false;
++ }
++ d->m_availablePhysical = memSize;
+
++ int physmem_mib[] = {CTL_HW, HW_PHYSMEM64};
++ sz = sizeof(memSize);
++ if (sysctl(physmem_mib, 2, &memSize, &sz, NULL, 0) != 0) {
++ return false;
++ }
++ d->m_totalPhysical = memSize;
++
+ int swap_free = 0;
+ int swap_tot = 0;
+ if (swap_usage(&swap_free, &swap_tot)) {
+@@ -484,17 +493,18 @@ bool KMemoryInfo::update()
+
+ int uvmexp_mib[] = {CTL_VM, VM_UVMEXP};
+ struct uvmexp uvmexp;
+- size_t size = sizeof(uvmexp);
+- if (sysctl(uvmexp_mib, 2, &uvmexp, &size, NULL, 0) == -1) {
++ sz = sizeof(uvmexp);
++ if (sysctl(uvmexp_mib, 2, &uvmexp, &sz, NULL, 0) == -1) {
+ bzero(&uvmexp, sizeof(uvmexp));
+ return false;
+ }
++ const long pagesize = sysconf(_SC_PAGESIZE);
+ d->m_freePhysical = uvmexp.free * pagesize / 1024;
+
+ int bcstats_mib[] = {CTL_VFS, VFS_GENERIC, VFS_BCACHESTAT};
+ struct bcachestats bcstats;
+- size = sizeof(bcstats);
+- if (sysctl(bcstats_mib, 3, &bcstats, &size, NULL, 0) == -1) {
++ sz = sizeof(bcstats);
++ if (sysctl(bcstats_mib, 3, &bcstats, &sz, NULL, 0) == -1) {
+ bzero(&bcstats, sizeof(bcstats));
+ return false;
+ }
Patch: kf6/kcoreaddons