From: Caisking Date: Fri, 26 Dec 2025 13:18:28 +0000 (+0800) Subject: 优化滑动的函数 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=700d838650b2db6b9a0d2c422c1a75695c4decd0;p=mirrors%2FFD230.git 优化滑动的函数 --- diff --git a/code/sdk/middleware/services/gui/uikit/ui/frameworks/dock/pointer_input_device.cpp b/code/sdk/middleware/services/gui/uikit/ui/frameworks/dock/pointer_input_device.cpp index 4994c4e0f..cc2d4fc47 100644 --- a/code/sdk/middleware/services/gui/uikit/ui/frameworks/dock/pointer_input_device.cpp +++ b/code/sdk/middleware/services/gui/uikit/ui/frameworks/dock/pointer_input_device.cpp @@ -118,6 +118,10 @@ void PointerInputDevice::DispatchPressEvent(UIViewGroup* rootView) bool PointerInputDevice::ProcessReleaseEvent() { + // 检查 touchableView_ 是否为空,防止空指针解引用 + if (touchableView_ == nullptr) { + return false; + } UIView* parent = touchableView_->GetParent(); // reissue press event. if (!pressSent_) { @@ -336,6 +340,10 @@ void PointerInputDevice::DispatchDragEndEvent() void PointerInputDevice::DispatchLongPressEvent(uint32_t elapse) { + // 检查 touchableView_ 是否为空,防止空指针解引用 + if (touchableView_ == nullptr) { + return; + } if (!longPressSent_ && (elapse > INDEV_LONG_PRESS_TIME)) { longPressSent_ = true; LongPressEvent evt(curPos_, pressTimeStamp_); @@ -368,6 +376,11 @@ void PointerInputDevice::DispatchLongPressEvent(uint32_t elapse) void PointerInputDevice::DispatchCancelEvent() { + // 检查 touchableView_ 是否为空,防止空指针解引用 + if (touchableView_ == nullptr) { + cancelSent_ = true; + return; + } CancelEvent evt(lastPos_); UIView* parent = touchableView_->GetParent(); if (!touchableView_->OnCancelEvent(evt)) {