Skip to content

Commit

Permalink
Fix -Wclazy-strict-iterators
Browse files Browse the repository at this point in the history
  • Loading branch information
daschuer authored Jun 21, 2023
1 parent 0a50a49 commit 08123bc
Show file tree
Hide file tree
Showing 12 changed files with 31 additions and 31 deletions.
6 changes: 3 additions & 3 deletions src/control/control.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,8 @@ QSharedPointer<ControlDoublePrivate> ControlDoublePrivate::getControl(
// Scope for MMutexLocker.
{
const MMutexLocker locker(&s_qCOHashMutex);
const auto it = s_qCOHash.find(key);
if (it != s_qCOHash.end()) {
const auto it = s_qCOHash.constFind(key);
if (it != s_qCOHash.constEnd()) {
auto pControl = it.value().lock();
if (pControl) {
// Control object already exists
Expand Down Expand Up @@ -213,7 +213,7 @@ QList<QSharedPointer<ControlDoublePrivate>> ControlDoublePrivate::getAllInstance
QList<QSharedPointer<ControlDoublePrivate>> result;
MMutexLocker locker(&s_qCOHashMutex);
result.reserve(s_qCOHash.size());
for (auto it = s_qCOHash.begin(); it != s_qCOHash.end(); ++it) {
for (auto it = s_qCOHash.constBegin(); it != s_qCOHash.constEnd(); ++it) {
auto pControl = it.value().lock();
if (pControl) {
result.append(std::move(pControl));
Expand Down
4 changes: 2 additions & 2 deletions src/controllers/midi/midicontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -307,8 +307,8 @@ void MidiController::processInputMapping(const MidiInputMapping& mapping,

if (mapping_is_14bit) {
bool found = false;
for (auto it = m_fourteen_bit_queued_mappings.begin();
it != m_fourteen_bit_queued_mappings.end(); ++it) {
for (auto it = m_fourteen_bit_queued_mappings.constBegin();
it != m_fourteen_bit_queued_mappings.constEnd(); ++it) {
if (it->first.control == mapping.control) {
if ((it->first.options & mapping.options) &
(MidiOption::FourteenBitLSB | MidiOption::FourteenBitMSB)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ ControllerScriptInterfaceLegacy::~ControllerScriptInterfaceLegacy() {

// Free all the ControlObjectScripts
{
auto it = m_controlCache.begin();
while (it != m_controlCache.end()) {
auto it = m_controlCache.constBegin();
while (it != m_controlCache.constEnd()) {
qCDebug(m_logger)
<< "Deleting ControlObjectScript"
<< it.key().group
Expand Down
6 changes: 3 additions & 3 deletions src/effects/effectsmessenger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,15 @@ void EffectsMessenger::processEffectsResponses() {
EffectsResponse response;
while (m_pRequestPipe->readMessage(&response)) {
QHash<qint64, EffectsRequest*>::iterator it =
m_activeRequests.find(response.request_id);
m_activeRequests.constFind(response.request_id);

VERIFY_OR_DEBUG_ASSERT(it != m_activeRequests.end()) {
VERIFY_OR_DEBUG_ASSERT(it != m_activeRequests.constEnd()) {
qWarning() << debugString()
<< "WARNING: EffectsResponse with an inactive request_id:"
<< response.request_id;
}

while (it != m_activeRequests.end() &&
while (it != m_activeRequests.constEnd() &&
it.key() == response.request_id) {
EffectsRequest* pRequest = it.value();

Expand Down
4 changes: 2 additions & 2 deletions src/engine/controls/loopingcontrol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1236,8 +1236,8 @@ void LoopingControl::slotBeatLoopDeactivateRoll(BeatLoopingControl* pBeatLoopCon
// and QVector::iterator is a pointer type in Qt5, but QStack inherits
// from QList in Qt6 so QStack::iterator is not a pointer type in Qt6.
// NOLINTNEXTLINE(readability-qualified-auto)
auto i = m_activeLoopRolls.begin();
while (i != m_activeLoopRolls.end()) {
auto i = m_activeLoopRolls.constBegin();
while (i != m_activeLoopRolls.constEnd()) {
if (size == *i) {
i = m_activeLoopRolls.erase(i);
} else {
Expand Down
4 changes: 2 additions & 2 deletions src/library/coverartdelegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ void CoverArtDelegate::emitRowsChanged(
return;
}
// Sort in ascending order...
std::sort(rows.begin(), rows.end());
std::sort(rows.constBegin(), rows.constEnd());
// ...and then deduplicate...
rows.erase(std::unique(rows.begin(), rows.end()), rows.end());
rows.erase(std::unique(rows.constBegin(), rows.constEnd()), rows.constEnd());
// ...before emitting the signal.
DEBUG_ASSERT(!rows.isEmpty());
emit rowsChanged(std::move(rows));
Expand Down
4 changes: 2 additions & 2 deletions src/library/dao/playlistdao.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,8 @@ void PlaylistDAO::deletePlaylist(const int playlistId) {
transaction.commit();
//TODO: Crap, we need to shuffle the positions of all the playlists?

for (QMultiHash<TrackId, int>::iterator it = m_playlistsTrackIsIn.begin();
it != m_playlistsTrackIsIn.end();) {
for (QMultiHash<TrackId, int>::iterator it = m_playlistsTrackIsIn.constBegin();
it != m_playlistsTrackIsIn.constEnd();) {
if (it.value() == playlistId) {
it = m_playlistsTrackIsIn.erase(it);
} else {
Expand Down
4 changes: 2 additions & 2 deletions src/library/treeitem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,6 @@ void TreeItem::removeChildren(int row, int count) {
DEBUG_ASSERT(count <= m_children.size());
DEBUG_ASSERT(row >= 0);
DEBUG_ASSERT(row <= (m_children.size() - count));
qDeleteAll(m_children.begin() + row, m_children.begin() + (row + count));
m_children.erase(m_children.begin() + row, m_children.begin() + (row + count));
qDeleteAll(m_children.constBegin() + row, m_children.constBegin() + (row + count));
m_children.erase(m_children.constBegin() + row, m_children.constBegin() + (row + count));
}
2 changes: 1 addition & 1 deletion src/preferences/broadcastsettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ void BroadcastSettings::applyModel(BroadcastSettingsModel* pModel) {
// TODO(Palakis): lock both lists against modifications while syncing

// Step 1: find profiles to delete from the settings
for (auto profileIter = m_profiles.begin(); profileIter != m_profiles.end();) {
for (auto profileIter = m_profiles.constBegin(); profileIter != m_profiles.constEnd();) {
QString profileName = (*profileIter)->getProfileName();
if (!pModel->getProfileByName(profileName)) {
// If profile exists in settings but not in the model,
Expand Down
10 changes: 5 additions & 5 deletions src/preferences/colorpaletteeditormodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,12 @@ bool ColorPaletteEditorModel::setData(const QModelIndex& modelIndex, const QVari
auto hotcueIndexList = pHotcueIndexListItem->getHotcueIndexList();

// make sure no index is outside of range
DEBUG_ASSERT(std::is_sorted(hotcueIndexList.cbegin(), hotcueIndexList.cend()));
DEBUG_ASSERT(std::is_sorted(hotcueIndexList.constBegin(), hotcueIndexList.constEnd()));
auto endUpper = std::upper_bound(
hotcueIndexList.begin(), hotcueIndexList.end(), NUM_HOT_CUES);
hotcueIndexList.erase(endUpper, hotcueIndexList.end());
auto endLower = std::upper_bound(hotcueIndexList.begin(), hotcueIndexList.end(), 0);
hotcueIndexList.erase(hotcueIndexList.begin(), endLower);
hotcueIndexList.constBegin(), hotcueIndexList.constEnd(), NUM_HOT_CUES);
hotcueIndexList.erase(endUpper, hotcueIndexList.constEnd());
auto endLower = std::upper_bound(hotcueIndexList.constBegin(), hotcueIndexList.constEnd(), 0);
hotcueIndexList.erase(hotcueIndexList.constBegin(), endLower);

for (int i = 0; i < rowCount(); ++i) {
auto* pHotcueIndexListItem = toHotcueIndexListItem(item(i, 1));
Expand Down
8 changes: 4 additions & 4 deletions src/sources/soundsourceproviderregistry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ void insertRegistration(
QList<SoundSourceProviderRegistration>* pRegistrations,
SoundSourceProviderRegistration&& registration) {
DEBUG_ASSERT(pRegistrations);
QList<SoundSourceProviderRegistration>::iterator listIter(
pRegistrations->begin());
QList<SoundSourceProviderRegistration>::iterator listIter =
pRegistrations->constBegin();
// Perform a linear search through the list & insert
while (pRegistrations->end() != listIter) {
while (pRegistrations->constEnd() != listIter) {
// Priority comparison with <=: New registrations will be inserted
// before existing registrations with equal priority, but after
// existing registrations with higher priority.
if (listIter->getProviderPriority() <= registration.getProviderPriority()) {
listIter = pRegistrations->insert(listIter, std::move(registration));
DEBUG_ASSERT(pRegistrations->end() != listIter);
DEBUG_ASSERT(pRegistrations->constEnd() != listIter);
return; // done
} else {
++listIter; // continue loop
Expand Down
6 changes: 3 additions & 3 deletions src/util/rangelist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ QList<int> parseRangeList(const QString& input) {
}
}

std::sort(intList.begin(), intList.end());
const auto end = std::unique(intList.begin(), intList.end());
intList.erase(end, intList.end());
std::sort(intList.constBegin(), intList.constEnd());
const auto end = std::unique(intList.constBegin(), intList.constEnd());
intList.erase(end, intList.constEnd());

return intList;
}
Expand Down

0 comments on commit 08123bc

Please sign in to comment.