Fix a crash that occurs when library "KF5WidgetsAddons" cannot be loaded

Add a check to see if the library "KF5WidgetsAddons" could be loaded and
return if that's not the case.

Also move a using declaration near the place where it is used first.
This commit is contained in:
Michael Gregorius
2017-12-07 18:55:40 +01:00
parent 004da34942
commit 17fb59cdeb

View File

@@ -69,8 +69,13 @@
//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);
if (!kf5WidgetsAddon.isLoaded())
{
return;
}
using DisablerFunc = void(*)(QWidget*);
DisablerFunc setNoAccelerators =
reinterpret_cast<DisablerFunc>(kf5WidgetsAddon.resolve("_ZN19KAcceleratorManager10setNoAccelEP7QWidget"));
if(setNoAccelerators)