on xenial help sign in
Get the engine from the parent context
commitd345593a3a6ecf9833cca71cbd175e75cf6d4e54 authorAlbert Astals Cid <albert.astals@canonical.com> dateFri 11 Mar 2016, 10:32 (11 years ago) parent8855d4b
1 file changed+2−5
tests/mocks/Unity/Application/MirSurfaceItem.cpp+2−5
tests/mocks/Unity/Application/MirSurfaceItem.cpp+2−5
@@ -20,6 +20,7 @@
2020
2121#include <QGuiApplication>
2222#include <QQuickView>
23+#include <QQmlContext>
2324#include <QQmlProperty>
2425#include <QQmlEngine>
2526#include <QString>
@@ -220,10 +221,6 @@ void MirSurfaceItem::setSurface(MirSurfaceInterface* surface)
220221 connect(m_qmlSurface, &MirSurface::liveChanged, this, &MirSurfaceItem::liveChanged);
221222 connect(m_qmlSurface, &MirSurface::stateChanged, this, &MirSurfaceItem::surfaceStateChanged);
222223
223− // The assumptions I make here really should hold.
224− QQuickView *quickView =
225− qobject_cast<QQuickView*>(QGuiApplication::topLevelWindows()[0]);
226−
227224 QUrl qmlComponentFilePath;
228225 if (!m_qmlSurface->qmlFilePath().isEmpty()) {
229226 qmlComponentFilePath = m_qmlSurface->qmlFilePath();
@@ -231,7 +228,7 @@ void MirSurfaceItem::setSurface(MirSurfaceInterface* surface)
231228 qmlComponentFilePath = QUrl("qrc:///Unity/Application/MirSurfaceItem.qml");
232229 }
233230
234− m_qmlContentComponent = new QQmlComponent(quickView->engine(), qmlComponentFilePath);
231+ m_qmlContentComponent = new QQmlComponent(QQmlEngine::contextForObject(parent())->engine(), qmlComponentFilePath);
235232
236233 switch (m_qmlContentComponent->status()) {
237234 case QQmlComponent::Ready: