forked from quickshell/quickshell
		
	all: ensure QObject ownership is Cpp when required
This commit is contained in:
		
							parent
							
								
									de8668eff3
								
							
						
					
					
						commit
						6966fc025c
					
				
					 4 changed files with 10 additions and 3 deletions
				
			
		| 
						 | 
					@ -1,6 +1,7 @@
 | 
				
			||||||
#include "proxywindow.hpp"
 | 
					#include "proxywindow.hpp"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <qobject.h>
 | 
					#include <qobject.h>
 | 
				
			||||||
 | 
					#include <qqmlengine.h>
 | 
				
			||||||
#include <qqmllist.h>
 | 
					#include <qqmllist.h>
 | 
				
			||||||
#include <qquickitem.h>
 | 
					#include <qquickitem.h>
 | 
				
			||||||
#include <qquickwindow.h>
 | 
					#include <qquickwindow.h>
 | 
				
			||||||
| 
						 | 
					@ -13,8 +14,10 @@
 | 
				
			||||||
#include "region.hpp"
 | 
					#include "region.hpp"
 | 
				
			||||||
#include "reload.hpp"
 | 
					#include "reload.hpp"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
ProxyWindowBase::ProxyWindowBase(QObject* parent): Reloadable(parent) {
 | 
					ProxyWindowBase::ProxyWindowBase(QObject* parent)
 | 
				
			||||||
	this->mContentItem = new QQuickItem(); // NOLINT
 | 
					    : Reloadable(parent)
 | 
				
			||||||
 | 
					    , mContentItem(new QQuickItem()) {
 | 
				
			||||||
 | 
						QQmlEngine::setObjectOwnership(this->mContentItem, QQmlEngine::CppOwnership);
 | 
				
			||||||
	this->mContentItem->setParent(this);
 | 
						this->mContentItem->setParent(this);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	QObject::connect(this, &ProxyWindowBase::widthChanged, this, &ProxyWindowBase::onWidthChanged);
 | 
						QObject::connect(this, &ProxyWindowBase::widthChanged, this, &ProxyWindowBase::onWidthChanged);
 | 
				
			||||||
| 
						 | 
					@ -34,7 +37,6 @@ void ProxyWindowBase::onReload(QObject* oldInstance) {
 | 
				
			||||||
	Reloadable::reloadRecursive(this->mContentItem, oldInstance);
 | 
						Reloadable::reloadRecursive(this->mContentItem, oldInstance);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	this->mContentItem->setParentItem(this->window->contentItem());
 | 
						this->mContentItem->setParentItem(this->window->contentItem());
 | 
				
			||||||
 | 
					 | 
				
			||||||
	this->mContentItem->setWidth(this->width());
 | 
						this->mContentItem->setWidth(this->width());
 | 
				
			||||||
	this->mContentItem->setHeight(this->height());
 | 
						this->mContentItem->setHeight(this->height());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -104,6 +104,8 @@ void Variants::updateVariants() {
 | 
				
			||||||
				continue;
 | 
									continue;
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								QQmlEngine::setObjectOwnership(instance, QQmlEngine::CppOwnership);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			instance->setParent(this);
 | 
								instance->setParent(this);
 | 
				
			||||||
			this->instances.insert(variant, instance);
 | 
								this->instances.insert(variant, instance);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -187,6 +187,8 @@ void SocketServer::onNewConnection() {
 | 
				
			||||||
			return;
 | 
								return;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							QQmlEngine::setObjectOwnership(instance, QQmlEngine::CppOwnership);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		this->mSockets.append(instance);
 | 
							this->mSockets.append(instance);
 | 
				
			||||||
		instance->setParent(this);
 | 
							instance->setParent(this);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -157,6 +157,7 @@ SessionLockSurface::SessionLockSurface(QObject* parent)
 | 
				
			||||||
    : Reloadable(parent)
 | 
					    : Reloadable(parent)
 | 
				
			||||||
    , mContentItem(new QQuickItem())
 | 
					    , mContentItem(new QQuickItem())
 | 
				
			||||||
    , ext(new LockWindowExtension(this)) {
 | 
					    , ext(new LockWindowExtension(this)) {
 | 
				
			||||||
 | 
						QQmlEngine::setObjectOwnership(this->mContentItem, QQmlEngine::CppOwnership);
 | 
				
			||||||
	this->mContentItem->setParent(this);
 | 
						this->mContentItem->setParent(this);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// clang-format off
 | 
						// clang-format off
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue