core/reloader: fix incorrect generation teardown on hard reload

This commit is contained in:
outfoxxed 2024-05-31 00:26:34 -07:00
parent 6c9526761c
commit 84bb4098ad
Signed by: outfoxxed
GPG key ID: 4C88A185FB89301E

View file

@ -65,7 +65,7 @@ void RootWrapper::reloadGraph(bool hard) {
auto* obj = component.beginCreate(generation->engine->rootContext());
if (obj == nullptr) {
QString error = "failed to create root component\n" + component.errorString();
const QString error = "failed to create root component\n" + component.errorString();
qWarning().noquote() << error;
delete generation;
@ -78,7 +78,7 @@ void RootWrapper::reloadGraph(bool hard) {
auto* newRoot = qobject_cast<ShellRoot*>(obj);
if (newRoot == nullptr) {
QString error = "root component was not a Quickshell.ShellRoot";
const QString error = "root component was not a Quickshell.ShellRoot";
qWarning().noquote() << error;
delete obj;
delete generation;
@ -96,7 +96,11 @@ void RootWrapper::reloadGraph(bool hard) {
auto isReload = this->generation != nullptr;
generation->onReload(hard ? nullptr : this->generation);
if (hard) delete this->generation;
if (hard && this->generation != nullptr) {
this->generation->destroy();
}
this->generation = generation;
qInfo() << "Configuration Loaded";