forked from quickshell/quickshell
		
	core/reloader: do not require ShellRoot
This commit is contained in:
		
							parent
							
								
									2996e40ff9
								
							
						
					
					
						commit
						c21df95087
					
				
					 3 changed files with 7 additions and 20 deletions
				
			
		| 
						 | 
					@ -124,7 +124,10 @@ void EngineGeneration::onReload(EngineGeneration* old) {
 | 
				
			||||||
	QObject::connect(this->engine, &QQmlEngine::quit, this, &EngineGeneration::quit);
 | 
						QObject::connect(this->engine, &QQmlEngine::quit, this, &EngineGeneration::quit);
 | 
				
			||||||
	QObject::connect(this->engine, &QQmlEngine::exit, this, &EngineGeneration::exit);
 | 
						QObject::connect(this->engine, &QQmlEngine::exit, this, &EngineGeneration::exit);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	this->root->reload(old == nullptr ? nullptr : old->root);
 | 
						if (auto* reloadable = qobject_cast<Reloadable*>(this->root)) {
 | 
				
			||||||
 | 
							reloadable->reload(old ? old->root : nullptr);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	this->singletonRegistry.onReload(old == nullptr ? nullptr : &old->singletonRegistry);
 | 
						this->singletonRegistry.onReload(old == nullptr ? nullptr : &old->singletonRegistry);
 | 
				
			||||||
	this->reloadComplete = true;
 | 
						this->reloadComplete = true;
 | 
				
			||||||
	emit this->reloadFinished();
 | 
						emit this->reloadFinished();
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -13,7 +13,6 @@
 | 
				
			||||||
#include "incubator.hpp"
 | 
					#include "incubator.hpp"
 | 
				
			||||||
#include "qsintercept.hpp"
 | 
					#include "qsintercept.hpp"
 | 
				
			||||||
#include "scan.hpp"
 | 
					#include "scan.hpp"
 | 
				
			||||||
#include "shell.hpp"
 | 
					 | 
				
			||||||
#include "singleton.hpp"
 | 
					#include "singleton.hpp"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class RootWrapper;
 | 
					class RootWrapper;
 | 
				
			||||||
| 
						 | 
					@ -58,7 +57,7 @@ public:
 | 
				
			||||||
	QsUrlInterceptor urlInterceptor;
 | 
						QsUrlInterceptor urlInterceptor;
 | 
				
			||||||
	QsInterceptNetworkAccessManagerFactory interceptNetFactory;
 | 
						QsInterceptNetworkAccessManagerFactory interceptNetFactory;
 | 
				
			||||||
	QQmlEngine* engine = nullptr;
 | 
						QQmlEngine* engine = nullptr;
 | 
				
			||||||
	ShellRoot* root = nullptr;
 | 
						QObject* root = nullptr;
 | 
				
			||||||
	SingletonRegistry singletonRegistry;
 | 
						SingletonRegistry singletonRegistry;
 | 
				
			||||||
	QFileSystemWatcher* watcher = nullptr;
 | 
						QFileSystemWatcher* watcher = nullptr;
 | 
				
			||||||
	QVector<QString> deletedWatchedFiles;
 | 
						QVector<QString> deletedWatchedFiles;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -14,7 +14,6 @@
 | 
				
			||||||
#include "generation.hpp"
 | 
					#include "generation.hpp"
 | 
				
			||||||
#include "qmlglobal.hpp"
 | 
					#include "qmlglobal.hpp"
 | 
				
			||||||
#include "scan.hpp"
 | 
					#include "scan.hpp"
 | 
				
			||||||
#include "shell.hpp"
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
RootWrapper::RootWrapper(QString rootPath, QString shellId)
 | 
					RootWrapper::RootWrapper(QString rootPath, QString shellId)
 | 
				
			||||||
    : QObject(nullptr)
 | 
					    : QObject(nullptr)
 | 
				
			||||||
| 
						 | 
					@ -60,9 +59,9 @@ void RootWrapper::reloadGraph(bool hard) {
 | 
				
			||||||
	url.setScheme("qsintercept");
 | 
						url.setScheme("qsintercept");
 | 
				
			||||||
	auto component = QQmlComponent(generation->engine, url);
 | 
						auto component = QQmlComponent(generation->engine, url);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	auto* obj = component.beginCreate(generation->engine->rootContext());
 | 
						auto* newRoot = component.beginCreate(generation->engine->rootContext());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (obj == nullptr) {
 | 
						if (newRoot == nullptr) {
 | 
				
			||||||
		const QString error = "failed to create root component\n" + component.errorString();
 | 
							const QString error = "failed to create root component\n" + component.errorString();
 | 
				
			||||||
		qWarning().noquote() << error;
 | 
							qWarning().noquote() << error;
 | 
				
			||||||
		generation->destroy();
 | 
							generation->destroy();
 | 
				
			||||||
| 
						 | 
					@ -74,20 +73,6 @@ void RootWrapper::reloadGraph(bool hard) {
 | 
				
			||||||
		return;
 | 
							return;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	auto* newRoot = qobject_cast<ShellRoot*>(obj);
 | 
					 | 
				
			||||||
	if (newRoot == nullptr) {
 | 
					 | 
				
			||||||
		const QString error = "root component was not a Quickshell.ShellRoot";
 | 
					 | 
				
			||||||
		qWarning().noquote() << error;
 | 
					 | 
				
			||||||
		delete obj;
 | 
					 | 
				
			||||||
		generation->destroy();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		if (this->generation != nullptr && this->generation->qsgInstance != nullptr) {
 | 
					 | 
				
			||||||
			emit this->generation->qsgInstance->reloadFailed(error);
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		return;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	generation->root = newRoot;
 | 
						generation->root = newRoot;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	component.completeCreate();
 | 
						component.completeCreate();
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue