Fixed issue where current frame rate was lost (due to IsMine changing it)

This commit is contained in:
Nikolaj Olsson 2016-03-23 22:09:03 +01:00
parent 530baed885
commit d673a34a00
7 changed files with 43 additions and 0 deletions

View File

@ -36,7 +36,9 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
if (!sb.ToString().Contains("$FORMAT"))
return false;
var oldFrameRate = Configuration.Settings.General.CurrentFrameRate;
LoadSubtitle(subtitle, lines, fileName);
Configuration.Settings.General.CurrentFrameRate = oldFrameRate;
return subtitle.Paragraphs.Count > _errorCount;
}

View File

@ -27,7 +27,9 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
public override bool IsMine(List<string> lines, string fileName)
{
var subtitle = new Subtitle();
var oldFrameRate = Configuration.Settings.General.CurrentFrameRate;
LoadSubtitle(subtitle, lines, fileName);
Configuration.Settings.General.CurrentFrameRate = oldFrameRate;
return subtitle.Paragraphs.Count > 0;
}

View File

@ -26,7 +26,9 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
public override bool IsMine(List<string> lines, string fileName)
{
var subtitle = new Subtitle();
var oldFrameRate = Configuration.Settings.General.CurrentFrameRate;
LoadSubtitle(subtitle, lines, fileName);
Configuration.Settings.General.CurrentFrameRate = oldFrameRate;
return subtitle.Paragraphs.Count > 0;
}

View File

@ -27,7 +27,9 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
public override bool IsMine(List<string> lines, string fileName)
{
var subtitle = new Subtitle();
var oldFrameRate = Configuration.Settings.General.CurrentFrameRate;
LoadSubtitle(subtitle, lines, fileName);
Configuration.Settings.General.CurrentFrameRate = oldFrameRate;
return subtitle.Paragraphs.Count > 0;
}

View File

@ -28,7 +28,9 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
public override bool IsMine(List<string> lines, string fileName)
{
var subtitle = new Subtitle();
var oldFrameRate = Configuration.Settings.General.CurrentFrameRate;
LoadSubtitle(subtitle, lines, fileName);
Configuration.Settings.General.CurrentFrameRate = oldFrameRate;
return subtitle.Paragraphs.Count > 0;
}

View File

@ -26,7 +26,9 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
public override bool IsMine(List<string> lines, string fileName)
{
Subtitle subtitle = new Subtitle();
var oldFrameRate = Configuration.Settings.General.CurrentFrameRate;
LoadSubtitle(subtitle, lines, fileName);
Configuration.Settings.General.CurrentFrameRate = oldFrameRate;
return subtitle.Paragraphs.Count > _errorCount;
}

View File

@ -5,6 +5,7 @@ using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Xml;
namespace Test.Logic.SubtitleFormats
@ -828,5 +829,35 @@ Dialogue: Marked=0,0:00:01.00,0:00:03.00,Default,NTP,0000,0000,0000,!Effect," +
Assert.AreEqual("#Every satellite...#", actual);
}
#endregion
#region Unknown format
[TestMethod]
public void TestUnknownFormatAndFrameRate()
{
var sb = new StringBuilder();
for (int i = 0; i < 500; i++)
{
sb.AppendLine(i.ToString(CultureInfo.InvariantCulture));
sb.AppendLine(string.Empty.PadLeft(50, '0'));
sb.AppendLine();
}
var lines = sb.ToString().SplitToLines().ToList();
Configuration.Settings.General.CurrentFrameRate = 27;
foreach (var format in SubtitleFormat.AllSubtitleFormats)
{
//if (format.IsTextBased)
{
if (format.IsMine(lines, null))
{
Assert.Fail("This format should not be recognized");
}
}
}
if (Math.Abs(Configuration.Settings.General.CurrentFrameRate - 27) > 0.01)
{
Assert.Fail("Frame rate changed in 'IsMine'!");
}
}
#endregion
}
}