diff options
author | Liang Qi <liang.qi@qt.io> | 2016-10-11 07:40:32 +0200 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2016-10-11 07:40:32 +0200 |
commit | 905329200f2f3f9372bf07a001371c30c0663684 (patch) | |
tree | e6f072ea693c377ae306b3960f4bde36ee20bc17 /src/widgets/kernel | |
parent | 91cde062968f97041bca8d2a30d13aa03b606c3d (diff) | |
parent | 1a78ef09b93b0a7337075555dc91032f39fab2a9 (diff) |
Merge remote-tracking branch 'origin/5.7' into 5.8
Conflicts:
src/gui/image/qpixmap.cpp
src/widgets/kernel/qformlayout.cpp
Change-Id: I8a8391a202adf7f18464a22ddf0a6c4974eab692
Diffstat (limited to 'src/widgets/kernel')
-rw-r--r-- | src/widgets/kernel/qformlayout.cpp | 15 |
1 files changed, 9 insertions, 6 deletions
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; } } |