Skip to content

Commit

Permalink
When casting a Sensor to a PoseSensor transfer the handle to avoid a …
Browse files Browse the repository at this point in the history
…double-delete.
  • Loading branch information
JBBee committed Dec 20, 2019
1 parent 95d1953 commit 3f66af0
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions wrappers/csharp/Intel.RealSense/Sensors/PoseSensor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,12 @@ public static PoseSensor FromSensor(Sensor sensor)
if (!sensor.Is(Extension.PoseSensor))
{
throw new ArgumentException($"Sensor does not support {nameof(Extension.PoseSensor)}");
}
return Create<PoseSensor>(sensor.Handle);
}

//Transfer the Sensor handle to the PoseSensor
var poseSensor = Create<PoseSensor>(sensor.Handle);
sensor.m_instance.SetHandleAsInvalid();
return poseSensor;
}

public byte[] ExportLocalizationMap()
Expand Down

0 comments on commit 3f66af0

Please sign in to comment.