forked from quickshell/quickshell
all: ensure QObject ownership is Cpp when required
This commit is contained in:
parent
de8668eff3
commit
6966fc025c
|
@ -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());
|
||||
|
||||
|
|
|
@ -104,6 +104,8 @@ void Variants::updateVariants() {
|
|||
continue;
|
||||
}
|
||||
|
||||
QQmlEngine::setObjectOwnership(instance, QQmlEngine::CppOwnership);
|
||||
|
||||
instance->setParent(this);
|
||||
this->instances.insert(variant, instance);
|
||||
}
|
||||
|
|
|
@ -187,6 +187,8 @@ void SocketServer::onNewConnection() {
|
|||
return;
|
||||
}
|
||||
|
||||
QQmlEngine::setObjectOwnership(instance, QQmlEngine::CppOwnership);
|
||||
|
||||
this->mSockets.append(instance);
|
||||
instance->setParent(this);
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue