close the menu if it was already open

sometimes on plasma start, other context events may be triggered
while the menu is in its exec(), byt the qqmlincubator.
if so, close the already existing menu.

BUG:334562
This commit is contained in:
Marco Martin 2014-05-12 11:02:56 +02:00
parent 939e01f554
commit 895c5b6b2b
2 changed files with 11 additions and 1 deletions

View File

@ -594,6 +594,13 @@ void ContainmentInterface::mousePressEvent(QMouseEvent *event)
void ContainmentInterface::mouseReleaseEvent(QMouseEvent *event)
{
//even if the menu is executed synchronously, other events may be processed
//by the qml incubator when plasma is loading, so we need to guard there
if (m_contextMenu) {
m_contextMenu.data()->close();
return;
}
const QString trigger = Plasma::ContainmentActions::eventToString(event);
Plasma::ContainmentActions *plugin = containment()->containmentActions().value(trigger);
@ -625,10 +632,12 @@ void ContainmentInterface::mouseReleaseEvent(QMouseEvent *event)
}
}
}
qDebug() << "Invoking menu for applet" << applet;
//qDebug() << "Invoking menu for applet" << applet;
QMenu desktopMenu;
m_contextMenu = &desktopMenu;
if (applet) {
addAppletActions(desktopMenu, applet, event);
} else {

View File

@ -174,6 +174,7 @@ private:
QHash<KJob *, QPoint> m_dropPoints;
QHash<KJob *, QMenu *> m_dropMenus;
KActivities::Info *m_activityInfo;
QWeakPointer<QMenu> m_contextMenu;
};
QML_DECLARE_TYPEINFO(ContainmentInterface, QML_HAS_ATTACHED_PROPERTIES)