Avoid crash in new waveform code

git-svn-id: https://subtitleedit.googlecode.com/svn/trunk@1612 99eadd0c-20b8-1223-b5c4-2a2b2df33de2
This commit is contained in:
niksedk 2013-02-08 15:09:09 +00:00
parent 561150b8bc
commit 79ed00571f

View File

@ -331,16 +331,25 @@ namespace Nikse.SubtitleEdit.Controls
if (_wavePeaks != null && _wavePeaks.AllSamples != null)
{
List<Paragraph> selectedParagraphs = new List<Paragraph>();
foreach (int index in _selectedIndices)
if (_selectedIndices != null)
{
Paragraph p = _subtitle.GetParagraphOrDefault(index);
if (p != null)
try
{
foreach (int index in _selectedIndices)
{
Paragraph p = _subtitle.GetParagraphOrDefault(index);
if (p != null)
{
p = new Paragraph(p);
// not really frames... just using them as position markers for better performance
p.StartFrame = (int)(p.StartTime.TotalSeconds * _wavePeaks.Header.SampleRate * _zoomFactor);
p.EndFrame = (int)(p.EndTime.TotalSeconds * _wavePeaks.Header.SampleRate * _zoomFactor);
selectedParagraphs.Add(p);
}
}
}
catch
{
p = new Paragraph(p);
// not really frames... just using them as position markers for better performance
p.StartFrame = (int)(p.StartTime.TotalSeconds * _wavePeaks.Header.SampleRate * _zoomFactor);
p.EndFrame = (int)(p.EndTime.TotalSeconds * _wavePeaks.Header.SampleRate * _zoomFactor);
selectedParagraphs.Add(p);
}
}