Suppress C4267 conversion warnings (#13307)

- warning C4267: 'initializing': conversion from 'size_t' to 'int', possible loss of data

Caused by mismatch between size_type of std and Qt containers. It is safe to cast to int as all of those containers hold low number of objects.
This commit is contained in:
Kacper Michajłow 2021-06-11 07:51:06 +02:00 committed by GitHub
parent 6c66d02aff
commit ccb59fbad3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 24 additions and 22 deletions

View file

@ -39,7 +39,7 @@ namespace
QVector<T> loadFromBuffer(const boost::circular_buffer_space_optimized<T> &src, const int offset = 0)
{
QVector<T> ret;
ret.reserve(src.size() - offset);
ret.reserve(static_cast<typename decltype(ret)::size_type>(src.size()) - offset);
std::copy((src.begin() + offset), src.end(), std::back_inserter(ret));
return ret;
}
@ -95,7 +95,7 @@ QVector<Log::Msg> Logger::getMessages(const int lastKnownId) const
const QReadLocker locker(&m_lock);
const int diff = m_msgCounter - lastKnownId - 1;
const int size = m_messages.size();
const int size = static_cast<int>(m_messages.size());
if ((lastKnownId == -1) || (diff >= size))
return loadFromBuffer(m_messages);
@ -111,7 +111,7 @@ QVector<Log::Peer> Logger::getPeers(const int lastKnownId) const
const QReadLocker locker(&m_lock);
const int diff = m_peerCounter - lastKnownId - 1;
const int size = m_peers.size();
const int size = static_cast<int>(m_peers.size());
if ((lastKnownId == -1) || (diff >= size))
return loadFromBuffer(m_peers);