Don't allow very long texts in waveform due to performance - thx Skrity :)

Fix #2536
This commit is contained in:
Nikolaj Olsson 2017-08-31 07:27:55 +02:00
parent 40f6be44e8
commit a43f8a1c48

View File

@ -746,10 +746,17 @@ namespace Nikse.SubtitleEdit.Controls
if (Configuration.Settings.General.RightToLeftMode && LanguageAutoDetect.CouldBeRightToLeftLanguge(new Subtitle(_displayableParagraphs)))
text = Utilities.ReverseStartAndEndingForRightToLeft(text);
int removeLength = 1;
if (text.Length > 500)
text = text.Substring(0, 500); // don't now allow very long texts as they can make SE unresponsive - see https://github.com/SubtitleEdit/subtitleedit/issues/2536
while (text.Length > removeLength && graphics.MeasureString(text, font).Width > currentRegionWidth - padding - 1)
{
text = text.Remove(text.Length - removeLength).TrimEnd() + "…";
removeLength = 2;
if (text.Length > 200)
removeLength = 21;
else if (text.Length > 100)
removeLength = 11;
else
removeLength = 2;
}
drawStringOutlined(text, currentRegionLeft + padding, padding);
}