Merge pull request #5850 from igorkorsukov/pvs_fizeds_step2

Fixed some issues from PVS-Studio report (step2)
This commit is contained in:
anatoly-os 2020-03-24 13:12:03 +02:00 committed by GitHub
commit 9e456031cf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
41 changed files with 233 additions and 180 deletions

View file

@ -1327,6 +1327,7 @@ void FiguredBass::endEdit(EditData& ed)
score()->startCmd(); score()->startCmd();
triggerLayout(); triggerLayout();
score()->endCmd(); score()->endCmd();
delete pItem;
return; return;
} }
pItem->setTrack(track()); pItem->setTrack(track());

View file

@ -2118,7 +2118,8 @@ static void readMeasure(Measure* m, int staffIdx, XmlReader& e)
e.addBeam(beam); e.addBeam(beam);
} }
else if (tag == "Segment") { else if (tag == "Segment") {
segment->read(e); if (segment)
segment->read(e);
while (e.readNextStartElement()) { while (e.readNextStartElement()) {
const QStringRef& t(e.name()); const QStringRef& t(e.name());
if (t == "off1") { if (t == "off1") {

View file

@ -2084,9 +2084,10 @@ qreal Segment::minHorizontalCollidingDistance(Segment* ns) const
qreal Segment::minHorizontalDistance(Segment* ns, bool systemHeaderGap) const qreal Segment::minHorizontalDistance(Segment* ns, bool systemHeaderGap) const
{ {
qreal ww = -1000000.0; // can remain negative qreal ww = -1000000.0; // can remain negative
for (unsigned staffIdx = 0; staffIdx < _shapes.size(); ++staffIdx) { for (unsigned staffIdx = 0; staffIdx < _shapes.size(); ++staffIdx) {
qreal d = staffShape(staffIdx).minHorizontalDistance(ns->staffShape(staffIdx)); qreal d = ns ? staffShape(staffIdx).minHorizontalDistance(ns->staffShape(staffIdx)) : 0.0;
// first chordrest of a staff should clear the widest header for any staff // first chordrest of a staff should clear the widest header for any staff
// so make sure segment is as wide as it needs to be // so make sure segment is as wide as it needs to be
if (systemHeaderGap) if (systemHeaderGap)

View file

@ -21,7 +21,7 @@ namespace Ms {
//------------------------------------------------------------------- //-------------------------------------------------------------------
class StaffLines final : public Element { class StaffLines final : public Element {
qreal lw; qreal lw { 0.0 };
QVector<QLineF> lines; QVector<QLineF> lines;
public: public:

View file

@ -30,11 +30,11 @@ enum class StaffStateType : char {
//--------------------------------------------------------- //---------------------------------------------------------
class StaffState final : public Element { class StaffState final : public Element {
StaffStateType _staffStateType; StaffStateType _staffStateType { StaffStateType::INVISIBLE };
qreal lw; qreal lw { 0.0 };
QPainterPath path; QPainterPath path;
Instrument* _instrument; Instrument* _instrument { nullptr };
virtual void draw(QPainter*) const; virtual void draw(QPainter*) const;
virtual void layout(); virtual void layout();

View file

@ -418,12 +418,12 @@ enum class TabBeamGrid : char {
}; };
class TabDurationSymbol final : public Element { class TabDurationSymbol final : public Element {
qreal _beamLength; // if _grid==MEDIALFINAL, length of the beam toward previous grid element qreal _beamLength { 0.0 }; // if _grid==MEDIALFINAL, length of the beam toward previous grid element
int _beamLevel; // if _grid==MEDIALFINAL, the number of beams int _beamLevel { 0 }; // if _grid==MEDIALFINAL, the number of beams
TabBeamGrid _beamGrid; // value for special 'English' grid display TabBeamGrid _beamGrid { TabBeamGrid::NONE }; // value for special 'English' grid display
const StaffType* _tab; const StaffType* _tab { nullptr};
QString _text; QString _text;
bool _repeat; bool _repeat { false };
public: public:
TabDurationSymbol(Score* s); TabDurationSymbol(Score* s);

View file

@ -147,8 +147,11 @@ void Stem::spatiumChanged(qreal oldValue, qreal newValue)
void Stem::draw(QPainter* painter) const void Stem::draw(QPainter* painter) const
{ {
if (!chord()) // may be need assert?
return;
// hide if second chord of a cross-measure pair // hide if second chord of a cross-measure pair
if (chord() && chord()->crossMeasure() == CrossMeasure::SECOND) if (chord()->crossMeasure() == CrossMeasure::SECOND)
return; return;
const Staff* st = staff(); const Staff* st = staff();
@ -158,17 +161,17 @@ void Stem::draw(QPainter* painter) const
painter->setPen(QPen(curColor(), lineWidthMag(), Qt::SolidLine, Qt::RoundCap)); painter->setPen(QPen(curColor(), lineWidthMag(), Qt::SolidLine, Qt::RoundCap));
painter->drawLine(line); painter->drawLine(line);
if (!(useTab && chord())) if (!useTab)
return; return;
// TODO: adjust bounding rectangle in layout() for dots and for slash // TODO: adjust bounding rectangle in layout() for dots and for slash
qreal sp = spatium(); qreal sp = spatium();
bool _up = up(); bool isUp = up();
// slashed half note stem // slashed half note stem
if (chord()->durationType().type() == TDuration::DurationType::V_HALF && stt->minimStyle() == TablatureMinimStyle::SLASHED) { if (chord()->durationType().type() == TDuration::DurationType::V_HALF && stt->minimStyle() == TablatureMinimStyle::SLASHED) {
// position slashes onto stem // position slashes onto stem
qreal y = _up ? -(_len+_userLen) + STAFFTYPE_TAB_SLASH_2STARTY_UP*sp : (_len+_userLen) - STAFFTYPE_TAB_SLASH_2STARTY_DN*sp; qreal y = isUp ? -(_len+_userLen) + STAFFTYPE_TAB_SLASH_2STARTY_UP*sp : (_len+_userLen) - STAFFTYPE_TAB_SLASH_2STARTY_DN*sp;
// if stems through, try to align slashes within or across lines // if stems through, try to align slashes within or across lines
if (stt->stemThrough()) { if (stt->stemThrough()) {
qreal halfLineDist = stt->lineDistance().val() * sp * 0.5; qreal halfLineDist = stt->lineDistance().val() * sp * 0.5;
@ -200,7 +203,7 @@ void Stem::draw(QPainter* painter) const
int nDots = chord()->dots(); int nDots = chord()->dots();
if (nDots > 0 && !stt->stemThrough()) { if (nDots > 0 && !stt->stemThrough()) {
qreal x = chord()->dotPosX(); qreal x = chord()->dotPosX();
qreal y = ( (STAFFTYPE_TAB_DEFAULTSTEMLEN_DN * 0.2) * sp) * (_up ? -1.0 : 1.0); qreal y = ( (STAFFTYPE_TAB_DEFAULTSTEMLEN_DN * 0.2) * sp) * (isUp ? -1.0 : 1.0);
qreal step = score()->styleS(Sid::dotDotDistance).val() * sp; qreal step = score()->styleS(Sid::dotDotDistance).val() * sp;
for (int dot = 0; dot < nDots; dot++, x += step) for (int dot = 0; dot < nDots; dot++, x += step)
drawSymbol(SymId::augmentationDot, painter, QPointF(x, y)); drawSymbol(SymId::augmentationDot, painter, QPointF(x, y));

View file

@ -77,17 +77,17 @@ class SysStaff {
//--------------------------------------------------------- //---------------------------------------------------------
class System final : public Element { class System final : public Element {
SystemDivider* _systemDividerLeft { 0 }; // to the next system SystemDivider* _systemDividerLeft { nullptr }; // to the next system
SystemDivider* _systemDividerRight { 0 }; SystemDivider* _systemDividerRight { nullptr };
std::vector<MeasureBase*> ml; std::vector<MeasureBase*> ml;
QList<SysStaff*> _staves; QList<SysStaff*> _staves;
QList<Bracket*> _brackets; QList<Bracket*> _brackets;
QList<SpannerSegment*> _spannerSegments; QList<SpannerSegment*> _spannerSegments;
qreal _leftMargin { 0.0 }; ///< left margin for instrument name, brackets etc. qreal _leftMargin { 0.0 }; ///< left margin for instrument name, brackets etc.
mutable bool fixedDownDistance { false }; mutable bool fixedDownDistance { false };
qreal _distance; // temp. variable used during layout qreal _distance { 0.0 }; // temp. variable used during layout
int firstVisibleSysStaff() const; int firstVisibleSysStaff() const;
int lastVisibleSysStaff() const; int lastVisibleSysStaff() const;

View file

@ -24,6 +24,7 @@ TEvent::TEvent()
type = TempoType::INVALID; type = TempoType::INVALID;
tempo = 0.0; tempo = 0.0;
pause = 0.0; pause = 0.0;
time = 0.0;
} }
TEvent::TEvent(const TEvent& e) TEvent::TEvent(const TEvent& e)

View file

@ -261,7 +261,7 @@ void TextLineBaseSegment::layout()
// diagonal line with no text or hooks - just use the basic rectangle for line // diagonal line with no text or hooks - just use the basic rectangle for line
if (_text->empty() && _endText->empty() && pp2.y() != 0 if (_text->empty() && _endText->empty() && pp2.y() != 0
&& textLineBase()->beginHookType() == HookType::NONE && textLineBase()->beginHookType() == HookType::NONE) { && textLineBase()->beginHookType() == HookType::NONE) {
npoints = 2; npoints = 2;
points[0] = pp1; points[0] = pp1;
points[1] = pp2; points[1] = pp2;

View file

@ -51,10 +51,14 @@ static const ElementStyle tupletStyle {
Tuplet::Tuplet(Score* s) Tuplet::Tuplet(Score* s)
: DurationElement(s) : DurationElement(s)
{ {
_direction = Direction::AUTO;
_numberType = TupletNumberType::SHOW_NUMBER;
_bracketType = TupletBracketType::AUTO_BRACKET;
_ratio = Fraction(1, 1); _ratio = Fraction(1, 1);
_number = 0; _number = 0;
_hasBracket = false; _hasBracket = false;
_isUp = true; _isUp = true;
_id = 0;
initElementStyle(&tupletStyle); initElementStyle(&tupletStyle);
} }
@ -77,6 +81,7 @@ Tuplet::Tuplet(const Tuplet& t)
_p1 = t._p1; _p1 = t._p1;
_p2 = t._p2; _p2 = t._p2;
_id = t._id;
// recreated on layout // recreated on layout
_number = 0; _number = 0;
} }

View file

@ -22,6 +22,7 @@
between startUndo() and endUndo(). between startUndo() and endUndo().
*/ */
#include "log.h"
#include "undo.h" #include "undo.h"
#include "element.h" #include "element.h"
#include "note.h" #include "note.h"
@ -2563,8 +2564,14 @@ void MoveTremolo::redo(EditData*)
// Find new tremolo chords // Find new tremolo chords
Measure* m1 = score->tick2measure(chord1Tick); Measure* m1 = score->tick2measure(chord1Tick);
Measure* m2 = score->tick2measure(chord2Tick); Measure* m2 = score->tick2measure(chord2Tick);
IF_ASSERT_FAILED(m1 && m2) {
return;
}
Chord* c1 = m1->findChord(chord1Tick, track); Chord* c1 = m1->findChord(chord1Tick, track);
Chord* c2 = m2->findChord(chord2Tick, track); Chord* c2 = m2->findChord(chord2Tick, track);
IF_ASSERT_FAILED(c1 && c2) {
return;
}
// Remember the old tremolo chords // Remember the old tremolo chords
oldC1 = trem->chord1(); oldC1 = trem->chord1();

View file

@ -538,7 +538,7 @@ static Fraction readCapVoice(Score* score, CapVoice* cvoice, int staffIdx, const
// //
Fraction startTick = tick; Fraction startTick = tick;
Tuplet* tuplet = 0; Tuplet* tuplet = nullptr;
int tupletCount = 0; int tupletCount = 0;
bool tuplettrp = false; bool tuplettrp = false;
bool tupletprol = false; bool tupletprol = false;
@ -559,7 +559,7 @@ static Fraction readCapVoice(Score* score, CapVoice* cvoice, int staffIdx, const
TDuration d; TDuration d;
d.setVal(ticks.ticks()); d.setVal(ticks.ticks());
if (o->count) { if (o->count) {
if (tuplet == 0) { if (tuplet == nullptr) {
tupletCount = o->count; tupletCount = o->count;
tuplettrp = o->tripartite; tuplettrp = o->tripartite;
tupletprol = o->isProlonging; tupletprol = o->isProlonging;
@ -616,7 +616,11 @@ static Fraction readCapVoice(Score* score, CapVoice* cvoice, int staffIdx, const
if (tuplet) { if (tuplet) {
if (++nTuplet >= tupletCount) { if (++nTuplet >= tupletCount) {
tick = tupletTick + tuplet->actualTicks(); tick = tupletTick + tuplet->actualTicks();
tuplet = 0; //! NOTE If the tuplet is not added anywhere, then delete it
if (tuplet->elements().empty())
delete tuplet;
tuplet = nullptr;
} }
else { else {
tick += ticks / tuplet->ratio(); tick += ticks / tuplet->ratio();
@ -640,7 +644,7 @@ static Fraction readCapVoice(Score* score, CapVoice* cvoice, int staffIdx, const
bool isgracenote = (!(o->invisible) && (ticks.isZero())); bool isgracenote = (!(o->invisible) && (ticks.isZero()));
if (o->count) { if (o->count) {
if (tuplet == 0) { if (tuplet == nullptr) {
tupletCount = o->count; tupletCount = o->count;
tuplettrp = o->tripartite; tuplettrp = o->tripartite;
tupletprol = o->isProlonging; tupletprol = o->isProlonging;
@ -796,7 +800,11 @@ static Fraction readCapVoice(Score* score, CapVoice* cvoice, int staffIdx, const
if (tuplet) { if (tuplet) {
if (++nTuplet >= tupletCount) { if (++nTuplet >= tupletCount) {
tick = tupletTick + tuplet->actualTicks(); tick = tupletTick + tuplet->actualTicks();
tuplet = 0; //! NOTE If the tuplet is not added anywhere, then delete it
if (tuplet->elements().empty())
delete tuplet;
tuplet = nullptr;
} }
else { else {
tick += ticks / tuplet->ratio(); tick += ticks / tuplet->ratio();

View file

@ -111,7 +111,7 @@ class CapKey : public NoteObj, public CapellaObj {
CapKey(Capella* c) : NoteObj(CapellaNoteObjectType::KEY), CapellaObj(c) {} CapKey(Capella* c) : NoteObj(CapellaNoteObjectType::KEY), CapellaObj(c) {}
void read(); void read();
void readCapx(XmlReader& e); void readCapx(XmlReader& e);
int signature; // -7 - +7 int signature { 0 }; // -7 - +7
}; };
//--------------------------------------------------------- //---------------------------------------------------------
@ -134,8 +134,8 @@ class CapMeter : public NoteObj, public CapellaObj {
//--------------------------------------------------------- //---------------------------------------------------------
class CapExplicitBarline : public NoteObj, public CapellaObj { class CapExplicitBarline : public NoteObj, public CapellaObj {
BarLineType _type; BarLineType _type { BarLineType::NORMAL };
int _barMode; // 0 = auto, 1 = nur Zeilen, 2 = durchgezogen int _barMode { 0 }; // 0 = auto, 1 = nur Zeilen, 2 = durchgezogen
public: public:
CapExplicitBarline(Capella* c) : NoteObj(CapellaNoteObjectType::EXPL_BARLINE), CapellaObj(c) {} CapExplicitBarline(Capella* c) : NoteObj(CapellaNoteObjectType::EXPL_BARLINE), CapellaObj(c) {}
@ -291,7 +291,7 @@ class TransposableObj : public BasicDrawObj {
void read(); void read();
QPointF relPos; QPointF relPos;
char b; char b { 0 };
QList<BasicDrawObj*> variants; QList<BasicDrawObj*> variants;
}; };
@ -318,7 +318,7 @@ class LineObj : public BasicDrawObj {
QPointF pt1, pt2; QPointF pt1, pt2;
QColor color; QColor color;
char lineWidth; char lineWidth { 0 };
}; };
//--------------------------------------------------------- //---------------------------------------------------------
@ -596,8 +596,8 @@ class ChordObj : public BasicDurationalObj, public NoteObj {
//--------------------------------------------------------- //---------------------------------------------------------
class RestObj : public BasicDurationalObj, public NoteObj { class RestObj : public BasicDurationalObj, public NoteObj {
bool bVerticalCentered; bool bVerticalCentered { false };
int vertShift; int vertShift { 0 };
public: public:
RestObj(Capella*); RestObj(Capella*);

View file

@ -155,7 +155,10 @@ ChordView::ChordView()
setDragMode(QGraphicsView::RubberBandDrag); setDragMode(QGraphicsView::RubberBandDrag);
magStep = 2; magStep = 2;
chord = 0; chord = 0;
_curNote = 0; _curNote = 0;
_locator = 0;
_pos = 0;
locatorLine = nullptr;
_evenGrid = true; _evenGrid = true;
lg = 0; lg = 0;
rg = 0; rg = 0;

View file

@ -37,10 +37,11 @@ namespace Ms {
ContinuousPanel::ContinuousPanel(ScoreView* sv) ContinuousPanel::ContinuousPanel(ScoreView* sv)
{ {
_sv = sv; _sv = sv;
_active = true; _score = nullptr;
_visible = false; _active = true;
_width = 0.0; _visible = false;
_width = 0.0;
} }
//--------------------------------------------------------- //---------------------------------------------------------

View file

@ -164,7 +164,7 @@ void ScoreView::endEdit()
for (int i = 0; i < editData.grips; ++i) for (int i = 0; i < editData.grips; ++i)
score()->addRefresh(editData.grip[i]); score()->addRefresh(editData.grip[i]);
editData.element->endEdit(editData); editData.element->endEdit(editData);
//! NOTE After endEdit, the element may be null
if (editData.element) { if (editData.element) {
_score->addRefresh(editData.element->canvasBoundingRect()); _score->addRefresh(editData.element->canvasBoundingRect());
ElementType tp = editData.element->type(); ElementType tp = editData.element->type();

View file

@ -5531,9 +5531,9 @@ void ExportMusicXml::writeElement(Element* el, const Measure* m, int sstaff, boo
} }
else if (el->isChord()) { else if (el->isChord()) {
const auto c = toChord(el); const auto c = toChord(el);
const auto ll = &c->lyrics();
// ise grace after // ise grace after
if (c) { if (c) {
const auto ll = &c->lyrics();
for (const auto g : c->graceNotesBefore()) { for (const auto g : c->graceNotesBefore()) {
chord(g, sstaff, ll, useDrumset); chord(g, sstaff, ll, useDrumset);
} }

View file

@ -43,6 +43,7 @@ FretCanvas::FretCanvas(QWidget* parent)
// setFrameStyle(QFrame::Raised | QFrame::Panel); // setFrameStyle(QFrame::Raised | QFrame::Panel);
cstring = -2; cstring = -2;
cfret = -2; cfret = -2;
_currentDtype = FretDotType::NORMAL;
} }
//--------------------------------------------------------- //---------------------------------------------------------

View file

@ -34,11 +34,11 @@ enum class FretDotType : signed char;
class FretCanvas : public QFrame { class FretCanvas : public QFrame {
Q_OBJECT Q_OBJECT
FretDiagram* diagram; FretDiagram* diagram { nullptr };
int cstring; int cstring { 0 };
int cfret; int cfret { 0 };
bool _automaticDotType { true }; bool _automaticDotType { true };
FretDotType _currentDtype; FretDotType _currentDtype;
bool _barreMode { false }; bool _barreMode { false };
bool _multidotMode { false }; bool _multidotMode { false };

View file

@ -117,10 +117,12 @@ void ChordStyleEditor::loadChordDescriptionFile(const QString& s)
ChordList* cl = new ChordList; ChordList* cl = new ChordList;
if (!cl->read("chords.xml")) { if (!cl->read("chords.xml")) {
qDebug("cannot read <chords.xml>"); qDebug("cannot read <chords.xml>");
delete cl;
return; return;
} }
if (!cl->read(s)) { if (!cl->read(s)) {
qDebug("cannot read <%s>", qPrintable(s)); qDebug("cannot read <%s>", qPrintable(s));
delete cl;
return; return;
} }
setChordList(cl); setChordList(cl);
@ -231,9 +233,10 @@ HarmonyCanvas::HarmonyCanvas(QWidget* parent)
setAcceptDrops(true); setAcceptDrops(true);
setFocusPolicy(Qt::StrongFocus); setFocusPolicy(Qt::StrongFocus);
extraMag = 3.0; extraMag = 3.0;
chordDescription = 0; chordDescription = nullptr;
chordList = 0; chordList = nullptr;
moveElement = 0; moveElement = nullptr;
dragElement = nullptr;
QAction* a = getAction("delete"); QAction* a = getAction("delete");
addAction(a); addAction(a);
connect(a, SIGNAL(triggered()), SLOT(deleteAction())); connect(a, SIGNAL(triggered()), SLOT(deleteAction()));

View file

@ -179,7 +179,8 @@ MsScWriter::MsScWriter()
currentMeasure(0), currentMeasure(0),
tuplet(0), tuplet(0),
lastVolta(0), lastVolta(0),
tempo(0) tempo(0),
ending(0)
{ {
qDebug() << "MsScWriter::MsScWriter()"; qDebug() << "MsScWriter::MsScWriter()";

View file

@ -724,7 +724,7 @@ void PowerTab::fillMeasure(tBeatList& elist, Measure* measure, int staff, std::v
} }
} }
if (tupleBeatCounter) { if (tupleBeatCounter && tuple) {
tupleBeatCounter--; tupleBeatCounter--;
cr->setTuplet(tuple); cr->setTuplet(tuple);
tuple->add(cr); tuple->add(cr);

View file

@ -241,22 +241,22 @@ class PowerTab {
struct ptTrack; struct ptTrack;
struct ptSection { struct ptSection {
int number{ 0 }; int number { 0 };
int staffs{ 0 }; int staffs { 0 };
std::string partName; std::string partName;
char partMarker; char partMarker { 0 };
std::vector<ptPosition> positions; std::vector<ptPosition> positions;
std::vector<int> staffMap; std::vector<int> staffMap;
int tempo{ 0 }; int tempo { 0 };
std::list<stRhytmSlash> rhytm; std::list<stRhytmSlash> rhytm;
std::map<int, ptChordText> chordTextMap; std::map<int, ptChordText> chordTextMap;
std::vector<tBeatList> beats; std::vector<tBeatList> beats;
std::list<shared_ptr<ptBar>> bars; std::list<shared_ptr<ptBar>> bars;
bool readed{ false }; bool readed { false };
void copyTracks(ptTrack*); void copyTracks(ptTrack*);

View file

@ -223,7 +223,7 @@ class InspectorClef : public InspectorElementBase {
Ui::InspectorSegment s; Ui::InspectorSegment s;
Ui::InspectorClef c; Ui::InspectorClef c;
Clef* otherClef; // the courtesy clef for a main clef or viceversa Clef* otherClef { nullptr }; // the courtesy clef for a main clef or viceversa
// used to keep in sync ShowCourtesy setting of both clefs // used to keep in sync ShowCourtesy setting of both clefs
protected slots: protected slots:
virtual void valueChanged(int idx) override; virtual void valueChanged(int idx) override;

View file

@ -387,7 +387,6 @@ void Mixer::updateTracks()
Instrument* proxyInstr = nullptr; Instrument* proxyInstr = nullptr;
Channel* proxyChan = nullptr; Channel* proxyChan = nullptr;
if (!il->empty()) { if (!il->empty()) {
il->begin();
proxyInstr = il->begin()->second; proxyInstr = il->begin()->second;
proxyChan = proxyInstr->playbackChannel(0, _score->masterScore()); proxyChan = proxyInstr->playbackChannel(0, _score->masterScore());
} }

View file

@ -61,6 +61,8 @@ Portaudio::Portaudio(Seq* s)
initialized = false; initialized = false;
state = Transport::STOP; state = Transport::STOP;
seekflag = false; seekflag = false;
pos = 0;
startTime = 0.0;
midiDriver = 0; midiDriver = 0;
} }

View file

@ -45,16 +45,19 @@ PianoLevels::PianoLevels(QWidget *parent)
: QWidget(parent) : QWidget(parent)
{ {
setMouseTracking(true); setMouseTracking(true);
_xpos = 0; _score = nullptr;
_xZoom = X_ZOOM_INITIAL; _xpos = 0;
_tuplet = 1; _xZoom = X_ZOOM_INITIAL;
_subdiv = 0; _locator = nullptr;
_staff = nullptr;
_tuplet = 1;
_subdiv = 0;
_levelsIndex = 0; _levelsIndex = 0;
minBeatGap = 20; minBeatGap = 20;
vMargin = 10; vMargin = 10;
levelLen = 20; levelLen = 20;
mouseDown = false; mouseDown = false;
dragging = false; dragging = false;
} }
//--------------------------------------------------------- //---------------------------------------------------------

View file

@ -110,8 +110,10 @@ PianoRuler::PianoRuler(QWidget* parent)
markIcon[2] = new QPixmap(rmark_xpm); markIcon[2] = new QPixmap(rmark_xpm);
} }
setMouseTracking(true); setMouseTracking(true);
_xpos = 0; _xpos = 0;
_xZoom = X_ZOOM_INITIAL; _score = nullptr;
_locator = nullptr;
_xZoom = X_ZOOM_INITIAL;
_timeType = TType::TICKS; _timeType = TType::TICKS;
_font2.setPixelSize(14); _font2.setPixelSize(14);
_font2.setBold(true); _font2.setBold(true);

View file

@ -276,19 +276,22 @@ PianoView::PianoView()
setTransformationAnchor(QGraphicsView::AnchorUnderMouse); setTransformationAnchor(QGraphicsView::AnchorUnderMouse);
setResizeAnchor(QGraphicsView::AnchorUnderMouse); setResizeAnchor(QGraphicsView::AnchorUnderMouse);
setMouseTracking(true); setMouseTracking(true);
_timeType = TType::TICKS; _timeType = TType::TICKS;
_playEventsView = true; _playEventsView = true;
_staff = 0; _staff = nullptr;
chord = 0; _chord = nullptr;
_locator = nullptr;
_ticks = 0;
_barPattern = 0; _barPattern = 0;
_tuplet = 1; _tuplet = 1;
_subdiv = 0; _subdiv = 0;
_noteHeight = DEFAULT_KEY_HEIGHT; _noteHeight = DEFAULT_KEY_HEIGHT;
_xZoom = X_ZOOM_INITIAL; _xZoom = X_ZOOM_INITIAL;
dragStarted = false; _dragStarted = false;
mouseDown = false; _lastDragPitch = 0;
dragStyle = DragStyle::NONE; _mouseDown = false;
inProgressUndoEvent = false; _dragStyle = DragStyle::NONE;
_inProgressUndoEvent = false;
} }
//--------------------------------------------------------- //---------------------------------------------------------
@ -351,7 +354,7 @@ void PianoView::drawBackground(QPainter* p, const QRectF& r)
QRectF r1; QRectF r1;
r1.setCoords(-1000000.0, 0.0, tickToPixelX(0), 1000000.0); r1.setCoords(-1000000.0, 0.0, tickToPixelX(0), 1000000.0);
QRectF r2; QRectF r2;
r2.setCoords(tickToPixelX(ticks), 0.0, 1000000.0, 1000000.0); r2.setCoords(tickToPixelX(_ticks), 0.0, 1000000.0, 1000000.0);
p->fillRect(r, colWhiteKeyBg); p->fillRect(r, colWhiteKeyBg);
if (r.intersects(r1)) if (r.intersects(r1))
@ -365,7 +368,7 @@ void PianoView::drawBackground(QPainter* p, const QRectF& r)
qreal y1 = r.y(); qreal y1 = r.y();
qreal y2 = y1 + r.height(); qreal y2 = y1 + r.height();
qreal x1 = qMax(r.x(), (qreal)tickToPixelX(0)); qreal x1 = qMax(r.x(), (qreal)tickToPixelX(0));
qreal x2 = qMin(x1 + r.width(), (qreal)tickToPixelX(ticks)); qreal x2 = qMin(x1 + r.width(), (qreal)tickToPixelX(_ticks));
int topPitch = ceil((_noteHeight * 128 - y1) / _noteHeight); int topPitch = ceil((_noteHeight * 128 - y1) / _noteHeight);
int bmPitch = floor((_noteHeight * 128 - y2) / _noteHeight); int bmPitch = floor((_noteHeight * 128 - y2) / _noteHeight);
@ -382,7 +385,7 @@ void PianoView::drawBackground(QPainter* p, const QRectF& r)
// if (degree == 1 || degree == 3 || degree == 6 || degree == 8 || degree == 10) { // if (degree == 1 || degree == 3 || degree == 6 || degree == 8 || degree == 10) {
if (!pat.isWhiteKey[degree]) { if (!pat.isWhiteKey[degree]) {
qreal px0 = qMax(r.x(), (qreal)tickToPixelX(0)); qreal px0 = qMax(r.x(), (qreal)tickToPixelX(0));
qreal px1 = qMin(r.x() + r.width(), (qreal)tickToPixelX(ticks)); qreal px1 = qMin(r.x() + r.width(), (qreal)tickToPixelX(_ticks));
QRectF hbar; QRectF hbar;
hbar.setCoords(px0, y, px1, y + _noteHeight); hbar.setCoords(px0, y, px1, y + _noteHeight);
@ -448,8 +451,8 @@ void PianoView::drawBackground(QPainter* p, const QRectF& r)
} }
//Draw notes //Draw notes
for (int i = 0; i < noteList.size(); ++i) for (int i = 0; i < _noteList.size(); ++i)
noteList[i]->paint(p); _noteList[i]->paint(p);
//Draw locators //Draw locators
for (int i = 0; i < 3; ++i) { for (int i = 0; i < 3; ++i) {
@ -462,11 +465,11 @@ void PianoView::drawBackground(QPainter* p, const QRectF& r)
} }
//Draw drag selection box //Draw drag selection box
if (dragStarted && dragStyle == DragStyle::SELECTION_RECT) { if (_dragStarted && _dragStyle == DragStyle::SELECTION_RECT) {
int minX = qMin(mouseDownPos.x(), lastMousePos.x()); int minX = qMin(_mouseDownPos.x(), _lastMousePos.x());
int minY = qMin(mouseDownPos.y(), lastMousePos.y()); int minY = qMin(_mouseDownPos.y(), _lastMousePos.y());
int maxX = qMax(mouseDownPos.x(), lastMousePos.x()); int maxX = qMax(_mouseDownPos.x(), _lastMousePos.x());
int maxY = qMax(mouseDownPos.y(), lastMousePos.y()); int maxY = qMax(_mouseDownPos.y(), _lastMousePos.y());
QRectF rect(minX, minY, maxX - minX + 1, maxY - minY + 1); QRectF rect(minX, minY, maxX - minX + 1, maxY - minY + 1);
p->setPen(QPen(colSelectionBox, 2)); p->setPen(QPen(colSelectionBox, 2));
@ -591,9 +594,9 @@ void PianoView::mousePressEvent(QMouseEvent* event)
{ {
bool rightBn = event->button() == Qt::RightButton; bool rightBn = event->button() == Qt::RightButton;
if (!rightBn) { if (!rightBn) {
mouseDown = true; _mouseDown = true;
mouseDownPos = mapToScene(event->pos()); _mouseDownPos = mapToScene(event->pos());
lastMousePos = mouseDownPos; _lastMousePos = _mouseDownPos;
} }
} }
@ -617,13 +620,13 @@ void PianoView::mouseReleaseEvent(QMouseEvent* event)
NoteSelectType selType = bnShift ? (bnCtrl ? NoteSelectType::SUBTRACT : NoteSelectType::XOR) NoteSelectType selType = bnShift ? (bnCtrl ? NoteSelectType::SUBTRACT : NoteSelectType::XOR)
: (bnCtrl ? NoteSelectType::ADD : NoteSelectType::REPLACE); : (bnCtrl ? NoteSelectType::ADD : NoteSelectType::REPLACE);
if (dragStarted) { if (_dragStarted) {
if (dragStyle == DragStyle::SELECTION_RECT) { if (_dragStyle == DragStyle::SELECTION_RECT) {
//Update selection //Update selection
qreal minX = qMin(mouseDownPos.x(), lastMousePos.x()); qreal minX = qMin(_mouseDownPos.x(), _lastMousePos.x());
qreal minY = qMin(mouseDownPos.y(), lastMousePos.y()); qreal minY = qMin(_mouseDownPos.y(), _lastMousePos.y());
qreal maxX = qMax(mouseDownPos.x(), lastMousePos.x()); qreal maxX = qMax(_mouseDownPos.x(), _lastMousePos.x());
qreal maxY = qMax(mouseDownPos.y(), lastMousePos.y()); qreal maxY = qMax(_mouseDownPos.y(), _lastMousePos.y());
int startTick = pixelXToTick((int)minX); int startTick = pixelXToTick((int)minX);
int endTick = pixelXToTick((int)maxX); int endTick = pixelXToTick((int)maxX);
@ -632,19 +635,19 @@ void PianoView::mouseReleaseEvent(QMouseEvent* event)
selectNotes(startTick, endTick, lowPitch, highPitch, selType); selectNotes(startTick, endTick, lowPitch, highPitch, selType);
} }
else if (dragStyle == DragStyle::MOVE_NOTES) { else if (_dragStyle == DragStyle::MOVE_NOTES) {
//Keep last note drag event, if any //Keep last note drag event, if any
if (inProgressUndoEvent) if (_inProgressUndoEvent)
inProgressUndoEvent = false; _inProgressUndoEvent = false;
} }
dragStarted = false; _dragStarted = false;
} }
else { else {
Score* score = _staff->score(); Score* score = _staff->score();
int pickTick = pixelXToTick((int)mouseDownPos.x()); int pickTick = pixelXToTick((int)_mouseDownPos.x());
int pickPitch = pixelYToPitch(mouseDownPos.y()); int pickPitch = pixelYToPitch(_mouseDownPos.y());
PianoItem *pn = pickNote(pickTick, pickPitch); PianoItem *pn = pickNote(pickTick, pickPitch);
if (pn) { if (pn) {
@ -773,8 +776,8 @@ void PianoView::mouseReleaseEvent(QMouseEvent* event)
} }
dragStyle = DragStyle::NONE; _dragStyle = DragStyle::NONE;
mouseDown = false; _mouseDown = false;
scene()->update(); scene()->update();
} }
@ -786,51 +789,51 @@ void PianoView::mouseReleaseEvent(QMouseEvent* event)
void PianoView::mouseMoveEvent(QMouseEvent* event) void PianoView::mouseMoveEvent(QMouseEvent* event)
{ {
lastMousePos = mapToScene(event->pos()); _lastMousePos = mapToScene(event->pos());
if (mouseDown && !dragStarted) { if (_mouseDown && !_dragStarted) {
qreal dx = lastMousePos.x() - mouseDownPos.x(); qreal dx = _lastMousePos.x() - _mouseDownPos.x();
qreal dy = lastMousePos.y() - mouseDownPos.y(); qreal dy = _lastMousePos.y() - _mouseDownPos.y();
if (dx * dx + dy * dy >= MIN_DRAG_DIST_SQ) { if (dx * dx + dy * dy >= MIN_DRAG_DIST_SQ) {
//Start dragging //Start dragging
dragStarted = true; _dragStarted = true;
//Check for move note //Check for move note
int tick = pixelXToTick(mouseDownPos.x()); int tick = pixelXToTick(_mouseDownPos.x());
int mouseDownPitch = pixelYToPitch(mouseDownPos.y()); int mouseDownPitch = pixelYToPitch(_mouseDownPos.y());
PianoItem* pi = pickNote(tick, mouseDownPitch); PianoItem* pi = pickNote(tick, mouseDownPitch);
if (pi) { if (pi) {
if (!pi->note()->selected()) { if (!pi->note()->selected()) {
selectNotes(tick, tick, mouseDownPitch, mouseDownPitch, NoteSelectType::REPLACE); selectNotes(tick, tick, mouseDownPitch, mouseDownPitch, NoteSelectType::REPLACE);
} }
dragStyle = DragStyle::MOVE_NOTES; _dragStyle = DragStyle::MOVE_NOTES;
lastDragPitch = mouseDownPitch; _lastDragPitch = mouseDownPitch;
} }
else { else {
dragStyle = DragStyle::SELECTION_RECT; _dragStyle = DragStyle::SELECTION_RECT;
} }
} }
} }
if (dragStarted) { if (_dragStarted) {
if (dragStyle == DragStyle::MOVE_NOTES) { if (_dragStyle == DragStyle::MOVE_NOTES) {
int curPitch = pixelYToPitch(lastMousePos.y()); int curPitch = pixelYToPitch(_lastMousePos.y());
if (curPitch != lastDragPitch) { if (curPitch != _lastDragPitch) {
int pitchDelta = curPitch - lastDragPitch; int pitchDelta = curPitch - _lastDragPitch;
Score* score = _staff->score(); Score* score = _staff->score();
if (inProgressUndoEvent) { if (_inProgressUndoEvent) {
// score->undoRedo(true, 0, false); // score->undoRedo(true, 0, false);
inProgressUndoEvent = false; _inProgressUndoEvent = false;
} }
score->startCmd(); score->startCmd();
score->upDownDelta(pitchDelta); score->upDownDelta(pitchDelta);
score->endCmd(); score->endCmd();
inProgressUndoEvent = true; _inProgressUndoEvent = true;
lastDragPitch = curPitch; _lastDragPitch = curPitch;
} }
} }
@ -919,8 +922,8 @@ bool PianoView::cutChordRest(ChordRest* e, int track, int cutTick, ChordRest*& c
PianoItem* PianoView::pickNote(int tick, int pitch) PianoItem* PianoView::pickNote(int tick, int pitch)
{ {
for (int i = 0; i < noteList.size(); ++i) { for (int i = 0; i < _noteList.size(); ++i) {
PianoItem* pi = noteList[i]; PianoItem* pi = _noteList[i];
if (pi->intersects(tick, tick, pitch, pitch)) if (pi->intersects(tick, tick, pitch, pitch))
return pi; return pi;
@ -940,8 +943,8 @@ void PianoView::selectNotes(int startTick, int endTick, int lowPitch, int highPi
score->startCmd(); score->startCmd();
QList<PianoItem*> oldSel; QList<PianoItem*> oldSel;
for (int i = 0; i < noteList.size(); ++i) { for (int i = 0; i < _noteList.size(); ++i) {
PianoItem* pi = noteList[i]; PianoItem* pi = _noteList[i];
if (pi->note()->selected()) if (pi->note()->selected())
oldSel.append(pi); oldSel.append(pi);
} }
@ -949,8 +952,8 @@ void PianoView::selectNotes(int startTick, int endTick, int lowPitch, int highPi
Selection& selection = score->selection(); Selection& selection = score->selection();
selection.deselectAll(); selection.deselectAll();
for (int i = 0; i < noteList.size(); ++i) { for (int i = 0; i < _noteList.size(); ++i) {
PianoItem* pi = noteList[i]; PianoItem* pi = _noteList[i];
bool inBounds = pi->intersects(startTick, endTick, highPitch, lowPitch); bool inBounds = pi->intersects(startTick, endTick, highPitch, lowPitch);
bool sel; bool sel;
@ -1022,9 +1025,9 @@ void PianoView::ensureVisible(int tick)
void PianoView::updateBoundingSize() void PianoView::updateBoundingSize()
{ {
Measure* lm = _staff->score()->lastMeasure(); Measure* lm = _staff->score()->lastMeasure();
ticks = (lm->tick() + lm->ticks()).ticks(); _ticks = (lm->tick() + lm->ticks()).ticks();
scene()->setSceneRect(0.0, 0.0, scene()->setSceneRect(0.0, 0.0,
double((ticks + MAP_OFFSET * 2) * _xZoom), double((_ticks + MAP_OFFSET * 2) * _xZoom),
_noteHeight * 128); _noteHeight * 128);
} }
@ -1059,7 +1062,7 @@ void PianoView::setStaff(Staff* s, Pos* l)
QRectF boundingRectSel; QRectF boundingRectSel;
bool brsInit = false; bool brsInit = false;
foreach (PianoItem* item, noteList) { foreach (PianoItem* item, _noteList) {
if (!brInit) { if (!brInit) {
boundingRect = item->boundingRect(); boundingRect = item->boundingRect();
brInit = true; brInit = true;
@ -1105,7 +1108,7 @@ void PianoView::addChord(Chord* chrd, int voice)
for (Note* note : chrd->notes()) { for (Note* note : chrd->notes()) {
if (note->tieBack()) if (note->tieBack())
continue; continue;
noteList.append(new PianoItem(note, this)); _noteList.append(new PianoItem(note, this));
} }
} }
@ -1146,10 +1149,10 @@ void PianoView::updateNotes()
void PianoView::clearNoteData() void PianoView::clearNoteData()
{ {
for (int i = 0; i < noteList.size(); ++i) for (int i = 0; i < _noteList.size(); ++i)
delete noteList[i]; delete _noteList[i];
noteList.clear(); _noteList.clear();
} }
@ -1160,9 +1163,9 @@ void PianoView::clearNoteData()
QList<PianoItem*> PianoView::getSelectedItems() QList<PianoItem*> PianoView::getSelectedItems()
{ {
QList<PianoItem*> list; QList<PianoItem*> list;
for (int i = 0; i < noteList.size(); ++i) { for (int i = 0; i < _noteList.size(); ++i) {
if (noteList[i]->note()->selected()) if (_noteList[i]->note()->selected())
list.append(noteList[i]); list.append(_noteList[i]);
} }
return list; return list;
} }
@ -1174,8 +1177,8 @@ QList<PianoItem*> PianoView::getSelectedItems()
QList<PianoItem*> PianoView::getItems() QList<PianoItem*> PianoView::getItems()
{ {
QList<PianoItem*> list; QList<PianoItem*> list;
for (int i = 0; i < noteList.size(); ++i) for (int i = 0; i < _noteList.size(); ++i)
list.append(noteList[i]); list.append(_noteList[i]);
return list; return list;
} }

View file

@ -81,11 +81,11 @@ public:
private: private:
Staff* _staff; Staff* _staff;
Chord* chord; Chord* _chord;
Pos trackingPos; //Track mouse position Pos trackingPos; //Track mouse position
Pos* _locator; Pos* _locator;
int ticks; int _ticks;
TType _timeType; TType _timeType;
int _noteHeight; int _noteHeight;
qreal _xZoom; qreal _xZoom;
@ -94,19 +94,19 @@ private:
int _barPattern; int _barPattern;
bool _playEventsView; bool _playEventsView;
bool mouseDown; bool _mouseDown;
bool dragStarted; bool _dragStarted;
QPointF mouseDownPos; QPointF _mouseDownPos;
QPointF lastMousePos; QPointF _lastMousePos;
DragStyle dragStyle; DragStyle _dragStyle;
int lastDragPitch; int _lastDragPitch;
bool inProgressUndoEvent; bool _inProgressUndoEvent;
QList<PianoItem*> noteList; QList<PianoItem*> _noteList;
virtual void drawBackground(QPainter* painter, const QRectF& rect); virtual void drawBackground(QPainter* painter, const QRectF& rect);
void addChord(Chord* chord, int voice); void addChord(Chord* _chord, int voice);
void updateBoundingSize(); void updateBoundingSize();
void clearNoteData(); void clearNoteData();
void selectNotes(int startTick, int endTick, int lowPitch, int highPitch, NoteSelectType selType); void selectNotes(int startTick, int endTick, int lowPitch, int highPitch, NoteSelectType selType);

View file

@ -285,9 +285,8 @@ void MuseScore::removeMenuEntry(PluginDescription* plugin)
QMenu* cmenu = qobject_cast<QMenu*>(cm->parent()); QMenu* cmenu = qobject_cast<QMenu*>(cm->parent());
if (cm->isEmpty()) if (cm->isEmpty())
if(cm->isEmpty()) { delete cm;
delete cm;
}
cm = cmenu; cm = cmenu;
} }
} }

View file

@ -31,8 +31,8 @@ class QmlIconView : public QQuickPaintedItem {
QColor _color; QColor _color;
QIcon _icon; QIcon _icon;
bool _selected; bool _selected { false };
bool _active = false; bool _active { false };
Q_PROPERTY(QVariant icon READ icon WRITE setIcon) Q_PROPERTY(QVariant icon READ icon WRITE setIcon)
Q_PROPERTY(bool selected READ selected WRITE setSelected) Q_PROPERTY(bool selected READ selected WRITE setSelected)

View file

@ -109,10 +109,12 @@ Ruler::Ruler(QWidget* parent)
markIcon[2] = new QPixmap(rmark_xpm); markIcon[2] = new QPixmap(rmark_xpm);
} }
setMouseTracking(true); setMouseTracking(true);
magStep = 0; _score = nullptr;
_xpos = 0; _locator = nullptr;
_xmag = 0.1; magStep = 0;
_timeType = TType::TICKS; _xpos = 0;
_xmag = 0.1;
_timeType = TType::TICKS;
_font2.setPixelSize(14); _font2.setPixelSize(14);
_font2.setBold(true); _font2.setBold(true);
_font1.setPixelSize(10); _font1.setPixelSize(10);

View file

@ -86,7 +86,7 @@ Startcenter::Startcenter(QWidget* parent)
} }
#endif #endif
if (enableExperimental) // if (enableExperimental)
// right now dont know how it use in WebEngine @handrok // right now dont know how it use in WebEngine @handrok
// QWebSettings::globalSettings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, true); // QWebSettings::globalSettings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, true);
// QWebSettings::globalSettings()->setAttribute(QWebSettings::PluginsEnabled, false); // QWebSettings::globalSettings()->setAttribute(QWebSettings::PluginsEnabled, false);

View file

@ -237,8 +237,8 @@ private:
SvgPaintEnginePrivate *d_ptr; SvgPaintEnginePrivate *d_ptr;
// Qt translates everything. These help avoid SVG transform="translate()". // Qt translates everything. These help avoid SVG transform="translate()".
qreal _dx; qreal _dx { 0.0 };
qreal _dy; qreal _dy { 0.0 };
protected: protected:
// The Ms::Element being generated right now // The Ms::Element being generated right now

View file

@ -97,9 +97,12 @@ static long ovTell(void* datasource)
WaveView::WaveView(QWidget* parent) WaveView::WaveView(QWidget* parent)
: QWidget(parent) : QWidget(parent)
{ {
_xpos = 0; _locator = nullptr;
_xmag = 0.1; _score = nullptr;
_xpos = 0;
_xmag = 0.1;
_timeType = TType::TICKS; // TType::FRAMES _timeType = TType::TICKS; // TType::FRAMES
_magStep = 0;
setMinimumHeight(50); setMinimumHeight(50);
} }

View file

@ -33,7 +33,7 @@ class WaveView : public QWidget
QByteArray waves; QByteArray waves;
TType _timeType; TType _timeType;
int magStep; int _magStep;
double _xmag; double _xmag;
int _xpos; int _xpos;

View file

@ -56,9 +56,9 @@ class Workspace : public QObject {
QTimer _saveTimer; QTimer _saveTimer;
bool saveComponents; bool saveComponents { false };
bool saveToolbars; bool saveToolbars { false };
bool saveMenuBar; bool saveMenuBar { false };
void readGlobalToolBar(); void readGlobalToolBar();
void readGlobalMenuBar(); void readGlobalMenuBar();

View file

@ -37,8 +37,12 @@ void MuseScore::createNewWorkspace()
void MuseScore::editWorkspace() void MuseScore::editWorkspace()
{ {
if (!WorkspacesManager::currentWorkspace() && !WorkspacesManager::currentWorkspace()->readOnly()) if (!WorkspacesManager::currentWorkspace())
return; return;
if (WorkspacesManager::currentWorkspace()->readOnly())
return;
if (!_workspaceDialog) if (!_workspaceDialog)
_workspaceDialog = new WorkspaceDialog(); _workspaceDialog = new WorkspaceDialog();

View file

@ -18,13 +18,13 @@
//--------------------------------------------------------- //---------------------------------------------------------
class Sample { class Sample {
int _channel; int _channel { 0 };
short* _data; short* _data { nullptr };
long long _frames; long long _frames { 0 };
int _sampleRate; int _sampleRate { 44100 };
long long _loopStart; long long _loopStart { 0 };
long long _loopEnd; long long _loopEnd { 0 };
int _loopMode; int _loopMode { 0 };
public: public:
Sample(int ch, short* val, int f, int sr) Sample(int ch, short* val, int f, int sr)