From 61b8af94763b4cacb2d06ad64576a9afb3d2d914 Mon Sep 17 00:00:00 2001 From: houzh <13923402541@gitee.com> Date: Thu, 31 Mar 2022 14:50:42 +0000 Subject: [PATCH] fix uieventsource.removeCallbacks --- src/gui/core/uieventsource.cc | 9 +++++---- src/gui/core/uieventsource.h | 2 +- src/gui/view/view.cc | 8 +++++--- src/gui/widget/viewpager.cc | 2 +- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/gui/core/uieventsource.cc b/src/gui/core/uieventsource.cc index 1a0c4f9d..a13b912d 100755 --- a/src/gui/core/uieventsource.cc +++ b/src/gui/core/uieventsource.cc @@ -76,14 +76,15 @@ bool UIEventSource::hasDelayedRunners()const{ return runner.timerun==what){ + if((it->run==what)&&(it->removed==false)){ it->removed=true; - return true; + count++; } } - return false; + return count; } }//end namespace diff --git a/src/gui/core/uieventsource.h b/src/gui/core/uieventsource.h index 15a4790f..d5893afb 100755 --- a/src/gui/core/uieventsource.h +++ b/src/gui/core/uieventsource.h @@ -24,7 +24,7 @@ public: int checkEvents()override; int handleEvents()override; bool postDelayed(Runnable& run,uint32_t delay=0); - bool removeCallbacks(const Runnable& what); + int removeCallbacks(const Runnable& what); }; }//end namespace diff --git a/src/gui/view/view.cc b/src/gui/view/view.cc index 3bb81e32..6f4c0578 100755 --- a/src/gui/view/view.cc +++ b/src/gui/view/view.cc @@ -141,7 +141,7 @@ public: } void run(){ long now = AnimationUtils::currentAnimationTimeMillis(); - if (now >= fadeStartTime) { + if (host && (now >= fadeStartTime)) { // the animation fades the scrollbars out by changing // the opacity (alpha) from fully opaque to fully // transparent @@ -1323,8 +1323,10 @@ void View::dispatchDetachedFromWindow(){ conts.erase(it); mPrivateFlags &= ~PFLAG_SCROLL_CONTAINER_ADDED; } - if(mScrollCache&&mScrollCache->mRunner) - removeCallbacks(mScrollCache->mRunner); + if(mScrollCache&&mScrollCache->mRunner){ + removeCallbacks(mScrollCache->mRunner); + mScrollCache->mRunner.reset(); + } mAttachInfo = nullptr; if(mOverlay) mOverlay->getOverlayView()->dispatchDetachedFromWindow(); diff --git a/src/gui/widget/viewpager.cc b/src/gui/widget/viewpager.cc index 8af6ffae..52c9d4a5 100755 --- a/src/gui/widget/viewpager.cc +++ b/src/gui/widget/viewpager.cc @@ -586,7 +586,7 @@ void ViewPager::populate(int newCurrentItem){ if (pos == ii->position && !ii->scrolling) { mItems.erase(mItems.begin()+itemIndex); mAdapter->destroyItem(this, pos, ii->object); - LOGD("destroyItem() with pos:%d/%d view:%p curitem=%d/%d",pos,ii->position,ii->object,mCurItem,mItems.size()); + LOGV("destroyItem() with pos:%d/%d view:%p curitem=%d/%d",pos,ii->position,ii->object,mCurItem,mItems.size()); delete ii; itemIndex--; curIndex--;