Skip to content

Commit

Permalink
fix null pointer (#813)
Browse files Browse the repository at this point in the history
Co-authored-by: liamcli <liamcli@tencent.com>
(cherry picked from commit e4e1e4d)
  • Loading branch information
h3r3x3 authored and kevingpqi123 committed Mar 24, 2023
1 parent f3eba48 commit 9bad3ba
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
8 changes: 3 additions & 5 deletions android/libpag/src/main/java/org/libpag/PAGImageView.java
Original file line number Diff line number Diff line change
Expand Up @@ -391,12 +391,10 @@ private float getAnimationScale(Context context) {

private void refreshDecodeInfo() {
if (decoderInfo != null) {
decoderInfo.release();
decoderInfo = null;
decoderInfo.reset();
}
releaseCurrentDiskCache();
lastKeyItem = null;
decoderInfo = new DecoderInfo();
initDecoderInfo();
}

Expand Down Expand Up @@ -614,7 +612,7 @@ protected void onDetachedFromWindow() {
releaseCurrentDiskCache();
renderBitmap = null;
if (decoderInfo != null) {
decoderInfo.release();
decoderInfo.reset();
}
bitmapCache.clear();
}
Expand Down Expand Up @@ -747,7 +745,7 @@ private void releaseDecoder() {
}
cacheItem.writeLock();
if (bitmapCache.size() == decoderInfo.numFrames || cacheItem.isAllCached()) {
decoderInfo.release();
decoderInfo.releaseDecoder();
cacheItem.releaseSaveBuffer();
if (bitmapCache.size() == decoderInfo.numFrames) {
cacheItem.release();
Expand Down
11 changes: 10 additions & 1 deletion android/libpag/src/main/java/org/libpag/PAGImageViewHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -338,11 +338,20 @@ boolean initDecoder(Context context, PAGComposition _composition,
return true;
}

void release() {
void releaseDecoder() {
if (_pagDecoder != null) {
_pagDecoder.release();
}
_pagDecoder = null;
}

void reset() {
releaseDecoder();
_width = 0;
_height = 0;
realFrameRate = 0;
numFrames = 0;
duration = 0;
}
}
}

0 comments on commit 9bad3ba

Please sign in to comment.