add infinite loop check for pick_ffi

This commit is contained in:
Nick Fisher
2023-10-11 15:00:17 +08:00
parent 5feaa57d81
commit 78af8e12a0

View File

@@ -809,12 +809,16 @@ class FilamentControllerFFI extends FilamentController {
} }
final outPtr = calloc<EntityId>(1); final outPtr = calloc<EntityId>(1);
outPtr.value = 0; outPtr.value = 0;
print("height ${size.height.toInt()} y $y");
_lib.pick_ffi(_viewer!, x, size.height.toInt() - y, outPtr); _lib.pick_ffi(_viewer!, x, size.height.toInt() - y, outPtr);
int wait = 0;
while (outPtr.value == 0) { while (outPtr.value == 0) {
await Future.delayed(Duration(milliseconds: 100)); await Future.delayed(Duration(milliseconds: 50));
print("Waiting"); wait++;
if (wait > 10) {
calloc.free(outPtr);
throw Exception("Failed to get picking result");
}
} }
var entityId = outPtr.value; var entityId = outPtr.value;