Fixed locking of input subtitle file + crash after unsuccessful load of subtitle file - thx darnn :)

Fix #2306
This commit is contained in:
Nikolaj Olsson 2017-03-23 17:34:00 +01:00
parent 9f2d437234
commit 82e9f4464b
2 changed files with 19 additions and 11 deletions

View File

@ -19,7 +19,9 @@
* Fixed issue regarding "Fix dialogs on one line" - thx ingo * Fixed issue regarding "Fix dialogs on one line" - thx ingo
* Fixed possible crash in EBU STL - thx Elena * Fixed possible crash in EBU STL - thx Elena
* Video player "Stop" resets playback position - thx askolesov/pavel-belenko * Video player "Stop" resets playback position - thx askolesov/pavel-belenko
* Many fixes for Timed Text 1.0 and Netflix Timed Text - thx askolesov/pavel-belenko * Many fixes for TTML 1.0 and Netflix Timed Text - thx askolesov/pavel-belenko
* Fixed locking of input subtitle (for unknown subtitles) - thx darnn
* Fixed crash after unsuccessful load of file - thx darnn
3.5.2 (3rd March 2017) 3.5.2 (3rd March 2017)

View File

@ -1980,13 +1980,17 @@ namespace Nikse.SubtitleEdit.Forms
return; return;
} }
var tempSubtitle = new Subtitle(_subtitle, false);
if (_subtitle.HistoryItems.Count > 0 || _subtitle.Paragraphs.Count > 0) if (_subtitle.HistoryItems.Count > 0 || _subtitle.Paragraphs.Count > 0)
MakeHistoryForUndo(string.Format(_language.BeforeLoadOf, Path.GetFileName(fileName))); MakeHistoryForUndo(string.Format(_language.BeforeLoadOf, Path.GetFileName(fileName)));
string _subtitleHash = _subtitle.GetFastHashCode(); string subtitleHash = _subtitle.GetFastHashCode();
bool hasChanged = (_changeSubtitleToString != _subtitleHash) && (_lastDoNotPrompt != _subtitleHash); bool hasChanged = (_changeSubtitleToString != subtitleHash) && (_lastDoNotPrompt != subtitleHash);
SubtitleFormat format = _subtitle.LoadSubtitle(fileName, out encoding, encoding); SubtitleFormat format = _subtitle.LoadSubtitle(fileName, out encoding, encoding);
if (format == null)
_subtitle = tempSubtitle;
if (!hasChanged) if (!hasChanged)
_changeSubtitleToString = _subtitle.GetFastHashCode(); _changeSubtitleToString = _subtitle.GetFastHashCode();
@ -2633,14 +2637,16 @@ namespace Nikse.SubtitleEdit.Forms
// retry Matroska (file with wrong extension) // retry Matroska (file with wrong extension)
if (format == null && !string.IsNullOrWhiteSpace(fileName)) if (format == null && !string.IsNullOrWhiteSpace(fileName))
{ {
var matroska = new MatroskaFile(fileName); using (var matroska = new MatroskaFile(fileName))
if (matroska.IsValid)
{ {
var subtitleList = matroska.GetTracks(true); if (matroska.IsValid)
if (subtitleList.Count > 0)
{ {
ImportSubtitleFromMatroskaFile(fileName); var subtitleList = matroska.GetTracks(true);
return; if (subtitleList.Count > 0)
{
ImportSubtitleFromMatroskaFile(fileName);
return;
}
} }
} }
} }
@ -20741,7 +20747,7 @@ namespace Nikse.SubtitleEdit.Forms
string msgFormat = string.Format("{0} {1}", string msgFormat = string.Format("{0} {1}",
Configuration.Settings.Language.NetflixQualityCheck.GlyphCheckFailed, Configuration.Settings.Language.NetflixQualityCheck.GlyphCheckFailed,
Configuration.Settings.Language.NetflixQualityCheck.ReportPrompt); Configuration.Settings.Language.NetflixQualityCheck.ReportPrompt);
messages.Add(string.Format(msgFormat , reportPath)); messages.Add(string.Format(msgFormat, reportPath));
reportFiles.Add(reportPath); reportFiles.Add(reportPath);
} }