Some more robustness against corrupt documents

This commit is contained in:
Matthias Neeracher 2011-08-26 16:13:51 +00:00
parent b915085530
commit c14ace59f8
2 changed files with 4 additions and 1 deletions

View File

@ -38,7 +38,7 @@ static size_t NextBreak(const VLSong & song, size_t after=0)
VLLayout::VLLayout(const VLSong & song, float width) VLLayout::VLLayout(const VLSong & song, float width)
{ {
size_t nextBreak = NextBreak(song); size_t nextBreak = song.fMeasures.empty() ? 0 : NextBreak(song);
for (size_t meas = 0; meas<song.fMeasures.size(); ) { for (size_t meas = 0; meas<song.fMeasures.size(); ) {
push_back(VLSystemLayout(song.Properties(meas), width, nextBreak-meas)); push_back(VLSystemLayout(song.Properties(meas), width, nextBreak-meas));
meas += back().NumMeasures(); meas += back().NumMeasures();

View File

@ -582,6 +582,9 @@ const char * sBreak[3] = {"", "\xE2\xA4\xBE", "\xE2\x8E\x98"};
- (void)drawRect:(NSRect)rect - (void)drawRect:(NSRect)rect
{ {
if (![self song])
return;
if (fNeedsRecalc || [self inLiveResize] || [self song]->CountMeasures() != fLastMeasures) { if (fNeedsRecalc || [self inLiveResize] || [self song]->CountMeasures() != fLastMeasures) {
[self recalculateDimensions]; [self recalculateDimensions];
rect = [self bounds]; rect = [self bounds];