If we ask the Table.withRowsColumns() constructor to build a table with a number of rows and columns which does not match the size of the cell array supplied, then omniJS crashes OmniGraffle 7.5 test (v181.3 r294205 built Aug 18 2017):
Test code with two examples:
- A well-formed call to
Table.withRowsColumns()
, which successfully generates a table, and - another call which differs only in providing an array of cell graphics of a length which does not match the specified number of rows and/or columns:
i.e. we get a crash whenever Array.length > (columns * rows)
(The following consistently crashes the app here)
(() => {
'use strict';
// GENERIC FUNCTION ------------------------------------------------------
// enumFromTo :: Int -> Int -> [Int]
const enumFromTo = (m, n) =>
Array.from({
length: Math.floor(n - m) + 1
}, (_, i) => m + i);
// TEST ------------------------------------------------------------------
const canvas = document.windows[0].selection.canvas;
// 1. CONTROL CASE WITHOUT A PROBLEM:
// TABLE IN WHICH CELL COUNT MATCHES PRODUCT OF ROWS AND COLUMNS ---------
const goodTable = Table.withRowsColumns(
2, 2,
enumFromTo(1, 4)
.map(i => Object.assign(
canvas.newShape(), {
'geometry': new Rect(80 * i, 105.00, 80.00, 80.00)
}
))
);
// 2. CRASHING CASE: MISMATCH BETWEEN CELL COUNT AND ROW/COL COUNT
// (Number of cells (4) longer than product of rows * cols (2))
const crashTable = Table.withRowsColumns(
2, 1,
enumFromTo(1, 4)
.map(i => Object.assign(
canvas.newShape(), {
'geometry': new Rect(200 + (80 * i), 105.00, 80.00, 80.00)
}
))
);
})();