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();
triggerLayout();
score()->endCmd();
delete pItem;
return;
}
pItem->setTrack(track());

View file

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

View file

@ -2084,9 +2084,10 @@ qreal Segment::minHorizontalCollidingDistance(Segment* ns) const
qreal Segment::minHorizontalDistance(Segment* ns, bool systemHeaderGap) const
{
qreal ww = -1000000.0; // can remain negative
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
// so make sure segment is as wide as it needs to be
if (systemHeaderGap)

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -24,6 +24,7 @@ TEvent::TEvent()
type = TempoType::INVALID;
tempo = 0.0;
pause = 0.0;
time = 0.0;
}
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
if (_text->empty() && _endText->empty() && pp2.y() != 0
&& textLineBase()->beginHookType() == HookType::NONE && textLineBase()->beginHookType() == HookType::NONE) {
&& textLineBase()->beginHookType() == HookType::NONE) {
npoints = 2;
points[0] = pp1;
points[1] = pp2;

View file

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

View file

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

View file

@ -538,7 +538,7 @@ static Fraction readCapVoice(Score* score, CapVoice* cvoice, int staffIdx, const
//
Fraction startTick = tick;
Tuplet* tuplet = 0;
Tuplet* tuplet = nullptr;
int tupletCount = 0;
bool tuplettrp = false;
bool tupletprol = false;
@ -559,7 +559,7 @@ static Fraction readCapVoice(Score* score, CapVoice* cvoice, int staffIdx, const
TDuration d;
d.setVal(ticks.ticks());
if (o->count) {
if (tuplet == 0) {
if (tuplet == nullptr) {
tupletCount = o->count;
tuplettrp = o->tripartite;
tupletprol = o->isProlonging;
@ -616,7 +616,11 @@ static Fraction readCapVoice(Score* score, CapVoice* cvoice, int staffIdx, const
if (tuplet) {
if (++nTuplet >= tupletCount) {
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 {
tick += ticks / tuplet->ratio();
@ -640,7 +644,7 @@ static Fraction readCapVoice(Score* score, CapVoice* cvoice, int staffIdx, const
bool isgracenote = (!(o->invisible) && (ticks.isZero()));
if (o->count) {
if (tuplet == 0) {
if (tuplet == nullptr) {
tupletCount = o->count;
tuplettrp = o->tripartite;
tupletprol = o->isProlonging;
@ -796,7 +800,11 @@ static Fraction readCapVoice(Score* score, CapVoice* cvoice, int staffIdx, const
if (tuplet) {
if (++nTuplet >= tupletCount) {
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 {
tick += ticks / tuplet->ratio();

View file

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

View file

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

View file

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

View file

@ -164,7 +164,7 @@ void ScoreView::endEdit()
for (int i = 0; i < editData.grips; ++i)
score()->addRefresh(editData.grip[i]);
editData.element->endEdit(editData);
//! NOTE After endEdit, the element may be null
if (editData.element) {
_score->addRefresh(editData.element->canvasBoundingRect());
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()) {
const auto c = toChord(el);
const auto ll = &c->lyrics();
// ise grace after
if (c) {
const auto ll = &c->lyrics();
for (const auto g : c->graceNotesBefore()) {
chord(g, sstaff, ll, useDrumset);
}

View file

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

View file

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

View file

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

View file

@ -179,7 +179,8 @@ MsScWriter::MsScWriter()
currentMeasure(0),
tuplet(0),
lastVolta(0),
tempo(0)
tempo(0),
ending(0)
{
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--;
cr->setTuplet(tuple);
tuple->add(cr);

View file

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

View file

@ -223,7 +223,7 @@ class InspectorClef : public InspectorElementBase {
Ui::InspectorSegment s;
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
protected slots:
virtual void valueChanged(int idx) override;

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -81,11 +81,11 @@ public:
private:
Staff* _staff;
Chord* chord;
Chord* _chord;
Pos trackingPos; //Track mouse position
Pos* _locator;
int ticks;
int _ticks;
TType _timeType;
int _noteHeight;
qreal _xZoom;
@ -94,19 +94,19 @@ private:
int _barPattern;
bool _playEventsView;
bool mouseDown;
bool dragStarted;
QPointF mouseDownPos;
QPointF lastMousePos;
DragStyle dragStyle;
int lastDragPitch;
bool inProgressUndoEvent;
bool _mouseDown;
bool _dragStarted;
QPointF _mouseDownPos;
QPointF _lastMousePos;
DragStyle _dragStyle;
int _lastDragPitch;
bool _inProgressUndoEvent;
QList<PianoItem*> noteList;
QList<PianoItem*> _noteList;
virtual void drawBackground(QPainter* painter, const QRectF& rect);
void addChord(Chord* chord, int voice);
void addChord(Chord* _chord, int voice);
void updateBoundingSize();
void clearNoteData();
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());
if (cm->isEmpty())
if(cm->isEmpty()) {
delete cm;
}
delete cm;
cm = cmenu;
}
}

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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