summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin T. H. Sandsmark <martin.sandsmark@kde.org>2016-10-15 13:22:16 (GMT)
committerMartin T. H. Sandsmark <martin.sandsmark@kde.org>2016-10-15 13:22:16 (GMT)
commitafb5e01aed442c862b053fbb8cb9323fb20c2dbe (patch)
tree9879c57c6c84deb2503a8ef78a41dcfe4eac58c9
parentc7bbf6f77c0128800e841b2e661d5c72e73b73b4 (diff)
Make the QML component plugin not crash when trying to be loaded without a QApplication
-rw-r--r--mobile/components/okularplugin.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/mobile/components/okularplugin.cpp b/mobile/components/okularplugin.cpp
index 2204bea..eafcef7 100644
--- a/mobile/components/okularplugin.cpp
+++ b/mobile/components/okularplugin.cpp
@@ -25,10 +25,17 @@
#include <QQmlEngine>
#include <QPluginLoader>
+#include <QApplication>
void OkularPlugin::registerTypes(const char *uri)
{
- Q_ASSERT(QString::fromLocal8Bit(uri) == QLatin1String("org.kde.okular"));
+ if (!qobject_cast<QApplication*>(qApp)) {
+ qWarning() << "The Okular QML components require a QApplication";
+ return;
+ }
+ if (QString::fromLocal8Bit(uri) != QLatin1String("org.kde.okular")) {
+ return;
+ }
qmlRegisterType<DocumentItem>(uri, 2, 0, "DocumentItem");
qmlRegisterType<PageItem>(uri, 2, 0, "PageItem");
qmlRegisterType<ThumbnailItem>(uri, 2, 0, "ThumbnailItem");