diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp
index 428588d..fccea82 100644
--- a/src/gui/kernel/qapplication.cpp
+++ b/src/gui/kernel/qapplication.cpp
@@ -3079,6 +3079,10 @@ QWidget *QApplicationPrivate::pickMouseReceiver(QWidget *candidate, const QPoint
                                                 Qt::MouseButtons buttons, QWidget *buttonDown,
                                                 QWidget *alienWidget)
 {
+    qDebug() << __FUNCTION__
+             << "buttons" <<buttons
+             << "candidate" << candidate << "buttonDown" << buttonDown
+             << "alienWidget" << alienWidget;
     Q_ASSERT(candidate);
 
     QWidget *mouseGrabber = QWidget::mouseGrabber();
diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp
index a99373a..c7ced0e 100644
--- a/src/gui/kernel/qwidget.cpp
+++ b/src/gui/kernel/qwidget.cpp
@@ -2473,8 +2473,10 @@ void QWidgetPrivate::deactivateWidgetCleanup()
     if (QApplication::activeWindow() == q)
         QApplication::setActiveWindow(0);
     // If the is the active mouse press widget, reset it
-    if (q == qt_button_down)
+    if (q == qt_button_down) {
+        qDebug() << __FUNCTION__ << "clearing qt_button_down" << qt_button_down;
         qt_button_down = 0;
+    }
 }
 
 
diff --git a/src/gui/widgets/qmenu.cpp b/src/gui/widgets/qmenu.cpp
index 23062d7..0c4a153 100644
--- a/src/gui/widgets/qmenu.cpp
+++ b/src/gui/widgets/qmenu.cpp
@@ -442,6 +442,7 @@ void QMenuPrivate::hideUpToMenuBar()
         while(caused) {
 #ifndef QT_NO_MENUBAR
             if (QMenuBar *mb = qobject_cast<QMenuBar*>(caused)) {
+                qDebug() << __FUNCTION__ << "Clearing menubar";
                 mb->d_func()->setCurrentAction(0);
                 mb->d_func()->setKeyboardMode(false);
                 caused = 0;
@@ -1819,6 +1820,7 @@ QSize QMenu::sizeHint() const
 */
 void QMenu::popup(const QPoint &p, QAction *atAction)
 {
+    qDebug() << '>' << __FUNCTION__ << this << p << atAction;
     Q_D(QMenu);
 #ifndef Q_OS_SYMBIAN
     if (d->scroll) { // reset scroll state from last popup
@@ -2052,6 +2054,7 @@ void QMenu::popup(const QPoint &p, QAction *atAction)
 #ifndef QT_NO_ACCESSIBILITY
     QAccessible::updateAccessibility(this, 0, QAccessible::PopupMenuStart);
 #endif
+    qDebug() << '<' << __FUNCTION__;
 }
 
 /*!
@@ -2199,8 +2202,10 @@ void QMenu::hideEvent(QHideEvent *)
     QAccessible::updateAccessibility(this, 0, QAccessible::PopupMenuEnd);
 #endif
 #ifndef QT_NO_MENUBAR
-    if (QMenuBar *mb = qobject_cast<QMenuBar*>(d->causedPopup.widget))
+    if (QMenuBar *mb = qobject_cast<QMenuBar*>(d->causedPopup.widget)) {
+        qDebug() << __FUNCTION__ << "Clearing menubar";
         mb->d_func()->setCurrentAction(0);
+    }
 #endif
     d->mouseDown = 0;
     d->hasHadMouse = false;
@@ -2716,6 +2721,7 @@ void QMenu::keyPressEvent(QKeyEvent *e)
             d->hideMenu(this); // hide after getting causedPopup
 #ifndef QT_NO_MENUBAR
             if (QMenuBar *mb = qobject_cast<QMenuBar*>(caused)) {
+                qDebug() << __FUNCTION__ << "setting menubar" << d->menuAction;
                 mb->d_func()->setCurrentAction(d->menuAction);
                 mb->d_func()->setKeyboardMode(true);
             }
diff --git a/src/gui/widgets/qmenubar.cpp b/src/gui/widgets/qmenubar.cpp
index 948604f..1932220 100644
--- a/src/gui/widgets/qmenubar.cpp
+++ b/src/gui/widgets/qmenubar.cpp
@@ -44,6 +44,8 @@
 #include <qstyle.h>
 #include <qlayout.h>
 #include <qapplication.h>
+#include <qaction.h>
+#include <qdebug.h>
 #include <qdesktopwidget.h>
 #ifndef QT_NO_ACCESSIBILITY
 # include <qaccessible.h>
@@ -305,8 +307,10 @@ void QMenuBarPrivate::focusFirstAction()
         updateGeometries();
         int index = 0;
         while (index < actions.count() && actionRects.at(index).isNull()) ++index;
-        if (index < actions.count())
+        if (index < actions.count()) {
+            qDebug() << __FUNCTION__ << "set"<<index << actions.at(index);
             setCurrentAction(actions.at(index));
+        }
     }
 }
 
@@ -339,10 +343,14 @@ void QMenuBarPrivate::setKeyboardMode(bool b)
 void QMenuBarPrivate::popupAction(QAction *action, bool activateFirst)
 {
     Q_Q(QMenuBar);
-    if(!action || !action->menu() || closePopupMode)
+    if(!action || !action->menu() || closePopupMode) {
+        qDebug() << __FUNCTION__ << "return" << action << "closePopupMode" << closePopupMode;
         return;
+    }
+    qDebug() << __FUNCTION__ << "popupState = true";
     popupState = true;
     if (action->isEnabled() && action->menu()->isEnabled()) {
+        qDebug() << __FUNCTION__ << "Clearing closePopupMode";
         closePopupMode = 0;
         activeMenu = action->menu();
         activeMenu->d_func()->causedPopup.widget = q;
@@ -381,6 +389,7 @@ void QMenuBarPrivate::popupAction(QAction *action, bool activateFirst)
 
         if(!defaultPopDown || (fitUp && !fitDown))
             pos.setY(qMax(screenRect.y(), q->mapToGlobal(QPoint(0, adjustedActionRect.top()-popup_size.height())).y()));
+        qDebug() << __FUNCTION__ << "activeMenu" << activeMenu << pos;
         activeMenu->popup(pos);
         if(activateFirst)
             activeMenu->d_func()->setFirstActionActive();
@@ -390,6 +399,13 @@ void QMenuBarPrivate::popupAction(QAction *action, bool activateFirst)
 
 void QMenuBarPrivate::setCurrentAction(QAction *action, bool popup, bool activateFirst)
 {
+    qDebug() << __FUNCTION__ << action << "popup" << popup << "activateFirst" << activateFirst;
+    if (action && action->objectName()==QLatin1String("EditMenuAction")) {
+        if (popup)
+            qDebug("POPPING up EditMenuAction");
+        else
+            qDebug("NOT POPPING up EditMenuAction");
+    }
     if(currentAction == action && popup == popupState)
         return;
 
@@ -410,6 +426,7 @@ void QMenuBarPrivate::setCurrentAction(QAction *action, bool popup, bool activat
     if(currentAction)
         q->update(actionRect(currentAction));
 
+    qDebug() << __FUNCTION__ << "popupState = " << popup;
     popupState = popup;
 #ifndef QT_NO_STATUSTIP
     QAction *previousAction = currentAction;
@@ -990,6 +1007,7 @@ QAction *QMenuBar::activeAction() const
 void QMenuBar::setActiveAction(QAction *act)
 {
     Q_D(QMenuBar);
+    qDebug() << __FUNCTION__ << "set"<<act;
     d->setCurrentAction(act, true, false);
 }
 
@@ -1168,13 +1186,18 @@ void QMenuBar::mouseReleaseEvent(QMouseEvent *e)
 
     d->mouseDown = false;
     QAction *action = d->actionAt(e->pos());
+    qDebug() << __FUNCTION__ << action << "d->currentAction" << d->currentAction
+             << "d->closePopupMode" << d->closePopupMode;
+
     if((d->closePopupMode && action == d->currentAction) || !action || !action->menu()) {
         //we set the current action before activating
         //so that we let the leave event set the current back to 0
+        qDebug() << __FUNCTION__ << "setCurrentAction" << action;
         d->setCurrentAction(action, false);
         if(action)
             d->activateAction(action, QAction::Trigger);
     }
+    qDebug() << __FUNCTION__ << "Clearing closePopupMode";
     d->closePopupMode = 0;
 }
 
@@ -1292,9 +1315,14 @@ void QMenuBar::mouseMoveEvent(QMouseEvent *e)
     if (!(e->buttons() & Qt::LeftButton))
         d->mouseDown = false;
     bool popupState = d->popupState || d->mouseDown;
+
     QAction *action = d->actionAt(e->pos());
-    if ((action && d->isVisible(action)) || !popupState)
+    if ((action && d->isVisible(action)) || !popupState) {
+        qDebug() << __FUNCTION__ <<e
+                 << "d->popupState" << d->popupState << "d->mouseDown" << d->mouseDown
+                 << "calling setCurrentAction" << action << "popupState" << popupState;
         d->setCurrentAction(action, popupState);
+    }
 }
 
 /*!
@@ -1363,9 +1391,10 @@ void QMenuBar::focusInEvent(QFocusEvent *)
 /*!
   \reimp
 */
-void QMenuBar::focusOutEvent(QFocusEvent *)
+void QMenuBar::focusOutEvent(QFocusEvent *f)
 {
     Q_D(QMenuBar);
+    qDebug() << __FUNCTION__ << f;
     if(!d->popupState) {
         d->setCurrentAction(0);
         d->setKeyboardMode(false);
@@ -1379,6 +1408,7 @@ void QMenuBar::timerEvent (QTimerEvent *e)
 {
     Q_D(QMenuBar);
     if (e->timerId() == d->autoReleaseTimer.timerId()) {
+        qDebug() << __FUNCTION__ ;
         d->autoReleaseTimer.stop();
         d->setCurrentAction(0);
     }
