From 4cfe6ee0a12f53850b059d5cdcc08de7d47e9873 Mon Sep 17 00:00:00 2001 From: outfoxxed Date: Sun, 3 Mar 2024 21:38:21 -0800 Subject: [PATCH] fix: fix scopes of created QQmlComponents Using the scope of the component itself makes sure things availible in its scope are usable, instead of the parent scope. --- src/core/variants.cpp | 2 +- src/io/socket.cpp | 2 +- src/wayland/session_lock.cpp | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/core/variants.cpp b/src/core/variants.cpp index f984f6d..3a05c47 100644 --- a/src/core/variants.cpp +++ b/src/core/variants.cpp @@ -95,7 +95,7 @@ void Variants::updateVariants() { auto* instance = this->mComponent->createWithInitialProperties( variant, - QQmlEngine::contextForObject(this) + QQmlEngine::contextForObject(this->mComponent) ); if (instance == nullptr) { diff --git a/src/io/socket.cpp b/src/io/socket.cpp index 0270316..fa840f0 100644 --- a/src/io/socket.cpp +++ b/src/io/socket.cpp @@ -177,7 +177,7 @@ void SocketServer::disableServer() { void SocketServer::onNewConnection() { if (auto* connection = this->server->nextPendingConnection()) { - auto* instanceObj = this->mHandler->create(QQmlEngine::contextForObject(this)); + auto* instanceObj = this->mHandler->create(QQmlEngine::contextForObject(this->mHandler)); auto* instance = qobject_cast(instanceObj); if (instance == nullptr) { diff --git a/src/wayland/session_lock.cpp b/src/wayland/session_lock.cpp index 94b427e..bd93dc0 100644 --- a/src/wayland/session_lock.cpp +++ b/src/wayland/session_lock.cpp @@ -73,7 +73,8 @@ void SessionLock::updateSurfaces(SessionLock* old) { for (auto* screen: screens) { if (!this->surfaces.contains(screen)) { - auto* instanceObj = this->mSurfaceComponent->create(QQmlEngine::contextForObject(this)); + auto* instanceObj = + this->mSurfaceComponent->create(QQmlEngine::contextForObject(this->mSurfaceComponent)); auto* instance = qobject_cast(instanceObj); if (instance == nullptr) {