Skip to content

Commit

Permalink
Access the Catalog data correctly in the "GetPageIndex" handler in …
Browse files Browse the repository at this point in the history
…`src/core/worker.js`

Even though the code obviously works as-is, given that we have unit-tests for it, it still feels incorrect to just *assume* that the `Catalog`-instance has all of its properties immediately available. Especially when (almost) all of the other handlers, in `src/core/worker.js`, protect their data accesses with appropriate `pdfManager.ensure` calls.
  • Loading branch information
Snuffleupagus committed Aug 25, 2020
1 parent 2e6e2c3 commit bd16c36
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/core/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -438,10 +438,9 @@ class WorkerMessageHandler {
});
});

handler.on("GetPageIndex", function wphSetupGetPageIndex(data) {
var ref = Ref.get(data.ref.num, data.ref.gen);
var catalog = pdfManager.pdfDocument.catalog;
return catalog.getPageIndex(ref);
handler.on("GetPageIndex", function wphSetupGetPageIndex({ ref }) {
const pageRef = Ref.get(ref.num, ref.gen);
return pdfManager.ensureCatalog("getPageIndex", [pageRef]);
});

handler.on("GetDestinations", function wphSetupGetDestinations(data) {
Expand Down

0 comments on commit bd16c36

Please sign in to comment.