Skip to content

Commit

Permalink
FIX: Warnings due to Qt containers now using qsizetype instead of int…
Browse files Browse the repository at this point in the history
  • Loading branch information
davidebeatrici committed Sep 19, 2024
1 parent c043779 commit ef97a5d
Show file tree
Hide file tree
Showing 38 changed files with 192 additions and 152 deletions.
4 changes: 2 additions & 2 deletions src/ChannelListenerManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,13 @@ const QSet< unsigned int > ChannelListenerManager::getListenedChannelsForUser(un
int ChannelListenerManager::getListenerCountForChannel(unsigned int channelID) const {
QReadLocker lock(&m_listenerLock);

return m_listenedChannels[channelID].size();
return static_cast< int >(m_listenedChannels[channelID].size());
}

int ChannelListenerManager::getListenedChannelCountForUser(unsigned int userSession) const {
QReadLocker lock(&m_listenerLock);

return m_listeningUsers[userSession].size();
return static_cast< int >(m_listeningUsers[userSession].size());
}

void ChannelListenerManager::setListenerVolumeAdjustment(unsigned int userSession, unsigned int channelID,
Expand Down
8 changes: 4 additions & 4 deletions src/Group.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ bool Group::appliesToUser(const Channel &currentChannel, const Channel &aclChann
channel = channel->cParent;
}

int requiredChannelIndex = currentChannelHierarchy.indexOf(contextChannel);
auto requiredChannelIndex = currentChannelHierarchy.indexOf(contextChannel);
Q_ASSERT(requiredChannelIndex != -1);

requiredChannelIndex += requiredChannelOffset;
Expand All @@ -211,10 +211,10 @@ bool Group::appliesToUser(const Channel &currentChannel, const Channel &aclChann
return RET_FALSE;
}

const int minDepth = requiredChannelIndex + minDescendantLevel;
const int maxDepth = requiredChannelIndex + maxDescendantLevel;
const auto minDepth = requiredChannelIndex + minDescendantLevel;
const auto maxDepth = requiredChannelIndex + maxDescendantLevel;

const int totalDepth = homeChannelHierarchy.count() - 1;
const auto totalDepth = homeChannelHierarchy.count() - 1;

matches = (totalDepth >= minDepth) && (totalDepth <= maxDepth);
} else {
Expand Down
4 changes: 2 additions & 2 deletions src/ProcessResolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,14 +154,14 @@ void ProcessResolver::doResolve() {
QByteArray cmdline = f.readAll();
f.close();

int nul = cmdline.indexOf('\0');
const auto nul = cmdline.indexOf('\0');
if (nul != -1) {
cmdline.truncate(nul);
}

QString exe = QString::fromUtf8(cmdline);
if (exe.contains(QLatin1String("\\"))) {
int lastBackslash = exe.lastIndexOf(QLatin1String("\\"));
const auto lastBackslash = exe.lastIndexOf(QLatin1String("\\"));
if (exe.length() > lastBackslash + 1) {
baseName = exe.mid(lastBackslash + 1);
}
Expand Down
14 changes: 9 additions & 5 deletions src/ServerResolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ class ServerResolverPrivate : public QObject {
quint16 m_origPort;

QList< QDnsServiceRecord > m_srvQueue;
QMap< int, int > m_hostInfoIdToIndexMap;
int m_srvQueueRemain;
QMap< qsizetype, qsizetype > m_hostInfoIdToIndexMap;
qsizetype m_srvQueueRemain;

QList< ServerResolverRecord > m_resolved;

Expand Down Expand Up @@ -66,7 +66,7 @@ void ServerResolverPrivate::srvResolved() {
m_srvQueueRemain = m_srvQueue.count();

if (resolver->error() == QDnsLookup::NoError && m_srvQueueRemain > 0) {
for (int i = 0; i < m_srvQueue.count(); i++) {
for (decltype(m_srvQueue.count()) i = 0; i < m_srvQueue.count(); i++) {
QDnsServiceRecord record = m_srvQueue.at(i);
int hostInfoId = QHostInfo::lookupHost(record.target(), this, SLOT(hostResolved(QHostInfo)));
m_hostInfoIdToIndexMap[hostInfoId] = i;
Expand All @@ -79,9 +79,13 @@ void ServerResolverPrivate::srvResolved() {
}

void ServerResolverPrivate::hostResolved(QHostInfo hostInfo) {
int lookupId = hostInfo.lookupId();
int idx = m_hostInfoIdToIndexMap[lookupId];
const int lookupId = hostInfo.lookupId();
const qsizetype idx = m_hostInfoIdToIndexMap[lookupId];
#if QT_VERSION >= 0x060000
QDnsServiceRecord record = m_srvQueue.at(idx);
#else
QDnsServiceRecord record = m_srvQueue.at(static_cast< int >(idx));
#endif

if (hostInfo.error() == QHostInfo::NoError) {
QList< QHostAddress > resolvedAddresses = hostInfo.addresses();
Expand Down
4 changes: 2 additions & 2 deletions src/mumble/ACLEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -790,7 +790,7 @@ void ACLEditor::on_qpbACLUp_clicked() {
if (!as || as->bInherited)
return;

int idx = qlACLs.indexOf(as);
const auto idx = qlACLs.indexOf(as);
if (idx <= numInheritACL + 1)
return;

Expand All @@ -808,7 +808,7 @@ void ACLEditor::on_qpbACLDown_clicked() {
if (!as || as->bInherited)
return;

int idx = qlACLs.indexOf(as) + 1;
const auto idx = qlACLs.indexOf(as) + 1;
if (idx >= qlACLs.count())
return;

Expand Down
16 changes: 8 additions & 8 deletions src/mumble/AudioConfigDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,16 +96,16 @@ QIcon AudioInputDialog::icon() const {
}

void AudioInputDialog::load(const Settings &r) {
int i;
QList< QString > keys;

if (AudioInputRegistrar::qmNew)
keys = AudioInputRegistrar::qmNew->keys();
else
keys.clear();
i = keys.indexOf(AudioInputRegistrar::current);
if (i >= 0)
loadComboBox(qcbSystem, i);

const auto index = keys.indexOf(AudioInputRegistrar::current);
if (index >= 0)
loadComboBox(qcbSystem, static_cast< int >(index));

verifyMicrophonePermission();

Expand Down Expand Up @@ -701,16 +701,16 @@ QString AudioOutputDialog::getCurrentlySelectedOutputInterfaceName() const {
}

void AudioOutputDialog::load(const Settings &r) {
int i;
QList< QString > keys;

if (AudioOutputRegistrar::qmNew)
keys = AudioOutputRegistrar::qmNew->keys();
else
keys.clear();
i = keys.indexOf(AudioOutputRegistrar::current);
if (i >= 0)
loadComboBox(qcbSystem, i);

const auto index = keys.indexOf(AudioOutputRegistrar::current);
if (index >= 0)
loadComboBox(qcbSystem, static_cast< int >(index));

loadCheckBox(qcbExclusive, r.bExclusiveOutput);
loadSlider(qsDelay, r.iOutputDelay);
Expand Down
2 changes: 1 addition & 1 deletion src/mumble/AudioOutputSpeech.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ bool AudioOutputSpeech::prepareSampleBuffer(unsigned int frameCount) {
// packet normally in order to be able to play it.
decodedSamples = opus_decode_float(
opusState, qba.isEmpty() ? nullptr : reinterpret_cast< const unsigned char * >(qba.constData()),
qba.size(), pOut, static_cast< int >(iAudioBufferSize), 0);
static_cast< opus_int32 >(qba.size()), pOut, static_cast< int >(iAudioBufferSize), 0);
} else {
// If the packet is non-empty, but the associated user is locally muted,
// we don't have to decode the packet. Instead it is enough to know how many
Expand Down
7 changes: 3 additions & 4 deletions src/mumble/BanEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ void BanEditor::on_qpbAdd_clicked() {
if (ok) {
qlBans << b;
refreshBanList();
qlwBans->setCurrentRow(qlBans.indexOf(b));
qlwBans->setCurrentRow(static_cast< int >(qlBans.indexOf(b)));
}

qlwBans->setCurrentRow(-1);
Expand All @@ -136,7 +136,7 @@ void BanEditor::on_qpbUpdate_clicked() {
if (ok) {
qlBans.replace(idx, b);
refreshBanList();
qlwBans->setCurrentRow(qlBans.indexOf(b));
qlwBans->setCurrentRow(static_cast< int >(qlBans.indexOf(b)));
}
}
}
Expand Down Expand Up @@ -174,8 +174,7 @@ void BanEditor::refreshBanList() {
qlwBans->addItem(ban.qsUsername);
}

int n = qlBans.count();
setWindowTitle(tr("Ban List - %n Ban(s)", "", n));
setWindowTitle(tr("Ban List - %n Ban(s)", "", static_cast< int >(qlBans.count())));
}

void BanEditor::on_qleSearch_textChanged(const QString &match) {
Expand Down
2 changes: 1 addition & 1 deletion src/mumble/Cert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ Settings::KeyPair CertWizard::importCert(QByteArray data, const QString &pw) {
Settings::KeyPair kp;
int ret = 0;

mem = BIO_new_mem_buf(data.data(), data.size());
mem = BIO_new_mem_buf(data.data(), static_cast< int >(data.size()));
Q_UNUSED(BIO_set_close(mem, BIO_NOCLOSE));
pkcs = d2i_PKCS12_bio(mem, nullptr);
if (pkcs) {
Expand Down
4 changes: 2 additions & 2 deletions src/mumble/ConnectDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -931,12 +931,12 @@ void ConnectDialogEdit::accept() {

// If the user accidentally added a schema or path part, drop it now.
// We can't do so during editing as that is quite jarring.
const int schemaPos = server.indexOf(QLatin1String("://"));
const auto schemaPos = server.indexOf(QLatin1String("://"));
if (schemaPos != -1) {
server.remove(0, schemaPos + 3);
}

const int pathPos = server.indexOf(QLatin1Char('/'));
const auto pathPos = server.indexOf(QLatin1Char('/'));
if (pathPos != -1) {
server.resize(pathPos);
}
Expand Down
10 changes: 5 additions & 5 deletions src/mumble/CustomElements.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -289,11 +289,11 @@ unsigned int ChatbarTextEdit::completeAtCursor() {
target = qlsUsernames.first();
tc.insertText(target);
} else {
bool bBaseIsName = false;
int iend = tc.position();
int istart = toPlainText().lastIndexOf(QLatin1Char(' '), iend - 1) + 1;
QString base = toPlainText().mid(istart, iend - istart);
tc.setPosition(istart);
bool bBaseIsName = false;
const int iend = tc.position();
const auto istart = toPlainText().lastIndexOf(QLatin1Char(' '), iend - 1) + 1;
const QString base = toPlainText().mid(istart, iend - istart);
tc.setPosition(static_cast< int >(istart));
tc.setPosition(iend, QTextCursor::KeepAnchor);

if (qlsUsernames.last() == base) {
Expand Down
4 changes: 2 additions & 2 deletions src/mumble/GlobalShortcut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -964,7 +964,7 @@ void GlobalShortcutEngine::remap() {
sk->gs = gs;

foreach (const QVariant &button, sc.qlButtons) {
int idx = qlButtonList.indexOf(button);
auto idx = qlButtonList.indexOf(button);
if (idx == -1) {
qlButtonList << button;
qlShortcutList << QList< ShortcutKey * >();
Expand Down Expand Up @@ -1037,7 +1037,7 @@ bool GlobalShortcutEngine::handleButton(const QVariant &button, bool down) {
}
}

int idx = qlButtonList.indexOf(button);
const auto idx = qlButtonList.indexOf(button);
if (idx == -1)
return false;

Expand Down
2 changes: 1 addition & 1 deletion src/mumble/GlobalShortcut.h
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ public slots:

struct ShortcutKey {
Shortcut s;
int iNumUp;
qsizetype iNumUp;
GlobalShortcut *gs;
};

Expand Down
3 changes: 2 additions & 1 deletion src/mumble/JackAudio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,8 @@ bool JackAudioSystem::initialize() {
Global::get().s.bJackStartServer ? JackNullOption : JackNoStartServer, &status);
if (!client) {
const auto errors = jackStatusToStringList(status);
qWarning("JackAudioSystem: unable to open client due to %i errors:", errors.count());
qWarning("JackAudioSystem: unable to open client due to %lld errors:",
static_cast< qsizetype >(errors.count()));
for (auto i = 0; i < errors.count(); ++i) {
qWarning("JackAudioSystem: %s", qPrintable(errors.at(i)));
}
Expand Down
2 changes: 1 addition & 1 deletion src/mumble/LCD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ void LCD::updateUserView() {
const int iHeight = size.height();
const int iUsersPerColumn = iHeight / iFontHeight;
const int iSplitterWidth = Global::get().s.iLCDUserViewSplitterWidth;
const int iUserColumns = (entries.count() + iUsersPerColumn - 1) / iUsersPerColumn;
const int iUserColumns = static_cast< int >((entries.count() + iUsersPerColumn - 1) / iUsersPerColumn);

int iColumns = iUserColumns;
int iColumnWidth = 1;
Expand Down
12 changes: 10 additions & 2 deletions src/mumble/Log.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -828,7 +828,7 @@ void Log::log(MsgType mt, const QString &console, const QString &terse, bool own
}

// Message notification with static sounds
int connectedUsers = 0;
qsizetype connectedUsers = 0;
{
QReadLocker lock(&ClientUser::c_qrwlUsers);
connectedUsers = ClientUser::c_qmUsers.size();
Expand Down Expand Up @@ -863,7 +863,7 @@ void Log::log(MsgType mt, const QString &console, const QString &terse, bool own

const QStringList qslAllowed = allowedSchemes();
QRegularExpressionMatch match = identifyURL.match(plain);
int pos = 0;
qsizetype pos = 0;

while (match.hasMatch()) {
QUrl url(match.captured(0).toLower());
Expand All @@ -883,12 +883,20 @@ void Log::log(MsgType mt, const QString &console, const QString &terse, bool own
else
replacement = tr("%1 link").arg(url.scheme());

#if QT_VERSION >= 0x060000
plain.replace(pos, match.capturedLength(), replacement);
#else
plain.replace(static_cast< int >(pos), match.capturedLength(), replacement);
#endif
} else {
pos += match.capturedLength();
}

#if QT_VERSION >= 0x060000
match = identifyURL.match(plain, pos);
#else
match = identifyURL.match(plain, static_cast< int >(pos));
#endif
}

#ifndef USE_NO_TTS
Expand Down
30 changes: 15 additions & 15 deletions src/mumble/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3818,23 +3818,23 @@ void MainWindow::customEvent(QEvent *evt) {
ServerHandlerMessageEvent *shme = static_cast< ServerHandlerMessageEvent * >(evt);

#ifdef QT_NO_DEBUG
# define PROCESS_MUMBLE_TCP_MESSAGE(name, value) \
case Mumble::Protocol::TCPMessageType::name: { \
MumbleProto::name msg; \
if (msg.ParseFromArray(shme->qbaMsg.constData(), shme->qbaMsg.size())) \
msg##name(msg); \
break; \
# define PROCESS_MUMBLE_TCP_MESSAGE(name, value) \
case Mumble::Protocol::TCPMessageType::name: { \
MumbleProto::name msg; \
if (msg.ParseFromArray(shme->qbaMsg.constData(), static_cast< int >(shme->qbaMsg.size()))) \
msg##name(msg); \
break; \
}
#else
# define PROCESS_MUMBLE_TCP_MESSAGE(name, value) \
case Mumble::Protocol::TCPMessageType::name: { \
MumbleProto::name msg; \
if (msg.ParseFromArray(shme->qbaMsg.constData(), shme->qbaMsg.size())) { \
printf("%s:\n", #name); \
msg.PrintDebugString(); \
msg##name(msg); \
} \
break; \
# define PROCESS_MUMBLE_TCP_MESSAGE(name, value) \
case Mumble::Protocol::TCPMessageType::name: { \
MumbleProto::name msg; \
if (msg.ParseFromArray(shme->qbaMsg.constData(), static_cast< int >(shme->qbaMsg.size()))) { \
printf("%s:\n", #name); \
msg.PrintDebugString(); \
msg##name(msg); \
} \
break; \
}
#endif
switch (shme->type) { MUMBLE_ALL_TCP_MESSAGES }
Expand Down
Loading

0 comments on commit ef97a5d

Please sign in to comment.