Fix crash in cmd line FixCommonErrors - thx Rouzax :)

Fix #3854 (and a few other minor changes)
This commit is contained in:
Nikolaj Olsson 2019-11-28 13:13:03 +01:00
parent 88092d4e58
commit fc949ee664
5 changed files with 29 additions and 39 deletions

View File

@ -2080,7 +2080,7 @@ can edit in same subtitle file (collaboration)</Information>
<Miscellaneous>Misc.</Miscellaneous>
<CpsIncludesSpace>Chars/sec (CPS) includes spaces</CpsIncludesSpace>
<UseDoNotBreakAfterList>Use do-not-break-after list</UseDoNotBreakAfterList>
<BreakEarlyForLineEnding>Break early for line ending (.!?)</BreakEarlyForLineEnding>
<BreakEarlyForLineEnding>Break early for end of sentence (.!?)</BreakEarlyForLineEnding>
<BreakByPixelWidth>Break by pixel width</BreakByPixelWidth>
<BreakPreferBottomHeavy>Prefer bottom heavy</BreakPreferBottomHeavy>
<BreakEarlyForDashDialog>Break early for dialog dash</BreakEarlyForDashDialog>

View File

@ -20,8 +20,7 @@ namespace Nikse.SubtitleEdit.Core.Forms.FixCommonErrors
if (p.Duration.TotalMilliseconds < 0) // negative display time...
{
bool isFixed = false;
string status = string.Format(language.StartTimeLaterThanEndTime,
i + 1, p.StartTime, p.EndTime, p.Text, Environment.NewLine);
string status = string.Format(language.StartTimeLaterThanEndTime, i + 1, p.StartTime, p.EndTime, p.Text, Environment.NewLine);
var prev = subtitle.GetParagraphOrDefault(i - 1);
var next = subtitle.GetParagraphOrDefault(i + 1);
@ -81,7 +80,7 @@ namespace Nikse.SubtitleEdit.Core.Forms.FixCommonErrors
double currentWantedDisplayTime = Utilities.GetOptimalDisplayMilliseconds(p.Text, Configuration.Settings.General.SubtitleMaximumCharactersPerSeconds);
double prevOptimalDisplayTime = Utilities.GetOptimalDisplayMilliseconds(prev.Text);
double currentOptimalDisplayTime = Utilities.GetOptimalDisplayMilliseconds(p.Text);
bool canBeEqual = callbacks != null && (callbacks.Format != null && callbacks.Format.GetType() == typeof(AdvancedSubStationAlpha) || callbacks.Format.GetType() == typeof(SubStationAlpha));
bool canBeEqual = callbacks.Format != null && (callbacks.Format.GetType() == typeof(AdvancedSubStationAlpha) || callbacks.Format.GetType() == typeof(SubStationAlpha));
if (!canBeEqual)
{
canBeEqual = Configuration.Settings.Tools.FixCommonErrorsFixOverlapAllowEqualEndStart;

View File

@ -36,14 +36,7 @@ namespace Nikse.SubtitleEdit.Core.Forms
s = s.Remove(0, 1);
if (s.StartsWith(' '))
{
if (s.StartsWith(" <i>", StringComparison.Ordinal))
{
pre = " <i>";
}
else
{
pre = " ";
}
pre = s.StartsWith(" <i>", StringComparison.Ordinal) ? " <i>" : " ";
}
else if (s.StartsWith("<i>", StringComparison.Ordinal))
{
@ -624,7 +617,7 @@ namespace Nikse.SubtitleEdit.Core.Forms
return newText;
}
private bool IsInsideBrackets(string text, int targetIndex)
private static bool IsInsideBrackets(string text, int targetIndex)
{
// <i>♪ (THE CAPITOLS: "COOL JERK") ♪</i>
var index = text.LastIndexOf('(', targetIndex - 1) + 1;
@ -642,7 +635,7 @@ namespace Nikse.SubtitleEdit.Core.Forms
return false;
}
private bool ShouldRemoveNarrator(string pre)
private static bool ShouldRemoveNarrator(string pre)
{
// Skip these: Barry, remember: She cannot; http://google.com; Improved by: ...
if (pre.IndexOfAny(new[] { "Previously on", "Improved by", "http", ", " }, StringComparison.OrdinalIgnoreCase) >= 0)
@ -973,7 +966,7 @@ namespace Nikse.SubtitleEdit.Core.Forms
return text.Trim();
}
private string RemoveEmptyFontTag(string text)
private static string RemoveEmptyFontTag(string text)
{
int indexOfStartFont = text.IndexOf("<font ", StringComparison.OrdinalIgnoreCase);
if (indexOfStartFont >= 0)
@ -1214,7 +1207,7 @@ namespace Nikse.SubtitleEdit.Core.Forms
text.StartsWith(Settings.CustomStart, StringComparison.Ordinal) && text.EndsWith(Settings.CustomEnd, StringComparison.Ordinal);
}
private bool StartsAndEndsWithHearImpairedTags(string text, char startTag, char endTag)
private static bool StartsAndEndsWithHearImpairedTags(string text, char startTag, char endTag)
{
if (text.Length > 1 && text.StartsWith(startTag) && (text.EndsWith(endTag) || text.EndsWith(endTag + ":")))
{

View File

@ -1140,7 +1140,7 @@ namespace Nikse.SubtitleEdit.Logic.CommandLineConvert
}
// Remove native formatting
if (format?.Name != sf.Name)
if (format != null && format.Name != sf.Name)
{
format.RemoveNativeFormatting(sub, sf);
}

View File

@ -1,30 +1,28 @@
using System;
namespace Nikse.SubtitleEdit.Logic.VideoPlayers.MpcHC
namespace Nikse.SubtitleEdit.Logic.VideoPlayers.MpcHC
{
/// <summary>
/// HPC-HC API commands - https://github.com/mpc-hc/mpc-hc/blob/master/src/mpc-hc/MpcApi.h
/// </summary>
public static class MpcHcCommand
{
public const UInt32 Connect = 0x50000000;
public const UInt32 State = 0x50000001;
public const UInt32 PlayMode = 0x50000002;
public const UInt32 NowPlaying = 0x50000003;
public const UInt32 CurrentPosition = 0x50000007;
public const UInt32 NotifyEndOfStream = 0x50000009;
public const UInt32 Disconnect = 0x5000000B;
public const UInt32 Version = 0x5000000A;
public const UInt32 OpenFile = 0xA0000000;
public const UInt32 Stop = 0xA0000001;
public const UInt32 Play = 0xA0000004;
public const UInt32 Pause = 0xA0000005;
public const UInt32 SetPosition = 0xA0002000;
public const UInt32 SetSubtitleTrack = 0xA0002005;
public const UInt32 GetCurrentPosition = 0xA0003004;
public const UInt32 IncreaseVolume = 0xA0004003;
public const UInt32 DecreaseVolume = 0xA0004004;
public const UInt32 CloseApplication = 0xA0004006;
public const UInt32 SetSpeed = 0xA0004008;
public const uint Connect = 0x50000000;
public const uint State = 0x50000001;
public const uint PlayMode = 0x50000002;
public const uint NowPlaying = 0x50000003;
public const uint CurrentPosition = 0x50000007;
public const uint NotifyEndOfStream = 0x50000009;
public const uint Disconnect = 0x5000000B;
public const uint Version = 0x5000000A;
public const uint OpenFile = 0xA0000000;
public const uint Stop = 0xA0000001;
public const uint Play = 0xA0000004;
public const uint Pause = 0xA0000005;
public const uint SetPosition = 0xA0002000;
public const uint SetSubtitleTrack = 0xA0002005;
public const uint GetCurrentPosition = 0xA0003004;
public const uint IncreaseVolume = 0xA0004003;
public const uint DecreaseVolume = 0xA0004004;
public const uint CloseApplication = 0xA0004006;
public const uint SetSpeed = 0xA0004008;
}
}