fix crash when extending a newly added line

This commit is contained in:
lasconic 2013-09-03 16:34:56 +02:00
parent 85f9416dee
commit 0cb6d87691
5 changed files with 35 additions and 11 deletions

View file

@ -210,8 +210,8 @@ bool LineSegment::edit(MuseScoreView* sv, int curGrip, int key, Qt::KeyboardModi
int track = l->track();
if (l->anchor() == Spanner::ANCHOR_SEGMENT) {
Segment* s1 = score()->tick2nearestSegment(spanner()->tick());
Segment* s2 = score()->tick2nearestSegment(spanner()->tick2());
Segment* s1 = spanner()->startSegment();
Segment* s2 = spanner()->endSegment();
if (!s1 && !s2) {
qDebug("LineSegment::edit: no start/end segment");
return true;

View file

@ -626,7 +626,8 @@ class Score : public QObject {
MeasureBase* tick2measureBase(int tick) const;
Segment* tick2segment(int tick, bool first = false, Segment::SegmentTypes st = Segment::SegAll) const;
Segment* tick2segmentEnd(int track, int tick) const;
Segment* tick2nearestSegment(int tick) const;
Segment* tick2leftSegment(int tick) const;
Segment* tick2rightSegment(int tick) const;
void fixTicks();
bool addArticulation(Element*, Articulation* atr);

View file

@ -449,7 +449,7 @@ ChordRest* Spanner::endCR() const
Segment* Spanner::startSegment() const
{
return score()->tick2segment(tick());
return score()->tick2rightSegment(tick());
}
//---------------------------------------------------------
@ -458,7 +458,7 @@ Segment* Spanner::startSegment() const
Segment* Spanner::endSegment() const
{
return score()->tick2segment(tick2());
return score()->tick2leftSegment(tick2());
}
}

View file

@ -134,14 +134,16 @@ Segment* Score::tick2segmentEnd(int track, int tick) const
}
//---------------------------------------------------------
// tick2nearestSegment
// tick2leftSegment
/// return the segment at this tick position if any or
/// the first segment *before* this tick position
//---------------------------------------------------------
Segment* Score::tick2nearestSegment(int tick) const
Segment* Score::tick2leftSegment(int tick) const
{
Measure* m = tick2measure(tick);
if (m == 0) {
qDebug("tick2nearestSegment(): not found tick %d\n", tick);
qDebug("tick2leftSegment(): not found tick %d\n", tick);
return 0;
}
// loop over all segments
@ -153,6 +155,27 @@ Segment* Score::tick2nearestSegment(int tick) const
return s;
ps = s;
}
return ps;
}
//---------------------------------------------------------
// tick2leftSegment
/// return the segment at this tick position if any or
/// the first segment *after* this tick position
//---------------------------------------------------------
Segment* Score::tick2rightSegment(int tick) const
{
Measure* m = tick2measure(tick);
if (m == 0) {
qDebug("tick2nearestSegment(): not found tick %d\n", tick);
return 0;
}
// loop over all segments
for (Segment* s = m->first(Segment::SegChordRest); s; s = s->next(Segment::SegChordRest)) {
if (tick <= s->tick())
return s;
}
return 0;
}

View file

@ -172,7 +172,7 @@
<item row="0" column="1">
<widget class="QStackedWidget" name="pageStack">
<property name="currentIndex">
<number>0</number>
<number>18</number>
</property>
<widget class="QWidget" name="Page1">
<layout class="QVBoxLayout" name="verticalLayout_20">
@ -5029,7 +5029,7 @@ p, li { white-space: pre-wrap; }
<double>5.000000000000000</double>
</property>
<property name="singleStep">
<double>0.500000000000000</double>
<double>0.050000000000000</double>
</property>
</widget>
</item>
@ -5064,7 +5064,7 @@ p, li { white-space: pre-wrap; }
<double>5.000000000000000</double>
</property>
<property name="singleStep">
<double>0.500000000000000</double>
<double>0.050000000000000</double>
</property>
</widget>
</item>