git: 8827164af8ac - main - audio/lmms: Fix issue caused by kwidgetsaddons

From: Rodrigo Osorio <rodrigo_at_FreeBSD.org>
Date: Sat, 17 Jun 2023 16:54:36 UTC
The branch main has been updated by rodrigo:

URL: https://cgit.FreeBSD.org/ports/commit/?id=8827164af8acf5fb7255f51a175b2d39d0ce76ff

commit 8827164af8acf5fb7255f51a175b2d39d0ce76ff
Author:     Rodrigo Osorio <rodrigo@FreeBSD.org>
AuthorDate: 2023-06-17 16:33:18 +0000
Commit:     Rodrigo Osorio <rodrigo@FreeBSD.org>
CommitDate: 2023-06-17 16:42:06 +0000

    audio/lmms: Fix issue caused by kwidgetsaddons
    
    Add temporary patch to fix a crash at startup if kwidgetsaddons
    5.101.0 is installed. The patch was obtained from LMMS ticket
    related with this issue[1].
    
    [1] https://github.com/LMMS/lmms/issues/6587
    
    Since I'm here reorder Makefile to make linters happy.
    
    PR:             270470
    Reported by:    Manuel <gnuandbsdguy@gmail.com>
    MFH:        2023Q2
---
 audio/lmms/Makefile                                | 20 ++++------
 audio/lmms/files/patch-src_gui_MainApplication.cpp | 21 +++++++++++
 audio/lmms/files/patch-src_gui_MainWindow.cpp      | 44 ++++++++++++++++++++++
 3 files changed, 73 insertions(+), 12 deletions(-)

diff --git a/audio/lmms/Makefile b/audio/lmms/Makefile
index 87c0bb0e0d83..b271dfe6a47d 100644
--- a/audio/lmms/Makefile
+++ b/audio/lmms/Makefile
@@ -1,7 +1,7 @@
 PORTNAME=	lmms
 DISTVERSIONPREFIX=	v
 DISTVERSION=	1.2.2
-PORTREVISION=	6
+PORTREVISION=	7
 PORTEPOCH=	2
 CATEGORIES=	audio
 
@@ -41,28 +41,24 @@ USE_LDCONFIG=	yes
 USE_QT=		core gui widgets x11extras xml buildtools:build linguisttools:build qmake:build
 USE_XORG=	xcursor xext xfixes xft xinerama xrender
 
+CMAKE_ON=	WANT_QT5
 CMAKE_OFF=	WANT_ALSA WANT_CALF WANT_CAPS WANT_CMT WANT_SWH WANT_STK \
 		WANT_TAP WANT_VST
-CMAKE_ON=	WANT_QT5
 
 OPTIONS_DEFINE=		OSS JACK PULSEAUDIO PORTAUDIO SDL SNDIO
 OPTIONS_DEFAULT=	OSS
 
-JACK_CMAKE_BOOL=	WANT_JACK
 JACK_LIB_DEPENDS=	libjack.so:audio/jack
-
-PULSEAUDIO_CMAKE_BOOL=	WANT_PULSEAUDIO
-PULSEAUDIO_LIB_DEPENDS=	libpulse.so:audio/pulseaudio
-
-PORTAUDIO_CMAKE_BOOL=	WANT_PORTAUDIO
+JACK_CMAKE_BOOL=	WANT_JACK
 PORTAUDIO_LIB_DEPENDS=	libportaudio.so:audio/portaudio
-
-SDL_CMAKE_OFF=		WANT_SDL
+PORTAUDIO_CMAKE_BOOL=	WANT_PORTAUDIO
+PULSEAUDIO_LIB_DEPENDS=	libpulse.so:audio/pulseaudio
+PULSEAUDIO_CMAKE_BOOL=	WANT_PULSEAUDIO
 SDL_USES=		sdl
 SDL_USE=		SDL=sdl
-
-SNDIO_CMAKE_BOOL=	WANT_SNDIO
+SDL_CMAKE_OFF=		WANT_SDL
 SNDIO_LIB_DEPENDS=	libsndio.so:audio/sndio
+SNDIO_CMAKE_BOOL=	WANT_SNDIO
 
 .include <bsd.port.options.mk>
 
diff --git a/audio/lmms/files/patch-src_gui_MainApplication.cpp b/audio/lmms/files/patch-src_gui_MainApplication.cpp
new file mode 100644
index 000000000000..d94bc5bd4c30
--- /dev/null
+++ b/audio/lmms/files/patch-src_gui_MainApplication.cpp
@@ -0,0 +1,21 @@
+--- src/gui/MainApplication.cpp.orig	2023-06-17 16:02:33 UTC
++++ src/gui/MainApplication.cpp
+@@ -35,6 +35,18 @@
+ 	QApplication(argc, argv),
+ 	m_queuedFile()
+ {
++#if !defined(LMMS_BUILD_WIN32) && !defined(LMMS_BUILD_APPLE) && !defined(LMMS_BUILD_HAIKU) && QT_VERSION >= 0x050000
++	// Work around a bug of KXmlGui < 5.55
++	// which breaks the recent files menu
++	// https://bugs.kde.org/show_bug.cgi?id=337491
++	for (auto child : children())
++	{
++		if (child->inherits("KCheckAcceleratorsInitializer"))
++		{
++			delete child;
++		}
++	}
++#endif
+ #if defined(LMMS_BUILD_WIN32) && QT_VERSION >= 0x050000
+ 	installNativeEventFilter(this);
+ #endif
diff --git a/audio/lmms/files/patch-src_gui_MainWindow.cpp b/audio/lmms/files/patch-src_gui_MainWindow.cpp
new file mode 100644
index 000000000000..0f4b4c105844
--- /dev/null
+++ b/audio/lmms/files/patch-src_gui_MainWindow.cpp
@@ -0,0 +1,44 @@
+--- src/gui/MainWindow.cpp.orig	2023-06-17 16:07:46 UTC
++++ src/gui/MainWindow.cpp
+@@ -33,7 +33,6 @@
+ #include <QMenuBar>
+ #include <QMessageBox>
+ #include <QShortcut>
+-#include <QLibrary>
+ #include <QSplitter>
+ #include <QUrl>
+ #include <QWhatsThis>
+@@ -65,23 +64,6 @@
+ 
+ #include "lmmsversion.h"
+ 
+-#if !defined(LMMS_BUILD_WIN32) && !defined(LMMS_BUILD_APPLE) && !defined(LMMS_BUILD_HAIKU) && QT_VERSION >= 0x050000
+-//Work around an issue on KDE5 as per https://bugs.kde.org/show_bug.cgi?id=337491#c21
+-void disableAutoKeyAccelerators(QWidget* mainWindow)
+-{
+-	using DisablerFunc = void(*)(QWidget*);
+-	QLibrary kf5WidgetsAddon("KF5WidgetsAddons", 5);
+-	DisablerFunc setNoAccelerators = 
+-			reinterpret_cast<DisablerFunc>(kf5WidgetsAddon.resolve("_ZN19KAcceleratorManager10setNoAccelEP7QWidget"));
+-	if(setNoAccelerators)
+-	{
+-		setNoAccelerators(mainWindow);
+-	}
+-	kf5WidgetsAddon.unload();
+-}
+-#endif
+-
+-
+ MainWindow::MainWindow() :
+ 	m_workspace( NULL ),
+ 	m_templatesMenu( NULL ),
+@@ -92,9 +74,6 @@
+ 	m_metronomeToggle( 0 ),
+ 	m_session( Normal )
+ {
+-#if !defined(LMMS_BUILD_WIN32) && !defined(LMMS_BUILD_APPLE) && !defined(LMMS_BUILD_HAIKU) && QT_VERSION >= 0x050000
+-	disableAutoKeyAccelerators(this);
+-#endif
+ 	setAttribute( Qt::WA_DeleteOnClose );
+ 
+ 	QWidget * main_widget = new QWidget( this );