Remove the hasImage
property from PDFThumbnailView
The `hasImage` property is a left-over from older thumbnail code, and has been made obsolete by `renderingState`. Having two different properties tracking (basically) the same state is asking for trouble, since it's very easy to forget to update one of them, with annoying bugs as the result.
This commit is contained in:
parent
05917b65d5
commit
95aa8b0415
@ -77,7 +77,6 @@ var PDFThumbnailView = (function PDFThumbnailViewClosure() {
|
||||
this.linkService = linkService;
|
||||
this.renderingQueue = renderingQueue;
|
||||
|
||||
this.hasImage = false;
|
||||
this.resume = null;
|
||||
this.renderingState = RenderingStates.INITIAL;
|
||||
|
||||
@ -133,7 +132,6 @@ var PDFThumbnailView = (function PDFThumbnailViewClosure() {
|
||||
if (this.renderTask) {
|
||||
this.renderTask.cancel();
|
||||
}
|
||||
this.hasImage = false;
|
||||
this.resume = null;
|
||||
this.renderingState = RenderingStates.INITIAL;
|
||||
|
||||
@ -238,11 +236,9 @@ var PDFThumbnailView = (function PDFThumbnailViewClosure() {
|
||||
draw: function PDFThumbnailView_draw() {
|
||||
if (this.renderingState !== RenderingStates.INITIAL) {
|
||||
console.error('Must be in new state before drawing');
|
||||
}
|
||||
if (this.hasImage) {
|
||||
return Promise.resolve(undefined);
|
||||
}
|
||||
this.hasImage = true;
|
||||
|
||||
this.renderingState = RenderingStates.RUNNING;
|
||||
|
||||
var resolveRenderPromise, rejectRenderPromise;
|
||||
@ -263,6 +259,7 @@ var PDFThumbnailView = (function PDFThumbnailViewClosure() {
|
||||
rejectRenderPromise(error);
|
||||
return;
|
||||
}
|
||||
|
||||
self.renderingState = RenderingStates.FINISHED;
|
||||
self._convertCanvasToImage();
|
||||
|
||||
@ -306,14 +303,17 @@ var PDFThumbnailView = (function PDFThumbnailViewClosure() {
|
||||
},
|
||||
|
||||
setImage: function PDFThumbnailView_setImage(pageView) {
|
||||
if (this.renderingState !== RenderingStates.INITIAL) {
|
||||
return;
|
||||
}
|
||||
var img = pageView.canvas;
|
||||
if (this.hasImage || !img) {
|
||||
if (!img) {
|
||||
return;
|
||||
}
|
||||
if (!this.pdfPage) {
|
||||
this.setPdfPage(pageView.pdfPage);
|
||||
}
|
||||
this.hasImage = true;
|
||||
|
||||
this.renderingState = RenderingStates.FINISHED;
|
||||
|
||||
var ctx = this._getPageDrawContext(true);
|
||||
|
Loading…
Reference in New Issue
Block a user