Skip to content

Commit b64b65c

Browse files
committed
Crashing fix?
1 parent 0052d74 commit b64b65c

File tree

1 file changed

+21
-19
lines changed

1 file changed

+21
-19
lines changed

plugin_KinectOne/KinectOne.cs

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,28 @@ public void OnLoad()
102102

103103
public void Initialize()
104104
{
105-
IsInitialized = InitKinect();
106-
Host.Log($"Tried to initialize the Kinect sensor with status: {DeviceStatusString}");
105+
try
106+
{
107+
try
108+
{
109+
if(InitKinect()) InitializeSkeleton(); // Init?
110+
ShutdownInternal(false); // Shut down
111+
}
112+
catch (Exception)
113+
{
114+
// ignored
115+
}
116+
117+
IsInitialized = InitKinect();
118+
Host.Log($"Tried to initialize the Kinect sensor with status: {DeviceStatusString}");
107119

108-
// Try to start the stream
109-
InitializeSkeleton();
120+
// Try to start the stream
121+
InitializeSkeleton();
122+
}
123+
catch (Exception e)
124+
{
125+
Host.Log($"Failed to open the Kinect sensor! Message: {e.Message}");
126+
}
110127
}
111128

112129
public void Shutdown()
@@ -145,21 +162,6 @@ private bool InitKinect()
145162

146163
try
147164
{
148-
try
149-
{
150-
// Try to open the kinect sensor
151-
KinectSensor.Open(); // Open 0th
152-
Thread.Sleep(500);
153-
154-
// First try to de-init the sensor
155-
ShutdownInternal(false);
156-
Thread.Sleep(500);
157-
}
158-
catch
159-
{
160-
// ignored
161-
}
162-
163165
// Try to open the kinect sensor
164166
KinectSensor.Open(); // Open 1st
165167
for (var i = 0; i < 20; i++)

0 commit comments

Comments
 (0)