Index: trunk/src/gui/kernel/qlayout.cpp
===================================================================
--- trunk/src/gui/kernel/qlayout.cpp	(revision 5)
+++ trunk/src/gui/kernel/qlayout.cpp	(revision 561)
@@ -2,5 +2,6 @@
 **
 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Qt Software Information (qt-info@nokia.com)
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
 **
 ** This file is part of the QtGui module of the Qt Toolkit.
@@ -21,8 +22,7 @@
 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
 **
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights.  These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
 **
 ** GNU General Public License Usage
@@ -34,6 +34,6 @@
 ** met: http://www.gnu.org/copyleft/gpl.html.
 **
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at qt-sales@nokia.com.
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
 ** $QT_END_LICENSE$
 **
@@ -62,5 +62,8 @@
         if (result != -1)
             return result;
-        result = menubar->sizeHint().height();
+        result = menubar->sizeHint()
+            .expandedTo(menubar->minimumSize())
+            .expandedTo(menubar->minimumSizeHint())
+            .boundedTo(menubar->maximumSize()).height();
         if (result != -1)
             return result;
@@ -73,5 +76,4 @@
     \brief The QLayout class is the base class of geometry managers.
 
-    \ingroup appearance
     \ingroup geomanagement
 
@@ -81,5 +83,5 @@
     For users of QLayout subclasses or of QMainWindow there is seldom
     any need to use the basic functions provided by QLayout, such as
-    setSizeConstraint() or setMenuBar(). See \l{Layout Classes}
+    setSizeConstraint() or setMenuBar(). See \l{Layout Management}
     for more information.
 
@@ -96,5 +98,5 @@
     Geometry management stops when the layout manager is deleted.
 
-    \sa QLayoutItem, {Layout Classes}, {Basic Layouts Example},
+    \sa QLayoutItem, {Layout Management}, {Basic Layouts Example},
         {Border Layout Example}, {Flow Layout Example}
 */
@@ -146,5 +148,10 @@
             d->topLevel = true;
             w->d_func()->layout = this;
-            invalidate();
+            QT_TRY {
+                invalidate();
+            } QT_CATCH(...) {
+                w->d_func()->layout = 0;
+                QT_RETHROW;
+            }
         }
     }
@@ -231,5 +238,10 @@
             d->topLevel = true;
             parent->d_func()->layout = this;
-            invalidate();
+            QT_TRY {
+                invalidate();
+            } QT_CATCH(...) {
+                parent->d_func()->layout = 0;
+                QT_RETHROW;
+            }
         }
     }
@@ -485,4 +497,19 @@
 
 /*!
+    \since 4.6
+
+    Sets the \a margins to use around the layout.
+
+    By default, QLayout uses the values provided by the style. On
+    most platforms, the margin is 11 pixels in all directions.
+
+    \sa contentsMargins()
+*/
+void QLayout::setContentsMargins(const QMargins &margins)
+{
+    setContentsMargins(margins.left(), margins.top(), margins.right(), margins.bottom());
+}
+
+/*!
     \since 4.3
 
@@ -507,4 +534,21 @@
     d->getMargin(right, d->userRightMargin, QStyle::PM_LayoutRightMargin);
     d->getMargin(bottom, d->userBottomMargin, QStyle::PM_LayoutBottomMargin);
+}
+
+/*!
+    \since 4.6
+
+    Returns the margins used around the layout.
+
+    By default, QLayout uses the values provided by the style. On
+    most platforms, the margin is 11 pixels in all directions.
+
+    \sa setContentsMargins()
+*/
+QMargins QLayout::contentsMargins() const
+{
+    int left, top, right, bottom;
+    getContentsMargins(&left, &top, &right, &bottom);
+    return QMargins(left, top, right, bottom);
 }
 
@@ -1029,6 +1073,11 @@
 {
     Q_D(QLayout);
-    if (widget)
-        addChildWidget(widget);
+
+#ifdef Q_OS_WINCE_WM
+    if (widget && widget->size().height() > 0)
+#else
+        if (widget)
+#endif
+            addChildWidget(widget);
     d->menubar = widget;
 }
@@ -1240,5 +1289,5 @@
     index from the layout, and return the item. If there is no such
     item, the function must do nothing and return 0.  Items are numbered
-    consecutively from 0. If an item is deleted, other items will be
+    consecutively from 0. If an item is removed, other items will be
     renumbered.
 
@@ -1579,7 +1628,5 @@
     return stream >> policy.data;
 }
-
-#endif
-
+#endif // QT_NO_DATASTREAM
 
 QT_END_NAMESPACE
