fix null pointer problems

Signed-off-by: caocan <1532643766@qq.com>
Change-Id: Ibb957a6f4744525c09126c0e12a12c98983decef
This commit is contained in:
caocan 2021-10-19 15:50:06 +08:00
parent e840a25b79
commit dde64e3cec
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.