Commit 41eacad7 authored by Nicolas Fella's avatar Nicolas Fella
Browse files

Properly load editor plugins

The assumption that the plugin dir is libdir + plugins is wrong

Use the correct Qt API to get all of the plugin search paths

(cherry picked from commit 5807e4de)
parent 685cafbe
Pipeline #274634 skipped
......@@ -34,10 +34,6 @@ install(FILES
install(EXPORT KF5ContactEditorTargets DESTINATION "${CMAKECONFIG_INSTALL_DIR}" FILE KF5ContactEditorTargets.cmake NAMESPACE KF5::)
configure_file(config-contact-editor.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-contact-editor.h)
target_sources(KF5ContactEditor PRIVATE
editor/customfieldeditor/customfieldswidget.cpp
editor/customfieldeditor/customfieldeditorwidget.cpp
......
#define EDITOR_CONTACT_LIB "${KDE_INSTALL_FULL_LIBDIR}/plugins/pim${QT_MAJOR_VERSION}"
......@@ -7,7 +7,6 @@
*/
#include "contacteditorwidget.h"
#include "config-contact-editor.h"
#include "contacteditorpageplugin.h"
#include "contactmetadatabase_p.h"
......@@ -22,6 +21,7 @@
#include "businesseditor/businesseditorwidget.h"
#include "customfieldeditor/customfieldswidget.h"
#include "generalinfoeditor/generalinfowidget.h"
#include <QCoreApplication>
#include <QDirIterator>
#include <QPluginLoader>
#include <QVBoxLayout>
......@@ -137,21 +137,24 @@ void ContactEditorWidgetPrivate::loadCustomPages()
qDeleteAll(mCustomPages);
mCustomPages.clear();
const QString pluginDirectory = QStringLiteral("%1/contacteditor/editorpageplugins/").arg(QStringLiteral(EDITOR_CONTACT_LIB));
QDirIterator it(pluginDirectory, QDir::Files);
const QStringList pluginDirs = QCoreApplication::libraryPaths();
while (it.hasNext()) {
QPluginLoader loader(it.next());
if (!loader.load()) {
continue;
}
for (const QString &dir : pluginDirs) {
QDirIterator it(dir + QLatin1String("/pim" QT_STRINGIFY(QT_VERSION_MAJOR) "/contacteditor/editorpageplugins"), QDir::Files);
ContactEditor::ContactEditorPagePlugin *plugin = qobject_cast<ContactEditor::ContactEditorPagePlugin *>(loader.instance());
if (!plugin) {
continue;
}
while (it.hasNext()) {
QPluginLoader loader(it.next());
if (!loader.load()) {
continue;
}
mCustomPages.append(plugin);
ContactEditor::ContactEditorPagePlugin *plugin = qobject_cast<ContactEditor::ContactEditorPagePlugin *>(loader.instance());
if (!plugin) {
continue;
}
mCustomPages.append(plugin);
}
}
for (ContactEditor::ContactEditorPagePlugin *plugin : std::as_const(mCustomPages)) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment