src/gui/widgets/qmenubar.cpp
changeset 30 5dc02b23752f
parent 25 e24348a560a6
child 33 3e2da88830cd
--- a/src/gui/widgets/qmenubar.cpp	Wed Jun 23 19:07:03 2010 +0300
+++ b/src/gui/widgets/qmenubar.cpp	Tue Jul 06 15:10:48 2010 +0300
@@ -268,19 +268,15 @@
 
 QRect QMenuBarPrivate::actionRect(QAction *act) const
 {
-    Q_Q(const QMenuBar);
     const int index = actions.indexOf(act);
-    if (index == -1)
-        return QRect();
 
     //makes sure the geometries are up-to-date
     const_cast<QMenuBarPrivate*>(this)->updateGeometries();
 
-    if (index >= actionRects.count())
+    if (index < 0 || index >= actionRects.count())
         return QRect(); // that can happen in case of native menubar
 
-    QRect ret = actionRects.at(index);
-    return QStyle::visualRect(q->layoutDirection(), q->rect(), ret);
+    return actionRects.at(index);
 }
 
 void QMenuBarPrivate::focusFirstAction()
@@ -505,6 +501,9 @@
 
         //keep moving along..
         x += rect.width() + itemSpacing;
+
+        //make sure we follow the layout direction
+        rect = QStyle::visualRect(q->layoutDirection(), q->rect(), rect);
     }
 }
 
@@ -1932,9 +1931,9 @@
             d->macCreateMenuBar(parentWidget());
         }
         macUpdateMenuBar();
-        updateGeometry();
-        setVisible(false);
-        setVisible(true);
+	updateGeometry();
+	if (!d->nativeMenuBar && parentWidget())
+	    setVisible(true);
 #endif
     }
 }