From 83194fc3680719de70c512b87f4578909d8404a5 Mon Sep 17 00:00:00 2001 From: Matthias Neeracher Date: Fri, 26 Aug 2011 17:26:24 +0000 Subject: [PATCH] Improve handling of empty songs --- Sources/VLModel.cpp | 2 ++ Sources/VLPListDocument.mm | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/Sources/VLModel.cpp b/Sources/VLModel.cpp index 6467753..18fda76 100644 --- a/Sources/VLModel.cpp +++ b/Sources/VLModel.cpp @@ -2288,6 +2288,8 @@ void VLSongVisitor::VisitMeasures(VLSong & song, bool performanceOrder) } } else { size_t e = song.CountMeasures() - song.EmptyEnding(); + if (!e && song.CountMeasures()) + e = 1; for (size_t m=0; m!=e; ++m) { VLMeasure & meas = song.fMeasures[m]; diff --git a/Sources/VLPListDocument.mm b/Sources/VLPListDocument.mm index 1bc0f5b..b79acd5 100644 --- a/Sources/VLPListDocument.mm +++ b/Sources/VLPListDocument.mm @@ -490,6 +490,11 @@ advanceAt: [self readPropertiesFromPlist:[plist objectForKey:@"properties"]]; [self readMeasuresFromPlist:[plist objectForKey:@"measures"]]; [undoMgr enableUndoRegistration]; + + if (song->fMeasures.empty()) { + delete song; + song = new VLSong(true); + } return YES; }