summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorMarius Bugge Monsen <mmonsen@trolltech.com>2009-10-21 12:46:52 (GMT)
committerMarius Bugge Monsen <mmonsen@trolltech.com>2009-10-21 12:46:52 (GMT)
commit95e438189a36c71d632099b3873557103697bc3b (patch)
tree6de1975fd26cbf028a0e3971341fd2e6e5632e23 /src/gui
parent757daee4365c8b4ed5fcf68bd5a38fc64593c549 (diff)
downloadQt-95e438189a36c71d632099b3873557103697bc3b.zip
Qt-95e438189a36c71d632099b3873557103697bc3b.tar.gz
Qt-95e438189a36c71d632099b3873557103697bc3b.tar.bz2
Make QMenu::activateCausedStack() exception safe.
Use an internal class to reset the activationRecursionGuard when the scope is closed. Reviewed-by: Leo Cunha
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/widgets/qmenu.cpp14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/gui/widgets/qmenu.cpp b/src/gui/widgets/qmenu.cpp
index 324bc90..ea25901 100644
--- a/src/gui/widgets/qmenu.cpp
+++ b/src/gui/widgets/qmenu.cpp
@@ -975,10 +975,19 @@ bool QMenuPrivate::mouseEventTaken(QMouseEvent *e)
return false;
}
+class ExceptionGuard
+{
+public:
+ inline ExceptionGuard(bool *w = 0) : watched(w) { Q_ASSERT(!(*watched)); *watched = true; }
+ inline ~ExceptionGuard() { *watched = false; }
+ inline operator bool() { return *watched; }
+private:
+ bool *watched;
+};
+
void QMenuPrivate::activateCausedStack(const QList<QPointer<QWidget> > &causedStack, QAction *action, QAction::ActionEvent action_e, bool self)
{
- Q_ASSERT(!activationRecursionGuard);
- activationRecursionGuard = true;
+ ExceptionGuard guard(&activationRecursionGuard);
#ifdef QT3_SUPPORT
const int actionId = q_func()->findIdForAction(action);
#endif
@@ -1023,7 +1032,6 @@ void QMenuPrivate::activateCausedStack(const QList<QPointer<QWidget> > &causedSt
#endif
}
}
- activationRecursionGuard = false;
}
void QMenuPrivate::activateAction(QAction *action, QAction::ActionEvent action_e, bool self)