Fixed a few resource leaks

This commit is contained in:
niksedk 2014-10-03 13:48:13 +02:00
parent 4554f450de
commit fc9127e8f7
3 changed files with 88 additions and 55 deletions

View File

@ -46,8 +46,8 @@ namespace Nikse.SubtitleEdit.Forms
private void FixLargeFonts()
{
Graphics graphics = this.CreateGraphics();
SizeF textSize = graphics.MeasureString(buttonOK.Text, this.Font);
var graphics = CreateGraphics();
var textSize = graphics.MeasureString(buttonOK.Text, Font);
if (textSize.Height > buttonOK.Height - 4)
{
int newButtonHeight = (int)(textSize.Height + 7 + 0.5);
@ -108,8 +108,8 @@ namespace Nikse.SubtitleEdit.Forms
height = height * 95 / 100;
}
Bitmap temp = new Bitmap((int)width, (int)height);
using (Graphics g = Graphics.FromImage((Image)temp))
var temp = new Bitmap((int)width, (int)height);
using (var g = Graphics.FromImage(temp))
g.DrawImage(bmp, 0, 0, (int)width, (int)height);
bmp = temp;
}
@ -191,9 +191,12 @@ namespace Nikse.SubtitleEdit.Forms
var formSubOcr = new VobSubOcr();
formSubOcr.InitializeQuick(subs, _palette, Configuration.Settings.VobSubOcr, SelectedLanguageString);
var subtitle = formSubOcr.ReadyVobSubRip();
formSubOcr.Dispose();
var exportBdnXmlPng = new ExportPngXml();
exportBdnXmlPng.InitializeFromVobSubOcr(subtitle, new Nikse.SubtitleEdit.Logic.SubtitleFormats.SubRip(), "VOBSUB", "DVD", formSubOcr, SelectedLanguageString);
exportBdnXmlPng.InitializeFromVobSubOcr(subtitle, new Logic.SubtitleFormats.SubRip(), "VOBSUB", "DVD", formSubOcr, SelectedLanguageString);
exportBdnXmlPng.ShowDialog(this);
exportBdnXmlPng.Dispose();
}
}

View File

@ -17450,9 +17450,11 @@ namespace Nikse.SubtitleEdit.Forms
private void ToolStripMenuItemExportPngXmlClick(object sender, EventArgs e)
{
var exportBdnXmlPng = new ExportPngXml();
exportBdnXmlPng.Initialize(_subtitle, GetCurrentSubtitleFormat(), "BDNXML", _fileName, _videoInfo);
exportBdnXmlPng.ShowDialog(this);
using (var exportBdnXmlPng = new ExportPngXml())
{
exportBdnXmlPng.Initialize(_subtitle, GetCurrentSubtitleFormat(), "BDNXML", _fileName, _videoInfo);
exportBdnXmlPng.ShowDialog(this);
}
}
private void TabControlSubtitleSelecting(object sender, TabControlCancelEventArgs e)
@ -17839,16 +17841,20 @@ namespace Nikse.SubtitleEdit.Forms
private void BluraySupToolStripMenuItemClick(object sender, EventArgs e)
{
var exportBdnXmlPng = new ExportPngXml();
exportBdnXmlPng.Initialize(_subtitle, GetCurrentSubtitleFormat(), "BLURAYSUP", _fileName, _videoInfo);
exportBdnXmlPng.ShowDialog(this);
using (var exportBdnXmlPng = new ExportPngXml())
{
exportBdnXmlPng.Initialize(_subtitle, GetCurrentSubtitleFormat(), "BLURAYSUP", _fileName, _videoInfo);
exportBdnXmlPng.ShowDialog(this);
}
}
private void VobSubsubidxToolStripMenuItemClick(object sender, EventArgs e)
{
var exportBdnXmlPng = new ExportPngXml();
exportBdnXmlPng.Initialize(_subtitle, GetCurrentSubtitleFormat(), "VOBSUB", _fileName, _videoInfo);
exportBdnXmlPng.ShowDialog(this);
using (var exportBdnXmlPng = new ExportPngXml())
{
exportBdnXmlPng.Initialize(_subtitle, GetCurrentSubtitleFormat(), "VOBSUB", _fileName, _videoInfo);
exportBdnXmlPng.ShowDialog(this);
}
}
private void TextBoxListViewTextAlternateKeyUp(object sender, KeyEventArgs e)
@ -18035,9 +18041,11 @@ namespace Nikse.SubtitleEdit.Forms
private void AdobeEncoreFabImageScriptToolStripMenuItemClick(object sender, EventArgs e)
{
var exportBdnXmlPng = new ExportPngXml();
exportBdnXmlPng.Initialize(_subtitle, GetCurrentSubtitleFormat(), "FAB", _fileName, _videoInfo);
exportBdnXmlPng.ShowDialog(this);
using (var exportBdnXmlPng = new ExportPngXml())
{
exportBdnXmlPng.Initialize(_subtitle, GetCurrentSubtitleFormat(), "FAB", _fileName, _videoInfo);
exportBdnXmlPng.ShowDialog(this);
}
}
private void ToolStripMenuItemMergeDialogClick(object sender, EventArgs e)
@ -18160,9 +18168,11 @@ namespace Nikse.SubtitleEdit.Forms
private void ToolStripMenuItemImagePerFrameClick(object sender, EventArgs e)
{
var exportBdnXmlPng = new ExportPngXml();
exportBdnXmlPng.Initialize(_subtitle, GetCurrentSubtitleFormat(), "IMAGE/FRAME", _fileName, _videoInfo);
exportBdnXmlPng.ShowDialog(this);
using (var exportBdnXmlPng = new ExportPngXml())
{
exportBdnXmlPng.Initialize(_subtitle, GetCurrentSubtitleFormat(), "IMAGE/FRAME", _fileName, _videoInfo);
exportBdnXmlPng.ShowDialog(this);
}
}
private void toolStripMenuItemApplyDisplayTimeLimits_Click(object sender, EventArgs e)
@ -18832,16 +18842,20 @@ namespace Nikse.SubtitleEdit.Forms
private void DvdStudioProStl_Click(object sender, EventArgs e)
{
var exportBdnXmlPng = new ExportPngXml();
exportBdnXmlPng.Initialize(_subtitle, GetCurrentSubtitleFormat(), "STL", _fileName, _videoInfo);
exportBdnXmlPng.ShowDialog(this);
using (var exportBdnXmlPng = new ExportPngXml())
{
exportBdnXmlPng.Initialize(_subtitle, GetCurrentSubtitleFormat(), "STL", _fileName, _videoInfo);
exportBdnXmlPng.ShowDialog(this);
}
}
private void toolStripMenuItemPlugins_Click(object sender, EventArgs e)
{
var form = new PluginsGet();
form.ShowDialog(this);
LoadPlugins();
using (var form = new PluginsGet())
{
form.ShowDialog(this);
LoadPlugins();
}
}
private void toolStripMenuItemUndo_Click(object sender, EventArgs e)
@ -18859,16 +18873,18 @@ namespace Nikse.SubtitleEdit.Forms
if (audioVisualizer == null)
return;
var form = new SeekSilence();
if (form.ShowDialog(this) == DialogResult.OK)
using (var form = new SeekSilence())
{
if (form.SeekForward)
if (form.ShowDialog(this) == DialogResult.OK)
{
audioVisualizer.FindDataBelowThreshold(form.VolumeBelow, form.SecondsDuration);
}
else
{
audioVisualizer.FindDataBelowThresholdBack(form.VolumeBelow, form.SecondsDuration);
if (form.SeekForward)
{
audioVisualizer.FindDataBelowThreshold(form.VolumeBelow, form.SecondsDuration);
}
else
{
audioVisualizer.FindDataBelowThresholdBack(form.VolumeBelow, form.SecondsDuration);
}
}
}
}
@ -19407,9 +19423,11 @@ namespace Nikse.SubtitleEdit.Forms
private void toolStripMenuItemExportFcpIImage_Click(object sender, EventArgs e)
{
var exportBdnXmlPng = new ExportPngXml();
exportBdnXmlPng.Initialize(_subtitle, GetCurrentSubtitleFormat(), "FCP", _fileName, _videoInfo);
exportBdnXmlPng.ShowDialog(this);
using (var exportBdnXmlPng = new ExportPngXml())
{
exportBdnXmlPng.Initialize(_subtitle, GetCurrentSubtitleFormat(), "FCP", _fileName, _videoInfo);
exportBdnXmlPng.ShowDialog(this);
}
}
private void ToolStripMenuItemNuendoPropertiesClick(object sender, EventArgs e)
@ -19426,9 +19444,11 @@ namespace Nikse.SubtitleEdit.Forms
private void toolStripMenuItemDost_Click(object sender, EventArgs e)
{
var exportBdnXmlPng = new ExportPngXml();
exportBdnXmlPng.Initialize(_subtitle, GetCurrentSubtitleFormat(), "DOST", _fileName, _videoInfo);
exportBdnXmlPng.ShowDialog(this);
using (var exportBdnXmlPng = new ExportPngXml())
{
exportBdnXmlPng.Initialize(_subtitle, GetCurrentSubtitleFormat(), "DOST", _fileName, _videoInfo);
exportBdnXmlPng.ShowDialog(this);
}
}
private void toolStripMenuItemMeasurementConverter_Click(object sender, EventArgs e)
@ -19676,9 +19696,11 @@ namespace Nikse.SubtitleEdit.Forms
private void toolStripMenuItemExportDcinemaInteropClick(object sender, EventArgs e)
{
var exportBdnXmlPng = new ExportPngXml();
exportBdnXmlPng.Initialize(_subtitle, GetCurrentSubtitleFormat(), "DCINEMA_INTEROP", _fileName, _videoInfo);
exportBdnXmlPng.ShowDialog(this);
using (var exportBdnXmlPng = new ExportPngXml())
{
exportBdnXmlPng.Initialize(_subtitle, GetCurrentSubtitleFormat(), "DCINEMA_INTEROP", _fileName, _videoInfo);
exportBdnXmlPng.ShowDialog(this);
}
}
internal Subtitle UndoFromSpellCheck(Subtitle subtitle)

View File

@ -8022,23 +8022,29 @@ namespace Nikse.SubtitleEdit.Forms
private void vobSubToolStripMenuItem_Click(object sender, EventArgs e)
{
var exportBdnXmlPng = new ExportPngXml();
exportBdnXmlPng.InitializeFromVobSubOcr(_subtitle, new SubRip(), "VOBSUB", FileName, this, _importLanguageString);
exportBdnXmlPng.ShowDialog(this);
using (var exportBdnXmlPng = new ExportPngXml())
{
exportBdnXmlPng.InitializeFromVobSubOcr(_subtitle, new SubRip(), "VOBSUB", FileName, this, _importLanguageString);
exportBdnXmlPng.ShowDialog(this);
}
}
private void bluraySupToolStripMenuItem_Click(object sender, EventArgs e)
{
var exportBdnXmlPng = new ExportPngXml();
exportBdnXmlPng.InitializeFromVobSubOcr(_subtitle, new SubRip(), "BLURAYSUP", FileName, this, _importLanguageString);
exportBdnXmlPng.ShowDialog(this);
using (var exportBdnXmlPng = new ExportPngXml())
{
exportBdnXmlPng.InitializeFromVobSubOcr(_subtitle, new SubRip(), "BLURAYSUP", FileName, this, _importLanguageString);
exportBdnXmlPng.ShowDialog(this);
}
}
private void bDNXMLToolStripMenuItem_Click(object sender, EventArgs e)
{
var exportBdnXmlPng = new ExportPngXml();
exportBdnXmlPng.InitializeFromVobSubOcr(_subtitle, new SubRip(), "BDNXML", FileName, this, _importLanguageString);
exportBdnXmlPng.ShowDialog(this);
using (var exportBdnXmlPng = new ExportPngXml())
{
exportBdnXmlPng.InitializeFromVobSubOcr(_subtitle, new SubRip(), "BDNXML", FileName, this, _importLanguageString);
exportBdnXmlPng.ShowDialog(this);
}
}
private void clearToolStripMenuItem_Click(object sender, EventArgs e)
@ -8163,9 +8169,11 @@ namespace Nikse.SubtitleEdit.Forms
private void dOSTToolStripMenuItem_Click(object sender, EventArgs e)
{
var exportBdnXmlPng = new ExportPngXml();
exportBdnXmlPng.InitializeFromVobSubOcr(_subtitle, new SubRip(), "DOST", FileName, this, _importLanguageString);
exportBdnXmlPng.ShowDialog(this);
using (var exportBdnXmlPng = new ExportPngXml())
{
exportBdnXmlPng.InitializeFromVobSubOcr(_subtitle, new SubRip(), "DOST", FileName, this, _importLanguageString);
exportBdnXmlPng.ShowDialog(this);
}
}
// TODO: Get language from ts file