Skip to content

Commit

Permalink
Merge pull request #117 from intvsteve/master
Browse files Browse the repository at this point in the history
Pull fixes for issue #41
  • Loading branch information
intvsteve committed Dec 3, 2017
2 parents 20a0b88 + 3780411 commit b282d23
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
9 changes: 9 additions & 0 deletions INTV.LtoFlash/Model/Device.cs
Expand Up @@ -569,6 +569,15 @@ public static IPeripheral GetLtoFlashDevice(IConnection connection, object state
{
var creationInfo = state as DeviceCreationInfo;
if (creationInfo == null)
{
var stateDictionaryData = state as Dictionary<string, object>;
object creationInfoObject = null;
if ((stateDictionaryData != null) && stateDictionaryData.TryGetValue(DeviceCreationInfo.ConfigName, out creationInfoObject))
{
creationInfo = (DeviceCreationInfo)creationInfoObject;
}
}
if (creationInfo == null)
{
creationInfo = new DeviceCreationInfo(Properties.Settings.Default.AutomaticallyConnectToDevices, false, Properties.Settings.Default.AutomaticallyConnectToDevices ? ActivationMode.ActivateIfFirst : ActivationMode.UserSettings);
}
Expand Down
17 changes: 17 additions & 0 deletions INTV.LtoFlash/ViewModel/LtoFlashViewModel.cs
Expand Up @@ -457,6 +457,16 @@ internal void PromptForDeviceSelection(IList<string> ports)
{
SelectionDialogShowing = true;
SingleInstanceApplication.Instance.IsBusy = true;
if (!ports.Select(p => Connection.CreatePseudoConnection(p, ConnectionType.Serial)).Where(p => IsLtoFlashSerialPortConnection(p)).Any())
{
// The newly arrived ports do does not appear to contain any LTO Flash! hardware, so skip showing the dialog.
return;
}
foreach (var additionalKnownLtoFlashPort in PotentialDevicePorts.Select(p => p.Name).Except(ports))
{
ports.Add(additionalKnownLtoFlashPort);
}

OSWindow dialog = null;
var multiSelect = ports.Count() > 1;
var title = multiSelect ? Resources.Strings.SelectDeviceDialog_Title : Resources.Strings.ConnectToDevice_Title;
Expand Down Expand Up @@ -511,6 +521,13 @@ internal void ResetCachedFileSystemsCompareResult()
_cachedFileSystemsCompareResult = null;
}

private static bool IsLtoFlashSerialPortConnection(IConnection connection)
{
// Always check the given connection regardless of the user setting. We *really* want to know if this is an LTO Flash! device.
var isLtoFlashPort = SerialConnectionPolicy.Instance.ExclusiveAccess(connection);
return isLtoFlashPort;
}

private static bool MessageBoxExceptionFilter(System.Exception exception)
{
var report = true;
Expand Down

0 comments on commit b282d23

Please sign in to comment.