summaryrefslogtreecommitdiffstats
path: root/src/webengine/ui_delegates_manager.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/webengine/ui_delegates_manager.cpp')
-rw-r--r--src/webengine/ui_delegates_manager.cpp31
1 files changed, 13 insertions, 18 deletions
diff --git a/src/webengine/ui_delegates_manager.cpp b/src/webengine/ui_delegates_manager.cpp
index 95e04d699..48e1bee7e 100644
--- a/src/webengine/ui_delegates_manager.cpp
+++ b/src/webengine/ui_delegates_manager.cpp
@@ -173,24 +173,15 @@ bool UIDelegatesManager::ensureComponentLoaded(ComponentType type)
*component = (new QQmlComponent(engine, QUrl::fromLocalFile(fi.absoluteFilePath()), QQmlComponent::PreferSynchronous, m_view));
if ((*component)->status() != QQmlComponent::Ready) {
-#ifdef UI_DELEGATES_DEBUG
Q_FOREACH (const QQmlError& err, (*component)->errors())
- fprintf(stderr, " component error: %s\n", qPrintable(err.toString()));
-#endif
+ qWarning("QtWebEngine: component error: %s\n", qPrintable(err.toString()));
+ delete *component;
+ *component = 0;
return false;
}
return true;
}
-QQmlContext *UIDelegatesManager::creationContextForComponent(QQmlComponent *component)
-{
- Q_ASSERT(component);
-
- QQmlContext* baseContext = component->creationContext() ? component->creationContext() : qmlContext(m_view);
- Q_ASSERT(baseContext);
- return baseContext;
-}
-
#define CHECK_QML_SIGNAL_PROPERTY(prop, location) \
if (!prop.isSignalProperty()) \
qWarning("%s is missing %s signal property.\n", qPrintable(location.toString()), qPrintable(prop.name()));
@@ -200,7 +191,7 @@ void UIDelegatesManager::addMenuItem(MenuItemHandler *menuItemHandler, const QSt
Q_ASSERT(menuItemHandler);
if (!ensureComponentLoaded(MenuItem))
return;
- QObject *it = menuItemComponent->beginCreate(creationContextForComponent(menuItemComponent));
+ QObject *it = menuItemComponent->beginCreate(qmlContext(m_view));
QQmlProperty(it, QStringLiteral("text")).write(text);
QQmlProperty(it, QStringLiteral("iconName")).write(iconName);
@@ -224,7 +215,7 @@ void UIDelegatesManager::addMenuSeparator(QObject *menu)
if (!ensureComponentLoaded(MenuSeparator))
return;
- QQmlContext *itemContext = creationContextForComponent(menuSeparatorComponent);
+ QQmlContext *itemContext = qmlContext(m_view);
QObject *sep = menuSeparatorComponent->create(itemContext);
sep->setParent(menu);
@@ -238,7 +229,7 @@ QObject *UIDelegatesManager::addMenu(QObject *parentMenu, const QString &title,
if (!ensureComponentLoaded(Menu))
return 0;
- QQmlContext *context(creationContextForComponent(menuComponent));
+ QQmlContext *context = qmlContext(m_view);
QObject *menu = menuComponent->beginCreate(context);
// Useful when not using Qt Quick Controls' Menu
if (QQuickItem* item = qobject_cast<QQuickItem*>(menu))
@@ -296,8 +287,12 @@ void UIDelegatesManager::showDialog(QSharedPointer<JavaScriptDialogController> d
Q_UNREACHABLE();
}
- if (!ensureComponentLoaded(dialogComponentType))
+ if (!ensureComponentLoaded(dialogComponentType)) {
+ // Let the controller know it couldn't be loaded
+ qWarning("Failed to load dialog, rejecting.");
+ dialogController->reject();
return;
+ }
QQmlComponent *dialogComponent = Q_NULLPTR;
switch (dialogComponentType) {
@@ -306,7 +301,7 @@ void UIDelegatesManager::showDialog(QSharedPointer<JavaScriptDialogController> d
Q_UNREACHABLE();
}
- QQmlContext *context(creationContextForComponent(dialogComponent));
+ QQmlContext *context = qmlContext(m_view);
QObject *dialog = dialogComponent->beginCreate(context);
dialog->setParent(m_view);
QQmlProperty textProp(dialog, QStringLiteral("text"));
@@ -391,7 +386,7 @@ void UIDelegatesManager::showFilePicker(WebContentsAdapterClient::FileChooserMod
if (!ensureComponentLoaded(FilePicker))
return;
- QQmlContext *context(creationContextForComponent(filePickerComponent));
+ QQmlContext *context = qmlContext(m_view);
QObject *filePicker = filePickerComponent->beginCreate(context);
if (QQuickItem* item = qobject_cast<QQuickItem*>(filePicker))
item->setParentItem(m_view);