summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobin Burchell <robin.burchell@theqtcompany.com>2015-01-05 16:41:34 +0100
committerRobin Burchell <robin.burchell@viroteck.net>2015-01-06 11:38:53 +0100
commit4641376b818dbd05b3303dbae026bdd6bb5a1174 (patch)
tree4ee768f827d77be42e08b3fdfc9d2cb013134e8f
parent16f3ed8044857c881d23a35b3ef8efc12ad72201 (diff)
UIDelegatesManager: Remove creationContextForComponent.
This doesn't seem to be too much sense, and according to the QQmlContext documentation, may not work as expected: "This is only valid for components created directly from QML." Change-Id: I49db5dad49288d196e8519b1a60dcf2192147672 Reviewed-by: Pierre Rossi <pierre.rossi@theqtcompany.com>
-rw-r--r--src/webengine/api/qquickwebengineview.cpp2
-rw-r--r--src/webengine/ui_delegates_manager.cpp19
2 files changed, 6 insertions, 15 deletions
diff --git a/src/webengine/api/qquickwebengineview.cpp b/src/webengine/api/qquickwebengineview.cpp
index ad850e84..3497c16a 100644
--- a/src/webengine/api/qquickwebengineview.cpp
+++ b/src/webengine/api/qquickwebengineview.cpp
@@ -184,7 +184,7 @@ bool QQuickWebEngineViewPrivate::contextMenuRequested(const WebEngineContextMenu
// FIXME: expose the context menu data as an attached property to make this more useful
if (contextMenuExtraItems) {
ui()->addMenuSeparator(menu);
- if (QObject* menuExtras = contextMenuExtraItems->create(ui()->creationContextForComponent(contextMenuExtraItems))) {
+ if (QObject* menuExtras = contextMenuExtraItems->create(qmlContext(q))) {
menuExtras->setParent(menu);
QQmlListReference entries(menu, defaultPropertyName(menu), qmlEngine(q));
if (entries.isValid())
diff --git a/src/webengine/ui_delegates_manager.cpp b/src/webengine/ui_delegates_manager.cpp
index e2f3855f..48e1bee7 100644
--- a/src/webengine/ui_delegates_manager.cpp
+++ b/src/webengine/ui_delegates_manager.cpp
@@ -182,15 +182,6 @@ bool UIDelegatesManager::ensureComponentLoaded(ComponentType type)
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))
@@ -310,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"));
@@ -395,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);