From 3edb3f4efa531dc90339589d0f026f256dd563c5 Mon Sep 17 00:00:00 2001 From: outfoxxed Date: Fri, 30 Aug 2024 15:23:48 -0700 Subject: [PATCH] core/reloader: disconnect old generation before reloading Previously the old generation was not disconnected, causing the root wrapper's generation pointer to be nulled when pointing to the new generation, leaving multiple shell versions running simultaneously. --- src/core/rootwrapper.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/core/rootwrapper.cpp b/src/core/rootwrapper.cpp index ec0d0a89..0365b523 100644 --- a/src/core/rootwrapper.cpp +++ b/src/core/rootwrapper.cpp @@ -17,10 +17,10 @@ #include "shell.hpp" RootWrapper::RootWrapper(QString rootPath, QString shellId) - : QObject(nullptr) - , rootPath(std::move(rootPath)) - , shellId(std::move(shellId)) - , originalWorkingDirectory(QDir::current().absolutePath()) { + : QObject(nullptr) + , rootPath(std::move(rootPath)) + , shellId(std::move(shellId)) + , originalWorkingDirectory(QDir::current().absolutePath()) { // clang-format off QObject::connect(QuickshellSettings::instance(), &QuickshellSettings::watchFilesChanged, this, &RootWrapper::onWatchFilesChanged); // clang-format on @@ -92,11 +92,14 @@ void RootWrapper::reloadGraph(bool hard) { component.completeCreate(); + if (this->generation) { + QObject::disconnect(this->generation, nullptr, this, nullptr); + } + auto isReload = this->generation != nullptr; generation->onReload(hard ? nullptr : this->generation); - if (hard && this->generation != nullptr) { - QObject::disconnect(this->generation, nullptr, this, nullptr); + if (hard && this->generation) { this->generation->destroy(); }