summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJekyll Wu <adaptee@gmail.com>2011-09-05 20:12:10 (GMT)
committerKurt Hindenburg <kurt.hindenburg@gmail.com>2011-09-15 15:35:05 (GMT)
commit000f84299c00e782dda75244d5daf35e1c88794c (patch)
tree0d0a4d2fd6be04ff36b1e0bc80a5959640513ea7
parentf8794521523836fae110f23a60a2953ae02ee121 (diff)
Check the validity of context menu after it gets closed.
The patch is from Francesco Cecconi <francesco.cecconi@gmail.com>, with slight modification by committer. BUG: 233377 FIXED-in : 4.8 (cherry picked from commit 0f89f1bba96163ab5dd37ab974927b5566439d36)
-rw-r--r--src/SessionController.cpp20
1 files changed, 14 insertions, 6 deletions
diff --git a/src/SessionController.cpp b/src/SessionController.cpp
index b6fa82b..24b1871 100644
--- a/src/SessionController.cpp
+++ b/src/SessionController.cpp
@@ -1096,7 +1096,7 @@ void SessionController::showDisplayContextMenu(const QPoint& position)
//kDebug(1211) << "Created xmlgui factory" << factory;
}
- QMenu* popup = qobject_cast<QMenu*>(factory()->container("session-popup-menu",this));
+ QPointer<QMenu> popup = qobject_cast<QMenu*>(factory()->container("session-popup-menu",this));
if (popup)
{
// prepend content-specific actions such as "Open Link", "Copy Email Address" etc.
@@ -1110,11 +1110,19 @@ void SessionController::showDisplayContextMenu(const QPoint& position)
popup->insertActions(popup->actions().value(0,0),contentActions);
QAction* chosen = popup->exec( _view->mapToGlobal(position) );
- // remove content-specific actions, unless the close action was chosen
- // in which case the popup menu will be partially destroyed at this point
- foreach(QAction* action,contentActions)
- popup->removeAction(action);
- delete contentSeparator;
+ // check for validity of the pointer to the popup menu
+ if (popup)
+ {
+ // Remove content-specific actions
+ //
+ // If the close action was chosen, the popup menu will be partially
+ // destroyed at this point, and the rest will be destroyed later by
+ // 'chosen->trigger()'
+ foreach (QAction* action,contentActions)
+ popup->removeAction(action);
+
+ delete contentSeparator;
+ }
_preventClose = false;