Fixed client crash when no hosts to connect

This commit is contained in:
MaxXor 2015-08-28 12:45:57 +02:00
parent e9fdb1a431
commit bbcc2f954e
5 changed files with 10 additions and 3 deletions

View File

@ -2,7 +2,6 @@
using System.Linq;
using System.Text;
using xClient.Core.Data;
using xClient.Core.Utilities;
namespace xClient.Core.Helper
{

View File

@ -16,7 +16,10 @@ namespace xClient.Core.Helper
public static void CloseMutex()
{
if (_appMutex != null)
{
_appMutex.Close();
_appMutex = null;
}
}
}
}

View File

@ -5,6 +5,8 @@ namespace xClient.Core.Utilities
{
public class HostsManager
{
public bool IsEmpty { get { return _hosts.Count == 0; } }
private readonly Queue<Host> _hosts = new Queue<Host>();
public HostsManager(List<Host> hosts)

View File

@ -122,8 +122,11 @@ namespace xClient
ClientData.InstallPath = Path.Combine(Settings.DIR, ((!string.IsNullOrEmpty(Settings.SUBFOLDER)) ? Settings.SUBFOLDER + @"\" : "") + Settings.INSTALLNAME);
GeoLocationHelper.Initialize();
if (_hosts.IsEmpty)
ClientData.Disconnect = true; // no hosts to connect
if (!MutexHelper.CreateMutex(Settings.MUTEX))
ClientData.Disconnect = true;
ClientData.Disconnect = true; // process with same mutex is already running
if (ClientData.Disconnect)
return;

View File

@ -213,7 +213,7 @@ namespace xServer.Forms
private void btnBuild_Click(object sender, EventArgs e)
{
if (!string.IsNullOrEmpty(txtTag.Text) && !string.IsNullOrEmpty(txtMutex.Text) && // General Settings
lstHosts.Items.Count > 0 && !string.IsNullOrEmpty(txtPassword.Text) && !string.IsNullOrEmpty(txtDelay.Text) && // Connection
_hosts.Count > 0 && !string.IsNullOrEmpty(txtPassword.Text) && !string.IsNullOrEmpty(txtDelay.Text) && // Connection
!chkInstall.Checked || (chkInstall.Checked && !string.IsNullOrEmpty(txtInstallname.Text)) && // Installation
!chkStartup.Checked || (chkStartup.Checked && !string.IsNullOrEmpty(txtRegistryKeyName.Text))) // Installation
{