summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/gui/graphicsview/qgraphicsgridlayout.cpp2
-rw-r--r--src/gui/graphicsview/qgridlayoutengine.cpp4
-rw-r--r--tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp13
3 files changed, 14 insertions, 5 deletions
diff --git a/src/gui/graphicsview/qgraphicsgridlayout.cpp b/src/gui/graphicsview/qgraphicsgridlayout.cpp
index 2660b06..8a3f17a 100644
--- a/src/gui/graphicsview/qgraphicsgridlayout.cpp
+++ b/src/gui/graphicsview/qgraphicsgridlayout.cpp
@@ -589,7 +589,7 @@ void QGraphicsGridLayout::removeAt(int index)
}
/*!
- Removes the layout item \a item without destroying it.
+ Removes the layout item \a item without destroying it.
Ownership of the item is transferred to the caller.
\sa addItem()
diff --git a/src/gui/graphicsview/qgridlayoutengine.cpp b/src/gui/graphicsview/qgridlayoutengine.cpp
index f68df73..8b65282 100644
--- a/src/gui/graphicsview/qgridlayoutengine.cpp
+++ b/src/gui/graphicsview/qgridlayoutengine.cpp
@@ -777,8 +777,8 @@ QGridLayoutItem *QGridLayoutEngine::itemAt(int index) const
int QGridLayoutEngine::indexOf(QGraphicsLayoutItem *item) const
{
- for(int i = 0; i < q_items.size(); ++i) {
- if(item == q_items.at(i)->layoutItem())
+ for (int i = 0; i < q_items.size(); ++i) {
+ if (item == q_items.at(i)->layoutItem())
return i;
}
return -1;
diff --git a/tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp b/tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp
index 123dd89..55d75af 100644
--- a/tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp
+++ b/tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp
@@ -78,7 +78,7 @@ private slots:
void horizontalSpacing();
void itemAt();
void removeAt();
- void removeLayoutItems();
+ void removeItem();
void rowAlignment();
void rowCount();
void rowMaximumHeight();
@@ -993,7 +993,7 @@ void tst_QGraphicsGridLayout::removeAt()
delete widget;
}
-void tst_QGraphicsGridLayout::removeLayoutItems()
+void tst_QGraphicsGridLayout::removeItem()
{
QGraphicsScene scene;
QGraphicsView view(&scene);
@@ -1008,6 +1008,15 @@ void tst_QGraphicsGridLayout::removeLayoutItems()
l->removeItem(l->itemAt(5));
l->removeItem(l->itemAt(4));
QCOMPARE(l->count(), 4);
+
+ // Avoid crashing. Note that the warning message might change in the future.
+ QTest::ignoreMessage(QtWarningMsg, QString::fromAscii("QGraphicsGridLayout::removeAt: invalid index -1").toLatin1().constData());
+ l->removeItem(0);
+ QCOMPARE(l->count(), 4);
+
+ QTest::ignoreMessage(QtWarningMsg, QString::fromAscii("QGraphicsGridLayout::removeAt: invalid index -1").toLatin1().constData());
+ l->removeItem(new QGraphicsWidget);
+ QCOMPARE(l->count(), 4);
}
// public Qt::Alignment rowAlignment(int row) const