Fix crash when entering invalid text in source view (thx Frédéric)

git-svn-id: https://subtitleedit.googlecode.com/svn/trunk@416 99eadd0c-20b8-1223-b5c4-2a2b2df33de2
This commit is contained in:
niksedk 2011-05-02 14:18:31 +00:00
parent 190c6fadbc
commit a2fa661448
3 changed files with 26 additions and 6 deletions

View File

@ -2868,6 +2868,7 @@
this.tabControlSubtitle.Size = new System.Drawing.Size(945, 280);
this.tabControlSubtitle.TabIndex = 0;
this.tabControlSubtitle.SelectedIndexChanged += new System.EventHandler(this.TabControlSubtitleSelectedIndexChanged);
this.tabControlSubtitle.Selecting += new System.Windows.Forms.TabControlCancelEventHandler(this.tabControlSubtitle_Selecting);
//
// tabPage1
//

View File

@ -2643,20 +2643,23 @@ namespace Nikse.SubtitleEdit.Forms
{
if (_sourceViewChange)
{
MakeHistoryForUndo(_language.BeforeChangesMadeInSourceView);
SaveSubtitleListviewIndexes();
if (textBoxSource.Text.Trim().Length > 0)
{
SubtitleFormat format = _subtitle.ReloadLoadSubtitle(new List<string>(textBoxSource.Lines), null);
if (format.IsFrameBased)
_subtitle.CalculateTimeCodesFromFrameNumbers(CurrentFrameRate);
_sourceViewChange = false;
Subtitle temp = new Subtitle(_subtitle);
SubtitleFormat format = temp.ReloadLoadSubtitle(new List<string>(textBoxSource.Lines), null);
if (format == null)
{
MessageBox.Show(_language.UnableToParseSourceView);
return;
}
else
{
_sourceViewChange = false;
MakeHistoryForUndo(_language.BeforeChangesMadeInSourceView);
_subtitle.ReloadLoadSubtitle(new List<string>(textBoxSource.Lines), null);
if (format.IsFrameBased)
_subtitle.CalculateTimeCodesFromFrameNumbers(CurrentFrameRate);
int index = 0;
foreach (object obj in comboBoxSubtitleFormats.Items)
{
@ -2668,6 +2671,8 @@ namespace Nikse.SubtitleEdit.Forms
}
else
{
_sourceViewChange = false;
MakeHistoryForUndo(_language.BeforeChangesMadeInSourceView);
_sourceViewChange = false;
_subtitle.Paragraphs.Clear();
}
@ -9856,5 +9861,16 @@ namespace Nikse.SubtitleEdit.Forms
exportBdnXmlPng.ShowDialog(this);
}
private void tabControlSubtitle_Selecting(object sender, TabControlCancelEventArgs e)
{
if (tabControlSubtitle.SelectedIndex != TabControlSourceView && textBoxSource.Text.Trim().Length > 1)
{
Subtitle temp = new Subtitle(_subtitle);
SubtitleFormat format = temp.ReloadLoadSubtitle(new List<string>(textBoxSource.Lines), null);
if (format == null)
e.Cancel = true;
}
}
}
}

View File

@ -577,6 +577,9 @@
<metadata name="toolStripWaveControls.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>208, 56</value>
</metadata>
<metadata name="toolStripWaveControls.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>208, 56</value>
</metadata>
<data name="toolStripButtonWaveFormZoomOut.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
@ -684,7 +687,7 @@
AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w
LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0
ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAAD2
CAAAAk1TRnQBSQFMAgEBAgEAAYABBAGAAQQBEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo
CAAAAk1TRnQBSQFMAgEBAgEAAYgBBAGIAQQBEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo
AwABQAMAARADAAEBAQABCAYAAQQYAAGAAgABgAMAAoABAAGAAwABgAEAAYABAAKAAgADwAEAAcAB3AHA
AQAB8AHKAaYBAAEzBQABMwEAATMBAAEzAQACMwIAAxYBAAMcAQADIgEAAykBAANVAQADTQEAA0IBAAM5
AQABgAF8Af8BAAJQAf8BAAGTAQAB1gEAAf8B7AHMAQABxgHWAe8BAAHWAucBAAGQAakBrQIAAf8BMwMA