diff --git a/src/main_wayland.cpp b/src/main_wayland.cpp index 9ea4c9b84..9e8be17ad 100644 --- a/src/main_wayland.cpp +++ b/src/main_wayland.cpp @@ -500,6 +500,27 @@ int main(int argc, char * argv[]) // reset QT_QPA_PLATFORM so we don't propagate it to our children (e.g. apps launched from the overview effect) qunsetenv("QT_QPA_PLATFORM"); +#if !defined(QT_NO_DEBUG) + QStringList newLibPaths(a.applicationDirPath()); + const QStringList oldLibPaths = QCoreApplication::libraryPaths(); + if (newLibPaths.contains("/usr/local/bin")) { + // when do “make install”, we need add plugins directory before normal qt plugins directory. + // we can get arch lib directory name from qt plugins directory and do a replace + // from "/usr/lib/x86_64-linux-gnu/qt5/plugins" to "/usr/local/lib/x86_64-linux-gnu/plugins" + // then kwin will load the right plugins. + QRegularExpression re("^/usr/lib/(.*)/qt.*$"); + QStringList plugins = oldLibPaths.filter(QRegularExpression("^/usr/lib/")) + .replaceInStrings(re, "/usr/local/lib/\\1/plugins"); + newLibPaths.append(plugins); + } + newLibPaths.append(oldLibPaths); + QCoreApplication::setLibraryPaths(newLibPaths); + qDebug() << "debug mode:"; + qDebug() << " set application dir path to be the first of libraryPaths,"; + qDebug() << " so we can be happy to debug kwin plugins."; + qDebug() << " libraryPaths:" << newLibPaths; +#endif + KWin::Application::createAboutData(); KQuickAddons::QtQuickSettings::init(); diff --git a/src/main_x11.cpp b/src/main_x11.cpp index 4171a861a..f92345164 100644 --- a/src/main_x11.cpp +++ b/src/main_x11.cpp @@ -537,6 +537,27 @@ int main(int argc, char * argv[]) KWin::ApplicationX11 a(argc, argv); a.setupTranslator(); +#if !defined(QT_NO_DEBUG) + QStringList newLibPaths(a.applicationDirPath()); + const QStringList oldLibPaths = QCoreApplication::libraryPaths(); + if (newLibPaths.contains("/usr/local/bin")) { + // when do “make install”, we need add plugins directory before normal qt plugins directory. + // we can get arch lib directory name from qt plugins directory and do a replace + // from "/usr/lib/x86_64-linux-gnu/qt5/plugins" to "/usr/local/lib/x86_64-linux-gnu/plugins" + // then kwin will load the right plugins. + QRegularExpression re("^/usr/lib/(.*)/qt.*$"); + QStringList plugins = oldLibPaths.filter(QRegularExpression("^/usr/lib/")) + .replaceInStrings(re, "/usr/local/lib/\\1/plugins"); + newLibPaths.append(plugins); + } + newLibPaths.append(oldLibPaths); + QCoreApplication::setLibraryPaths(newLibPaths); + qDebug() << "debug mode:"; + qDebug() << " set application dir path to be the first of libraryPaths,"; + qDebug() << " so we can be happy to debug kwin plugins."; + qDebug() << " libraryPaths:" << newLibPaths; +#endif + KWin::Application::createAboutData(); KQuickAddons::QtQuickSettings::init();