Skip to content

Commit

Permalink
Fix exception when disposing Ft232h device with SPI manager initializ…
Browse files Browse the repository at this point in the history
…ed (#2270)
  • Loading branch information
jb1685 authored Jan 28, 2024
1 parent 3fb06eb commit c70264f
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/devices/Board/Board.cs
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ protected virtual void Dispose(bool disposing)
bus.Value.Dispose();
}

foreach (var bus in _managers)
foreach (var bus in _managers.ToList())
{
bus.Dispose();
}
Expand Down
2 changes: 1 addition & 1 deletion src/devices/Ft232H/Ftx232HDevice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1062,7 +1062,7 @@ private uint GetAvailableBytes()
/// </summary>
protected override void Dispose(bool disposing)
{
if (disposing)
if (disposing && _ftHandle != null)
{
_ftHandle.Dispose();
_ftHandle = null!;
Expand Down
2 changes: 1 addition & 1 deletion src/devices/Ft232H/samples/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ void TestI2c(Ftx232HDevice ft232h)

void TestI2cTsl2561(Ftx232HDevice ft232H)
{
var ftI2cBus = ft232h.CreateOrGetI2cBus(ft232h.GetDefaultI2cBusNumber());
var ftI2cBus = ft232H.CreateOrGetI2cBus(ft232H.GetDefaultI2cBusNumber());
var i2cDevice = ftI2cBus.CreateDevice(Tsl256x.DefaultI2cAddress);
Tsl256x tsl256X = new(i2cDevice, PackageType.Other);

Expand Down

0 comments on commit c70264f

Please sign in to comment.