@@ -20,6 +20,7 @@
21#include <QGuiApplication>
21#include <QGuiApplication>
22#include <QQuickView>
22#include <QQuickView>
23+#include <QQmlContext>
23#include <QQmlProperty>
24#include <QQmlProperty>
24#include <QQmlEngine>
25#include <QQmlEngine>
25#include <QString>
26#include <QString>
@@ -220,10 +221,6 @@ void MirSurfaceItem::setSurface(MirSurfaceInterface* surface)
220 connect(m_qmlSurface, &MirSurface::liveChanged, this, &MirSurfaceItem::liveChanged);
221 connect(m_qmlSurface, &MirSurface::liveChanged, this, &MirSurfaceItem::liveChanged);
221 connect(m_qmlSurface, &MirSurface::stateChanged, this, &MirSurfaceItem::surfaceStateChanged);
222 connect(m_qmlSurface, &MirSurface::stateChanged, this, &MirSurfaceItem::surfaceStateChanged);
223− // The assumptions I make here really should hold.
224− QQuickView *quickView =
225− qobject_cast<QQuickView*>(QGuiApplication::topLevelWindows()[0]);
227 QUrl qmlComponentFilePath;
224 QUrl qmlComponentFilePath;
228 if (!m_qmlSurface->qmlFilePath().isEmpty()) {
225 if (!m_qmlSurface->qmlFilePath().isEmpty()) {
229 qmlComponentFilePath = m_qmlSurface->qmlFilePath();
226 qmlComponentFilePath = m_qmlSurface->qmlFilePath();
@@ -231,7 +228,7 @@ void MirSurfaceItem::setSurface(MirSurfaceInterface* surface)
231 qmlComponentFilePath = QUrl("qrc:///Unity/Application/MirSurfaceItem.qml");
228 qmlComponentFilePath = QUrl("qrc:///Unity/Application/MirSurfaceItem.qml");
234− m_qmlContentComponent = new QQmlComponent(quickView->engine(), qmlComponentFilePath);
231+ m_qmlContentComponent = new QQmlComponent(QQmlEngine::contextForObject(parent())->engine(), qmlComponentFilePath);
236 switch (m_qmlContentComponent->status()) {
233 switch (m_qmlContentComponent->status()) {
237 case QQmlComponent::Ready:
234 case QQmlComponent::Ready: