2
0
mirror of https://github.com/koreader/koreader synced 2024-11-10 01:10:34 +00:00

ImageWidget: Don't attempt to pan if we haven't rendered the bb yet (#12331)

Input events from ImageViewer can be caught between it clearing an old
ImageWidget & instantiating a new one, but before the new one has had a
chance to actually render anything.

Fix #12327
This commit is contained in:
NiLuJe 2024-08-12 03:46:45 +02:00 committed by GitHub
parent de2a9d54f1
commit 4689e4f257
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 2 deletions

View File

@ -844,6 +844,7 @@ function ImageViewer:onCloseWidget()
self._scaled_image_func(false) -- invoke :free() on the creimage object
self._scaled_image_func = nil
end
self._image_wg = nil
-- Those, on the other hand, are always initialized, but may not actually be in our widget tree right now,
-- depending on what we needed to show, so they might not get sent a CloseWidget event.

View File

@ -480,6 +480,10 @@ function ImageWidget:getPanByCenterRatio(x, y)
end
function ImageWidget:panBy(x, y)
if not self._bb then
return
end
-- update center ratio from new offset
self.center_x_ratio = (x + self._offset_x + self.width/2) / self._bb_w
self.center_y_ratio = (y + self._offset_y + self.height/2) / self._bb_h
@ -595,8 +599,10 @@ end
-- BlitBuffer zombies
function ImageWidget:free()
--print("ImageWidget:free on", self, "for BB?", self._bb, self._bb_disposable)
if self._bb and self._bb_disposable and self._bb.free then
self._bb:free()
if self._bb then
if self._bb_disposable and self._bb.free then
self._bb:free()
end
self._bb = nil
end
-- reset self.scale_factor to its initial value, in case