From 700d838650b2db6b9a0d2c422c1a75695c4decd0 Mon Sep 17 00:00:00 2001 From: Caisking Date: Fri, 26 Dec 2025 21:18:28 +0800 Subject: [PATCH] =?utf8?q?=E4=BC=98=E5=8C=96=E6=BB=91=E5=8A=A8=E7=9A=84?= =?utf8?q?=E5=87=BD=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../ui/frameworks/dock/pointer_input_device.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) 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)) { -- 2.17.1