diff --git a/libse/SubtitleFormats/Dost.cs b/libse/SubtitleFormats/Dost.cs index 1ba852afb..ac2a0005d 100644 --- a/libse/SubtitleFormats/Dost.cs +++ b/libse/SubtitleFormats/Dost.cs @@ -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; } diff --git a/libse/SubtitleFormats/FinalCutProTest2Xml.cs b/libse/SubtitleFormats/FinalCutProTest2Xml.cs index 58dc86565..4a481f8fd 100644 --- a/libse/SubtitleFormats/FinalCutProTest2Xml.cs +++ b/libse/SubtitleFormats/FinalCutProTest2Xml.cs @@ -27,7 +27,9 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats public override bool IsMine(List 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; } diff --git a/libse/SubtitleFormats/FinalCutProTextXml.cs b/libse/SubtitleFormats/FinalCutProTextXml.cs index 38d36dc0d..87be59432 100644 --- a/libse/SubtitleFormats/FinalCutProTextXml.cs +++ b/libse/SubtitleFormats/FinalCutProTextXml.cs @@ -26,7 +26,9 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats public override bool IsMine(List 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; } diff --git a/libse/SubtitleFormats/FinalCutProXml.cs b/libse/SubtitleFormats/FinalCutProXml.cs index 09c826dac..bed74361e 100644 --- a/libse/SubtitleFormats/FinalCutProXml.cs +++ b/libse/SubtitleFormats/FinalCutProXml.cs @@ -27,7 +27,9 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats public override bool IsMine(List 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; } diff --git a/libse/SubtitleFormats/IssXml.cs b/libse/SubtitleFormats/IssXml.cs index ce0fcd4af..b8f0894a4 100644 --- a/libse/SubtitleFormats/IssXml.cs +++ b/libse/SubtitleFormats/IssXml.cs @@ -28,7 +28,9 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats public override bool IsMine(List 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; } diff --git a/libse/SubtitleFormats/UnknownSubtitle41.cs b/libse/SubtitleFormats/UnknownSubtitle41.cs index 1bd8e130c..01ee88e0c 100644 --- a/libse/SubtitleFormats/UnknownSubtitle41.cs +++ b/libse/SubtitleFormats/UnknownSubtitle41.cs @@ -26,7 +26,9 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats public override bool IsMine(List 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; } diff --git a/src/Test/Logic/SubtitleFormats/SubtitleFormatsTest.cs b/src/Test/Logic/SubtitleFormats/SubtitleFormatsTest.cs index f62887b50..c13f49a2d 100644 --- a/src/Test/Logic/SubtitleFormats/SubtitleFormatsTest.cs +++ b/src/Test/Logic/SubtitleFormats/SubtitleFormatsTest.cs @@ -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 } }