tst_QDnsLookup: don't add duplicate 'nameserver' lines

I don't know why systemd-resolved did have those for me, but it did, so
QtTest complains.

QWARN  : tst_QDnsLookup::setNameserver() Duplicate data tag "..." - please rename.

Change-Id: I8df70eb429682b529ecefffd0aca735f94d77225
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
(cherry picked from commit 1420ee85165c03bac2aa1678b295f7b1ebe44f51)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Thiago Macieira 2024-09-30 09:15:39 -07:00 committed by Qt Cherry-pick Bot
parent c2df419edf
commit 4374f3ce41

View File

@ -128,8 +128,9 @@ static QList<QHostAddress> systemNameservers(QDnsLookup::Protocol protocol)
if (!line.startsWith(command))
continue;
QString addr = QLatin1StringView(line).mid(sizeof(command));
result.emplaceBack(addr);
QHostAddress addr(QLatin1StringView(line).mid(sizeof(command)));
if (!result.contains(addr))
result.emplaceBack(std::move(addr));
}
};
parseFile("/etc/resolv.conf"_L1);