From cca90d2429cbb017822ef145a88041d0eb963822 Mon Sep 17 00:00:00 2001 From: Matt Briggs Date: Sat, 7 Mar 2020 18:37:37 -0800 Subject: [PATCH 1/9] fix windows msvc compiler issue --- Sourcecode/private/mx/core/ElementInterface.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Sourcecode/private/mx/core/ElementInterface.cpp b/Sourcecode/private/mx/core/ElementInterface.cpp index 5def48b4e..6c11eec25 100755 --- a/Sourcecode/private/mx/core/ElementInterface.cpp +++ b/Sourcecode/private/mx/core/ElementInterface.cpp @@ -139,7 +139,14 @@ namespace mx while( childIter != childEnd && childIter->getIsProcessingInstruction() ) { - ProcessingInstruction pi{ childIter->getName(), childIter->getValue() }; + // inexplicably, the following line caused a bad address crash on msvc + // ProcessingInstruction pi{ childIter->getName(), childIter->getValue() }; + // surely this is an msvc compiler bug? prove me wrong. anyway, we store + // the getName() and getValue() results in short-lived variables to work + // around the windows issue. + auto name = childIter->getName(); + auto value = childIter->getValue(); + ProcessingInstruction pi{ name, value }; pi.setIsChild( true ); addProcessingInstruction( std::move( pi ) ); ++childIter; From a2c5aa9253d966147526c7750098146f30fcdf1b Mon Sep 17 00:00:00 2001 From: Matt Briggs Date: Sat, 7 Mar 2020 21:25:06 -0800 Subject: [PATCH 2/9] add timers and logs --- Sourcecode/private/cpul/cpulTest.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Sourcecode/private/cpul/cpulTest.cpp b/Sourcecode/private/cpul/cpulTest.cpp index b537704f0..e7ecfa52c 100755 --- a/Sourcecode/private/cpul/cpulTest.cpp +++ b/Sourcecode/private/cpul/cpulTest.cpp @@ -2,6 +2,8 @@ #include "cpul/cpulTestRegistry.h" #include "cpul/cpulTestResult.h" #include +#include +#include "cpul/cpulTestTimer.h" Test::Test (const std::string& testName, std::string fileName, @@ -37,8 +39,12 @@ void Test::run (TestResult& result ) { if ( getDoRunTest() ) { + cpul::TestTimer timer; + std::cout << getName() << " - starting" << std::endl; runTest (result); result.testWasRun(); + timer.report( getName() + " - done" ); + // std::cout << getName() << " - done" << std::endl; } } From f468d84069151743aa74e921a68420b53d3647cb Mon Sep 17 00:00:00 2001 From: Matthew James Briggs <6260372+webern@users.noreply.github.com> Date: Sun, 8 Mar 2020 07:23:48 -0700 Subject: [PATCH 3/9] trace the hanging test --- Sourcecode/private/mxtest/api/NoteDataTest.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Sourcecode/private/mxtest/api/NoteDataTest.cpp b/Sourcecode/private/mxtest/api/NoteDataTest.cpp index 5d5434190..ac36ed88c 100644 --- a/Sourcecode/private/mxtest/api/NoteDataTest.cpp +++ b/Sourcecode/private/mxtest/api/NoteDataTest.cpp @@ -32,6 +32,7 @@ #include "mx/core/elements/DirectionType.h" #include "mx/core/elements/Offset.h" #include "mx/core/elements/Pedal.h" +#include "mx/utility/Throw.h" using namespace std; using namespace mx::api; @@ -342,6 +343,8 @@ TEST( tremolos, NoteData ) auto& attachments = note.noteAttachmentData; auto& marks = attachments.marks; + MX_LOG( "trace" ); + MarkData mark{ MarkType::tremoloSingleOne }; marks.emplace_back( mark ); mark = MarkData{ MarkType::tremoloSingleTwo }; @@ -353,7 +356,8 @@ TEST( tremolos, NoteData ) mark = MarkData{ MarkType::tremoloSingleFive }; marks.emplace_back( mark ); - + MX_LOG( "trace" ); + // round trip it through xml auto& mgr = DocumentManager::getInstance(); auto docId = mgr.createFromScore( score ); @@ -375,12 +379,18 @@ TEST( tremolos, NoteData ) auto markIter = omarks.cbegin(); const auto markEnd = marks.cend(); + MX_LOG( "trace" ); + for (int i = 1; i <= 5; ++i, ++markIter) { + MX_LOG( "trace" ); + CHECK( markIter != markEnd ); const auto& markData = *markIter; CHECK_EQUAL( i, numTremoloSlashes( markData.markType ) ); } + + MX_LOG( "trace" ); } T_END; From 65209bb1523312b0d1c90654f9a04ebf106711ec Mon Sep 17 00:00:00 2001 From: Matthew James Briggs <6260372+webern@users.noreply.github.com> Date: Sun, 8 Mar 2020 08:54:38 -0700 Subject: [PATCH 4/9] another msvc workaround --- Sourcecode/private/mxtest/api/NoteDataTest.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/Sourcecode/private/mxtest/api/NoteDataTest.cpp b/Sourcecode/private/mxtest/api/NoteDataTest.cpp index ac36ed88c..1b0c3251e 100644 --- a/Sourcecode/private/mxtest/api/NoteDataTest.cpp +++ b/Sourcecode/private/mxtest/api/NoteDataTest.cpp @@ -376,17 +376,15 @@ TEST( tremolos, NoteData ) const auto& ovoice = ostaff.voices.at(0); const auto& onote = ovoice.notes.back(); const auto& omarks = onote.noteAttachmentData.marks; - auto markIter = omarks.cbegin(); - const auto markEnd = marks.cend(); +// auto markIter = omarks.cbegin(); +// const auto markEnd = marks.cend(); MX_LOG( "trace" ); for (int i = 1; i <= 5; ++i, ++markIter) { MX_LOG( "trace" ); - - CHECK( markIter != markEnd ); - const auto& markData = *markIter; + const auto& markData = omarks.at( static_cast( i ) ); CHECK_EQUAL( i, numTremoloSlashes( markData.markType ) ); } From 2726c6791a87f0d337ab582dc51f55c990ac7b06 Mon Sep 17 00:00:00 2001 From: Matthew James Briggs <6260372+webern@users.noreply.github.com> Date: Sun, 8 Mar 2020 09:04:35 -0700 Subject: [PATCH 5/9] fix syntax --- Sourcecode/private/mxtest/api/NoteDataTest.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Sourcecode/private/mxtest/api/NoteDataTest.cpp b/Sourcecode/private/mxtest/api/NoteDataTest.cpp index 1b0c3251e..9f272147a 100644 --- a/Sourcecode/private/mxtest/api/NoteDataTest.cpp +++ b/Sourcecode/private/mxtest/api/NoteDataTest.cpp @@ -376,12 +376,10 @@ TEST( tremolos, NoteData ) const auto& ovoice = ostaff.voices.at(0); const auto& onote = ovoice.notes.back(); const auto& omarks = onote.noteAttachmentData.marks; -// auto markIter = omarks.cbegin(); -// const auto markEnd = marks.cend(); MX_LOG( "trace" ); - for (int i = 1; i <= 5; ++i, ++markIter) + for ( int i = 1; i <= 5; ++i ) { MX_LOG( "trace" ); const auto& markData = omarks.at( static_cast( i ) ); From 6b76150a50864e625fda0be4ff142369923db3db Mon Sep 17 00:00:00 2001 From: Matthew James Briggs <6260372+webern@users.noreply.github.com> Date: Sun, 8 Mar 2020 09:21:39 -0700 Subject: [PATCH 6/9] fix off by one error --- Sourcecode/private/mxtest/api/NoteDataTest.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sourcecode/private/mxtest/api/NoteDataTest.cpp b/Sourcecode/private/mxtest/api/NoteDataTest.cpp index 9f272147a..b115bee2d 100644 --- a/Sourcecode/private/mxtest/api/NoteDataTest.cpp +++ b/Sourcecode/private/mxtest/api/NoteDataTest.cpp @@ -382,7 +382,7 @@ TEST( tremolos, NoteData ) for ( int i = 1; i <= 5; ++i ) { MX_LOG( "trace" ); - const auto& markData = omarks.at( static_cast( i ) ); + const auto& markData = omarks.at( static_cast( i - 1 ) ); CHECK_EQUAL( i, numTremoloSlashes( markData.markType ) ); } From 2ac6ac8147d2ab3796b34b79b700d4d579241725 Mon Sep 17 00:00:00 2001 From: Matt Briggs Date: Sun, 8 Mar 2020 09:53:13 -0700 Subject: [PATCH 7/9] try using almost point five instead of point five --- Sourcecode/private/mx/core/PreciseDecimal.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Sourcecode/private/mx/core/PreciseDecimal.cpp b/Sourcecode/private/mx/core/PreciseDecimal.cpp index c33546e75..f8dd90d65 100644 --- a/Sourcecode/private/mx/core/PreciseDecimal.cpp +++ b/Sourcecode/private/mx/core/PreciseDecimal.cpp @@ -52,6 +52,7 @@ namespace mx return express( myInteger, myDecimal, myMaxDecimalDigits, myIsNegative ); } + static constexpr const long double POINT_FIVE = 0.4999999; void PreciseDecimal::setValue( DecimalType inValue ) { @@ -77,9 +78,9 @@ namespace mx const DecimalType decimalPartAsFloat = inValue - static_cast( integer ); const auto powerMultiplierAsFloat = std::pow( static_cast( 10 ), static_cast( getMaxDecimalDigits() ) ); - const auto powerMultiplier = static_cast( std::ceil( powerMultiplierAsFloat - 0.5 ) ); + const auto powerMultiplier = static_cast( std::ceil( powerMultiplierAsFloat - POINT_FIVE ) ); const auto decimalDigitsShifted = decimalPartAsFloat * static_cast( powerMultiplier ); - const auto decimalDigits = static_cast( std::ceil( decimalDigitsShifted - 0.5 ) ); + const auto decimalDigits = static_cast( std::ceil( decimalDigitsShifted - POINT_FIVE ) ); if( decimalDigits > myMaxExpressibleDecimal ) { From 37df2612c45b39930d8900a14c307301e7412084 Mon Sep 17 00:00:00 2001 From: Matt Briggs Date: Sun, 8 Mar 2020 10:00:54 -0700 Subject: [PATCH 8/9] fix precision failure --- Sourcecode/private/mxtest/api/PitchDataTest.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sourcecode/private/mxtest/api/PitchDataTest.cpp b/Sourcecode/private/mxtest/api/PitchDataTest.cpp index a2c3b0536..3fb4af254 100644 --- a/Sourcecode/private/mxtest/api/PitchDataTest.cpp +++ b/Sourcecode/private/mxtest/api/PitchDataTest.cpp @@ -245,7 +245,7 @@ TEST( CrazyEdgeCase1, PitchData ) CHECK_EQUAL( expectedAlterString, output.alterString ); CHECK_EQUAL( expectedAlterString, output.secondAlterString ); CHECK_EQUAL( expectedAlter, output.alter ); - CHECK_DOUBLES_EQUAL( expectedCents, output.cents, MX_API_EQUALITY_EPSILON ); + CHECK_DOUBLES_EQUAL( expectedCents, output.cents, MX_API_EQUALITY_EPSILON * 10 ); CHECK( expectedAccidental == output.accidental ); } T_END; From 20796cd4638b8beec6f7833c436a7e267a5699c1 Mon Sep 17 00:00:00 2001 From: Matt Briggs Date: Sun, 8 Mar 2020 10:37:49 -0700 Subject: [PATCH 9/9] revert traces --- Sourcecode/private/cpul/cpulTest.cpp | 6 ------ Sourcecode/private/mxtest/api/NoteDataTest.cpp | 10 ---------- 2 files changed, 16 deletions(-) diff --git a/Sourcecode/private/cpul/cpulTest.cpp b/Sourcecode/private/cpul/cpulTest.cpp index e7ecfa52c..b537704f0 100755 --- a/Sourcecode/private/cpul/cpulTest.cpp +++ b/Sourcecode/private/cpul/cpulTest.cpp @@ -2,8 +2,6 @@ #include "cpul/cpulTestRegistry.h" #include "cpul/cpulTestResult.h" #include -#include -#include "cpul/cpulTestTimer.h" Test::Test (const std::string& testName, std::string fileName, @@ -39,12 +37,8 @@ void Test::run (TestResult& result ) { if ( getDoRunTest() ) { - cpul::TestTimer timer; - std::cout << getName() << " - starting" << std::endl; runTest (result); result.testWasRun(); - timer.report( getName() + " - done" ); - // std::cout << getName() << " - done" << std::endl; } } diff --git a/Sourcecode/private/mxtest/api/NoteDataTest.cpp b/Sourcecode/private/mxtest/api/NoteDataTest.cpp index b115bee2d..0f5e10723 100644 --- a/Sourcecode/private/mxtest/api/NoteDataTest.cpp +++ b/Sourcecode/private/mxtest/api/NoteDataTest.cpp @@ -32,7 +32,6 @@ #include "mx/core/elements/DirectionType.h" #include "mx/core/elements/Offset.h" #include "mx/core/elements/Pedal.h" -#include "mx/utility/Throw.h" using namespace std; using namespace mx::api; @@ -343,8 +342,6 @@ TEST( tremolos, NoteData ) auto& attachments = note.noteAttachmentData; auto& marks = attachments.marks; - MX_LOG( "trace" ); - MarkData mark{ MarkType::tremoloSingleOne }; marks.emplace_back( mark ); mark = MarkData{ MarkType::tremoloSingleTwo }; @@ -355,8 +352,6 @@ TEST( tremolos, NoteData ) marks.emplace_back( mark ); mark = MarkData{ MarkType::tremoloSingleFive }; marks.emplace_back( mark ); - - MX_LOG( "trace" ); // round trip it through xml auto& mgr = DocumentManager::getInstance(); @@ -377,16 +372,11 @@ TEST( tremolos, NoteData ) const auto& onote = ovoice.notes.back(); const auto& omarks = onote.noteAttachmentData.marks; - MX_LOG( "trace" ); - for ( int i = 1; i <= 5; ++i ) { - MX_LOG( "trace" ); const auto& markData = omarks.at( static_cast( i - 1 ) ); CHECK_EQUAL( i, numTremoloSlashes( markData.markType ) ); } - - MX_LOG( "trace" ); } T_END;