Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix windows msvc bad address bug #61

Merged
merged 9 commits into from
Mar 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion Sourcecode/private/mx/core/ElementInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 3 additions & 2 deletions Sourcecode/private/mx/core/PreciseDecimal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
{
Expand All @@ -77,9 +78,9 @@ namespace mx

const DecimalType decimalPartAsFloat = inValue - static_cast<DecimalType>( integer );
const auto powerMultiplierAsFloat = std::pow( static_cast<DecimalType>( 10 ), static_cast<DecimalType>( getMaxDecimalDigits() ) );
const auto powerMultiplier = static_cast<uint64_t>( std::ceil( powerMultiplierAsFloat - 0.5 ) );
const auto powerMultiplier = static_cast<uint64_t>( std::ceil( powerMultiplierAsFloat - POINT_FIVE ) );
const auto decimalDigitsShifted = decimalPartAsFloat * static_cast<decltype( decimalPartAsFloat )>( powerMultiplier );
const auto decimalDigits = static_cast<decltype( myDecimal )>( std::ceil( decimalDigitsShifted - 0.5 ) );
const auto decimalDigits = static_cast<decltype( myDecimal )>( std::ceil( decimalDigitsShifted - POINT_FIVE ) );

if( decimalDigits > myMaxExpressibleDecimal )
{
Expand Down
10 changes: 3 additions & 7 deletions Sourcecode/private/mxtest/api/NoteDataTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -352,8 +352,7 @@ TEST( tremolos, NoteData )
marks.emplace_back( mark );
mark = MarkData{ MarkType::tremoloSingleFive };
marks.emplace_back( mark );



// round trip it through xml
auto& mgr = DocumentManager::getInstance();
auto docId = mgr.createFromScore( score );
Expand All @@ -372,13 +371,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();

for (int i = 1; i <= 5; ++i, ++markIter)
for ( int i = 1; i <= 5; ++i )
{
CHECK( markIter != markEnd );
const auto& markData = *markIter;
const auto& markData = omarks.at( static_cast<size_t>( i - 1 ) );
CHECK_EQUAL( i, numTremoloSlashes( markData.markType ) );
}
}
Expand Down
2 changes: 1 addition & 1 deletion Sourcecode/private/mxtest/api/PitchDataTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down