summaryrefslogtreecommitdiffstats
path: root/src/webengine
diff options
context:
space:
mode:
authorPierre Rossi <pierre.rossi@digia.com>2014-03-13 14:40:44 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-03-14 11:43:31 +0100
commit0402743339cbf9efe0ea4ebbd36b27bbc7e9e7a6 (patch)
tree6929f6b0190806465ab73d8bfaa00819a7d4df07 /src/webengine
parent38b5dc5fbdae25491435395202f6980f44ca8ef5 (diff)
UI: fix a crash on shutdown
Use a raw pointer instead of QScopedPointer for the UI components. Since the components are always parented to the view and deleted through the QObject cleanup mechanism, it was not correct to use QScopedPointer in the first place. Change-Id: I0c8fd9526e898439c52c6a6f538a66f8a1185ef9 Reviewed-by: Jocelyn Turcotte <jocelyn.turcotte@digia.com>
Diffstat (limited to 'src/webengine')
-rw-r--r--src/webengine/ui_delegates_manager.cpp20
-rw-r--r--src/webengine/ui_delegates_manager.h3
2 files changed, 13 insertions, 10 deletions
diff --git a/src/webengine/ui_delegates_manager.cpp b/src/webengine/ui_delegates_manager.cpp
index 1402c7625..5fb5ef475 100644
--- a/src/webengine/ui_delegates_manager.cpp
+++ b/src/webengine/ui_delegates_manager.cpp
@@ -109,8 +109,12 @@ void NavigateMenuItem::onTriggered()
m_adapter->load(m_targetUrl);
}
+#define COMPONENT_MEMBER_INIT(TYPE, COMPONENT) \
+ , COMPONENT##Component(0)
+
UIDelegatesManager::UIDelegatesManager(QQuickWebEngineView *view)
: m_view(view)
+ FOR_EACH_COMPONENT_TYPE(COMPONENT_MEMBER_INIT, NO_SEPARATOR)
{
}
@@ -121,7 +125,7 @@ UIDelegatesManager::UIDelegatesManager(QQuickWebEngineView *view)
bool UIDelegatesManager::ensureComponentLoaded(ComponentType type)
{
- QScopedPointer<QQmlComponent> *component;
+ QQmlComponent **component;
switch (type) {
FOR_EACH_COMPONENT_TYPE(COMPONENT_MEMBER_CASE_STATEMENT, NO_SEPARATOR)
default:
@@ -130,7 +134,7 @@ bool UIDelegatesManager::ensureComponentLoaded(ComponentType type)
}
QString fileName(fileNameForComponent(type));
#ifndef UI_DELEGATES_DEBUG
- if (!(*component).isNull())
+ if (*component)
return true;
#else // Unconditionally reload the components each time.
fprintf(stderr, "%s: %s\n", Q_FUNC_INFO, qPrintable(fileName));
@@ -145,7 +149,7 @@ bool UIDelegatesManager::ensureComponentLoaded(ComponentType type)
absolutePath = fi.absoluteFilePath();
}
// FIXME: handle async loading
- (*component).reset(new QQmlComponent(engine, QUrl(absolutePath), QQmlComponent::PreferSynchronous, m_view));
+ *component = (new QQmlComponent(engine, QUrl(absolutePath), QQmlComponent::PreferSynchronous, m_view));
if ((*component)->status() != QQmlComponent::Ready) {
#ifdef UI_DELEGATES_DEBUG
@@ -175,7 +179,7 @@ void UIDelegatesManager::addMenuItem(MenuItemHandler *menuItemHandler, const QSt
Q_ASSERT(menuItemHandler);
if (!ensureComponentLoaded(MenuItem))
return;
- QObject *it = menuItemComponent->beginCreate(creationContextForComponent(menuItemComponent.data()));
+ QObject *it = menuItemComponent->beginCreate(creationContextForComponent(menuItemComponent));
QQmlProperty(it, QStringLiteral("text")).write(text);
QQmlProperty(it, QStringLiteral("iconName")).write(iconName);
@@ -199,7 +203,7 @@ void UIDelegatesManager::addMenuSeparator(QObject *menu)
if (!ensureComponentLoaded(MenuSeparator))
return;
- QQmlContext *itemContext = creationContextForComponent(menuSeparatorComponent.data());
+ QQmlContext *itemContext = creationContextForComponent(menuSeparatorComponent);
QObject *sep = menuSeparatorComponent->create(itemContext);
sep->setParent(menu);
@@ -213,7 +217,7 @@ QObject *UIDelegatesManager::addMenu(QObject *parentMenu, const QString &title,
if (!ensureComponentLoaded(Menu))
return 0;
- QQmlContext *context(creationContextForComponent(menuComponent.data()));
+ QQmlContext *context(creationContextForComponent(menuComponent));
QObject *menu = menuComponent->beginCreate(context);
// Useful when not using Qt Quick Controls' Menu
if (QQuickItem* item = qobject_cast<QQuickItem*>(menu))
@@ -241,7 +245,7 @@ QObject *UIDelegatesManager::addMenu(QObject *parentMenu, const QString &title,
#define ASSIGN_DIALOG_COMPONENT_DATA_CASE_STATEMENT(TYPE, COMPONENT) \
case TYPE:\
- dialogComponent = COMPONENT##Component.data(); \
+ dialogComponent = COMPONENT##Component; \
break;
@@ -360,7 +364,7 @@ void UIDelegatesManager::showFilePicker(WebContentsAdapterClient::FileChooserMod
if (!ensureComponentLoaded(FilePicker))
return;
- QQmlContext *context(creationContextForComponent(filePickerComponent.data()));
+ QQmlContext *context(creationContextForComponent(filePickerComponent));
QObject *filePicker = filePickerComponent->beginCreate(context);
if (QQuickItem* item = qobject_cast<QQuickItem*>(filePicker))
item->setParentItem(m_view);
diff --git a/src/webengine/ui_delegates_manager.h b/src/webengine/ui_delegates_manager.h
index a6d15a530..125cacff4 100644
--- a/src/webengine/ui_delegates_manager.h
+++ b/src/webengine/ui_delegates_manager.h
@@ -49,7 +49,6 @@
#include <QExplicitlySharedDataPointer>
#include <QPoint>
#include <QQmlComponent>
-#include <QScopedPointer>
#include <QSharedPointer>
#include <QUrl>
@@ -67,7 +66,7 @@
#define ENUM_DECLARATION(TYPE, COMPONENT) \
TYPE
#define MEMBER_DECLARATION(TYPE, COMPONENT) \
- QScopedPointer<QQmlComponent> COMPONENT##Component
+ QQmlComponent *COMPONENT##Component
class JavaScriptDialogController;
QT_BEGIN_NAMESPACE