diff options
author | Jan Arve Saether <jan-arve.saether@theqtcompany.com> | 2015-02-06 14:47:16 +0100 |
---|---|---|
committer | Jan Arve Sæther <jan-arve.saether@theqtcompany.com> | 2015-02-09 21:10:31 +0000 |
commit | 3ab6653d97a5dd01fd5f5cb4e52d5816274e4cbd (patch) | |
tree | fc94f2cc49a23fedd9571a0e785458d4e8c3d78d /tests | |
parent | e67ebe8ba4f59a4554a47fa26e9c374b1022d36f (diff) | |
download | qtbase-3ab6653d97a5dd01fd5f5cb4e52d5816274e4cbd.tar.gz |
Fixed crash when adding items with spans
This only occurred if the item added was the only item in the last
row/column, since then the the internal grid failed to expand
(in this case it would always call expand(0, 0), which would not
create the extra row/column).
[ChangeLog][QtWidgets][QGridLayout] Fixed crash that sometimes happened
when adding items with spans that spanned to the bottom/right edge.
Task-number: QTBUG-38052
Change-Id: Iba95f6d9d9356b4d1c84c7b93f4af9b4ea0cf714
Reviewed-by: Paul Olav Tvete <paul.tvete@theqtcompany.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/widgets/kernel/qgridlayout/tst_qgridlayout.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/auto/widgets/kernel/qgridlayout/tst_qgridlayout.cpp b/tests/auto/widgets/kernel/qgridlayout/tst_qgridlayout.cpp index 004b3b1731..046d6e032f 100644 --- a/tests/auto/widgets/kernel/qgridlayout/tst_qgridlayout.cpp +++ b/tests/auto/widgets/kernel/qgridlayout/tst_qgridlayout.cpp @@ -96,6 +96,7 @@ private slots: void taskQTBUG_40609_addingWidgetToItsOwnLayout(); void taskQTBUG_40609_addingLayoutToItself(); void replaceWidget(); + void dontCrashWhenExtendsToEnd(); private: QWidget *testWidget; @@ -1728,5 +1729,22 @@ void tst_QGridLayout::replaceWidget() } } +void tst_QGridLayout::dontCrashWhenExtendsToEnd() +{ + QWidget window; + window.resize(320,200); + QWidget parent(&window); + QLabel *lbl0 = new QLabel(QLatin1String("lbl0:")); + QLabel *lbl1 = new QLabel(QLatin1String("lbl1:")); + QPushButton *pb = new QPushButton(QLatin1String("pb1")); + QGridLayout *l = new QGridLayout(&parent); + l->addWidget(lbl0, 0, 0); + l->addWidget(lbl1, 1, 0); + // adding an item in the bottom right corner than spans to the end (!)... + l->addWidget(pb, 1, 1, -1, -1); + // ...should not cause a crash when the items are distributed.... + l->setGeometry(QRect(0, 0, 200, 50)); // DONT CRASH HERE +} + QTEST_MAIN(tst_QGridLayout) #include "tst_qgridlayout.moc" |