Don't allow saving empty subtitle

This commit is contained in:
Nikolaj Olsson 2016-06-08 04:45:58 +02:00
parent 22c96def55
commit 19b2a9d378

View File

@ -1537,11 +1537,7 @@ namespace Nikse.SubtitleEdit.Forms
{ {
get get
{ {
if (_subtitle == null || _subtitle.Paragraphs.Count == 0) return _subtitle != null && (_subtitle.Paragraphs.Count > 1 || (_subtitle.Paragraphs.Count == 1 && !string.IsNullOrWhiteSpace(_subtitle.Paragraphs[0].Text)));
return false;
if (_subtitle.Paragraphs.Count == 1 && string.IsNullOrEmpty(_subtitle.Paragraphs[0].Text))
return false;
return true;
} }
} }
@ -3110,12 +3106,22 @@ namespace Nikse.SubtitleEdit.Forms
private void SaveToolStripMenuItemClick(object sender, EventArgs e) private void SaveToolStripMenuItemClick(object sender, EventArgs e)
{ {
if (!IsSubtitleLoaded)
{
return;
}
ReloadFromSourceView(); ReloadFromSourceView();
SaveSubtitle(GetCurrentSubtitleFormat()); SaveSubtitle(GetCurrentSubtitleFormat());
} }
private void SaveAsToolStripMenuItemClick(object sender, EventArgs e) private void SaveAsToolStripMenuItemClick(object sender, EventArgs e)
{ {
if (!IsSubtitleLoaded)
{
return;
}
ReloadFromSourceView(); ReloadFromSourceView();
FileSaveAs(true); FileSaveAs(true);
} }
@ -3903,6 +3909,11 @@ namespace Nikse.SubtitleEdit.Forms
private void ToolStripButtonSaveClick(object sender, EventArgs e) private void ToolStripButtonSaveClick(object sender, EventArgs e)
{ {
if (!IsSubtitleLoaded)
{
return;
}
ReloadFromSourceView(); ReloadFromSourceView();
bool oldChange = _changeSubtitleToString != _subtitle.GetFastHashCode(); bool oldChange = _changeSubtitleToString != _subtitle.GetFastHashCode();
SaveSubtitle(GetCurrentSubtitleFormat()); SaveSubtitle(GetCurrentSubtitleFormat());