From eb7e9ac03919f364dc6f57fcc2f51eecec55646f Mon Sep 17 00:00:00 2001
From: Slávek Banko <slavek.banko@axis.cz>
Date: Wed, 7 May 2025 02:05:15 +0200
Subject: ArchLinux digikam: Backport commit TDE/digikam@0254a5942b - closes
 TDE/digikam#50.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Slávek Banko <slavek.banko@axis.cz>
---
 arch/tde-extra/tde-digikam/PKGBUILD                | 14 ++++--
 .../tde-digikam/bp000-fix-showfoto-crashes.diff    | 56 ++++++++++++++++++++++
 2 files changed, 67 insertions(+), 3 deletions(-)
 create mode 100644 arch/tde-extra/tde-digikam/bp000-fix-showfoto-crashes.diff

diff --git a/arch/tde-extra/tde-digikam/PKGBUILD b/arch/tde-extra/tde-digikam/PKGBUILD
index 9d2c0b146..75677944a 100644
--- a/arch/tde-extra/tde-digikam/PKGBUILD
+++ b/arch/tde-extra/tde-digikam/PKGBUILD
@@ -7,7 +7,7 @@ _kdemod="${_mod/tde/kde}"
 
 pkgname="tde-${_mod/tde-}"
 pkgver=14.1.4
-pkgrel=1
+pkgrel=2
 pkgdesc="Trinity Photo Management and Retouching Suite"
 arch=('i686' 'x86_64' 'aarch64' 'armv7h' 'powerpc64le')
 url="https://scm.trinitydesktop.org/scm/git/${_mod}"
@@ -33,12 +33,20 @@ replaces=("trinity-${_mod}")
 options=('staticlibs' 'libtool' '!strip')
 install=
 
-source=("https://mirror.ppa.trinitydesktop.org/trinity/releases/R${pkgver}/main/${_cat}${_mod}-trinity-${pkgver}.tar.xz")
-md5sums=('92daeb849329f4b21b32662272542aef')
+source=("https://mirror.ppa.trinitydesktop.org/trinity/releases/R${pkgver}/main/${_cat}${_mod}-trinity-${pkgver}.tar.xz"
+        'bp000-fix-showfoto-crashes.diff')
+md5sums=('92daeb849329f4b21b32662272542aef'
+         'eea6a195a649d502b73b20c7e2302191')
 
 [ -n "$TDEDIR" ] || TDEDIR=/opt/trinity
 [ -n "$TQTDIR" ] || TQTDIR=${TDEDIR}/tqt3
 
+prepare() {
+  msg "Apply backported patches"
+  cd ${srcdir}/${pkgname#*-}-trinity-${pkgver} || exit 1
+  patch -p1 < ${srcdir}/bp000-fix-showfoto-crashes.diff
+}
+
 build() {
   msg "Creating out-of-source build directory: ${srcdir}/build"
   mkdir -p "$srcdir/build"
diff --git a/arch/tde-extra/tde-digikam/bp000-fix-showfoto-crashes.diff b/arch/tde-extra/tde-digikam/bp000-fix-showfoto-crashes.diff
new file mode 100644
index 000000000..f3dda49bb
--- /dev/null
+++ b/arch/tde-extra/tde-digikam/bp000-fix-showfoto-crashes.diff
@@ -0,0 +1,56 @@
+commit 0254a5942b7ff18bf0072db3ebcd591512d99a10
+Author: Michele Calgaro <michele.calgaro@yahoo.it>
+Date:   Sat May 3 22:45:33 2025 +0900
+
+    Fix showfoto usability.
+    
+    This resolves issue #50.
+    
+    The problem seems to be a known issue already addressed by the original
+    authors. This is an extract from the 'ChangeLog' file that best
+    describes the issue:
+    ```
+    Fix a linking problem with showfoto, image plugins and
+    --enable-gcc-hidden-visibility:
+    All image plugins link to libdigikam.so.
+    The showfoto executable however does not link to this lib, but
+    statically links the relevant parts.
+    With visibility hidden, now the linker obviously cannot see the
+    already linked DImgInterface class,
+    and there would be two different static variables for
+    DImgInterface::instance(). One with the loaded
+    image, the other (from the image plugins) with a null image.
+    ```
+    Linking against libdigikam.so instead of including the libraries in a
+    static way solves the issue.
+    
+    Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
+    (cherry picked from commit f8074c05d9a2ad3b4a4e44557222ad51539b7e79)
+
+diff --git a/src/digikam/CMakeLists.txt b/src/digikam/CMakeLists.txt
+index 42785dbf..f756c188 100644
+--- a/src/digikam/CMakeLists.txt
++++ b/src/digikam/CMakeLists.txt
+@@ -44,7 +44,7 @@ tde_add_library( digikam SHARED AUTOMOC
+     tagfolderview.cpp tagspopupmenu.cpp timelinefolderview.cpp timelineview.cpp timelinewidget.cpp
+     upgradedb_sqlite2tosqlite3.cpp welcomepageview.cpp
+   LINK
+-    sqlite2-static thumbbar-static themeengine-static dialog-static  metadatawidgets-static
++    sqlite2-static thumbbar-static themeengine-static dialog-static metadatawidgets-static
+     iccprofileswidgets-static imagepluginswidgets-static commonwidgets-static
+     jpegutils-static dimg-static imagepropertiesdigikam-static threadimageio-static
+     greycstoration-static batch-static slideshow-static cameragui-static
+diff --git a/src/showfoto/CMakeLists.txt b/src/showfoto/CMakeLists.txt
+index 96993fb3..526b1a58 100644
+--- a/src/showfoto/CMakeLists.txt
++++ b/src/showfoto/CMakeLists.txt
+@@ -25,8 +25,7 @@ add_subdirectory( setup )
+ tde_add_executable( showfoto AUTOMOC
+   SOURCES main.cpp showfoto.cpp
+   LINK
+-    imagepropertiesshowfoto-static jpegutils-static showfoto-static showfotosetupinternal-static
+-    slideshow-static themeengine-static threadimageio-static thumbbar-static
++    showfotosetupinternal-static digikam-shared
+     tdeparts-shared tdeutils-shared ${CMAKE_THREAD_LIBS_INIT} ${KDCRAW_LIBRARIES} ${KEXIV2_LIBRARIES}
+   DESTINATION ${BIN_INSTALL_DIR}
+ )
-- 
cgit v1.2.3

