mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-11-22 03:02:35 +01:00
Fixed issue where current frame rate was lost (due to IsMine changing it)
This commit is contained in:
parent
530baed885
commit
d673a34a00
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user