mirror of
https://github.com/JulianGro/overte.git
synced 2025-06-03 10:00:27 +02:00
Make sure root item is created before lambda gets called for desktop loader
This commit is contained in:
parent
f5d77104c3
commit
dfaa8761e5
1 changed files with 16 additions and 11 deletions
|
@ -690,7 +690,6 @@ void OffscreenQmlSurface::finishQmlLoad(QQmlComponent* qmlComponent, QQmlContext
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QObject* newObject = qmlComponent->beginCreate(qmlContext);
|
QObject* newObject = qmlComponent->beginCreate(qmlContext);
|
||||||
if (qmlComponent->isError()) {
|
if (qmlComponent->isError()) {
|
||||||
for (const auto& error : qmlComponent->errors()) {
|
for (const auto& error : qmlComponent->errors()) {
|
||||||
|
@ -704,7 +703,20 @@ void OffscreenQmlSurface::finishQmlLoad(QQmlComponent* qmlComponent, QQmlContext
|
||||||
}
|
}
|
||||||
|
|
||||||
qmlContext->engine()->setObjectOwnership(this, QQmlEngine::CppOwnership);
|
qmlContext->engine()->setObjectOwnership(this, QQmlEngine::CppOwnership);
|
||||||
f(qmlContext, newObject);
|
|
||||||
|
// All quick items should be focusable
|
||||||
|
QQuickItem* newItem = qobject_cast<QQuickItem*>(newObject);
|
||||||
|
if (newItem) {
|
||||||
|
// Make sure we make items focusable (critical for
|
||||||
|
// supporting keyboard shortcuts)
|
||||||
|
newItem->setFlag(QQuickItem::ItemIsFocusScope, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Make sure we will call callback for this codepath
|
||||||
|
// Caal this before qmlComponent->completeCreate() otherwise ghost window appears
|
||||||
|
if (newItem && _rootItem) {
|
||||||
|
f(qmlContext, newObject);
|
||||||
|
}
|
||||||
|
|
||||||
QObject* eventBridge = qmlContext->contextProperty("eventBridge").value<QObject*>();
|
QObject* eventBridge = qmlContext->contextProperty("eventBridge").value<QObject*>();
|
||||||
if (qmlContext != _qmlContext && eventBridge && eventBridge != this) {
|
if (qmlContext != _qmlContext && eventBridge && eventBridge != this) {
|
||||||
|
@ -716,15 +728,6 @@ void OffscreenQmlSurface::finishQmlLoad(QQmlComponent* qmlComponent, QQmlContext
|
||||||
qmlComponent->completeCreate();
|
qmlComponent->completeCreate();
|
||||||
qmlComponent->deleteLater();
|
qmlComponent->deleteLater();
|
||||||
|
|
||||||
|
|
||||||
// All quick items should be focusable
|
|
||||||
QQuickItem* newItem = qobject_cast<QQuickItem*>(newObject);
|
|
||||||
if (newItem) {
|
|
||||||
// Make sure we make items focusable (critical for
|
|
||||||
// supporting keyboard shortcuts)
|
|
||||||
newItem->setFlag(QQuickItem::ItemIsFocusScope, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
// If we already have a root, just set a couple of flags and the ancestry
|
// If we already have a root, just set a couple of flags and the ancestry
|
||||||
if (newItem && _rootItem) {
|
if (newItem && _rootItem) {
|
||||||
// Allow child windows to be destroyed from JS
|
// Allow child windows to be destroyed from JS
|
||||||
|
@ -747,6 +750,8 @@ void OffscreenQmlSurface::finishQmlLoad(QQmlComponent* qmlComponent, QQmlContext
|
||||||
_rootItem = newItem;
|
_rootItem = newItem;
|
||||||
_rootItem->setParentItem(_quickWindow->contentItem());
|
_rootItem->setParentItem(_quickWindow->contentItem());
|
||||||
_rootItem->setSize(_quickWindow->renderTargetSize());
|
_rootItem->setSize(_quickWindow->renderTargetSize());
|
||||||
|
// Call this callback after rootitem is set, otherwise VrMenu wont work
|
||||||
|
f(qmlContext, newObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OffscreenQmlSurface::updateQuick() {
|
void OffscreenQmlSurface::updateQuick() {
|
||||||
|
|
Loading…
Reference in a new issue