Fix some issues found by PVS-Studio

Work on #2810
This commit is contained in:
Nikolaj Olsson 2018-03-07 20:14:42 +01:00
parent 74009da776
commit 0a20cd90b4
5 changed files with 7 additions and 15 deletions

View File

@ -9,7 +9,7 @@ namespace Nikse.SubtitleEdit.Core.ContainerFormats.Mp4.Boxes
{
public Mdhd Mdhd;
public Minf Minf;
public readonly string HandlerType = null;
public readonly string HandlerType;
public readonly string HandlerName = string.Empty;
public bool IsTextSubtitle => HandlerType == "sbtl" || HandlerType == "text";
@ -24,6 +24,7 @@ namespace Nikse.SubtitleEdit.Core.ContainerFormats.Mp4.Boxes
public Mdia(Stream fs, ulong maximumLength)
{
HandlerType = string.Empty;
Position = (ulong)fs.Position;
while (fs.Position < (long)maximumLength)
{

View File

@ -19,7 +19,7 @@ namespace Nikse.SubtitleEdit.Core.NetflixQualityCheck
var m = NumberOneToNine.Match(newText);
while (m.Success)
{
bool ok = newText.Length > m.Index + 1 && !":.".Contains(newText[m.Index + 1].ToString()) || newText.Length <= m.Index + 1;
bool ok = newText.Length <= m.Index + 1 || newText.Length > m.Index + 1 && !":.".Contains(newText[m.Index + 1].ToString());
if (!ok && newText.Length > m.Index + 1)
{
var rest = newText.Substring(m.Index + 1);
@ -41,7 +41,7 @@ namespace Nikse.SubtitleEdit.Core.NetflixQualityCheck
m = NumberTen.Match(newText);
while (m.Success)
{
bool ok = newText.Length > m.Index + 2 && newText[m.Index + 2] != ':' || newText.Length <= m.Index + 2;
bool ok = newText.Length <= m.Index + 2 || newText.Length > m.Index + 2 && newText[m.Index + 2] != ':';
if (ok && m.Index > 0 && ":.".Contains(newText[m.Index - 1].ToString()))
ok = false;
if (ok)

View File

@ -165,7 +165,7 @@
this.numericUpDownVideoHeight.Name = "numericUpDownVideoHeight";
this.numericUpDownVideoHeight.Size = new System.Drawing.Size(47, 20);
this.numericUpDownVideoHeight.TabIndex = 1;
this.numericUpDownVideoHeight.ValueChanged += new System.EventHandler(this.numericUpDownVideoHeight_ValueChanged);
this.numericUpDownVideoHeight.ValueChanged += new System.EventHandler(this.NumericUpDownVideoWidthOrHeightValueChanged);
//
// buttonGetResolutionFromVideo
//
@ -197,7 +197,7 @@
this.numericUpDownVideoWidth.Name = "numericUpDownVideoWidth";
this.numericUpDownVideoWidth.Size = new System.Drawing.Size(47, 20);
this.numericUpDownVideoWidth.TabIndex = 0;
this.numericUpDownVideoWidth.ValueChanged += new System.EventHandler(this.numericUpDownVideoWidth_ValueChanged);
this.numericUpDownVideoWidth.ValueChanged += new System.EventHandler(this.NumericUpDownVideoWidthOrHeightValueChanged);
//
// groupBoxOptions
//

View File

@ -677,20 +677,12 @@ namespace Nikse.SubtitleEdit.Forms.Styles
_header = sb.ToString().Trim();
}
private void numericUpDownVideoWidth_ValueChanged(object sender, EventArgs e)
private void NumericUpDownVideoWidthOrHeightValueChanged(object sender, EventArgs e)
{
UpdatePropertiesTag("PlayResX", numericUpDownVideoWidth.Value.ToString(CultureInfo.InvariantCulture), numericUpDownVideoWidth.Value == 0);
UpdatePropertiesTag("PlayResY", numericUpDownVideoHeight.Value.ToString(CultureInfo.InvariantCulture), numericUpDownVideoHeight.Value == 0);
UpdateRawHeader();
}
private void numericUpDownVideoHeight_ValueChanged(object sender, EventArgs e)
{
UpdatePropertiesTag("PlayResX", numericUpDownVideoWidth.Value.ToString(CultureInfo.InvariantCulture), numericUpDownVideoWidth.Value == 0);
UpdatePropertiesTag("PlayResY", numericUpDownVideoHeight.Value.ToString(CultureInfo.InvariantCulture), numericUpDownVideoHeight.Value == 0);
UpdateRawHeader();
}
private void comboBoxCollision_SelectedIndexChanged(object sender, EventArgs e)
{
if (comboBoxCollision.SelectedIndex == 0)

View File

@ -1437,7 +1437,6 @@ namespace Test.Logic.Forms
target.Settings.RemoveIfAllUppercase = false;
target.Settings.RemoveTextBeforeColon = true;
target.Settings.OnlyIfInSeparateLine = false;
target.Settings.OnlyIfInSeparateLine = false;
target.Settings.ColonSeparateLine = false;
target.Settings.RemoveTextBeforeColonOnlyUppercase = false;
string text = "- I have a theory, captain--" + Environment.NewLine + "UHURA: Captain Kirk.";