-
-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix recent files #3872
Fix recent files #3872
Conversation
This is currently still broken if the & character appears in the file name. |
String replacement can most certainly cause other issues. Would it be possible to kill this ridiculous behavior? It's just going to cause more problems. Here's a solution from the KDE5 bug tracker... This solution seems to be written for KDE desktop environments only. I assume this is safe, since this problem doesn't occur on Mac or Windows but should be tested on Gnome3, Pantheon, whatever isn't Qt5 based but I would expect the
|
It looks like that may be the better option. There needs to be some level of string replacement though, because right now files with the & character don't work correctly. |
src/gui/MainWindow.cpp
Outdated
@@ -76,6 +94,9 @@ MainWindow::MainWindow() : | |||
m_metronomeToggle( 0 ), | |||
m_session( Normal ) | |||
{ | |||
#ifdef LMMS_BUILD_LINUX |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps a #ifndef
Mac and Windows check would be sufficient here instead to avoid non-Linux KDEs from being impacted (e.g. BSD, etc).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My concern there is that it would be basically untested. The CMake file change would also have to be set up this way as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you mean by "untested"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CI doesn't cover platforms other than windows, mac, and linux, and I don't have a machine to attempt building for anything else. This code is very much not portable, and if allowances are being for other platforms the code should be compiled for them at some point.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@BumblingCoder perhaps there's some confusion... I'm asking you disable the option for Mac + Windows, which will inadvertently enable it for all others. Enabling it for Linux-only is going to just cause this same issue to happen for (e.g.) OpenBSD users that chose the KDE desktop. Regardless, it's a safe call for all platforms everywhere since the library won't be found, I was just trying to be consistent with the "probably only on KDE desktop" logic that I presume you were choosing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is stuff in the CMake files about Haiku. Is this something that we intend to support? I would be more ok making this change say linux or bsd than saying not windows or mac.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would be more ok making this change say linux or bsd than saying not windows or mac.
Well Since Haiku isn't BSD, it's BeOS I find this to be a rare an edge-case (and it can't run the full KDE desktop yet apparently). However, most Unixes can run KDE.
I'd rather blacklist than whitelist, it's more scalable. KDE will never be a primary desktop on Windows or MacOS in the foreseeable future and we can predictably and reliably code to that, which covers 99% of use-cases. I can't say the same for new/undocumented Unixes or even BeOS for that matter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My concern isn't really about where KDE is common, but about putting in stuff depending on dlopen() and specifying where to run that by specifying the platforms it isn't available or needed on rather than the ones it is. I could go either way on this though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
putting in stuff depending on
dlopen()
and specifying where to run that by specifying the platforms it isn't available or needed
Great point. BeOS seems to be the major exception in what we currently support. Even Solaris supports dlopen()
. Until we require dlopen
for something else, I would suggest simply blacklisting Haiku along side Windows and Mac then. Down the road if we need dlopen
for a future feature, we can leverage a cross-platform wapper.
src/gui/MainWindow.cpp
Outdated
//Found at https://bugs.kde.org/show_bug.cgi?id=337491#c21 | ||
void DisableSystemAccel(QWidget *what) | ||
{ | ||
void *d = dlopen("libKF5WidgetsAddons.so", RTLD_LAZY); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpicking, but...
- We should prefer something more descriptive such as
void *handle = dlopen(...)
. - This function name should start with a lowercase letter.
- I find the name to be agnostic to hardware acceleration, please give it a name which is less agnostic, e.g.
disableAutoMnemonics
or something about "Keys" or even Qt. - For the code comment, we already use a lot of workaround code we've borrowed and a simple link should be enough. e.g.
// Disable auto-keyboard accelerators for KDE per https://bugs.kde.org/show_bug.cgi?id=337491
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The function name is referring to keyboard accelerators, but I agree, the naming isn't great.
The latest version of this should work on any platform it is needed on. |
Call into KDE stuff to stop it adding accelerators. Escape & as && when building the recent file lists, and reverse that when getting the file name.
src/CMakeLists.txt
Outdated
@@ -147,6 +152,7 @@ SET(LMMS_REQUIRED_LIBS | |||
${SAMPLERATE_LIBRARIES} | |||
${SNDFILE_LIBRARIES} | |||
${EXTRA_LIBRARIES} | |||
${KDE_FIX_LIBRARIES} |
There was a problem hiding this comment.
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.
I don't have KDE but templates and recent files works as it should with this PR applied under linuxmint/mate. |
The bug was only present with Qt5 on KDE. The issue is that on KDE Qt loads platform theme stuff that adds accelerators to all of the menu items. I guess it is good to know that it doesn't break things on other desktops though. :) |
Yeah, I tested what I could. Do you want me to push the rebased version to |
I'm fine with you pushing the rebase. The soonest I could do it is about 6 hours from now, and I'm not particularly familiar with git anyway. |
3bde918
to
13214e0
Compare
Aight, fixed! Looks about right... :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested with KDE+Qt5, Ubuntu 16.04. Works as expected. &
display issue is also gone. However, you should fix coding styles according to ours.
Note that Ubuntu provides libKF5WidgetsAddons.so.5
only, unless one installs libkf5widgetsaddons-dev
. I think it'd better if it works for (K)Ubuntu systems without installing them.
And one more note: we may use QLibrary
for this purpose.
src/gui/MainWindow.cpp
Outdated
DisablerFunc setNoAccelerators = | ||
reinterpret_cast<DisablerFunc>(dlsym(libraryHandle, | ||
"_ZN19KAcceleratorManager10setNoAccelEP7QWidget")); | ||
if (setNoAccelerators) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.)
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
).
src/gui/MainWindow.cpp
Outdated
void disableAutoKeyAccelerators(QWidget* mainWindow) | ||
{ | ||
void *libraryHandle = dlopen("libKF5WidgetsAddons.so", RTLD_LAZY); | ||
if (!libraryHandle) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here, too.
QLibrary is significantly simpler of code. We don't extra stuff in the cmake files for QLibrary
QLibrary means you don't need to put "lib" on the front or ".so" on the end.
src/gui/MainWindow.cpp
Outdated
@@ -70,7 +70,7 @@ | |||
void disableAutoKeyAccelerators(QWidget* mainWindow) | |||
{ | |||
using DisablerFunc = void(*)(QWidget*); | |||
QLibrary kf5WidgetsAddon("libKF5WidgetsAddons.so"); | |||
QLibrary kf5WidgetsAddon("KF5WidgetsAddons"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good, but it may not work on Ubuntu if libkf5widgetsaddons-dev
is not installed. A simple solution is here:
// try with version number(for some systems like Ubuntu)
if (!kf5WidgetsAddon.load())
{
kf5WidgetsAddon.setFileNameAndVersion("KF5WidgetsAddons", 5);
kf5WidgetsAddon.load();
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@BumblingCoder May I push a commit addressing this? Or you may do that yourself if you want.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you want to pull this tonight you can do it, otherwise I can deal with it tomorrow evening. I think it is safe to always try to load version 5 though, so we could just throw the 5 in the constructor.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is safe to always try to load version 5 though, so we could just throw the 5 in the constructor.
I'm not quite sure, but it should work if libKF5WidgetsAddons.so.5
exists. Since the bug is a KDE 5 + Qt 5 issue, that looks safe for me. I'll wait for you, since you said you can do that tomorrow.
@@ -64,6 +65,21 @@ | |||
|
|||
#include "lmmsversion.h" | |||
|
|||
#if !defined(LMMS_BUILD_WIN32) && !defined(LMMS_BULID_APPLE) && !defined(LMMS_BUILD_HAIKU) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
Ubuntu doesn't ship libKF5WidgetAddons.so, but does ship libKF5WidgetAddons.so.5
Merge? |
👍 |
@@ -1500,7 +1518,7 @@ void MainWindow::fillTemplatesMenu() | |||
{ | |||
m_templatesMenu->addAction( | |||
embed::getIconPixmap( "project_file" ), | |||
( *it ).left( ( *it ).length() - 4 ) ); | |||
( *it ).left( ( *it ).length() - 4 ).replace("&", "&&") ); |
There was a problem hiding this comment.
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?
* Fix templates and recent files on KDE. Workaround for https://bugs.kde.org/show_bug.cgi?id=337491 , Call into KDE stuff to stop it adding accelerators. * Fix & in recent files. Escape & as && when building the recent file lists, and reverse that when getting the file name.
This is a quick fix for issue #3741 which causes templates and recent files to not work in KDE.