From dce08a8771098ac1a56dd4548202454ab268e951 Mon Sep 17 00:00:00 2001 From: whiteshark0 Date: Tue, 3 Jul 2007 14:56:15 +0000 Subject: Fixed a bug in EditorSub that causes a crash when the last note of a sentence was deleted. git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@273 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Screens/UScreenEditSub.pas | 53 ++++++++++++++++++++++++++++-------- 1 file changed, 41 insertions(+), 12 deletions(-) (limited to 'Game/Code/Screens') diff --git a/Game/Code/Screens/UScreenEditSub.pas b/Game/Code/Screens/UScreenEditSub.pas index 8a5eaab8..9e84462d 100644 --- a/Game/Code/Screens/UScreenEditSub.pas +++ b/Game/Code/Screens/UScreenEditSub.pas @@ -882,20 +882,49 @@ var begin C := Czesci[0].Akt; - // we copy all notes from the next to the selected one - for N := AktNuta+1 to Czesci[0].Czesc[C].HighNut do begin - Czesci[0].Czesc[C].Nuta[N-1] := Czesci[0].Czesc[C].Nuta[N]; - end; - - NLen := Czesci[0].Czesc[C].IlNut - 1; - SetLength(Czesci[0].Czesc[C].Nuta, NLen); - Dec(Czesci[0].Czesc[C].HighNut); - Dec(Czesci[0].Czesc[C].IlNut); + //Do Not delete Last Note + if (Czesci[0].High > 0) OR (Czesci[0].Czesc[C].HighNut > 0) then + begin + // we copy all notes from the next to the selected one + for N := AktNuta+1 to Czesci[0].Czesc[C].HighNut do begin + Czesci[0].Czesc[C].Nuta[N-1] := Czesci[0].Czesc[C].Nuta[N]; + end; - // me slightly modify new note - if AktNuta > Czesci[0].Czesc[C].HighNut then Dec(AktNuta); - Czesci[0].Czesc[C].Nuta[AktNuta].Color := 1; + NLen := Czesci[0].Czesc[C].IlNut - 1; + + if (NLen > 0) then + begin + SetLength(Czesci[0].Czesc[C].Nuta, NLen); + Dec(Czesci[0].Czesc[C].HighNut); + Dec(Czesci[0].Czesc[C].IlNut); + + + // me slightly modify new note + if AktNuta > Czesci[0].Czesc[C].HighNut then Dec(AktNuta); + Czesci[0].Czesc[C].Nuta[AktNuta].Color := 1; + end + //Last Note of current Sentence Deleted - > Delete Sentence + else + begin + //Move all Sentences after the current to the Left + for N := C+1 to Czesci[0].High do + Czesci[0].Czesc[N-1] := Czesci[0].Czesc[N]; + + //Delete Last Sentence + SetLength(Czesci[0].Czesc, Czesci[0].High); + Czesci[0].High := High(Czesci[0].Czesc); + Czesci[0].Ilosc := Length(Czesci[0].Czesc); + + AktNuta := 0; + if (C > 0) then + Czesci[0].Akt := C - 1 + else + Czesci[0].Akt := 0; + + Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Color := 1; + end; + end; end; procedure TScreenEditSub.TransposeNote(Transpose: integer); -- cgit v1.2.3