Skip to content

Commit

Permalink
Merge pull request #18526 from calixteman/bug1907958
Browse files Browse the repository at this point in the history
[Editor] Allow Float32Array for quadpoints in annotations (bug 1907958)
  • Loading branch information
calixteman authored Jul 31, 2024
2 parents f6b356e + 5f95d9b commit 63371ea
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
15 changes: 12 additions & 3 deletions src/core/core_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,10 +242,19 @@ function isBooleanArray(arr, len) {
* @returns {boolean}
*/
function isNumberArray(arr, len) {
if (Array.isArray(arr)) {
return (
(len === null || arr.length === len) &&
arr.every(x => typeof x === "number")
);
}

// This check allows us to have typed arrays but not the
// BigInt64Array/BigUint64Array types (their elements aren't "number").
return (
Array.isArray(arr) &&
(len === null || arr.length === len) &&
arr.every(x => typeof x === "number")
ArrayBuffer.isView(arr) &&
(arr.length === 0 || typeof arr[0] === "number") &&
(len === null || arr.length === len)
);
}

Expand Down
7 changes: 6 additions & 1 deletion test/driver.js
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,7 @@ class Driver {

if (task.annotationStorage) {
for (const annotation of Object.values(task.annotationStorage)) {
const { bitmapName } = annotation;
const { bitmapName, quadPoints } = annotation;
if (bitmapName) {
promise = promise.then(async doc => {
const response = await fetch(
Expand Down Expand Up @@ -643,6 +643,11 @@ class Driver {
return doc;
});
}
if (quadPoints) {
// Just to ensure that the quadPoints are always a Float32Array
// like IRL (in order to avoid bugs like bug 1907958).
annotation.quadPoints = new Float32Array(quadPoints);
}
}
}

Expand Down

0 comments on commit 63371ea

Please sign in to comment.