mirror of
https://github.com/mRemoteNG/mRemoteNG.git
synced 2026-02-17 22:11:48 +08:00
Remove deadlock in #1247
#1247 was caused by a loop of the putty control calling the tab dispose and back again. Created a flag to indicate the ConnectionTab that the closing process was called by the protocol and not the user.
This commit is contained in:
@@ -236,11 +236,8 @@ namespace mRemoteNG.Connection.Protocol
|
||||
|
||||
try
|
||||
{
|
||||
Console.WriteLine(@"Skipping Dispose for now!");
|
||||
PuttyProcess.Close();
|
||||
// TODO: Figure out why this hangs...
|
||||
//PuttyProcess.Dispose();
|
||||
Runtime.MessageCollector.AddMessage(MessageClass.ErrorMsg, Language.strPuttyDisposeFailed + Environment.NewLine + @"SKIPPING DISPOSE - CAUSES HANG IN THIS BUILD!!!", true);
|
||||
PuttyProcess.Close();
|
||||
PuttyProcess.Dispose();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
@@ -13,11 +13,18 @@ namespace mRemoteNG.UI.Tabs
|
||||
{
|
||||
public partial class ConnectionTab : DockContent
|
||||
{
|
||||
/// <summary>
|
||||
///Silent close ignores the popup asking for confirmation
|
||||
/// </summary>
|
||||
public bool silentClose { get; set; }
|
||||
/// <summary>
|
||||
/// Protocol close ignores the interface controller cleanup and the user confirmation dialog
|
||||
/// </summary>
|
||||
public bool protocolClose { get; set; }
|
||||
|
||||
public ConnectionTab()
|
||||
{
|
||||
InitializeComponent();
|
||||
InitializeComponent();
|
||||
GotFocus += ConnectionTab_GotFocus;
|
||||
}
|
||||
|
||||
@@ -28,34 +35,37 @@ namespace mRemoteNG.UI.Tabs
|
||||
|
||||
protected override void OnFormClosing(FormClosingEventArgs e)
|
||||
{
|
||||
if(!silentClose)
|
||||
if(!protocolClose)
|
||||
{
|
||||
if (Settings.Default.ConfirmCloseConnection == (int)ConfirmCloseEnum.All)
|
||||
if (!silentClose)
|
||||
{
|
||||
var result = CTaskDialog.MessageBox(this, GeneralAppInfo.ProductName, string.Format(Language.strConfirmCloseConnectionPanelMainInstruction, TabText), "", "", "", Language.strCheckboxDoNotShowThisMessageAgain, ETaskDialogButtons.YesNo, ESysIcons.Question, ESysIcons.Question);
|
||||
if (CTaskDialog.VerificationChecked)
|
||||
if (Settings.Default.ConfirmCloseConnection == (int)ConfirmCloseEnum.All)
|
||||
{
|
||||
Settings.Default.ConfirmCloseConnection--;
|
||||
}
|
||||
if (result == DialogResult.No)
|
||||
{
|
||||
e.Cancel = true;
|
||||
var result = CTaskDialog.MessageBox(this, GeneralAppInfo.ProductName, string.Format(Language.strConfirmCloseConnectionPanelMainInstruction, TabText), "", "", "", Language.strCheckboxDoNotShowThisMessageAgain, ETaskDialogButtons.YesNo, ESysIcons.Question, ESysIcons.Question);
|
||||
if (CTaskDialog.VerificationChecked)
|
||||
{
|
||||
Settings.Default.ConfirmCloseConnection--;
|
||||
}
|
||||
if (result == DialogResult.No)
|
||||
{
|
||||
e.Cancel = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
((InterfaceControl)Tag)?.Protocol.Close();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// close without the confirmation prompt...
|
||||
((InterfaceControl)Tag)?.Protocol.Close();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// close without the confirmation prompt...
|
||||
((InterfaceControl)Tag)?.Protocol.Close();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
((InterfaceControl)Tag)?.Protocol.Close();
|
||||
}
|
||||
base.OnFormClosing(e);
|
||||
}
|
||||
|
||||
|
||||
@@ -741,7 +741,7 @@ namespace mRemoteNG.UI.Window
|
||||
var protocolBase = sender as ProtocolBase;
|
||||
if (!(protocolBase?.InterfaceControl.Parent is ConnectionTab tabPage)) return;
|
||||
if (tabPage.Disposing) return;
|
||||
tabPage.silentClose = true;
|
||||
tabPage.protocolClose = true;
|
||||
Invoke(new Action(() => tabPage.Close()));
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user