From 8cf160e7178941090748cdbf91a5d5f9e74b4f72 Mon Sep 17 00:00:00 2001 From: zhaoyingzhen Date: Mon, 13 May 2024 16:37:06 +0800 Subject: [PATCH] fix: tray plugin mouse right click cause dock crash 1.double screen and set extended mode 2.adjust dock height size 3.logout computer and then click the tray plugin right-click menu when the dock comes out Log: fix tray plugin mouse right click cause dock crash Issue: https://github.com/linuxdeepin/developer-center/issues/8506 Influence: tray plugin menu display --- panels/dock/tray/frame/window/quickpluginwindow.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/panels/dock/tray/frame/window/quickpluginwindow.cpp b/panels/dock/tray/frame/window/quickpluginwindow.cpp index 5153947e1..1ecd68cd2 100644 --- a/panels/dock/tray/frame/window/quickpluginwindow.cpp +++ b/panels/dock/tray/frame/window/quickpluginwindow.cpp @@ -921,10 +921,15 @@ void QuickDockItem::mousePressEvent(QMouseEvent *event) } if (!m_contextMenu->actions().isEmpty()) { - m_contextMenu->popup(QCursor::pos()); + QTimer::singleShot(0, this, [this]() { + QMenu contextMenu(this); + contextMenu.addActions(m_contextMenu->actions()); + contextMenu.exec(QCursor::pos()); + }); + + // Fixme: Can cause crash in some cases + //m_contextMenu->popup(QCursor::pos()); } - - return QWidget::mousePressEvent(event); } void QuickDockItem::enterEvent(QEnterEvent *event)