From 84bb4098adb8cf9a559772ad42a05ed0cdf8e7b1 Mon Sep 17 00:00:00 2001 From: outfoxxed Date: Fri, 31 May 2024 00:26:34 -0700 Subject: [PATCH] core/reloader: fix incorrect generation teardown on hard reload --- src/core/rootwrapper.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/core/rootwrapper.cpp b/src/core/rootwrapper.cpp index 35060be..3c69615 100644 --- a/src/core/rootwrapper.cpp +++ b/src/core/rootwrapper.cpp @@ -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(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";