tst_QStringListModel: don't leak memory when tests fail
Simply allocate objects on the stack instead of the heap. Change-Id: Ic047d78e49668878821cce1c8ab599a8551b6476 Reviewed-by: David Faure <david.faure@kdab.com>
This commit is contained in:
parent
b57f743c46
commit
c38ac3dab8
@ -139,22 +139,19 @@ void tst_QStringListModel::rowsAboutToBeRemoved_rowsRemoved()
|
|||||||
QFETCH(QStringList, aboutto);
|
QFETCH(QStringList, aboutto);
|
||||||
QFETCH(QStringList, res);
|
QFETCH(QStringList, res);
|
||||||
|
|
||||||
QStringListModel *model = new QStringListModel(input);
|
QStringListModel model(input);
|
||||||
QModelListener *pListener = new QModelListener(&aboutto, &res, model);
|
QModelListener listener(&aboutto, &res, &model);
|
||||||
pListener->connect(model, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)),
|
connect(&model, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)),
|
||||||
pListener, SLOT(rowsAboutToBeRemovedOrInserted(QModelIndex,int,int)) );
|
&listener, SLOT(rowsAboutToBeRemovedOrInserted(QModelIndex,int,int)));
|
||||||
|
|
||||||
pListener->connect(model, SIGNAL(rowsRemoved(QModelIndex,int,int)),
|
connect(&model, SIGNAL(rowsRemoved(QModelIndex,int,int)),
|
||||||
pListener, SLOT(rowsRemovedOrInserted(QModelIndex,int,int)) );
|
&listener, SLOT(rowsRemovedOrInserted(QModelIndex,int,int)));
|
||||||
|
|
||||||
model->removeRows(row,count);
|
model.removeRows(row, count);
|
||||||
// At this point, control goes to our connected slots inn this order:
|
// At this point, control goes to our connected slots inn this order:
|
||||||
// 1. rowsAboutToBeRemovedOrInserted
|
// 1. rowsAboutToBeRemovedOrInserted
|
||||||
// 2. rowsRemovedOrInserted
|
// 2. rowsRemovedOrInserted
|
||||||
// Control returns here
|
// Control returns here
|
||||||
|
|
||||||
delete pListener;
|
|
||||||
delete model;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QStringListModel::rowsAboutToBeInserted_rowsInserted_data()
|
void tst_QStringListModel::rowsAboutToBeInserted_rowsInserted_data()
|
||||||
@ -203,22 +200,19 @@ void tst_QStringListModel::rowsAboutToBeInserted_rowsInserted()
|
|||||||
QFETCH(QStringList, aboutto);
|
QFETCH(QStringList, aboutto);
|
||||||
QFETCH(QStringList, res);
|
QFETCH(QStringList, res);
|
||||||
|
|
||||||
QStringListModel *model = new QStringListModel(input);
|
QStringListModel model(input);
|
||||||
QModelListener *pListener = new QModelListener(&aboutto, &res, model);
|
QModelListener listener(&aboutto, &res, &model);
|
||||||
connect(model, SIGNAL(rowsAboutToBeInserted(QModelIndex,int,int)),
|
connect(&model, SIGNAL(rowsAboutToBeInserted(QModelIndex,int,int)),
|
||||||
pListener, SLOT(rowsAboutToBeRemovedOrInserted(QModelIndex,int,int)) );
|
&listener, SLOT(rowsAboutToBeRemovedOrInserted(QModelIndex,int,int)));
|
||||||
|
|
||||||
connect(model, SIGNAL(rowsInserted(QModelIndex,int,int)),
|
connect(&model, SIGNAL(rowsInserted(QModelIndex,int,int)),
|
||||||
pListener, SLOT(rowsRemovedOrInserted(QModelIndex,int,int)) );
|
&listener, SLOT(rowsRemovedOrInserted(QModelIndex,int,int)));
|
||||||
|
|
||||||
model->insertRows(row,count);
|
model.insertRows(row, count);
|
||||||
// At this point, control goes to our connected slots inn this order:
|
// At this point, control goes to our connected slots inn this order:
|
||||||
// 1. rowsAboutToBeRemovedOrInserted
|
// 1. rowsAboutToBeRemovedOrInserted
|
||||||
// 2. rowsRemovedOrInserted
|
// 2. rowsRemovedOrInserted
|
||||||
// Control returns here
|
// Control returns here
|
||||||
|
|
||||||
delete pListener;
|
|
||||||
delete model;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QStringListModel::setData_emits_both_roles_data()
|
void tst_QStringListModel::setData_emits_both_roles_data()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user