diff --git a/0001-PreviewJob-Create-a-larger-SHM-when-necessary.patch b/0001-PreviewJob-Create-a-larger-SHM-when-necessary.patch new file mode 100644 index 0000000..d085814 --- /dev/null +++ b/0001-PreviewJob-Create-a-larger-SHM-when-necessary.patch @@ -0,0 +1,56 @@ +From bc02b2528c97eab0961b3ad608a4914d3ce4b46c Mon Sep 17 00:00:00 2001 +From: Fabian Vogt +Date: Tue, 4 May 2021 22:22:53 +0200 +Subject: [PATCH] PreviewJob: Create a larger SHM when necessary + +It's possible that during the lifetime of a PreviewJob thumbnails with +different sizes are created. The SHM was created to match the size of the first +(non-empty) thumbnail, so any larger ones after that would reuse the SHM with +insufficient size. + +BUG: 430862 +--- + src/widgets/previewjob.cpp | 14 +++++++++----- + 1 file changed, 9 insertions(+), 5 deletions(-) + +diff --git a/src/widgets/previewjob.cpp b/src/widgets/previewjob.cpp +index d30f71cf..4f71c1c7 100644 +--- a/src/widgets/previewjob.cpp ++++ b/src/widgets/previewjob.cpp +@@ -136,6 +136,8 @@ public: + int shmid; + // And the data area + uchar *shmaddr; ++ // Size of the shm segment ++ size_t shmsize; + // Root of thumbnail cache + QString thumbRoot; + // List of encrypted mount points for checking if we should save thumbnail +@@ -733,17 +735,19 @@ void PreviewJobPrivate::createThumbnail(const QString &pixPath) + } + + #if WITH_SHM +- if (shmid == -1) { ++ size_t requiredSize = thumb_width * devicePixelRatio * thumb_height * devicePixelRatio * 4; ++ if (shmid == -1 || shmsize < requiredSize) { + if (shmaddr) { + // clean previous shared memory segment + shmdt((char *)shmaddr); +- shmctl(shmid, IPC_RMID, nullptr); + shmaddr = nullptr; ++ shmctl(shmid, IPC_RMID, nullptr); ++ shmid = -1; + } +- auto size = thumb_width * thumb_height; +- if (size > 0) { +- shmid = shmget(IPC_PRIVATE, size * 4 * devicePixelRatio * devicePixelRatio, IPC_CREAT | 0600); ++ if (requiredSize > 0) { ++ shmid = shmget(IPC_PRIVATE, requiredSize, IPC_CREAT | 0600); + if (shmid != -1) { ++ shmsize = requiredSize; + shmaddr = (uchar *)(shmat(shmid, nullptr, SHM_RDONLY)); + if (shmaddr == (uchar *)-1) { + shmctl(shmid, IPC_RMID, nullptr); +-- +2.25.1 + diff --git a/kio.changes b/kio.changes index 9c9c257..954fe78 100644 --- a/kio.changes +++ b/kio.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Tue May 4 20:28:31 UTC 2021 - Fabian Vogt + +- Add patch to fix thumnail creation in certain conditions (kde#430862): + * 0001-PreviewJob-Create-a-larger-SHM-when-necessary.patch + ------------------------------------------------------------------- Mon Apr 5 07:12:32 UTC 2021 - Christophe Giboudeaux diff --git a/kio.spec b/kio.spec index 3fc223f..d9df625 100644 --- a/kio.spec +++ b/kio.spec @@ -37,6 +37,8 @@ Source2: frameworks.keyring Source99: baselibs.conf # PATCH-FIX-OPENSUSE kio_help-fallback-to-kde4-docs.patch -- allow kio_help to see into kde4 documentation, needed especially for khelpcenter5 Patch0: kio_help-fallback-to-kde4-docs.patch +# PATCH-FIX-UPSTREAM +Patch1: 0001-PreviewJob-Create-a-larger-SHM-when-necessary.patch BuildRequires: extra-cmake-modules >= %{_kf5_bugfix_version} BuildRequires: fdupes BuildRequires: kf5-filesystem