From afb5e01aed442c862b053fbb8cb9323fb20c2dbe Mon Sep 17 00:00:00 2001 From: "Martin T. H. Sandsmark" Date: Sat, 15 Oct 2016 15:22:16 +0200 Subject: [PATCH] Make the QML component plugin not crash when trying to be loaded without a QApplication --- mobile/components/okularplugin.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/mobile/components/okularplugin.cpp b/mobile/components/okularplugin.cpp index 2204bea5b..eafcef7ee 100644 --- a/mobile/components/okularplugin.cpp +++ b/mobile/components/okularplugin.cpp @@ -25,10 +25,17 @@ #include #include +#include void OkularPlugin::registerTypes(const char *uri) { - Q_ASSERT(QString::fromLocal8Bit(uri) == QLatin1String("org.kde.okular")); + if (!qobject_cast(qApp)) { + qWarning() << "The Okular QML components require a QApplication"; + return; + } + if (QString::fromLocal8Bit(uri) != QLatin1String("org.kde.okular")) { + return; + } qmlRegisterType(uri, 2, 0, "DocumentItem"); qmlRegisterType(uri, 2, 0, "PageItem"); qmlRegisterType(uri, 2, 0, "ThumbnailItem");