From 87d00992cae18cbc25bf34d81ac4e063ed30246b Mon Sep 17 00:00:00 2001 From: xiepengfei Date: Fri, 18 Sep 2026 19:39:47 +0800 Subject: [PATCH] fix: add null check for event pointer in gesture handling MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. Root cause: SheetBrowser::event() dereferences event pointer at gesture check without null guard, while KeyPress branch already guards with "event &&", causing crash when event is null 2. Fix: add "event &&" null check before event->type() call in the Gesture branch, consistent with existing KeyPress branch pattern 3. Impact: prevents null pointer dereference crash, no behavior change for valid event pointers Log: fix crash caused by null event pointer in gesture event handling Influence: 1. Test gesture events with valid event pointer 2. Test event handling when event pointer is null 3. Verify no regression on existing keyboard and gesture handling fix: 修复手势事件处理中的空指针解引用问题 1. 根因:SheetBrowser::event() 在手势事件检查处直接解引用 event 指针而未做空检查,而 KeyPress 分支已有 "event &&" 防护,当 event 为空时导致崩溃 2. 方案:在 Gesture 分支的 event->type() 调用前添加 "event &&" 空指针检查,与既有 KeyPress 分支防护模式一致 3. 影响:防止空指针解引用崩溃,对有效事件指针无行为变化 Log: 修复手势事件处理中空指针导致的崩溃问题 Influence: 1. 测试有效事件指针的手势事件处理 2. 测试事件指针为空时的事件处理 3. 验证现有键盘和手势处理无回归 --- reader/browser/SheetBrowser.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reader/browser/SheetBrowser.cpp b/reader/browser/SheetBrowser.cpp index 74adbbd78..433304ac4 100644 --- a/reader/browser/SheetBrowser.cpp +++ b/reader/browser/SheetBrowser.cpp @@ -922,7 +922,7 @@ bool SheetBrowser::event(QEvent *event) } } - if (event->type() == QEvent::Gesture) { + if (event && event->type() == QEvent::Gesture) { // qCDebug(appLog) << "SheetBrowser::event() - Gesture event"; return gestureEvent(reinterpret_cast(event)); }