mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-26 01:58:06 +02:00
[Regression] Convert Catalog.builtInCMapCache
into a Map
, instead of an Object, to ensure that it's correctly reset (PR 8064 follow-up)
With the `builtInCMapCache` being a simple Object, it unfortunately means that the `Catalog.cleanup` method isn't resetting it as intended. By just replacing the `builtInCMapCache` with an empty Object, existing references to it will not actually be updated. The result is that e.g. `Page` instances still keeps references to, what should have been removed, CMap data. To fix these problems, the `builtInCMapCache` is converted into a `Map` instead (since it can be easily reset).
This commit is contained in:
parent
51b0e60f9b
commit
81b471c781
2 changed files with 5 additions and 6 deletions
|
@ -132,16 +132,15 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
|
|||
this.pdfFunctionFactory = pdfFunctionFactory;
|
||||
|
||||
this.fetchBuiltInCMap = (name) => {
|
||||
var cachedCMap = this.builtInCMapCache[name];
|
||||
if (cachedCMap) {
|
||||
return Promise.resolve(cachedCMap);
|
||||
if (this.builtInCMapCache.has(name)) {
|
||||
return Promise.resolve(this.builtInCMapCache.get(name));
|
||||
}
|
||||
return this.handler.sendWithPromise('FetchBuiltInCMap', {
|
||||
name,
|
||||
}).then((data) => {
|
||||
if (data.compressionType !== CMapCompressionType.NONE) {
|
||||
// Given the size of uncompressed CMaps, only cache compressed ones.
|
||||
this.builtInCMapCache[name] = data;
|
||||
this.builtInCMapCache.set(name, data);
|
||||
}
|
||||
return data;
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue