diff --git a/src/base/UFiles.pas b/src/base/UFiles.pas index 55ea526e5..d257fecd5 100644 --- a/src/base/UFiles.pas +++ b/src/base/UFiles.pas @@ -150,6 +150,7 @@ function SaveSong(const Song: TSong; const Tracks: array of TLines; const Name: if Song.Video.IsSet then SongFile.WriteLine('#VIDEO:' + EncodeToken(Song.Video.ToUTF8)); if Song.VideoGAP <> 0.0 then SongFile.WriteLine('#VIDEOGAP:' + FloatToStr(Song.VideoGAP)); + // TODO: this default also appears in USong.ReadTXTHeader and USong.Clear if Song.Resolution <> 4 then SongFile.WriteLine('#RESOLUTION:' + IntToStr(Song.Resolution)); if Song.NotesGAP <> 0 then SongFile.WriteLine('#NOTESGAP:' + IntToStr(Song.NotesGAP)); if Song.Start <> 0.0 then SongFile.WriteLine('#START:' + FloatToStr(Song.Start)); diff --git a/src/base/USong.pas b/src/base/USong.pas index fc91d3c1c..82b6dbe75 100644 --- a/src/base/USong.pas +++ b/src/base/USong.pas @@ -971,7 +971,12 @@ function TSong.ReadTXTHeader(SongFile: TTextFileStream; ReadCustomTags: Boolean) // Resolution else if (Identifier = 'RESOLUTION') then begin - TryStrtoInt(Value, self.Resolution) + TryStrtoInt(Value, self.Resolution); + if (self.Resolution < 1) then begin + // TODO: this hardcoded default also appears in Clear and UFiles.SaveSong + Log.LogError('Ignoring invalid resolution in song: ' + FullFileName); + self.Resolution := 4; + end end // Notes Gap @@ -1472,6 +1477,7 @@ procedure TSong.Clear(); Video := PATH_NONE; VideoGAP := 0; NotesGAP := 0; + // TODO: this default also appears in ReadTXTHeader and UFiles.SaveSong Resolution := 4; Creator := ''; PreviewStart := 0;