Skip to content
This repository has been archived by the owner on Feb 12, 2023. It is now read-only.

Commit

Permalink
fix(import): don't use java-style iterator before first element
Browse files Browse the repository at this point in the history
Fix #4962
  • Loading branch information
anthonybilinski committed Mar 21, 2018
1 parent 4951f90 commit acea7c3
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/widget/form/addfriendform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,17 +245,19 @@ void AddFriendForm::onImportOpenClicked()
}

contactsToImport = QString::fromUtf8(contactFile.readAll()).split('\n');
QMutableListIterator<QString> it(contactsToImport);
qDebug() << "Import list:";
while (it.hasNext()) {
const QString id = it.value().trimmed();
const bool valid = !id.isEmpty() && checkIsValidId(id);
if (valid) {
it.value() = id;
for (auto it = contactsToImport.begin(); it != contactsToImport.end();) {
const QString id = it->trimmed();
if (checkIsValidId(id)) {
*it = id;
qDebug() << *it;
++it;
} else {
it.remove();
if (!id.isEmpty()) {
qDebug() << "Invalid ID:" << *it;
}
it = contactsToImport.erase(it);
}
qDebug() << it.next();
}

if (contactsToImport.isEmpty()) {
Expand Down

0 comments on commit acea7c3

Please sign in to comment.