feat: implement soft reloading

This commit is contained in:
outfoxxed committed 2024-02-01 01:29:45 -08:00
1 parent ba1e18a125
commit 362789fc46
11 files changed
+385 -21

No files matched your search

+20 -2
View File
@@ -1,4 +1,5 @@
#include "shell.hpp"
#include <utility>
#include <qlogging.h>
#include <qobject.h>
@@ -8,7 +9,7 @@
#include "rootwrapper.hpp"
void QtShell::reload() {
void QtShell::reload(bool hard) {
auto* rootobj = QQmlEngine::contextForObject(this)->engine()->parent();
auto* root = qobject_cast<RootWrapper*>(rootobj);
@@ -17,7 +18,23 @@ void QtShell::reload() {
return;
}
root->reloadGraph();
root->reloadGraph(hard);
}
void QtShell::earlyInit(QObject* old) {
auto* oldshell = qobject_cast<QtShell*>(old);
if (oldshell != nullptr) {
this->scavengeableChildren = std::move(oldshell->children);
}
}
QObject* QtShell::scavengeTargetFor(QObject* /* child */) {
if (this->scavengeableChildren.length() > this->children.length()) {
return this->scavengeableChildren[this->children.length()];
}
return nullptr;
}
QQmlListProperty<QObject> QtShell::components() {
@@ -36,4 +53,5 @@ QQmlListProperty<QObject> QtShell::components() {
void QtShell::appendComponent(QQmlListProperty<QObject>* list, QObject* component) {
auto* shell = static_cast<QtShell*>(list->object); // NOLINT
component->setParent(shell);
shell->children.append(component);
}