all: ensure QObject ownership is Cpp when required

This commit is contained in:
outfoxxed 2024-03-08 18:33:01 -08:00
parent de8668eff3
commit 6966fc025c
Signed by: outfoxxed
GPG key ID: 4C88A185FB89301E
4 changed files with 10 additions and 3 deletions

View file

@ -1,6 +1,7 @@
#include "proxywindow.hpp"
#include <qobject.h>
#include <qqmlengine.h>
#include <qqmllist.h>
#include <qquickitem.h>
#include <qquickwindow.h>
@ -13,8 +14,10 @@
#include "region.hpp"
#include "reload.hpp"
ProxyWindowBase::ProxyWindowBase(QObject* parent): Reloadable(parent) {
this->mContentItem = new QQuickItem(); // NOLINT
ProxyWindowBase::ProxyWindowBase(QObject* parent)
: Reloadable(parent)
, mContentItem(new QQuickItem()) {
QQmlEngine::setObjectOwnership(this->mContentItem, QQmlEngine::CppOwnership);
this->mContentItem->setParent(this);
QObject::connect(this, &ProxyWindowBase::widthChanged, this, &ProxyWindowBase::onWidthChanged);
@ -34,7 +37,6 @@ void ProxyWindowBase::onReload(QObject* oldInstance) {
Reloadable::reloadRecursive(this->mContentItem, oldInstance);
this->mContentItem->setParentItem(this->window->contentItem());
this->mContentItem->setWidth(this->width());
this->mContentItem->setHeight(this->height());

View file

@ -104,6 +104,8 @@ void Variants::updateVariants() {
continue;
}
QQmlEngine::setObjectOwnership(instance, QQmlEngine::CppOwnership);
instance->setParent(this);
this->instances.insert(variant, instance);
}

View file

@ -187,6 +187,8 @@ void SocketServer::onNewConnection() {
return;
}
QQmlEngine::setObjectOwnership(instance, QQmlEngine::CppOwnership);
this->mSockets.append(instance);
instance->setParent(this);

View file

@ -157,6 +157,7 @@ SessionLockSurface::SessionLockSurface(QObject* parent)
: Reloadable(parent)
, mContentItem(new QQuickItem())
, ext(new LockWindowExtension(this)) {
QQmlEngine::setObjectOwnership(this->mContentItem, QQmlEngine::CppOwnership);
this->mContentItem->setParent(this);
// clang-format off