Fix (MSVC) compiler warnings

This commit is contained in:
Casper Jeukendrup 2021-11-02 16:36:59 +01:00
parent 6a3de6b553
commit ccfe159f81
7 changed files with 31 additions and 25 deletions

View file

@ -102,7 +102,7 @@ TestCaseContext::Val TestCaseContext::stepVal(const QString& stepName, const Key
TestCaseContext::Val TestCaseContext::findVal(const Key& key) const
{
for (int i = m_steps.size() - 1; i >= 0; --i) {
for (size_t i = m_steps.size() - 1; i >= 0; --i) {
const StepContext& s = m_steps.at(i);
auto it = s.vals.find(key);
if (it != s.vals.end()) {

View file

@ -65,7 +65,7 @@ QVariant AbFilesModel::data(const QModelIndex& index, int role) const
int AbFilesModel::rowCount(const QModelIndex&) const
{
return m_files.val.size();
return static_cast<int>(m_files.val.size());
}
QHash<int, QByteArray> AbFilesModel::roleNames() const
@ -97,7 +97,7 @@ void AbFilesModel::updateFile(const File& f)
File& cur = m_files.val.at(i);
if (cur.path == f.path) {
cur = f;
emit dataChanged(index(i), index(i));
emit dataChanged(index(static_cast<int>(i)), index(static_cast<int>(i)));
break;
}
}

View file

@ -60,7 +60,7 @@ QVariant AutobotScriptsModel::data(const QModelIndex& index, int role) const
int AutobotScriptsModel::rowCount(const QModelIndex&) const
{
return m_scripts.size();
return static_cast<int>(m_scripts.size());
}
QHash<int, QByteArray> AutobotScriptsModel::roleNames() const

View file

@ -36,7 +36,7 @@ namespace mu::mpe {
// common
using msecs_t = uint64_t;
using percentage_t = float; // from 0.0 (0%) to 1.0 (100%)
constexpr percentage_t PERCENTAGE_PRECISION_STEP = 0.1; // 10%
constexpr percentage_t PERCENTAGE_PRECISION_STEP = 0.1f; // 10%
// Arrangement
using timestamp_t = msecs_t;

View file

@ -88,7 +88,7 @@ protected:
DynamicType dynamic = DynamicType::Undefined;
};
std::map<int, NoteMetaData> m_initialData;
std::map<size_t, NoteMetaData> m_initialData;
ArticulationPattern m_standardPattern;
};
@ -105,7 +105,7 @@ TEST_F(MultiNoteArticulationsTest, StandardPattern)
ArticulationMap appliedArticulations = {};
// [WHEN] Notes sequence with given parameters being built
std::map<int, NoteEvent> noteEvents;
std::map<size_t, NoteEvent> noteEvents;
for (const auto& pair : m_initialData) {
NoteEvent noteEvent(m_standardPattern,
@ -146,7 +146,7 @@ TEST_F(MultiNoteArticulationsTest, StandardPattern)
*/
TEST_F(MultiNoteArticulationsTest, GlissandoPattern)
{
std::map<int, ArticulationMap> appliedArticulations;
std::map<size_t, ArticulationMap> appliedArticulations;
// [GIVEN] Articulation pattern "Glissando", which instructs a performer to start on the pitch/rhythm
// and slide the pitch up/down to land on the next pitch/rhythm
@ -171,7 +171,7 @@ TEST_F(MultiNoteArticulationsTest, GlissandoPattern)
appliedArticulations[1].emplace(ArticulationType::Glissando, glissandoAppliedOnTheSecondNote);
// [WHEN] Notes sequence with given parameters being built
std::map<int, NoteEvent> noteEvents;
std::map<size_t, NoteEvent> noteEvents;
for (const auto& pair : m_initialData) {
NoteEvent noteEvent(m_standardPattern,
@ -192,13 +192,13 @@ TEST_F(MultiNoteArticulationsTest, GlissandoPattern)
dynamicLevelFromType(DynamicType::f));
}
for (int i = 0; i < 2; ++i) {
for (size_t i = 0; i < 2; ++i) {
// [THEN] We expect that pitch curve of the notes 1 and 2 will be using a curve from the glissando pattern
EXPECT_EQ(noteEvents.at(i).pitchCtx().pitchCurve,
glissandoPattern.pitchPattern.pitchOffsetMap);
}
for (int i = 2; i < 4; ++i) {
for (size_t i = 2; i < 4; ++i) {
// [THEN] We expect that pitch curve of the notes 3 and 4 will be using a curve from the standard pattern
EXPECT_EQ(noteEvents.at(i).pitchCtx().pitchCurve,
m_standardPattern.pitchPattern.pitchOffsetMap);
@ -213,13 +213,13 @@ TEST_F(MultiNoteArticulationsTest, GlissandoPattern)
*/
TEST_F(MultiNoteArticulationsTest, CrescendoPattern)
{
std::map<int, ArticulationMap> appliedArticulations;
std::map<size_t, ArticulationMap> appliedArticulations;
// [GIVEN] Articulation pattern "Crescendo", which instructs a performer to gradually increase a volume of every note,
// using a certain range of dynamics. In our case there will be a crescendo from forte up to fortissimo
int noteCount = m_initialData.size();
int dynamicSegmentsCount = noteCount - 1;
size_t noteCount = m_initialData.size();
size_t dynamicSegmentsCount = noteCount - 1;
// [GIVEN] The last note is marked by fortissimo dynamic
m_initialData[noteCount].dynamic = DynamicType::ff;
@ -228,7 +228,7 @@ TEST_F(MultiNoteArticulationsTest, CrescendoPattern)
ArticulationPatternsScope crescendoScope;
for (int i = 0; i < noteCount; ++i) {
for (size_t i = 0; i < noteCount; ++i) {
ArticulationPattern crescendoPattern;
crescendoPattern.arrangementPattern = createArrangementPattern(1.f /*duration_factor*/, 0 /*timestamp_offset*/);
crescendoPattern.pitchPattern = createSimplePitchPattern(0.f /*increment_pitch_diff*/);
@ -237,14 +237,14 @@ TEST_F(MultiNoteArticulationsTest, CrescendoPattern)
crescendoScope.emplace(0.25f * i, std::move(crescendoPattern));
}
for (int i = 0; i < noteCount; ++i) {
for (size_t i = 0; i < noteCount; ++i) {
// [GIVEN] Crescendo articulation applied on the note
ArticulationData crescendoApplied(ArticulationType::Glissando, crescendoScope, 0.25 * i, 0.25 * (i + 1));
appliedArticulations[i].emplace(ArticulationType::Glissando, crescendoApplied);
}
// [WHEN] Notes sequence with given parameters being built
std::map<int, NoteEvent> noteEvents;
std::map<size_t, NoteEvent> noteEvents;
for (const auto& pair : m_initialData) {
NoteEvent noteEvent(m_standardPattern,
@ -259,7 +259,7 @@ TEST_F(MultiNoteArticulationsTest, CrescendoPattern)
noteEvents.emplace(pair.first, std::move(noteEvent));
}
for (int i = 0; i < noteCount; ++i) {
for (size_t i = 0; i < noteCount; ++i) {
// [THEN] We expect that ExpressionCurve of every note will be adapted to the applied CrescendoPattern
// That means that every note will be played louder on 125% than the previous one
EXPECT_EQ(noteEvents.at(i).expressionCtx().expressionCurve.maxAmplitudeLevel(),

View file

@ -137,7 +137,7 @@ public:
for (size_t ci = 0; ci < controlsCount; ++ci) {
INavigation::Index& idx = make_idx(env);
idx.column = ci;
idx.column = static_cast<int>(ci);
Control* c = make_control(idx);
@ -163,7 +163,7 @@ public:
Section* s = new Section();
for (size_t pi = 0; pi < panelsCount; ++pi) {
Panel* p = make_panel(env, pi, controlsCount);
Panel* p = make_panel(env, static_cast<int>(pi), controlsCount);
s->panels.push_back(p);
s->ipanels.insert(p->panel);
}
@ -198,26 +198,32 @@ public:
}
}
#ifdef Q_OS_LINUX
QEvent expectSendingEventOnNavigation(Env& env)
{
QEvent event(QEvent::None);
#ifdef Q_OS_LINUX
//! For Linux it needs to send spontanous event for canceling reading the name of previous control on accessibility
QWindow* window = new QWindow();
EXPECT_CALL(*env.mainWindow, qWindow()).WillOnce(Return(window));
EXPECT_CALL(*env.application, notify(window, _)).WillOnce(DoAll(SaveArgPointee<1>(&event), Return(true)));
#endif
return event;
}
void checkSendingEventOnNavigation(const QEvent& event)
{
#ifdef Q_OS_LINUX
EXPECT_TRUE(event.spontaneous());
#endif
}
#else
QEvent expectSendingEventOnNavigation(Env&)
{
return QEvent(QEvent::None);
}
void checkSendingEventOnNavigation(const QEvent&) {}
#endif
};
TEST_F(NavigationControllerTests, FirstActiveOnNextSection)

View file

@ -786,7 +786,7 @@ bool areTupletChordsConsistent(
{
auto it = chords.begin();
const bool isInTuplet = (*it)->second.isInTuplet;
for (std::next(it); it != chords.end(); ++it) {
for (it = std::next(it); it != chords.end(); ++it) {
if (isInTuplet && (!(*it)->second.isInTuplet
|| (*it)->second.tuplet != (*chords.begin())->second.tuplet)) {
return false;