mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
fix(import): don't use java-style iterator before first element
Fix #4962
This commit is contained in:
parent
4951f90964
commit
acea7c315f
|
@ -245,17 +245,19 @@ void AddFriendForm::onImportOpenClicked()
|
||||||
}
|
}
|
||||||
|
|
||||||
contactsToImport = QString::fromUtf8(contactFile.readAll()).split('\n');
|
contactsToImport = QString::fromUtf8(contactFile.readAll()).split('\n');
|
||||||
QMutableListIterator<QString> it(contactsToImport);
|
|
||||||
qDebug() << "Import list:";
|
qDebug() << "Import list:";
|
||||||
while (it.hasNext()) {
|
for (auto it = contactsToImport.begin(); it != contactsToImport.end();) {
|
||||||
const QString id = it.value().trimmed();
|
const QString id = it->trimmed();
|
||||||
const bool valid = !id.isEmpty() && checkIsValidId(id);
|
if (checkIsValidId(id)) {
|
||||||
if (valid) {
|
*it = id;
|
||||||
it.value() = id;
|
qDebug() << *it;
|
||||||
|
++it;
|
||||||
} else {
|
} else {
|
||||||
it.remove();
|
if (!id.isEmpty()) {
|
||||||
|
qDebug() << "Invalid ID:" << *it;
|
||||||
|
}
|
||||||
|
it = contactsToImport.erase(it);
|
||||||
}
|
}
|
||||||
qDebug() << it.next();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (contactsToImport.isEmpty()) {
|
if (contactsToImport.isEmpty()) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user