Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,11 @@ IF(LMMS_BUILD_HAIKU)
SET(EXTRA_LIBRARIES "-lnetwork")
ENDIF()

if(NOT LMMS_BUILD_WIN32 AND NOT LMMS_BUILD_APPLE AND NOT LMMS_BUILD_HAIKU)
#see https://bugs.kde.org/show_bug.cgi?id=337491#c21
SET(KDE_FIX_LIBRARIES "-ldl")
endif()

SET(LMMS_REQUIRED_LIBS
${CMAKE_THREAD_LIBS_INIT}
${QT_LIBRARIES}
Expand All @@ -149,6 +154,7 @@ SET(LMMS_REQUIRED_LIBS
${SAMPLERATE_LIBRARIES}
${SNDFILE_LIBRARIES}
${EXTRA_LIBRARIES}
${KDE_FIX_LIBRARIES}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR can't be merged since rpmalloc. Reabse and just stick rpmalloc to the end.

rpmalloc
)

Expand Down
34 changes: 28 additions & 6 deletions src/gui/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,26 @@

#include "lmmsversion.h"

#if !defined(LMMS_BUILD_WIN32) && !defined(LMMS_BULID_APPLE) && !defined(LMMS_BUILD_HAIKU)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this check still needed? Since @BumblingCoder switched the loader to QLibrary, it can be removed safely. If there are some reason to keep this, however, leaving is okay, too.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be safe to run the code on all platforms. Pointless on the ones it is disabled on, but safe.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It saves a few cpu cycles to preprocess it out. I agree with the logic, especially when loading libraries. Why add an unnecessary step to MainWindow for systems which can't experience the bug?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why add an unnecessary step to MainWindow for systems which can't experience the bug?

Okay then. Keep it if leaving makes sense.

#include <dlfcn.h>
//Work around an issue on KDE5 as per https://bugs.kde.org/show_bug.cgi?id=337491#c21
void disableAutoKeyAccelerators(QWidget* mainWindow)
{
void *libraryHandle = dlopen("libKF5WidgetsAddons.so", RTLD_LAZY);
if (!libraryHandle) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here, too.

//KDE not installed, nothing to do.
return;
}
using DisablerFunc = void(*)(QWidget*);
DisablerFunc setNoAccelerators =
reinterpret_cast<DisablerFunc>(dlsym(libraryHandle,
"_ZN19KAcceleratorManager10setNoAccelEP7QWidget"));
if (setNoAccelerators) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should use detached braces for blocking. See https://github.com/LMMS/lmms/wiki/Coding-conventions.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There isn't actually anything in that document that says that braces should be on the next line. ( Or in what cases they should.)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More of a consistency with the file being edited than a formal convention. It's fine as-is.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK. We should look over the documentation if there's something missing.
Is the braces the only thing that's holding this PR back now?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The braces don't matter too much, but I think it needs some more works(ex. libKF5WidgetsAddons.so.5 for ubuntu-based systems, (optional)using QLibrary).

setNoAccelerators(mainWindow);
}
dlclose(libraryHandle);
}
#endif


MainWindow::MainWindow() :
Expand All @@ -76,6 +96,9 @@ MainWindow::MainWindow() :
m_metronomeToggle( 0 ),
m_session( Normal )
{
#if !defined(LMMS_BUILD_WIN32) && !defined(LMMS_BULID_APPLE) && !defined(LMMS_BUILD_HAIKU)
disableAutoKeyAccelerators(this);
#endif
setAttribute( Qt::WA_DeleteOnClose );

QWidget * main_widget = new QWidget( this );
Expand Down Expand Up @@ -836,8 +859,8 @@ void MainWindow::createNewProjectFromTemplate( QAction * _idx )
ConfigManager::inst()->factoryTemplatesDir() :
ConfigManager::inst()->userTemplateDir();

Engine::getSong()->createNewProjectFromTemplate(
dirBase + _idx->text() + ".mpt" );
const QString f = dirBase + _idx->text().replace("&&", "&") + ".mpt";
Engine::getSong()->createNewProjectFromTemplate(f);
}
}

Expand Down Expand Up @@ -888,7 +911,7 @@ void MainWindow::updateRecentlyOpenedProjectsMenu()
}

m_recentlyOpenedProjectsMenu->addAction(
embed::getIconPixmap( "project_file" ), *it );
embed::getIconPixmap( "project_file" ), it->replace("&", "&&") );
#ifdef LMMS_BUILD_APPLE
m_recentlyOpenedProjectsMenu->actions().last()->setIconVisibleInMenu(false); // QTBUG-44565 workaround
m_recentlyOpenedProjectsMenu->actions().last()->setIconVisibleInMenu(true);
Expand All @@ -904,12 +927,11 @@ void MainWindow::updateRecentlyOpenedProjectsMenu()




void MainWindow::openRecentlyOpenedProject( QAction * _action )
{
if ( mayChangeProject(true) )
{
const QString & f = _action->text();
const QString f = _action->text().replace("&&", "&");
setCursor( Qt::WaitCursor );
Engine::getSong()->loadProject( f );
setCursor( Qt::ArrowCursor );
Expand Down Expand Up @@ -1500,7 +1522,7 @@ void MainWindow::fillTemplatesMenu()
{
m_templatesMenu->addAction(
embed::getIconPixmap( "project_file" ),
( *it ).left( ( *it ).length() - 4 ) );
( *it ).left( ( *it ).length() - 4 ).replace("&", "&&") );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should line 1500 have this change as well?

#ifdef LMMS_BUILD_APPLE
m_templatesMenu->actions().last()->setIconVisibleInMenu(false); // QTBUG-44565 workaround
m_templatesMenu->actions().last()->setIconVisibleInMenu(true);
Expand Down