pan event crash bug fix

Signed-off-by: zhouchaobo <zhouchaobo@huawei.com>
Change-Id: I7aed4048c454631342e08e3aebd9a38acbeefa90
This commit is contained in:
zhouchaobo 2024-11-20 10:25:37 +08:00
parent 040d005eec
commit 905287d9a4

View File

@ -48,7 +48,9 @@ void PanEventActuator::OnCollectTouchTarget(const OffsetF& coordinateOffset, con
auto actionStart = [weak = WeakClaim(this)](GestureEvent& info) {
auto actuator = weak.Upgrade();
CHECK_NULL_VOID(actuator);
for (const auto& panEvent : actuator->panEvents_) {
// In the actionStart callback, actuator->panEvents_ may be modified
auto copyPanEvents = actuator->panEvents_;
for (const auto& panEvent : copyPanEvents) {
auto actionStart = panEvent->GetActionStartEventFunc();
if (actionStart) {
actionStart(info);
@ -68,7 +70,9 @@ void PanEventActuator::OnCollectTouchTarget(const OffsetF& coordinateOffset, con
auto actionUpdate = [weak = WeakClaim(this)](GestureEvent& info) {
auto actuator = weak.Upgrade();
CHECK_NULL_VOID(actuator);
for (const auto& panEvent : actuator->panEvents_) {
// In the actionUpdate callback, actuator->panEvents_ may be modified
auto copyPanEvents = actuator->panEvents_;
for (const auto& panEvent : copyPanEvents) {
auto actionUpdate = panEvent->GetActionUpdateEventFunc();
if (actionUpdate) {
actionUpdate(info);
@ -89,8 +93,8 @@ void PanEventActuator::OnCollectTouchTarget(const OffsetF& coordinateOffset, con
auto actuator = weak.Upgrade();
CHECK_NULL_VOID(actuator);
// In the actionEnd callback, actuator->panEvents_ may be modified
auto copyPanEvents_ = actuator->panEvents_;
for (const auto& panEvent : copyPanEvents_) {
auto copyPanEvents = actuator->panEvents_;
for (const auto& panEvent : copyPanEvents) {
auto actionEnd = panEvent->GetActionEndEventFunc();
if (actionEnd) {
actionEnd(info);
@ -110,7 +114,9 @@ void PanEventActuator::OnCollectTouchTarget(const OffsetF& coordinateOffset, con
auto actionCancel = [weak = WeakClaim(this)]() {
auto actuator = weak.Upgrade();
CHECK_NULL_VOID(actuator);
for (const auto& panEvent : actuator->panEvents_) {
// In the actionCancel callback, actuator->panEvents_ may be modified
auto copyPanEvents = actuator->panEvents_;
for (const auto& panEvent : copyPanEvents) {
auto actionCancel = panEvent->GetActionCancelEventFunc();
if (actionCancel) {
actionCancel();