Skip to content

Commit

Permalink
Fix: check the frame bounds after calling loadFile
Browse files Browse the repository at this point in the history
  • Loading branch information
chchwy committed Jul 3, 2020
1 parent b11aa67 commit 6dc848a
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions core_lib/src/canvaspainter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -304,12 +304,6 @@ void CanvasPainter::paintBitmapFrame(QPainter& painter,
paintedImage = bitmapLayer->getBitmapImageAtFrame(nFrame);
}

if ((paintedImage == nullptr || paintedImage->bounds().isEmpty())
&& !(isCurrentFrame && mBuffer != nullptr && !mBuffer->bounds().isEmpty()))
{
return;
}

if (paintedImage == nullptr)
{
paintedImage = new BitmapImage;
Expand All @@ -318,6 +312,15 @@ void CanvasPainter::paintBitmapFrame(QPainter& painter,
paintedImage->loadFile(); // Critical! force the BitmapImage to load the image
CANVASPAINTER_LOG(" Paint Image Size: %dx%d", paintedImage->image()->width(), paintedImage->image()->height());

const bool frameIsEmpty = (paintedImage == nullptr || paintedImage->bounds().isEmpty());
const bool isDrawing = isCurrentFrame && mBuffer && !mBuffer->bounds().isEmpty();

if (frameIsEmpty && !isDrawing)
{
CANVASPAINTER_LOG(" Early return frame %d, %d", frameIsEmpty, isDrawing);
return;
}

BitmapImage paintToImage;
paintToImage.paste(paintedImage);

Expand Down

0 comments on commit 6dc848a

Please sign in to comment.