From 83b3e2cf19360fe886f3e76e56d7b3525c1d6d8f Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 24 Aug 2014 22:27:39 +0530 Subject: [PATCH] Workaround for crash when running job (conversion to PDF or MOBI/reading metadata from epub without cover) that requires Qt WebKit on Ubuntu. Fixes #1360693 [Ubuntu: Import EPUB, Metadata Error](https://bugs.launchpad.net/calibre/+bug/1360693) See https://bugreports.qt-project.org/browse/QTBUG-40946 --- src/calibre/headless/headless_integration.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/calibre/headless/headless_integration.cpp b/src/calibre/headless/headless_integration.cpp index 1efe5b31e1..573e8f06d3 100644 --- a/src/calibre/headless/headless_integration.cpp +++ b/src/calibre/headless/headless_integration.cpp @@ -14,6 +14,15 @@ QT_BEGIN_NAMESPACE +class GenericUnixServices : public QGenericUnixServices { + /* We must return desktop environment as UNKNOWN otherwise other parts of + * Qt will try to query the nativeInterface() without checking if it exists + * leading to a segfault. For example, defaultHintStyleFromMatch() queries + * the nativeInterface() without checking that it is NULL. See + * https://bugreports.qt-project.org/browse/QTBUG-40946 */ + QByteArray desktopEnvironment() const { return QByteArrayLiteral("UNKNOWN"); } +}; + HeadlessIntegration::HeadlessIntegration(const QStringList ¶meters) { Q_UNUSED(parameters); @@ -26,7 +35,7 @@ HeadlessIntegration::HeadlessIntegration(const QStringList ¶meters) screenAdded(mPrimaryScreen); m_fontDatabase.reset(new QFontconfigDatabase()); - platform_services.reset(new QGenericUnixServices()); + platform_services.reset(new GenericUnixServices()); } HeadlessIntegration::~HeadlessIntegration()