Make the QML component plugin not crash when trying to be loaded without a QApplication

frameworks
Martin T. H. Sandsmark 10 years ago
parent c7bbf6f77c
commit afb5e01aed
  1. 9
      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");

Loading…
Cancel
Save