fix invalid pointer return with QGridLayout::itemAt(-1)

upstream commit:
c47bb4478a

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2021-09-10 19:37:24 +03:00
parent 0671458656
commit 4d725af061
2 changed files with 7 additions and 8 deletions

2
README
View file

@ -87,7 +87,7 @@ QTBUG-12564, QTBUG-20028, QTBUG-71967, QTBUG-70956, QTBUG-71446, QTBUG-61307,
QTBUG-27287, QTBUG-25143, QTBUG-22833, QTBUG-57399, QTBUG-59159, QTBUG-15773,
QTBUG-70506, QTBUG-46054, QTBUG-11223, QTBUG-63108, QTBUG-6932, QTBUG-42365,
QTBUG-83817, QTBUG-4341, QTBUG-36933, QTBUG-49113, QTBUG-69920, QTBUG-40015,
QTBUG-54942
QTBUG-54942, QTBUG-91261
Unless you use QMake and QDoc porting to Katie or even supporting it along with
Qt4 in the same codebase is trivial and requires only minor changes because

View file

@ -130,30 +130,29 @@ public:
QRect cellRect(int row, int col) const;
inline QLayoutItem *itemAt(int index) const {
if (index < things.count())
if (index >= 0 && index < things.count())
return things.at(index)->item();
else
return 0;
return nullptr;
}
inline QLayoutItem *takeAt(int index) {
Q_Q(QGridLayout);
if (index < things.count()) {
if (index >= 0 && index < things.count()) {
if (QGridBox *b = things.takeAt(index)) {
QLayoutItem *item = b->takeItem();
if (QLayout *l = item->layout()) {
// sanity check in case the user passed something weird to QObject::setParent()
if (l->parent() == q)
l->setParent(0);
l->setParent(nullptr);
}
delete b;
return item;
}
}
return 0;
return nullptr;
}
void getItemPosition(int index, int *row, int *column, int *rowSpan, int *columnSpan) {
if (index < things.count()) {
if (index >= 0 && index < things.count()) {
QGridBox *b = things.at(index);
int toRow = b->toRow(rr);
int toCol = b->toCol(cc);