Commit c25dcbd8 authored by Daniel Vrátil's avatar Daniel Vrátil 🤖

Don't link AkonadiContact from serializer plugins

This leads to crashes when the serializer plugin gets loaded from
non-GUI thread (like from KRunner), because AkonadiContact depends
on Qt5WebEngine, and even just linking Qt5WebEngine triggers static
globals initialization that crashes in non-GUI thread.

BUG: 364342
FIXED-IN: 16.08.1
parent 5f67eab0
......@@ -8,7 +8,7 @@ add_definitions(-DTRANSLATION_DOMAIN=\"akonadi_serializer_plugins\")
set(akonadi_serializer_addressee_PART_SRCS akonadi_serializer_addressee.cpp )
add_library(akonadi_serializer_addressee MODULE ${SERIALIZER_TYPE} ${akonadi_serializer_addressee_PART_SRCS})
target_link_libraries(akonadi_serializer_addressee KF5::Contacts KF5::AkonadiCore KF5::AkonadiContact KF5::I18n)
target_link_libraries(akonadi_serializer_addressee KF5::Contacts KF5::AkonadiCore KF5::I18n)
install(TARGETS akonadi_serializer_addressee DESTINATION ${KDE_INSTALL_PLUGINDIR})
set(akonadi_serializer_mail_PART_SRCS akonadi_serializer_mail.cpp)
......@@ -25,7 +25,7 @@ install(TARGETS akonadi_serializer_kcalcore DESTINATION ${KDE_INSTALL_PLUGINDIR}
set(akonadi_serializer_contactgroup_PART_SRCS akonadi_serializer_contactgroup.cpp )
add_library(akonadi_serializer_contactgroup MODULE ${SERIALIZER_TYPE} ${akonadi_serializer_contactgroup_PART_SRCS})
target_link_libraries(akonadi_serializer_contactgroup KF5::Contacts KF5::AkonadiCore KF5::AkonadiContact KF5::I18n)
target_link_libraries(akonadi_serializer_contactgroup KF5::Contacts KF5::AkonadiCore KF5::I18n)
install(TARGETS akonadi_serializer_contactgroup DESTINATION ${KDE_INSTALL_PLUGINDIR})
set(akonadi_serializer_kalarm_SRCS akonadi_serializer_kalarm.cpp kaeventformatter.cpp)
......
......@@ -21,7 +21,6 @@
#include <AkonadiCore/abstractdifferencesreporter.h>
#include <AkonadiCore/item.h>
#include <Akonadi/Contact/ContactParts>
#include <kcontacts/addressee.h>
#include <KLocalizedString>
......@@ -32,6 +31,14 @@ using namespace Akonadi;
//// ItemSerializerPlugin interface
// FIXME: these values map to Akonadi::ContactParts::Standard and
// Akonadi::ContactParts::Lookup from AkonadiContact library. We don't use those
// symbols here, because AkonadiContact library links to Qt5WebEngine, which when
// loaded tries to initialize OpenGL. When this plugin gets loaded by Akonadi
// from KRunner, it happens in a non-GUI thread, leading to a crash in Qt5WebEngine.
#define CONTACTPART_STANDARD "CONTACT_STANDARD"
#define CONTACTPART_LOOKUP "CONTACT_LOOKUP"
bool SerializerPluginAddressee::deserialize(Item &item, const QByteArray &label, QIODevice &data, int version)
{
Q_UNUSED(version);
......@@ -39,14 +46,14 @@ bool SerializerPluginAddressee::deserialize(Item &item, const QByteArray &label,
KContacts::Addressee addr;
if (label == Item::FullPayload) {
addr = m_converter.parseVCard(data.readAll());
} else if (label == Akonadi::ContactPart::Standard) {
} else if (label == CONTACTPART_STANDARD) {
addr = m_converter.parseVCard(data.readAll());
// remove pictures and sound
addr.setPhoto(KContacts::Picture());
addr.setLogo(KContacts::Picture());
addr.setSound(KContacts::Sound());
} else if (label == Akonadi::ContactPart::Lookup) {
} else if (label == CONTACTPART_LOOKUP) {
const KContacts::Addressee temp = m_converter.parseVCard(data.readAll());
// copy only uid, name and email addresses
......@@ -74,7 +81,7 @@ void SerializerPluginAddressee::serialize(const Item &item, const QByteArray &la
{
Q_UNUSED(version);
if (label != Item::FullPayload && label != Akonadi::ContactPart::Standard && label != Akonadi::ContactPart::Lookup) {
if (label != Item::FullPayload && label != CONTACTPART_STANDARD && label != CONTACTPART_LOOKUP) {
return;
}
......@@ -88,14 +95,14 @@ void SerializerPluginAddressee::serialize(const Item &item, const QByteArray &la
if (label == Item::FullPayload) {
addr = temp;
} else if (label == Akonadi::ContactPart::Standard) {
} else if (label == CONTACTPART_STANDARD) {
addr = temp;
// remove pictures and sound
addr.setPhoto(KContacts::Picture());
addr.setLogo(KContacts::Picture());
addr.setSound(KContacts::Sound());
} else if (label == Akonadi::ContactPart::Lookup) {
} else if (label == CONTACTPART_LOOKUP) {
// copy only uid, name and email addresses
addr.setUid(temp.uid());
addr.setPrefix(temp.prefix());
......
......@@ -22,7 +22,6 @@
#include <AkonadiCore/abstractdifferencesreporter.h>
#include <Akonadi/Contact/ContactGroupExpandJob>
#include <AkonadiCore/item.h>
#include <Akonadi/Contact/ContactParts>
#include <kcontacts/contactgroup.h>
#include <kcontacts/contactgrouptool.h>
......
Markdown is supported
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