mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-08-13 04:55:44 +08:00
refs #937 Resolved clazy warnings: unnecessary detaching of containers.
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
|
||||
#include "expect.h"
|
||||
#include "blackmisc/range.h"
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QEventLoop>
|
||||
@@ -81,7 +82,8 @@ void Expect::wait(const SourceLocation& srcloc, int timeout)
|
||||
{
|
||||
i->onDone([&](const ExpectUnit* u){ unitsCopy.remove(u); });
|
||||
}
|
||||
for (auto i : unitsCopy.toList()) // toList is an easy way to make a temporary copy, needed because init might invalidate iterators
|
||||
// toList is an easy way to make a temporary copy, needed because init might invalidate iterators
|
||||
for (auto i : unitsCopy.toList()) // clazy:exclude=container-anti-pattern,range-loop
|
||||
{
|
||||
i->init();
|
||||
}
|
||||
@@ -90,7 +92,7 @@ void Expect::wait(const SourceLocation& srcloc, int timeout)
|
||||
timer.setSingleShot(true);
|
||||
QObject::connect(&timer, &QTimer::timeout, [=, &unitsCopy]{
|
||||
reportTimeout(srcloc, unitsCopy);
|
||||
for (auto i : unitsCopy)
|
||||
for (auto i : BlackMisc::as_const(unitsCopy))
|
||||
{
|
||||
i->onDone(nullptr); //paranoia
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ namespace BlackCoreTest
|
||||
ConnectGuard &operator+= (const QMetaObject::Connection &conn) { m_conns += conn; return *this; }
|
||||
|
||||
//! Disconnect and remove all stored connections.
|
||||
void cleanup() { for (auto i = m_conns.begin(); i != m_conns.end(); ++i) QObject::disconnect(*i); m_conns.clear(); }
|
||||
void cleanup() { for (auto i = m_conns.cbegin(); i != m_conns.cend(); ++i) QObject::disconnect(*i); m_conns.clear(); }
|
||||
|
||||
//! Copying is only allowed when there are no connections stored.
|
||||
//! @{
|
||||
|
||||
Reference in New Issue
Block a user