!280 修改空指针调用导致的崩溃

Merge pull request !280 from caocan/master
This commit is contained in:
openharmony_ci 2021-10-20 09:48:10 +00:00 committed by Gitee
commit 7628cd8f36
2 changed files with 10 additions and 2 deletions

View File

@ -1314,14 +1314,14 @@ void RenderSwiper::UpdateItemPosition(double offset, int32_t index, int32_t othe
int32_t prevIndex = GetPrevIndex(index);
if (prevIndex != index && prevIndex != otherIndex) {
auto item = items_.find(prevIndex);
if (iter != items_.end()) {
if (item != items_.end()) {
item->second->SetPosition(GetMainAxisOffset(offset + (needReverse_ ? nextItemOffset_ : prevItemOffset_)));
}
}
int32_t nextIndex = GetNextIndex(index);
if (nextIndex != index && nextIndex != otherIndex) {
auto item = items_.find(nextIndex);
if (iter != items_.end()) {
if (item != items_.end()) {
item->second->SetPosition(GetMainAxisOffset(offset + (needReverse_ ? prevItemOffset_ : nextItemOffset_)));
}
}

View File

@ -248,6 +248,10 @@ void ImageProvider::UploadImageToGPUForRender(
const std::function<void(flutter::SkiaGPUObject<SkImage>)>&& callback,
const RefPtr<FlutterRenderTaskHolder>& renderTaskHolder)
{
if (!renderTaskHolder) {
LOGW("renderTaskHolder has been released.");
return;
}
#if defined(DUMP_DRAW_CMD) || defined(GPU_DISABLED)
// If want to dump draw command or gpu disabled, should use CPU image.
callback({ image, renderTaskHolder->unrefQueue });
@ -261,6 +265,10 @@ void ImageProvider::UploadImageToGPUForRender(
return;
}
auto task = [rasterizedImage, callback, renderTaskHolder] () {
if (!renderTaskHolder) {
LOGW("renderTaskHolder has been released.");
return;
}
// weak reference of io manager must be check and used on io thread, because io manager is created on io thread.
if (!renderTaskHolder->ioManager) {
// Shell is closing.