Skip to content

Commit

Permalink
Merge pull request #4427 from uklotzde/playermanager
Browse files Browse the repository at this point in the history
PlayerManager: Replace debug assertions with warnings
  • Loading branch information
Be-ing authored Oct 15, 2021
2 parents 79915d5 + 609f7f6 commit 01dc66a
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions src/mixer/playermanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,28 @@ const mixxx::Logger kLogger("PlayerManager");
// Utilize half of the available cores for adhoc analysis of tracks
const int kNumberOfAnalyzerThreads = math_max(1, QThread::idealThreadCount() / 2);

const QRegularExpression kDeckRegex(QStringLiteral("\\[Channel\\d+\\]"));
const QRegularExpression kSamplerRegex(QStringLiteral("\\[Sampler\\d+\\]"));
const QRegularExpression kPreviewDeckRegex(QStringLiteral("\\[PreviewDeck\\d+\\]"));
const QRegularExpression kDeckRegex(QStringLiteral("^\\[Channel(\\d+)\\]$"));
const QRegularExpression kSamplerRegex(QStringLiteral("^\\[Sampler(\\d+)\\]$"));
const QRegularExpression kPreviewDeckRegex(QStringLiteral("^\\[PreviewDeck(\\d+)\\]$"));

bool extractIntFromRegex(const QRegularExpression& regex, const QString& group, int* number) {
QRegularExpressionMatch match = regex.match(group);
const QRegularExpressionMatch match = regex.match(group);
DEBUG_ASSERT(match.isValid());
if (!match.hasMatch()) {
return false;
}
// The regex is expected to contain a single capture group with the number
constexpr int capturedNumberIndex = 1;
DEBUG_ASSERT(match.lastCapturedIndex() <= capturedNumberIndex);
if (match.lastCapturedIndex() < capturedNumberIndex) {
qWarning() << "No number found in group" << group;
return false;
}
if (number) {
const QString capturedNumber = match.captured(capturedNumberIndex);
DEBUG_ASSERT(!capturedNumber.isNull());
bool okay = false;
const int numberFromMatch = match.captured(1).toInt(&okay);
const int numberFromMatch = capturedNumber.toInt(&okay);
VERIFY_OR_DEBUG_ASSERT(okay) {
return false;
}
Expand Down

0 comments on commit 01dc66a

Please sign in to comment.