forked from quickshell/quickshell
		
	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.
This commit is contained in:
		
							parent
							
								
									60349f1894
								
							
						
					
					
						commit
						3edb3f4efa
					
				
					 1 changed files with 9 additions and 6 deletions
				
			
		| 
						 | 
					@ -17,10 +17,10 @@
 | 
				
			||||||
#include "shell.hpp"
 | 
					#include "shell.hpp"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
RootWrapper::RootWrapper(QString rootPath, QString shellId)
 | 
					RootWrapper::RootWrapper(QString rootPath, QString shellId)
 | 
				
			||||||
		: QObject(nullptr)
 | 
					    : QObject(nullptr)
 | 
				
			||||||
		, rootPath(std::move(rootPath))
 | 
					    , rootPath(std::move(rootPath))
 | 
				
			||||||
		, shellId(std::move(shellId))
 | 
					    , shellId(std::move(shellId))
 | 
				
			||||||
		, originalWorkingDirectory(QDir::current().absolutePath()) {
 | 
					    , originalWorkingDirectory(QDir::current().absolutePath()) {
 | 
				
			||||||
	// clang-format off
 | 
						// clang-format off
 | 
				
			||||||
	QObject::connect(QuickshellSettings::instance(), &QuickshellSettings::watchFilesChanged, this, &RootWrapper::onWatchFilesChanged);
 | 
						QObject::connect(QuickshellSettings::instance(), &QuickshellSettings::watchFilesChanged, this, &RootWrapper::onWatchFilesChanged);
 | 
				
			||||||
	// clang-format on
 | 
						// clang-format on
 | 
				
			||||||
| 
						 | 
					@ -92,11 +92,14 @@ void RootWrapper::reloadGraph(bool hard) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	component.completeCreate();
 | 
						component.completeCreate();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (this->generation) {
 | 
				
			||||||
 | 
							QObject::disconnect(this->generation, nullptr, this, nullptr);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	auto isReload = this->generation != nullptr;
 | 
						auto isReload = this->generation != nullptr;
 | 
				
			||||||
	generation->onReload(hard ? nullptr : this->generation);
 | 
						generation->onReload(hard ? nullptr : this->generation);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (hard && this->generation != nullptr) {
 | 
						if (hard && this->generation) {
 | 
				
			||||||
		QObject::disconnect(this->generation, nullptr, this, nullptr);
 | 
					 | 
				
			||||||
		this->generation->destroy();
 | 
							this->generation->destroy();
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue