Skip to content

Commit 7a00962

Browse files
cbjeukendrupJojo-Schmitz
authored andcommitted
Eliminate (the need for) #undef small and #undef STRING_NONE
as it was needed for MSVC, which uses these in some headers, so they conflict with MuseScore's functions, variables, marcos. Partial backport of musescore#8765
1 parent c117bd3 commit 7a00962

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+161
-164
lines changed

all.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -224,12 +224,6 @@
224224
#define Q_ASSERT(a)
225225
#endif
226226

227-
#if (defined (_MSCVER) || defined (_MSC_VER))
228-
// Undefined problematic #def'd macros in Microsoft headers
229-
#undef STRING_NONE
230-
#undef small
231-
#endif
232-
233227
#endif // __cplusplus
234228

235229
#endif

importexport/musicxml/exportxml.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3178,7 +3178,7 @@ static int tremoloCorrection(const Note* const note)
31783178

31793179
static bool isSmallNote(const Note* const note)
31803180
{
3181-
return note->small() || note->chord()->small();
3181+
return note->isSmall() || note->chord()->isSmall();
31823182
}
31833183

31843184
//---------------------------------------------------------
@@ -3601,7 +3601,7 @@ void ExportMusicXml::rest(Rest* rest, int staff, const std::vector<Lyrics*>* ll)
36013601
if (d.type() != TDuration::DurationType::V_MEASURE) {
36023602
QString s = d.name();
36033603
int dots = rest->dots();
3604-
if (rest->small())
3604+
if (rest->isSmall())
36053605
_xml.tag("type size=\"cue\"", s);
36063606
else
36073607
_xml.tag("type", s);

importexport/musicxml/importmxmlpass2.cpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2248,7 +2248,7 @@ static void markUserAccidentals(const int firstStaff,
22482248

22492249
static void coerceGraceCue(Chord* mainChord, Chord* graceChord)
22502250
{
2251-
if (mainChord->small())
2251+
if (mainChord->isSmall())
22522252
graceChord->setSmall(true);
22532253
bool anyPlays = false;
22542254
for (auto n : mainChord->notes()) {
@@ -4949,7 +4949,7 @@ static TDuration determineDuration(const bool rest, const QString& type, const i
49494949
static Chord* findOrCreateChord(Score* score, Measure* m,
49504950
const Fraction& tick, const int track, const int move,
49514951
const TDuration duration, const Fraction dura,
4952-
Beam::Mode bm, bool small)
4952+
Beam::Mode bm, bool isSmall)
49534953
{
49544954
//qDebug("findOrCreateChord tick %d track %d dur ticks %d ticks %s bm %hhd",
49554955
// tick, track, duration.ticks(), qPrintable(dura.print()), bm);
@@ -4965,7 +4965,7 @@ static Chord* findOrCreateChord(Score* score, Measure* m,
49654965
c->setTrack(track);
49664966
// Chord is initialized with the smallness of its first note.
49674967
// If a non-small note is added later, this is handled in handleSmallness.
4968-
c->setSmall(small);
4968+
c->setSmall(isSmall);
49694969

49704970
setChordRestDuration(c, duration, dura);
49714971
Segment* s = m->getSegment(SegmentType::ChordRest, tick);
@@ -5009,14 +5009,14 @@ NoteType graceNoteType(const TDuration duration, const bool slash)
50095009
*/
50105010

50115011
static Chord* createGraceChord(Score* score, const int track,
5012-
const TDuration duration, const bool slash, const bool small)
5012+
const TDuration duration, const bool slash, const bool isSmall)
50135013
{
50145014
Chord* c = new Chord(score);
50155015
c->setNoteType(graceNoteType(duration, slash));
50165016
c->setTrack(track);
50175017
// Chord is initialized with the smallness of its first note.
50185018
// If a non-small note is added later, this is handled in handleSmallness.
5019-
c->setSmall(small);
5019+
c->setSmall(isSmall);
50205020
// note grace notes have no durations, use default fraction 0/1
50215021
setChordRestDuration(c, duration, Fraction());
50225022
return c;
@@ -5058,11 +5058,11 @@ static void handleDisplayStep(ChordRest* cr, int step, int octave, const Fractio
50585058
static void handleSmallness(bool cueOrSmall, Note* note, Chord* c)
50595059
{
50605060
if (cueOrSmall) {
5061-
note->setSmall(!c->small()); // Avoid redundant smallness
5061+
note->setSmall(!c->isSmall()); // Avoid redundant smallness
50625062
}
50635063
else {
50645064
note->setSmall(false);
5065-
if (c->small()) {
5065+
if (c->isSmall()) {
50665066
// What was a small chord becomes small notes in a non-small chord
50675067
c->setSmall(false);
50685068
for (Note* otherNote : c->notes()) {
@@ -5329,7 +5329,7 @@ Note* MusicXMLParserPass2::note(const QString& partId,
53295329

53305330
bool chord = false;
53315331
bool cue = false;
5332-
bool small = false;
5332+
bool isSmall = false;
53335333
bool grace = false;
53345334
bool rest = false;
53355335
int staff = 1;
@@ -5416,7 +5416,7 @@ Note* MusicXMLParserPass2::note(const QString& partId,
54165416
else if (_e.name() == "stem")
54175417
stem(stemDir, noStem);
54185418
else if (_e.name() == "type") {
5419-
small = (_e.attributes().value("size") == "cue" || _e.attributes().value("size") == "grace-cue");
5419+
isSmall = (_e.attributes().value("size") == "cue" || _e.attributes().value("size") == "grace-cue");
54205420
type = _e.readElementText();
54215421
}
54225422
else if (_e.name() == "voice")
@@ -5521,14 +5521,14 @@ Note* MusicXMLParserPass2::note(const QString& partId,
55215521
c = findOrCreateChord(_score, measure,
55225522
noteStartTime,
55235523
msTrack + msVoice, msMove,
5524-
duration, dura, bm, small || cue);
5524+
duration, dura, bm, isSmall || cue);
55255525
}
55265526
else {
55275527
// grace note
55285528
// TODO: check if explicit stem direction should also be set for grace notes
55295529
// (the DOM parser does that, but seems to have no effect on the autotester)
55305530
if (!chord || gcl.isEmpty()) {
5531-
c = createGraceChord(_score, msTrack + msVoice, duration, graceSlash, small || cue);
5531+
c = createGraceChord(_score, msTrack + msVoice, duration, graceSlash, isSmall || cue);
55325532
// TODO FIX
55335533
// the setStaffMove() below results in identical behaviour as 2.0:
55345534
// grace note will be at the wrong staff with the wrong pitch,
@@ -5570,15 +5570,15 @@ Note* MusicXMLParserPass2::note(const QString& partId,
55705570
}
55715571
else
55725572
cr->setBeamMode(Beam::Mode::NONE);
5573-
cr->setSmall(small);
5573+
cr->setSmall(isSmall);
55745574
if (noteColor != QColor::Invalid)
55755575
cr->setColor(noteColor);
55765576
cr->setVisible(printObject);
55775577
handleDisplayStep(cr, mnp.displayStep(), mnp.displayOctave(), noteStartTime, _score->spatium());
55785578
}
55795579
}
55805580
else {
5581-
handleSmallness(cue || small, note, c);
5581+
handleSmallness(cue || isSmall, note, c);
55825582
note->setPlay(!cue); // cue notes don't play
55835583
note->setHeadGroup(headGroup);
55845584
if (noteColor != QColor::Invalid)

libmscore/accidental.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ void Accidental::read(XmlReader& e)
252252
_role = r;
253253
}
254254
else if (tag == "small")
255-
_small = e.readInt();
255+
m_isSmall = e.readInt();
256256
else if (Element::readProperties(e))
257257
;
258258
else
@@ -365,7 +365,7 @@ void Accidental::layout()
365365
}
366366

367367
qreal m = parent() ? parent()->mag() : 1.0;
368-
if (_small)
368+
if (m_isSmall)
369369
m *= score()->styleD(Sid::smallNoteMag);
370370
setMag(m);
371371

@@ -572,7 +572,7 @@ QVariant Accidental::getProperty(Pid propertyId) const
572572
{
573573
switch (propertyId) {
574574
case Pid::ACCIDENTAL_TYPE: return int(_accidentalType);
575-
case Pid::SMALL: return _small;
575+
case Pid::SMALL: return m_isSmall;
576576
case Pid::ACCIDENTAL_BRACKET: return int(bracket());
577577
case Pid::ROLE: return int(role());
578578
default:
@@ -607,7 +607,7 @@ bool Accidental::setProperty(Pid propertyId, const QVariant& v)
607607
setAccidentalType(AccidentalType(v.toInt()));
608608
break;
609609
case Pid::SMALL:
610-
_small = v.toBool();
610+
m_isSmall = v.toBool();
611611
break;
612612
case Pid::ACCIDENTAL_BRACKET:
613613
_bracket = AccidentalBracket(v.toInt());

libmscore/accidental.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,13 @@ struct SymElement {
6565
//---------------------------------------------------------
6666
// @@ Accidental
6767
// @P role enum (Accidental.AUTO, .USER) (read only)
68-
// @P small bool
68+
// @P isSmall bool
6969
//---------------------------------------------------------
7070

7171
class Accidental final : public Element {
7272
QList<SymElement> el;
7373
AccidentalType _accidentalType { AccidentalType::NONE };
74-
bool _small { false };
74+
bool m_isSmall { false };
7575
AccidentalBracket _bracket { AccidentalBracket::NONE };
7676
AccidentalRole _role { AccidentalRole::AUTO };
7777

@@ -108,8 +108,8 @@ class Accidental final : public Element {
108108

109109
void setRole(AccidentalRole r) { _role = r; }
110110

111-
bool small() const { return _small; }
112-
void setSmall(bool val) { _small = val; }
111+
bool isSmall() const { return m_isSmall; }
112+
void setSmall(bool val) { m_isSmall = val; }
113113

114114
void undoSetSmall(bool val);
115115

libmscore/beam.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ void Beam::layout1()
366366

367367
int staffIdx = -1;
368368
for (ChordRest* cr : qAsConst(_elements)) {
369-
qreal m = cr->small() ? score()->styleD(Sid::smallNoteMag) : 1.0;
369+
qreal m = cr->isSmall() ? score()->styleD(Sid::smallNoteMag) : 1.0;
370370
mag = qMax(mag, m);
371371
if (cr->isChord()) {
372372
c2 = toChord(cr);
@@ -1503,11 +1503,11 @@ void Beam::computeStemLen(const std::vector<ChordRest*>& cl, qreal& py1, int bea
15031503
qreal firstStemLenPoints = bm.l * _spStaff4;
15041504
const qreal sgn = (firstStemLenPoints < 0 ? -1.0 : 1.0);
15051505
const QPointF p1 = cl[0]->stemPosBeam();
1506-
bool small = true;
1506+
bool isSmall = true;
15071507
for (const ChordRest* cr : cl) {
15081508
if (cr->isChord()) {
1509-
if (!cr->small())
1510-
small = false;
1509+
if (!cr->isSmall())
1510+
isSmall = false;
15111511

15121512
const qreal minAbsLen = toChord(cr)->minAbsStemLength();
15131513

@@ -1524,7 +1524,7 @@ void Beam::computeStemLen(const std::vector<ChordRest*>& cl, qreal& py1, int bea
15241524
}
15251525

15261526
py1 += (dy + bm.l) * _spStaff4;
1527-
if (small && !staff()->isTabStaff(Fraction(0,1))) {
1527+
if (isSmall && !staff()->isTabStaff(Fraction(0,1))) {
15281528
const qreal offset = (beamLevels == 4) ? _beamDist/2.0 : 0.0;
15291529

15301530
if (bm.l > 0)

libmscore/chord.cpp

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1275,49 +1275,49 @@ void Chord::setScore(Score* s)
12751275
// Adjustment to the length of the stem in order to accommodate hooks
12761276
// This function replaces this bit of code:
12771277
// switch (hookIdx) {
1278-
// case 3: normalStemLen += small() ? .5 : 0.75; break; //32nd notes
1279-
// case 4: normalStemLen += small() ? 1.0 : 1.5; break; //64th notes
1280-
// case 5: normalStemLen += small() ? 1.5 : 2.25; break; //128th notes
1278+
// case 3: normalStemLen += isSmall() ? .5 : 0.75; break; //32nd notes
1279+
// case 4: normalStemLen += isSmall() ? 1.0 : 1.5; break; //64th notes
1280+
// case 5: normalStemLen += isSmall() ? 1.5 : 2.25; break; //128th notes
12811281
// }
12821282
// which was not sufficient for two reasons:
12831283
// 1. It only lengthened the stem for 3, 4, or 5 hooks.
12841284
// 2. It was too general to produce good results for all combinations of factors.
12851285
// This provides a way to take a number of factors into account. Further tweaking may be in order.
12861286
//-----------------------------------------------------------------------------
12871287

1288-
qreal hookAdjustment(QString font, int hooks, bool up, bool small)
1288+
qreal hookAdjustment(QString font, int hooks, bool up, bool isSmall)
12891289
{
12901290
bool fallback = MScore::useFallbackFont && (hooks > 5);
12911291

12921292
if (font == "Emmentaler" && !fallback) {
12931293
if (up) {
12941294
if (hooks > 2)
1295-
return (hooks - 2) * (small ? .75 : 1);
1295+
return (hooks - 2) * (isSmall ? .75 : 1);
12961296
}
12971297
else {
12981298
if (hooks == 3)
1299-
return (small ? .75 : 1);
1299+
return (isSmall ? .75 : 1);
13001300
else if (hooks > 3)
1301-
return (hooks - 2) * (small ? .5 : .75);
1301+
return (hooks - 2) * (isSmall ? .5 : .75);
13021302
}
13031303
}
13041304
else if (font == "Gonville" && !fallback) {
13051305
if (up) {
13061306
if (hooks > 2)
1307-
return (hooks - 2) * (small ? .5 : .75);
1307+
return (hooks - 2) * (isSmall ? .5 : .75);
13081308
}
13091309
else {
13101310
if (hooks > 1)
1311-
return (hooks - 1) * (small ? .5 : .75);
1311+
return (hooks - 1) * (isSmall ? .5 : .75);
13121312
}
13131313
}
13141314
else if (font == "MuseJazz") {
13151315
if (hooks > 2)
1316-
return (hooks - 2) * (small ? .75 : 1);
1316+
return (hooks - 2) * (isSmall ? .75 : 1);
13171317
}
13181318
else {
13191319
if (hooks > 2)
1320-
return (hooks - 2) * (small ? .5 : .75);
1320+
return (hooks - 2) * (isSmall ? .5 : .75);
13211321
}
13221322
return 0;
13231323
}
@@ -1369,12 +1369,12 @@ qreal Chord::defaultStemLength() const
13691369
qreal shortest = score()->styleS(Sid::shortestStem).val();
13701370
if (hookIdx) {
13711371
if (up())
1372-
shortest = qMax(shortest, small() ? 2.0 : 3.0);
1372+
shortest = qMax(shortest, isSmall() ? 2.0 : 3.0);
13731373
else
1374-
shortest = qMax(shortest, small() ? 2.25 : 3.5);
1374+
shortest = qMax(shortest, isSmall() ? 2.25 : 3.5);
13751375
}
13761376

1377-
qreal normalStemLen = small() ? 2.5 : 3.5;
1377+
qreal normalStemLen = isSmall() ? 2.5 : 3.5;
13781378
if (hookIdx && tab == 0) {
13791379
if (up() && durationType().dots()) {
13801380
//
@@ -2769,7 +2769,7 @@ QVariant Chord::getProperty(Pid propertyId) const
27692769
{
27702770
switch (propertyId) {
27712771
case Pid::NO_STEM: return noStem();
2772-
case Pid::SMALL: return small();
2772+
case Pid::SMALL: return isSmall();
27732773
case Pid::STEM_DIRECTION: return QVariant::fromValue<Direction>(stemDirection());
27742774
default:
27752775
return ChordRest::getProperty(propertyId);
@@ -2982,7 +2982,7 @@ void Chord::removeMarkings(bool keepTremolo)
29822982
qreal Chord::chordMag() const
29832983
{
29842984
qreal m = 1.0;
2985-
if (small())
2985+
if (isSmall())
29862986
m *= score()->styleD(Sid::smallNoteMag);
29872987
if (_noteType != NoteType::NORMAL)
29882988
m *= score()->styleD(Sid::graceNoteMag);
@@ -3445,7 +3445,7 @@ void Chord::layoutArticulations()
34453445
return;
34463446
const Staff* st = staff();
34473447
const StaffType* staffType = st->staffTypeForElement(this);
3448-
qreal mag = (staffType->small() ? score()->styleD(Sid::smallStaffMag) : 1.0) * staffType->userMag();
3448+
qreal mag = (staffType->isSmall() ? score()->styleD(Sid::smallStaffMag) : 1.0) * staffType->userMag();
34493449
qreal _spatium = score()->spatium() * mag;
34503450
qreal _spStaff = _spatium * staffType->lineDistance().val();
34513451

libmscore/chordrest.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ ChordRest::ChordRest(Score* s)
6363
_tabDur = 0;
6464
_up = true;
6565
_beamMode = Beam::Mode::AUTO;
66-
_small = false;
66+
m_isSmall = false;
6767
_crossMeasure = CrossMeasure::UNKNOWN;
6868
}
6969

@@ -78,7 +78,7 @@ ChordRest::ChordRest(const ChordRest& cr, bool link)
7878

7979
_beamMode = cr._beamMode;
8080
_up = cr._up;
81-
_small = cr._small;
81+
m_isSmall = cr.m_isSmall;
8282
_melismaEnds = cr._melismaEnds;
8383
_crossMeasure = cr._crossMeasure;
8484

@@ -268,7 +268,7 @@ bool ChordRest::readProperties(XmlReader& e)
268268
e.skipCurrentElement();
269269
}
270270
else if (tag == "small")
271-
_small = e.readInt();
271+
m_isSmall = e.readInt();
272272
else if (tag == "duration")
273273
setTicks(e.readFraction());
274274
else if (tag == "ticklen") { // obsolete (version < 1.12)
@@ -387,7 +387,7 @@ void ChordRest::readAddConnector(ConnectorInfoReader* info, bool pasteMode)
387387

388388
void ChordRest::setSmall(bool val)
389389
{
390-
_small = val;
390+
m_isSmall = val;
391391
}
392392

393393
//---------------------------------------------------------
@@ -845,7 +845,7 @@ void ChordRest::localSpatiumChanged(qreal oldValue, qreal newValue)
845845
QVariant ChordRest::getProperty(Pid propertyId) const
846846
{
847847
switch (propertyId) {
848-
case Pid::SMALL: return QVariant(small());
848+
case Pid::SMALL: return QVariant(isSmall());
849849
case Pid::BEAM_MODE: return int(beamMode());
850850
case Pid::STAFF_MOVE: return staffMove();
851851
case Pid::DURATION_TYPE: return QVariant::fromValue(actualDurationType());

0 commit comments

Comments
 (0)