[graphics/kphotoalbum] /: Fix video backend selection with newer versions of VLC

Johannes Zarl-Zierl <[email protected]>
Newsgroups gmane.comp.kde.cvs
Message-ID <[email protected]>
Git commit 854acccaf13a992f21654e84b340c5582d5412e0 by Johannes Zarl-Zierl.
Committed on 17/08/2026 at 21:36.
Pushed by johanneszarl into branch 'master'.

Fix video backend selection with newer versions of VLC

For VLC version 4.0 and newer, the build system finds VLC, but the
VLCDisplay is not actually compatible. With this configuration, it's
possible to end up without a usable video backend (and therefore with a
crash).

This patch makes sure that VLC is only considered if it's a compatible
version.

M  +4    -2    Settings/VideoPlayerSelectorDialog.cpp
M  +0    -2    Viewer/ViewerWidget.cpp
M  +4    -0    lib/kpabase/SettingsData.cpp

https://invent.kde.org/graphics/kphotoalbum/-/commit/854acccaf13a992f21654e84b340c5582d5412e0

diff --git a/Settings/VideoPlayerSelectorDialog.cpp b/Settings/VideoPlayerSelectorDialog.cpp
index efcd3ec44..3b087bbb5 100644
--- a/Settings/VideoPlayerSelectorDialog.cpp
+++ b/Settings/VideoPlayerSelectorDialog.cpp
@@ -1,6 +1,6 @@
 // SPDX-FileCopyrightText: 2021 Yuri Chornoivan <[email protected]>
 // SPDX-FileCopyrightText: 2021-2022 Jesper K. Pedersen <[email protected]>
-// SPDX-FileCopyrightText: 2021-2024 Johannes Zarl-Zierl <[email protected]>
+// SPDX-FileCopyrightText: 2021-2026 Johannes Zarl-Zierl <[email protected]>
 //
 // SPDX-License-Identifier: GPL-2.0-or-later
 
@@ -15,6 +15,8 @@
 #include <QRadioButton>
 #include <QVBoxLayout>
 
+#include <vlc/libvlc_version.h>
+
 namespace Settings
 {
 
@@ -117,7 +119,7 @@ VideoBackend VideoPlayerSelectorDialog::backend() const
 constexpr VideoBackends availableVideoBackends()
 {
     VideoBackends availableBackends = VideoBackend::QtMultimedia;
-#if LIBVLC_FOUND
+#if LIBVLC_FOUND && (LIBVLC_VERSION_INT < LIBVLC_VERSION(4, 0, 0, 0))
     availableBackends |= VideoBackend::VLC;
 #endif
 #if Phonon4Qt6_FOUND
diff --git a/Viewer/ViewerWidget.cpp b/Viewer/ViewerWidget.cpp
index cec9bc3b5..e2d97bedd 100644
--- a/Viewer/ViewerWidget.cpp
+++ b/Viewer/ViewerWidget.cpp
@@ -1451,9 +1451,7 @@ static VideoDisplay *instantiateVideoDisplay(QWidget *parent, KPABase::CrashSent
         return new QtMultimediaDisplay(parent);
     case Settings::VideoBackend::VLC:
 #if LIBVLC_FOUND
-#if (LIBVLC_VERSION_INT < LIBVLC_VERSION(4, 0, 0, 0))
         return new VLCDisplay(parent);
-#endif
 #else
         qCWarning(ViewerLog) << "Video backend VLC not available. Selecting first available backend...";
 #endif
diff --git a/lib/kpabase/SettingsData.cpp b/lib/kpabase/SettingsData.cpp
index c25abf47c..2e549907a 100644
--- a/lib/kpabase/SettingsData.cpp
+++ b/lib/kpabase/SettingsData.cpp
@@ -33,6 +33,8 @@
 #include <QStringLiteral>
 #include <QThread>
 
+#include <vlc/libvlc_version.h>
+
 // enable _L1 string literal operator
 using namespace Qt::Literals::StringLiterals;
 
@@ -386,7 +388,9 @@ setValueFunc_(setVideoBackend, VideoBackend, "Viewer"_L1, "videoBackend", static
     switch (value) {
     case VideoBackend::VLC:
 #if LIBVLC_FOUND
+#if (LIBVLC_VERSION_INT < LIBVLC_VERSION(4, 0, 0, 0))
         return value;
+#endif
 #else
         qCWarning(BaseLog) << "Configuration value for Viewer.videoBackend is not available. Ignoring value...";
         return VideoBackend::NotConfigured;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.