forked from quickshell/quickshell
		
	core/menu: correctly handle menu destruction while open
This commit is contained in:
		
							parent
							
								
									26280b34b4
								
							
						
					
					
						commit
						2d05c7a89e
					
				
					 1 changed files with 12 additions and 2 deletions
				
			
		| 
						 | 
				
			
			@ -78,8 +78,17 @@ void QsMenuAnchor::onClosed() {
 | 
			
		|||
		this->platformMenu = nullptr;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	QObject::disconnect(this->mMenu, &QsMenuHandle::menuChanged, this, &QsMenuAnchor::onMenuChanged);
 | 
			
		||||
	this->mMenu->unrefHandle();
 | 
			
		||||
	if (this->mMenu) {
 | 
			
		||||
		QObject::disconnect(
 | 
			
		||||
		    this->mMenu,
 | 
			
		||||
		    &QsMenuHandle::menuChanged,
 | 
			
		||||
		    this,
 | 
			
		||||
		    &QsMenuAnchor::onMenuChanged
 | 
			
		||||
		);
 | 
			
		||||
 | 
			
		||||
		this->mMenu->unrefHandle();
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	emit this->closed();
 | 
			
		||||
	emit this->visibleChanged();
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -109,6 +118,7 @@ bool QsMenuAnchor::isVisible() const { return this->mOpen; }
 | 
			
		|||
 | 
			
		||||
void QsMenuAnchor::onMenuDestroyed() {
 | 
			
		||||
	this->mMenu = nullptr;
 | 
			
		||||
	this->onClosed();
 | 
			
		||||
	emit this->menuChanged();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue