diff options
author | Liang Qi <liang.qi@qt.io> | 2016-10-13 09:49:38 +0200 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2016-10-13 09:49:38 +0200 |
commit | dfc177e3a99dd593db4b1e9445d6243ce75ebf07 (patch) | |
tree | 4e33c7be90a44642e672fff22ea163b500ff3aef /src/widgets/kernel | |
parent | 72efb2e6f4af2fd909daaf9104f09fd1425acfb0 (diff) | |
parent | 1d6eb70dcec105af28d6a5e9b59d56c895c70389 (diff) |
Merge remote-tracking branch 'origin/5.8' into dev
Conflicts:
qmake/library/qmakeevaluator.cpp
(cherry picked from commit 1af6dc2c8fb4d91400fddc5050166f972ae57c9a in qttools)
src/corelib/kernel/qcore_mac_objc.mm
src/gui/painting/qcolor.h
src/plugins/platforms/cocoa/qcocoawindow.mm
Change-Id: I5b3ec468a5a9a73911b528d3d24ff8e19f339f31
Diffstat (limited to 'src/widgets/kernel')
-rw-r--r-- | src/widgets/kernel/qapplication.cpp | 6 | ||||
-rw-r--r-- | src/widgets/kernel/qformlayout.cpp | 15 | ||||
-rw-r--r-- | src/widgets/kernel/qlayoutitem.cpp | 14 |
3 files changed, 24 insertions, 11 deletions
diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index 815ae7fe33..b94aa826d3 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -608,7 +608,7 @@ void qt_init_tooltip_palette() #endif } -#ifndef QT_NO_STATEMACHINE +#if QT_CONFIG(statemachine) void qRegisterGuiStateMachine(); void qUnregisterGuiStateMachine(); #endif @@ -634,7 +634,7 @@ void QApplicationPrivate::initialize() if (application_type != QApplicationPrivate::Tty) (void) QApplication::style(); // trigger creation of application style -#ifndef QT_NO_STATEMACHINE +#if QT_CONFIG(statemachine) // trigger registering of QStateMachine's GUI types qRegisterGuiStateMachine(); #endif @@ -862,7 +862,7 @@ QApplication::~QApplication() QApplicationPrivate::enabledAnimations = QPlatformTheme::GeneralUiEffect; QApplicationPrivate::widgetCount = false; -#ifndef QT_NO_STATEMACHINE +#if QT_CONFIG(statemachine) // trigger unregistering of QStateMachine's GUI types qUnregisterGuiStateMachine(); #endif diff --git a/src/widgets/kernel/qformlayout.cpp b/src/widgets/kernel/qformlayout.cpp index 73e82c577c..3e60723f17 100644 --- a/src/widgets/kernel/qformlayout.cpp +++ b/src/widgets/kernel/qformlayout.cpp @@ -165,7 +165,7 @@ public: int insertRow(int row); void insertRows(int row, int count); void removeRow(int row); - void setItem(int row, QFormLayout::ItemRole role, QLayoutItem *item); + bool setItem(int row, QFormLayout::ItemRole role, QLayoutItem *item); void setLayout(int row, QFormLayout::ItemRole role, QLayout *layout); void setWidget(int row, QFormLayout::ItemRole role, QWidget *widget); @@ -933,21 +933,21 @@ void QFormLayoutPrivate::removeRow(int row) m_matrix.removeRow(row); } -void QFormLayoutPrivate::setItem(int row, QFormLayout::ItemRole role, QLayoutItem *item) +bool QFormLayoutPrivate::setItem(int row, QFormLayout::ItemRole role, QLayoutItem *item) { const bool fullRow = role == QFormLayout::SpanningRole; const int column = role == QFormLayout::SpanningRole ? 1 : static_cast<int>(role); if (Q_UNLIKELY(uint(row) >= uint(m_matrix.rowCount()) || uint(column) > 1U)) { qWarning("QFormLayoutPrivate::setItem: Invalid cell (%d, %d)", row, column); - return; + return false; } if (!item) - return; + return false; if (Q_UNLIKELY(m_matrix(row, column))) { qWarning("QFormLayoutPrivate::setItem: Cell (%d, %d) already occupied", row, column); - return; + return false; } QFormLayoutItem *i = new QFormLayoutItem(item); @@ -955,6 +955,7 @@ void QFormLayoutPrivate::setItem(int row, QFormLayout::ItemRole role, QLayoutIte m_matrix(row, column) = i; m_things.append(i); + return true; } void QFormLayoutPrivate::setLayout(int row, QFormLayout::ItemRole role, QLayout *layout) @@ -971,7 +972,9 @@ void QFormLayoutPrivate::setWidget(int row, QFormLayout::ItemRole role, QWidget if (widget) { Q_Q(QFormLayout); q->addChildWidget(widget); - setItem(row, role, QLayoutPrivate::createWidgetItem(q, widget)); + QWidgetItem *item = QLayoutPrivate::createWidgetItem(q, widget); + if (!setItem(row, role, item)) + delete item; } } diff --git a/src/widgets/kernel/qlayoutitem.cpp b/src/widgets/kernel/qlayoutitem.cpp index 76568a2c33..ee0c28ec76 100644 --- a/src/widgets/kernel/qlayoutitem.cpp +++ b/src/widgets/kernel/qlayoutitem.cpp @@ -306,6 +306,8 @@ void QLayoutItem::invalidate() /*! If this item is a QLayout, it is returned as a QLayout; otherwise 0 is returned. This function provides type-safe casting. + + \sa spacerItem(), widget() */ QLayout * QLayoutItem::layout() { @@ -315,6 +317,8 @@ QLayout * QLayoutItem::layout() /*! If this item is a QSpacerItem, it is returned as a QSpacerItem; otherwise 0 is returned. This function provides type-safe casting. + + \sa layout(), widget() */ QSpacerItem * QLayoutItem::spacerItem() { @@ -345,8 +349,14 @@ QSpacerItem * QSpacerItem::spacerItem() */ /*! - If this item is a QWidget, it is returned as a QWidget; otherwise - 0 is returned. This function provides type-safe casting. + If this item manages a QWidget, returns that widget. Otherwise, + \c nullptr is returned. + + \note While the functions layout() and spacerItem() perform casts, this + function returns another object: QLayout and QSpacerItem inherit QLayoutItem, + while QWidget does not. + + \sa layout(), spacerItem() */ QWidget * QLayoutItem::widget() { |