Skip to content

Commit

Permalink
Merge remote-tracking branch 'daschauer/qt6-build-checks-fix'
Browse files Browse the repository at this point in the history
  • Loading branch information
Swiftb0y committed Aug 20, 2023
2 parents b9df1ff + 86bfbe5 commit 643e366
Show file tree
Hide file tree
Showing 19 changed files with 168 additions and 90 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
12 changes: 7 additions & 5 deletions src/controllers/midi/midicontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "errordialoghandler.h"
#include "mixer/playermanager.h"
#include "moc_midicontroller.cpp"
#include "util/make_const_iterator.h"
#include "util/math.h"
#include "util/screensaver.h"

Expand Down Expand Up @@ -279,7 +280,7 @@ void MidiController::processInputMapping(const MidiInputMapping& mapping,
status,
mapping.control.group,
};
if (!pEngine->executeFunction(function, args)) {
if (!pEngine->executeFunction(&function, args)) {
qCWarning(m_logBase) << "MidiController: Invalid script function"
<< mapping.control.item;
}
Expand Down Expand Up @@ -307,16 +308,17 @@ 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)) {
qCWarning(m_logBase)
<< "MidiController: 14-bit MIDI mapping has "
"mis-matched LSB/MSB options."
<< "Ignoring both messages.";
m_fourteen_bit_queued_mappings.erase(it);
constErase(&m_fourteen_bit_queued_mappings, it);
return;
}

Expand All @@ -343,7 +345,7 @@ void MidiController::processInputMapping(const MidiInputMapping& mapping,
newValue = math_min(newValue, 127.0);

// Erase the queued message since we processed it.
m_fourteen_bit_queued_mappings.erase(it);
constErase(&m_fourteen_bit_queued_mappings, it);

found = true;
break;
Expand Down
12 changes: 6 additions & 6 deletions src/controllers/scripting/controllerscriptenginebase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,28 +70,28 @@ void ControllerScriptEngineBase::reload() {
}

bool ControllerScriptEngineBase::executeFunction(
QJSValue functionObject, const QJSValueList& args) {
QJSValue* pFunctionObject, const QJSValueList& args) {
// This function is called from outside the controller engine, so we can't
// use VERIFY_OR_DEBUG_ASSERT here
if (!m_pJSEngine) {
return false;
}

if (functionObject.isError()) {
if (pFunctionObject->isError()) {
qDebug() << "ControllerScriptHandlerBase::executeFunction:"
<< functionObject.toString();
<< pFunctionObject->toString();
return false;
}

// If it's not a function, we're done.
if (!functionObject.isCallable()) {
if (!pFunctionObject->isCallable()) {
qDebug() << "ControllerScriptHandlerBase::executeFunction:"
<< functionObject.toVariant() << "Not a function";
<< pFunctionObject->toVariant() << "Not a function";
return false;
}

// If it does happen to be a function, call it.
QJSValue returnValue = functionObject.call(args);
QJSValue returnValue = pFunctionObject->call(args);
if (returnValue.isError()) {
showScriptExceptionDialog(returnValue);
return false;
Expand Down
2 changes: 1 addition & 1 deletion src/controllers/scripting/controllerscriptenginebase.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class ControllerScriptEngineBase : public QObject {

virtual bool initialize();

bool executeFunction(QJSValue functionObject, const QJSValueList& arguments = {});
bool executeFunction(QJSValue* pFunctionObject, const QJSValueList& arguments = {});

/// Shows a UI dialog notifying of a script evaluation error.
/// Precondition: QJSValue.isError() == true
Expand Down
4 changes: 2 additions & 2 deletions src/controllers/scripting/controllerscriptmoduleengine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ bool ControllerScriptModuleEngine::initialize() {
}

QJSValue initFunction = mod.property("init");
if (!executeFunction(initFunction)) {
if (!executeFunction(&initFunction)) {
shutdown();
return false;
}
Expand All @@ -47,6 +47,6 @@ bool ControllerScriptModuleEngine::initialize() {
}

void ControllerScriptModuleEngine::shutdown() {
executeFunction(m_shutdownFunction);
executeFunction(&m_shutdownFunction);
ControllerScriptEngineBase::shutdown();
}
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,8 @@ bool ControllerScriptEngineLegacy::handleIncomingData(const QByteArray& data) {
static_cast<uint>(data.size()),
};

for (const QJSValue& function : std::as_const(m_incomingDataFunctions)) {
ControllerScriptEngineBase::executeFunction(function, args);
for (auto&& function : m_incomingDataFunctions) {
ControllerScriptEngineBase::executeFunction(&function, args);
}

return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "mixer/playermanager.h"
#include "moc_controllerscriptinterfacelegacy.cpp"
#include "util/fpclassify.h"
#include "util/make_const_iterator.h"
#include "util/time.h"

#define SCRATCH_DEBUG_OUTPUT false
Expand Down Expand Up @@ -77,15 +78,15 @@ 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
<< it.key().item;
delete it.value();
// Advance iterator
it = m_controlCache.erase(it);
it = constErase(&m_controlCache, it);
}
}
}
Expand Down Expand Up @@ -540,12 +541,12 @@ void ControllerScriptInterfaceLegacy::timerEvent(QTimerEvent* event) {
// why but this causes segfaults in ~QScriptValue while scratching if we
// don't copy here -- even though internalExecute passes the QScriptValues
// by value. *boggle*
const TimerInfo timerTarget = it.value();
TimerInfo timerTarget = it.value();
if (timerTarget.oneShot) {
stopTimer(timerId);
}

m_pScriptEngineLegacy->executeFunction(timerTarget.callback);
m_pScriptEngineLegacy->executeFunction(&timerTarget.callback);
}

void ControllerScriptInterfaceLegacy::softTakeover(
Expand Down
10 changes: 5 additions & 5 deletions src/effects/effectsmessenger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include "engine/effects/engineeffect.h"
#include "engine/effects/engineeffectchain.h"
#include "util/make_const_iterator.h"

EffectsMessenger::EffectsMessenger(
std::unique_ptr<EffectsRequestPipe> pRequestPipe)
Expand Down Expand Up @@ -53,16 +54,15 @@ void EffectsMessenger::processEffectsResponses() {

EffectsResponse response;
while (m_pRequestPipe->readMessage(&response)) {
QHash<qint64, EffectsRequest*>::iterator it =
m_activeRequests.find(response.request_id);
auto it = 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 All @@ -73,7 +73,7 @@ void EffectsMessenger::processEffectsResponses() {
collectGarbage(pRequest);

delete pRequest;
it = m_activeRequests.erase(it);
it = constErase(&m_activeRequests, it);
}
}
}
Expand Down
7 changes: 4 additions & 3 deletions src/engine/controls/loopingcontrol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "preferences/usersettings.h"
#include "track/track.h"
#include "util/compatibility/qatomic.h"
#include "util/make_const_iterator.h"
#include "util/math.h"
#include "util/sample.h"

Expand Down Expand Up @@ -1256,10 +1257,10 @@ 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);
i = constErase(&m_activeLoopRolls, i);
} else {
++i;
}
Expand Down
7 changes: 6 additions & 1 deletion src/library/coverartdelegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "moc_coverartdelegate.cpp"
#include "track/track.h"
#include "util/logger.h"
#include "util/make_const_iterator.h"

namespace {

Expand Down Expand Up @@ -48,7 +49,11 @@ void CoverArtDelegate::emitRowsChanged(
// Sort in ascending order...
std::sort(rows.begin(), rows.end());
// ...and then deduplicate...
rows.erase(std::unique(rows.begin(), rows.end()), rows.end());
constErase(
&rows,
make_const_iterator(
rows, std::unique(rows.begin(), rows.end())),
rows.constEnd());
// ...before emitting the signal.
DEBUG_ASSERT(!rows.isEmpty());
emit rowsChanged(std::move(rows));
Expand Down
7 changes: 4 additions & 3 deletions src/library/dao/playlistdao.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "track/track.h"
#include "util/db/dbconnection.h"
#include "util/db/fwdsqlquery.h"
#include "util/make_const_iterator.h"
#include "util/math.h"

PlaylistDAO::PlaylistDAO()
Expand Down Expand Up @@ -212,10 +213,10 @@ 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 (auto it = m_playlistsTrackIsIn.constBegin();
it != m_playlistsTrackIsIn.constEnd();) {
if (it.value() == playlistId) {
it = m_playlistsTrackIsIn.erase(it);
it = constErase(&m_playlistsTrackIsIn, it);
} else {
++it;
}
Expand Down
10 changes: 6 additions & 4 deletions src/library/trackset/setlogfeature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "mixer/playermanager.h"
#include "moc_setlogfeature.cpp"
#include "track/track.h"
#include "util/make_const_iterator.h"
#include "widget/wlibrary.h"
#include "widget/wlibrarysidebar.h"
#include "widget/wtracktableview.h"
Expand Down Expand Up @@ -561,14 +562,15 @@ void SetlogFeature::slotPlayingTrackChanged(TrackPointer currentPlayingTrack) {
if (currentPlayingTrackId.isValid()) {
// Remove the track from the recent tracks list if it's present and put
// at the front of the list.
auto it = std::find(std::begin(m_recentTracks),
std::end(m_recentTracks),
const auto it = std::find(
m_recentTracks.cbegin(),
m_recentTracks.cend(),
currentPlayingTrackId);
if (it == std::end(m_recentTracks)) {
if (it == m_recentTracks.cend()) {
track_played_recently = false;
} else {
track_played_recently = true;
m_recentTracks.erase(it);
constErase(&m_recentTracks, it);
}
m_recentTracks.push_front(currentPlayingTrackId);

Expand Down
6 changes: 4 additions & 2 deletions src/library/treeitem.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include "library/treeitem.h"

#include "util/make_const_iterator.h"

/*
* Just a word about how the TreeItem objects and TreeItemModels are used in general:
* TreeItems are used by the TreeItemModel class to display tree
Expand Down Expand Up @@ -105,6 +107,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));
constErase(&m_children, m_children.constBegin() + row, m_children.constBegin() + (row + count));
}
5 changes: 3 additions & 2 deletions src/preferences/broadcastsettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "defs_urls.h"
#include "moc_broadcastsettings.cpp"
#include "util/logger.h"
#include "util/make_const_iterator.h"
#include "util/memory.h"

namespace {
Expand Down Expand Up @@ -202,15 +203,15 @@ 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,
// remove the profile from the settings
const auto removedProfile = *profileIter;
DEBUG_ASSERT(removedProfile);
deleteFileForProfile(*removedProfile);
profileIter = m_profiles.erase(profileIter);
profileIter = constErase(&m_profiles, profileIter);
emit profileRemoved(removedProfile);
} else {
++profileIter;
Expand Down
17 changes: 9 additions & 8 deletions src/preferences/colorpaletteeditormodel.cpp
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
#include "preferences/colorpaletteeditormodel.h"

#include <util/assert.h>
#include <util/rangelist.h>

#include <QList>
#include <QMap>
#include <QMultiMap>
#include <algorithm>

#include "engine/controls/cuecontrol.h"
#include "moc_colorpaletteeditormodel.cpp"
#include "util/assert.h"
#include "util/make_const_iterator.h"
#include "util/rangelist.h"

namespace {

Expand Down Expand Up @@ -79,12 +79,13 @@ 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);
constErase(&hotcueIndexList, endUpper, hotcueIndexList.constEnd());
auto endLower = std::upper_bound(
hotcueIndexList.constBegin(), hotcueIndexList.constEnd(), 0);
constErase(&hotcueIndexList, hotcueIndexList.constBegin(), endLower);

for (int i = 0; i < rowCount(); ++i) {
auto* pHotcueIndexListItem = toHotcueIndexListItem(item(i, 1));
Expand Down
Loading

0 comments on commit 643e366

Please sign in to comment.