Skip to content

Commit c21df95

Browse files
committed
core/reloader: do not require ShellRoot
1 parent 2996e40 commit c21df95

File tree

3 files changed

+7
-20
lines changed

3 files changed

+7
-20
lines changed

src/core/generation.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,10 @@ void EngineGeneration::onReload(EngineGeneration* old) {
124124
QObject::connect(this->engine, &QQmlEngine::quit, this, &EngineGeneration::quit);
125125
QObject::connect(this->engine, &QQmlEngine::exit, this, &EngineGeneration::exit);
126126

127-
this->root->reload(old == nullptr ? nullptr : old->root);
127+
if (auto* reloadable = qobject_cast<Reloadable*>(this->root)) {
128+
reloadable->reload(old ? old->root : nullptr);
129+
}
130+
128131
this->singletonRegistry.onReload(old == nullptr ? nullptr : &old->singletonRegistry);
129132
this->reloadComplete = true;
130133
emit this->reloadFinished();

src/core/generation.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
#include "incubator.hpp"
1414
#include "qsintercept.hpp"
1515
#include "scan.hpp"
16-
#include "shell.hpp"
1716
#include "singleton.hpp"
1817

1918
class RootWrapper;
@@ -58,7 +57,7 @@ class EngineGeneration: public QObject {
5857
QsUrlInterceptor urlInterceptor;
5958
QsInterceptNetworkAccessManagerFactory interceptNetFactory;
6059
QQmlEngine* engine = nullptr;
61-
ShellRoot* root = nullptr;
60+
QObject* root = nullptr;
6261
SingletonRegistry singletonRegistry;
6362
QFileSystemWatcher* watcher = nullptr;
6463
QVector<QString> deletedWatchedFiles;

src/core/rootwrapper.cpp

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
#include "generation.hpp"
1515
#include "qmlglobal.hpp"
1616
#include "scan.hpp"
17-
#include "shell.hpp"
1817

1918
RootWrapper::RootWrapper(QString rootPath, QString shellId)
2019
: QObject(nullptr)
@@ -60,25 +59,11 @@ void RootWrapper::reloadGraph(bool hard) {
6059
url.setScheme("qsintercept");
6160
auto component = QQmlComponent(generation->engine, url);
6261

63-
auto* obj = component.beginCreate(generation->engine->rootContext());
62+
auto* newRoot = component.beginCreate(generation->engine->rootContext());
6463

65-
if (obj == nullptr) {
66-
const QString error = "failed to create root component\n" + component.errorString();
67-
qWarning().noquote() << error;
68-
generation->destroy();
69-
70-
if (this->generation != nullptr && this->generation->qsgInstance != nullptr) {
71-
emit this->generation->qsgInstance->reloadFailed(error);
72-
}
73-
74-
return;
75-
}
76-
77-
auto* newRoot = qobject_cast<ShellRoot*>(obj);
7864
if (newRoot == nullptr) {
79-
const QString error = "root component was not a Quickshell.ShellRoot";
65+
const QString error = "failed to create root component\n" + component.errorString();
8066
qWarning().noquote() << error;
81-
delete obj;
8267
generation->destroy();
8368

8469
if (this->generation != nullptr && this->generation->qsgInstance != nullptr) {

0 commit comments

Comments
 (0)