CP-17161: Add 'using' statement around dialogs to ensure garbage collection

- fix UpsellDialog usages

Signed-off-by: Mihaela Stoica <mihaela.stoica@citrix.com>
This commit is contained in:
Mihaela Stoica 2016-06-20 13:26:52 +01:00
parent da9e99b1cb
commit 62870544c6
16 changed files with 52 additions and 50 deletions

View File

@ -124,9 +124,9 @@ namespace XenAdmin.Commands
Helpers.FeatureForbidden(host, Host.RestrictCpuMasking) &&
!PoolJoinRules.FreeHostPaidMaster(host, master, false))) // in this case we can upgrade the license and then mask the CPU
{
UpsellDialog dlg = new UpsellDialog(HiddenFeatures.LinkLabelHidden ? Messages.UPSELL_BLURB_CPUMASKING : Messages.UPSELL_BLURB_CPUMASKING + Messages.UPSELL_BLURB_CPUMASKING_MORE,
InvisibleMessages.UPSELL_LEARNMOREURL_CPUMASKING);
dlg.ShowDialog(Parent);
using (var dlg = new UpsellDialog(HiddenFeatures.LinkLabelHidden ? Messages.UPSELL_BLURB_CPUMASKING : Messages.UPSELL_BLURB_CPUMASKING + Messages.UPSELL_BLURB_CPUMASKING_MORE,
InvisibleMessages.UPSELL_LEARNMOREURL_CPUMASKING))
dlg.ShowDialog(Parent);
return;
}

View File

@ -93,9 +93,9 @@ namespace XenAdmin.Commands
public static void ShowUpsellDialog(IWin32Window parent)
{
UpsellDialog dlg = new UpsellDialog(HiddenFeatures.LinkLabelHidden ? Messages.UPSELL_BLURB_CPM : Messages.UPSELL_BLURB_CPM + Messages.UPSELL_BLURB_CPM_MORE,
InvisibleMessages.UPSELL_LEARNMOREURL_CPM);
dlg.ShowDialog(parent);
using (var dlg = new UpsellDialog(HiddenFeatures.LinkLabelHidden ? Messages.UPSELL_BLURB_CPM : Messages.UPSELL_BLURB_CPM + Messages.UPSELL_BLURB_CPM_MORE,
InvisibleMessages.UPSELL_LEARNMOREURL_CPM))
dlg.ShowDialog(parent);
}
protected override bool CanExecute(VM vm)

View File

@ -118,9 +118,9 @@ namespace XenAdmin.Commands
private static void ShowUpsellDialog(IWin32Window parent)
{
// Show upsell dialog
UpsellDialog dlg = new UpsellDialog(HiddenFeatures.LinkLabelHidden ? Messages.UPSELL_BLURB_DR : Messages.UPSELL_BLURB_DR + Messages.UPSELL_BLURB_DR_MORE,
InvisibleMessages.UPSELL_LEARNMOREURL_DR);
dlg.ShowDialog(parent);
using (var dlg = new UpsellDialog(HiddenFeatures.LinkLabelHidden ? Messages.UPSELL_BLURB_DR : Messages.UPSELL_BLURB_DR + Messages.UPSELL_BLURB_DR_MORE,
InvisibleMessages.UPSELL_LEARNMOREURL_DR))
dlg.ShowDialog(parent);
}
protected override bool CanExecuteCore(SelectedItemCollection selection)

View File

@ -94,9 +94,9 @@ namespace XenAdmin.Commands
public static void ShowUpsellDialog(IWin32Window parent)
{
// Show upsell dialog
UpsellDialog dlg = new UpsellDialog(HiddenFeatures.LinkLabelHidden ? Messages.UPSELL_BLURB_DR : Messages.UPSELL_BLURB_DR + Messages.UPSELL_BLURB_DR_MORE,
InvisibleMessages.UPSELL_LEARNMOREURL_DR);
dlg.ShowDialog(parent);
using (var dlg = new UpsellDialog(HiddenFeatures.LinkLabelHidden ? Messages.UPSELL_BLURB_DR : Messages.UPSELL_BLURB_DR + Messages.UPSELL_BLURB_DR_MORE,
InvisibleMessages.UPSELL_LEARNMOREURL_DR))
dlg.ShowDialog(parent);
}
protected override bool CanExecuteCore(SelectedItemCollection selection)

View File

@ -97,9 +97,9 @@ namespace XenAdmin.Commands
public static void ShowUpsellDialog(IWin32Window parent)
{
// Show upsell dialog
UpsellDialog dlg = new UpsellDialog(HiddenFeatures.LinkLabelHidden ? Messages.UPSELL_BLURB_DR : Messages.UPSELL_BLURB_DR + Messages.UPSELL_BLURB_DR_MORE,
InvisibleMessages.UPSELL_LEARNMOREURL_DR);
dlg.ShowDialog(parent);
using (var dlg = new UpsellDialog(HiddenFeatures.LinkLabelHidden ? Messages.UPSELL_BLURB_DR : Messages.UPSELL_BLURB_DR + Messages.UPSELL_BLURB_DR_MORE,
InvisibleMessages.UPSELL_LEARNMOREURL_DR))
dlg.ShowDialog(parent);
}
protected override bool CanExecuteCore(SelectedItemCollection selection)

View File

@ -94,9 +94,9 @@ namespace XenAdmin.Commands
public static void ShowUpsellDialog(IWin32Window parent)
{
// Show upsell dialog
UpsellDialog dlg = new UpsellDialog(HiddenFeatures.LinkLabelHidden ? Messages.UPSELL_BLURB_DR : Messages.UPSELL_BLURB_DR + Messages.UPSELL_BLURB_DR_MORE,
InvisibleMessages.UPSELL_LEARNMOREURL_DR);
dlg.ShowDialog(parent);
using (var dlg = new UpsellDialog(HiddenFeatures.LinkLabelHidden ? Messages.UPSELL_BLURB_DR : Messages.UPSELL_BLURB_DR + Messages.UPSELL_BLURB_DR_MORE,
InvisibleMessages.UPSELL_LEARNMOREURL_DR))
dlg.ShowDialog(parent);
}
protected override bool CanExecuteCore(SelectedItemCollection selection)

View File

@ -91,9 +91,9 @@ namespace XenAdmin.Commands
public static void ShowUpsellDialog(IWin32Window parent)
{
// Show upsell dialog
UpsellDialog dlg = new UpsellDialog(HiddenFeatures.LinkLabelHidden ? Messages.UPSELL_BLURB_DR : Messages.UPSELL_BLURB_DR + Messages.UPSELL_BLURB_DR_MORE,
InvisibleMessages.UPSELL_LEARNMOREURL_DR);
dlg.ShowDialog(parent);
using (var dlg = new UpsellDialog(HiddenFeatures.LinkLabelHidden ? Messages.UPSELL_BLURB_DR : Messages.UPSELL_BLURB_DR + Messages.UPSELL_BLURB_DR_MORE,
InvisibleMessages.UPSELL_LEARNMOREURL_DR))
dlg.ShowDialog(parent);
}
protected override bool CanExecuteCore(SelectedItemCollection selection)

View File

@ -63,9 +63,9 @@ namespace XenAdmin.Commands
if (Helpers.FeatureForbidden(selection[0].XenObject, Host.RestrictWLB))
{
// Show upsell dialog
UpsellDialog dlg = new UpsellDialog(HiddenFeatures.LinkLabelHidden ? Messages.UPSELL_BLURB_WLB : Messages.UPSELL_BLURB_WLB + Messages.UPSELL_BLURB_WLB_MORE,
InvisibleMessages.UPSELL_LEARNMOREURL_WLB);
dlg.ShowDialog(Parent);
using (var dlg = new UpsellDialog(HiddenFeatures.LinkLabelHidden ? Messages.UPSELL_BLURB_WLB : Messages.UPSELL_BLURB_WLB + Messages.UPSELL_BLURB_WLB_MORE,
InvisibleMessages.UPSELL_LEARNMOREURL_WLB))
dlg.ShowDialog(Parent);
return;
}

View File

@ -82,9 +82,9 @@ namespace XenAdmin.Commands
if (Helpers.FeatureForbidden(pool, Host.RestrictHA))
{
// Show upsell dialog
UpsellDialog dlg = new UpsellDialog(HiddenFeatures.LinkLabelHidden ? Messages.UPSELL_BLURB_HA : Messages.UPSELL_BLURB_HA + Messages.UPSELL_BLURB_HA_MORE,
InvisibleMessages.UPSELL_LEARNMOREURL_HA);
dlg.ShowDialog(Parent);
using (var dlg = new UpsellDialog(HiddenFeatures.LinkLabelHidden ? Messages.UPSELL_BLURB_HA : Messages.UPSELL_BLURB_HA + Messages.UPSELL_BLURB_HA_MORE,
InvisibleMessages.UPSELL_LEARNMOREURL_HA))
dlg.ShowDialog(Parent);
}
else if (pool.ha_enabled)
{

View File

@ -85,9 +85,9 @@ namespace XenAdmin.Commands
public static void ShowUpsellDialog(IWin32Window parent)
{
UpsellDialog dlg = new UpsellDialog(HiddenFeatures.LinkLabelHidden ? Messages.MIGRATE_VDI_UPSELL_BLURB : Messages.MIGRATE_VDI_UPSELL_BLURB + Messages.MIGRATE_VDI_UPSELL_BLURB_MORE,
InvisibleMessages.UPSELL_LEARNMOREURL_CPM);
dlg.ShowDialog(parent);
using (var dlg = new UpsellDialog(HiddenFeatures.LinkLabelHidden ? Messages.MIGRATE_VDI_UPSELL_BLURB : Messages.MIGRATE_VDI_UPSELL_BLURB + Messages.MIGRATE_VDI_UPSELL_BLURB_MORE,
InvisibleMessages.UPSELL_LEARNMOREURL_CPM))
dlg.ShowDialog(parent);
}
protected override bool CanExecuteCore(SelectedItemCollection selection)

View File

@ -84,8 +84,8 @@ namespace XenAdmin.Commands
public static void ShowUpsellDialog(IWin32Window parent)
{
UpsellDialog dlg = new UpsellDialog(VMGroup<T>.UpsellBlurb, VMGroup<T>.UpsellLearnMoreUrl);
dlg.ShowDialog(parent);
using (var dlg = new UpsellDialog(VMGroup<T>.UpsellBlurb, VMGroup<T>.UpsellLearnMoreUrl))
dlg.ShowDialog(parent);
}
protected override bool CanExecuteCore(SelectedItemCollection selection)

View File

@ -84,9 +84,9 @@ namespace XenAdmin.Commands
if (Helpers.FeatureForbidden(selection[0].XenObject, Host.RestrictWLB))
{
// Show upsell dialog
UpsellDialog dlg = new UpsellDialog(HiddenFeatures.LinkLabelHidden ? Messages.UPSELL_BLURB_WLB : Messages.UPSELL_BLURB_WLB + Messages.UPSELL_BLURB_WLB_MORE,
InvisibleMessages.UPSELL_LEARNMOREURL_WLB);
dlg.ShowDialog(Parent);
using (var dlg = new UpsellDialog(HiddenFeatures.LinkLabelHidden ? Messages.UPSELL_BLURB_WLB : Messages.UPSELL_BLURB_WLB + Messages.UPSELL_BLURB_WLB_MORE,
InvisibleMessages.UPSELL_LEARNMOREURL_WLB))
dlg.ShowDialog(Parent);
return;
}

View File

@ -58,15 +58,17 @@ namespace XenAdmin.Diagnostics.Problems.HostProblem
protected override AsyncAction CreateAction(out bool cancelled)
{
SelectVMsToSuspendDialog dlg = new SelectVMsToSuspendDialog(Server);
if (dlg.ShowDialog() == DialogResult.OK)
using (var dlg = new SelectVMsToSuspendDialog(Server))
{
cancelled = false;
if (dlg.ShowDialog() == DialogResult.OK)
{
cancelled = false;
VmsToSuspend = dlg.SelectedVMsToSuspend;
VmsToShutdown = dlg.SelectedVMsToShutdown;
VmsToSuspend = dlg.SelectedVMsToSuspend;
VmsToShutdown = dlg.SelectedVMsToShutdown;
return new SuspendAndShutdownVMsAction(Server.Connection, Server, VmsToSuspend, VmsToShutdown);
return new SuspendAndShutdownVMsAction(Server.Connection, Server, VmsToSuspend, VmsToShutdown);
}
}
cancelled = true;

View File

@ -161,9 +161,9 @@ namespace XenAdmin.Dialogs
Helpers.FeatureForbidden(host, Host.RestrictCpuMasking) &&
!PoolJoinRules.FreeHostPaidMaster(host, master, false))) // in this case we can upgrade the license and then mask the CPU
{
UpsellDialog dlg = new UpsellDialog(HiddenFeatures.LinkLabelHidden ? Messages.UPSELL_BLURB_CPUMASKING : Messages.UPSELL_BLURB_CPUMASKING + Messages.UPSELL_BLURB_CPUMASKING_MORE,
InvisibleMessages.UPSELL_LEARNMOREURL_CPUMASKING);
dlg.ShowDialog(this);
using (var dlg = new UpsellDialog(HiddenFeatures.LinkLabelHidden ? Messages.UPSELL_BLURB_CPUMASKING : Messages.UPSELL_BLURB_CPUMASKING + Messages.UPSELL_BLURB_CPUMASKING_MORE,
InvisibleMessages.UPSELL_LEARNMOREURL_CPUMASKING))
dlg.ShowDialog(this);
return;
}

View File

@ -1035,9 +1035,9 @@ namespace XenAdmin.TabPages
if (Helpers.FeatureForbidden(pool.Connection, Host.RestrictRBAC))
{
// Show upsell dialog
UpsellDialog dlg = new UpsellDialog(HiddenFeatures.LinkLabelHidden ? Messages.UPSELL_BLURB_RBAC : Messages.UPSELL_BLURB_RBAC + Messages.UPSELL_BLURB_RBAC_MORE,
InvisibleMessages.UPSELL_LEARNMOREURL_RBAC);
dlg.ShowDialog(this);
using (var dlg = new UpsellDialog(HiddenFeatures.LinkLabelHidden ? Messages.UPSELL_BLURB_RBAC : Messages.UPSELL_BLURB_RBAC + Messages.UPSELL_BLURB_RBAC_MORE,
InvisibleMessages.UPSELL_LEARNMOREURL_RBAC))
dlg.ShowDialog(this);
return;
}

View File

@ -303,9 +303,9 @@ namespace XenAdmin.TabPages
private void ShowUpsell()
{
UpsellDialog upsellDialog = new UpsellDialog(HiddenFeatures.LinkLabelHidden ? Messages.UPSELL_BLURB_PERFORMANCE : Messages.UPSELL_BLURB_PERFORMANCE + Messages.UPSELL_BLURB_PERFORMANCE_MORE,
InvisibleMessages.UPSELL_LEARNMOREURL_PERFORMANCE);
upsellDialog.ShowDialog(this);
using (var upsellDialog = new UpsellDialog(HiddenFeatures.LinkLabelHidden ? Messages.UPSELL_BLURB_PERFORMANCE : Messages.UPSELL_BLURB_PERFORMANCE + Messages.UPSELL_BLURB_PERFORMANCE_MORE,
InvisibleMessages.UPSELL_LEARNMOREURL_PERFORMANCE))
upsellDialog.ShowDialog(this);
}
private void MoveGraphUp()