forked from osmocom/wireshark
Qt: Fix CredentialsModel::clear()
The last parameter to beginRemoveRows() is the last row index, not the number of rows. The QAbstractItemModel::beginRemoveRows() source code expliticly checks if the value is smaller than row count. Do not emit beginRemoveRows() if the model is empty as it does not make sense and it is impossible to pass the QAbstractItemModel assertions in such case. Emit endRemoveRows() when finished instead of endInsertRows(). Change-Id: I93be4820b1ea0fbb5c0f3cd28edca329b4017814 Reviewed-on: https://code.wireshark.org/review/34318 Petri-Dish: Gerald Combs <gerald@wireshark.org> Tested-by: Petri Dish Buildbot Reviewed-by: Gerald Combs <gerald@wireshark.org>
This commit is contained in:
parent
97a9c7a12e
commit
22b5495485
|
@ -117,14 +117,16 @@ void CredentialsModel::addRecord(tap_credential_t* auth)
|
|||
|
||||
void CredentialsModel::clear()
|
||||
{
|
||||
emit beginRemoveRows(QModelIndex(), 0, rowCount());
|
||||
for (QList<tap_credential_t*>::iterator itr = credentials_.begin(); itr != credentials_.end(); ++itr) {
|
||||
g_free((*itr)->username);
|
||||
g_free((*itr)->info);
|
||||
delete *itr;
|
||||
if (!credentials_.isEmpty()) {
|
||||
emit beginRemoveRows(QModelIndex(), 0, rowCount() - 1);
|
||||
for (QList<tap_credential_t*>::iterator itr = credentials_.begin(); itr != credentials_.end(); ++itr) {
|
||||
g_free((*itr)->username);
|
||||
g_free((*itr)->info);
|
||||
delete *itr;
|
||||
}
|
||||
credentials_.clear();
|
||||
emit endRemoveRows();
|
||||
}
|
||||
credentials_.clear();
|
||||
emit endInsertRows();
|
||||
}
|
||||
|
||||
QVariant CredentialsModel::headerData(int section, Qt::Orientation orientation, int role) const
|
||||
|
|
Loading…
Reference in New Issue