From edae495e542261b11a5005d5f058326058c4024a Mon Sep 17 00:00:00 2001 From: hct95 Date: Wed, 13 Nov 2024 09:31:04 +0000 Subject: [PATCH] =?UTF-8?q?getContext=E6=95=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: hct95 Change-Id: I0d4652bd2a911a9f23ecdc249ffe382d35a10883 --- adapter/ohos/entrance/mmi_event_convertor.cpp | 2 +- .../core/components_ng/event/drag_event.cpp | 54 +++++++++---------- .../core/components_ng/event/event_hub.cpp | 6 +-- .../core/components_ng/event/focus_hub.cpp | 12 ++--- .../event/gesture_event_hub_drag.cpp | 14 ++--- .../event/state_style_manager.cpp | 4 +- .../core/components_ng/event/touch_event.cpp | 2 +- .../gestures/recognizers/click_recognizer.cpp | 8 +-- .../recognizers/gesture_recognizer.cpp | 6 +-- .../recognizers/long_press_recognizer.cpp | 12 ++--- .../gestures/recognizers/pan_recognizer.cpp | 4 +- .../gestures/recognizers/pinch_recognizer.cpp | 2 +- .../recognizers/sequenced_recognizer.cpp | 2 +- .../gestures/recognizers/swipe_recognizer.cpp | 2 +- .../drag_drop/drag_drop_func_wrapper.cpp | 4 +- .../manager/drag_drop/drag_drop_manager.cpp | 20 ++++--- .../manager/drag_drop/drag_drop_proxy.cpp | 20 +++---- .../drag_drop/utils/drag_animation_helper.cpp | 12 ++--- .../manager/post_event/post_event_manager.cpp | 4 +- .../pattern/app_bar/app_bar_view.cpp | 6 +-- .../property/templates_parser.cpp | 2 +- 21 files changed, 95 insertions(+), 103 deletions(-) diff --git a/adapter/ohos/entrance/mmi_event_convertor.cpp b/adapter/ohos/entrance/mmi_event_convertor.cpp index d398582edfc..b7a5a29c5b2 100644 --- a/adapter/ohos/entrance/mmi_event_convertor.cpp +++ b/adapter/ohos/entrance/mmi_event_convertor.cpp @@ -626,7 +626,7 @@ void CalculatePointerEvent(const NG::OffsetF& offsetF, const std::shared_ptrGetDisplayWindowRectInfo(); auto windowWidth = displayWindowRect.Width(); diff --git a/frameworks/core/components_ng/event/drag_event.cpp b/frameworks/core/components_ng/event/drag_event.cpp index 03edd18c7df..62521dbd8ec 100644 --- a/frameworks/core/components_ng/event/drag_event.cpp +++ b/frameworks/core/components_ng/event/drag_event.cpp @@ -149,7 +149,7 @@ void DragEventActuator::CancelDragForWeb() */ bool DragEventActuator::IsGlobalStatusSuitableForDragging() { - auto pipeline = PipelineContext::GetCurrentContext(); + auto pipeline = PipelineContext::GetCurrentContextSafelyWithCheck(); CHECK_NULL_RETURN(pipeline, false); auto dragDropManager = pipeline->GetDragDropManager(); CHECK_NULL_RETURN(dragDropManager, false); @@ -277,7 +277,7 @@ void DragEventActuator::OnCollectTouchTarget(const OffsetF& coordinateOffset, co CHECK_NULL_VOID(gestureHub); auto frameNode = gestureHub->GetFrameNode(); CHECK_NULL_VOID(frameNode); - auto pipeline = PipelineContext::GetCurrentContext(); + auto pipeline = frameNode->GetContextRefPtr(); CHECK_NULL_VOID(pipeline); auto dragDropManager = pipeline->GetDragDropManager(); CHECK_NULL_VOID(dragDropManager); @@ -298,7 +298,7 @@ void DragEventActuator::OnCollectTouchTarget(const OffsetF& coordinateOffset, co DragEventActuator::ResetDragStatus(); return; } - auto pipeline = PipelineContext::GetCurrentContext(); + auto pipeline = PipelineContext::GetCurrentContextSafelyWithCheck(); CHECK_NULL_VOID(pipeline); auto dragDropManager = pipeline->GetDragDropManager(); CHECK_NULL_VOID(dragDropManager); @@ -415,7 +415,7 @@ void DragEventActuator::OnCollectTouchTarget(const OffsetF& coordinateOffset, co auto actionEnd = [weak = WeakClaim(this)](GestureEvent& info) { TAG_LOGI(AceLogTag::ACE_DRAG, "Trigger drag action end."); - auto pipelineContext = PipelineContext::GetCurrentContext(); + auto pipelineContext = PipelineContext::GetCurrentContextSafelyWithCheck(); CHECK_NULL_VOID(pipelineContext); auto dragDropManager = pipelineContext->GetDragDropManager(); CHECK_NULL_VOID(dragDropManager); @@ -455,7 +455,7 @@ void DragEventActuator::OnCollectTouchTarget(const OffsetF& coordinateOffset, co panRecognizer_->SetOnActionEnd(actionEnd); auto actionCancel = [weak = WeakClaim(this), touchSourceType = touchRestrict.sourceType]() { TAG_LOGD(AceLogTag::ACE_DRAG, "Drag event has been canceled."); - auto pipelineContext = PipelineContext::GetCurrentContext(); + auto pipelineContext = PipelineContext::GetCurrentContextSafelyWithCheck(); CHECK_NULL_VOID(pipelineContext); auto dragDropManager = pipelineContext->GetDragDropManager(); CHECK_NULL_VOID(dragDropManager); @@ -534,7 +534,7 @@ void DragEventActuator::OnCollectTouchTarget(const OffsetF& coordinateOffset, co auto gestureHub = actuator->gestureEventHub_.Upgrade(); CHECK_NULL_VOID(gestureHub); actuator->ResetResponseRegion(); - auto pipelineContext = PipelineContext::GetCurrentContext(); + auto pipelineContext = PipelineContext::GetCurrentContextSafelyWithCheck(); CHECK_NULL_VOID(pipelineContext); auto manager = pipelineContext->GetOverlayManager(); CHECK_NULL_VOID(manager); @@ -835,7 +835,7 @@ void DragEventActuator::OnCollectTouchTarget(const OffsetF& coordinateOffset, co void DragEventActuator::ResetDragStatus() { - auto pipelineContext = PipelineContext::GetCurrentContext(); + auto pipelineContext = PipelineContext::GetCurrentContextSafelyWithCheck(); CHECK_NULL_VOID(pipelineContext); auto overlayManager = pipelineContext->GetOverlayManager(); CHECK_NULL_VOID(overlayManager); @@ -848,7 +848,7 @@ void DragEventActuator::ResetDragStatus() void DragEventActuator::SetDragDampStartPointInfo(const Point& point, int32_t pointerId) { - auto pipeline = PipelineContext::GetCurrentContext(); + auto pipeline = PipelineContext::GetCurrentContextSafelyWithCheck(); CHECK_NULL_VOID(pipeline); auto dragDropManager = pipeline->GetDragDropManager(); CHECK_NULL_VOID(dragDropManager); @@ -859,7 +859,7 @@ void DragEventActuator::SetDragDampStartPointInfo(const Point& point, int32_t po void DragEventActuator::HandleDragDampingMove(const Point& point, int32_t pointerId, bool isRedragStart) { - auto pipeline = PipelineContext::GetCurrentContext(); + auto pipeline = PipelineContext::GetCurrentContextSafelyWithCheck(); CHECK_NULL_VOID(pipeline); auto dragDropManager = pipeline->GetDragDropManager(); CHECK_NULL_VOID(dragDropManager); @@ -918,7 +918,7 @@ void DragEventActuator::SetFilter(const RefPtr& actuator) frameNode->GetTag().c_str(), frameNode->GetDepth()); return; } - auto pipelineContext = PipelineContext::GetCurrentContext(); + auto pipelineContext = PipelineContext::GetCurrentContextSafelyWithCheck(); CHECK_NULL_VOID(pipelineContext); auto manager = pipelineContext->GetOverlayManager(); CHECK_NULL_VOID(manager); @@ -996,7 +996,7 @@ OffsetF DragEventActuator::GetFloatImageOffset(const RefPtr& frameNod } #endif // Check web tag. - auto pipelineContext = PipelineContext::GetCurrentContext(); + auto pipelineContext = PipelineContext::GetCurrentContextSafelyWithCheck(); CHECK_NULL_RETURN(pipelineContext, OffsetF()); if (pipelineContext->HasFloatTitle()) { offsetX -= static_cast((CONTAINER_BORDER_WIDTH + CONTENT_PADDING).ConvertToPx()); @@ -1227,7 +1227,7 @@ RefPtr DragEventActuator::GetScreenShotPixelMap(const RefPtr& actuator) { TAG_LOGD(AceLogTag::ACE_DRAG, "DragEvent start set pixelMap"); - auto pipelineContext = PipelineContext::GetCurrentContext(); + auto pipelineContext = PipelineContext::GetCurrentContextSafelyWithCheck(); CHECK_NULL_VOID(pipelineContext); auto manager = pipelineContext->GetOverlayManager(); CHECK_NULL_VOID(manager); @@ -1381,7 +1381,7 @@ float DragEventActuator::RadiusToSigma(float radius) std::optional DragEventActuator::BrulStyleToEffection(const std::optional& blurStyleOp) { - auto pipeline = PipelineContext::GetCurrentContext(); + auto pipeline = PipelineContext::GetCurrentContextSafelyWithCheck(); CHECK_NULL_RETURN(pipeline, std::nullopt); auto blurStyleTheme = pipeline->GetTheme(); if (!blurStyleTheme) { @@ -1431,7 +1431,7 @@ void DragEventActuator::ApplyNewestOptionExecutedFromModifierToNode( void DragEventActuator::SetEventColumn(const RefPtr& actuator) { TAG_LOGI(AceLogTag::ACE_DRAG, "DragEvent start set eventColumn."); - auto pipelineContext = PipelineContext::GetCurrentContext(); + auto pipelineContext = PipelineContext::GetCurrentContextSafelyWithCheck(); CHECK_NULL_VOID(pipelineContext); auto manager = pipelineContext->GetOverlayManager(); CHECK_NULL_VOID(manager); @@ -1476,7 +1476,7 @@ void DragEventActuator::HideFilter() if (frameNode->GetTag() != V2::WEB_ETS_TAG) { return; } - auto pipelineContext = PipelineContext::GetCurrentContext(); + auto pipelineContext = PipelineContext::GetCurrentContextSafelyWithCheck(); CHECK_NULL_VOID(pipelineContext); auto manager = pipelineContext->GetOverlayManager(); CHECK_NULL_VOID(manager); @@ -1507,7 +1507,7 @@ void DragEventActuator::HidePixelMap(bool startDrag, double x, double y, bool sh void DragEventActuator::HideEventColumn() { - auto pipelineContext = PipelineContext::GetCurrentContext(); + auto pipelineContext = PipelineContext::GetCurrentContextSafelyWithCheck(); CHECK_NULL_VOID(pipelineContext); auto manager = pipelineContext->GetOverlayManager(); CHECK_NULL_VOID(manager); @@ -1648,7 +1648,7 @@ void DragEventActuator::SetTextPixelMap(const RefPtr& gestureHu void DragEventActuator::SetTextAnimation(const RefPtr& gestureHub, const Offset& globalLocation) { TAG_LOGD(AceLogTag::ACE_DRAG, "DragEvent start set textAnimation."); - auto pipelineContext = PipelineContext::GetCurrentContext(); + auto pipelineContext = PipelineContext::GetCurrentContextSafelyWithCheck(); CHECK_NULL_VOID(pipelineContext); auto manager = pipelineContext->GetOverlayManager(); CHECK_NULL_VOID(manager); @@ -1741,7 +1741,7 @@ void DragEventActuator::HideTextAnimation(bool startDrag, double globalX, double option.SetCurve(Curves::SHARP); option.SetOnFinishEvent(removeColumnNode); - auto pipeline = PipelineContext::GetCurrentContext(); + auto pipeline = PipelineContext::GetCurrentContextSafelyWithCheck(); CHECK_NULL_VOID(pipeline); auto manager = pipeline->GetOverlayManager(); auto dragNode = manager->GetPixelMapNode(); @@ -1865,7 +1865,7 @@ void DragEventActuator::CopyDragEvent(const RefPtr& dragEvent void DragEventActuator::FlushSyncGeometryNodeTasks() { - auto pipeline = PipelineBase::GetCurrentContext(); + auto pipeline = PipelineBase::GetCurrentContextSafelyWithCheck(); CHECK_NULL_VOID(pipeline); pipeline->FlushSyncGeometryNodeTasks(); } @@ -1876,7 +1876,7 @@ void DragEventActuator::SetGatherNodeAboveFilter(const RefPtr if (!actuator->IsNeedGather()) { return; } - auto pipelineContext = PipelineContext::GetCurrentContext(); + auto pipelineContext = PipelineContext::GetCurrentContextSafelyWithCheck(); CHECK_NULL_VOID(pipelineContext); auto manager = pipelineContext->GetOverlayManager(); CHECK_NULL_VOID(manager); @@ -1931,7 +1931,7 @@ RefPtr DragEventActuator::CreateGatherNode(const RefPtrGetFrameNode(); CHECK_NULL_RETURN(frameNode, nullptr); - auto pipelineContext = PipelineContext::GetCurrentContext(); + auto pipelineContext = PipelineContext::GetCurrentContextSafelyWithCheck(); CHECK_NULL_RETURN(pipelineContext, nullptr); auto manager = pipelineContext->GetOverlayManager(); CHECK_NULL_RETURN(manager, nullptr); @@ -2087,8 +2087,6 @@ void DragEventActuator::GetFrameNodePreviewPixelMap(const RefPtr& fra auto gestureHub = frameNode->GetOrCreateGestureEventHub(); CHECK_NULL_VOID(gestureHub); auto dragPreviewInfo = frameNode->GetDragPreview(); - auto pipeline = PipelineContext::GetCurrentContext(); - CHECK_NULL_VOID(pipeline); if (dragPreviewInfo.inspectorId != "") { auto previewPixelMap = GetPreviewPixelMap(dragPreviewInfo.inspectorId, frameNode); gestureHub->SetDragPreviewPixelMap(previewPixelMap); @@ -2106,7 +2104,7 @@ void DragEventActuator::GetFrameNodePreviewPixelMap(const RefPtr& fra bool DragEventActuator::IsBelongToMultiItemNode(const RefPtr& frameNode) { CHECK_NULL_RETURN(frameNode, false); - auto pipeline = PipelineContext::GetCurrentContext(); + auto pipeline = PipelineContext::GetCurrentContextSafelyWithCheck(); CHECK_NULL_RETURN(pipeline, false); auto dragDropManager = pipeline->GetDragDropManager(); CHECK_NULL_RETURN(dragDropManager, false); @@ -2257,7 +2255,7 @@ void DragEventActuator::HandleTouchMoveEvent() longPressRecognizer_->GetGestureDisposal() == GestureDisposal::REJECT) { SetGatherNode(nullptr); ClearGatherNodeChildrenInfo(); - auto pipelineContext = PipelineContext::GetCurrentContext(); + auto pipelineContext = PipelineContext::GetCurrentContextSafelyWithCheck(); CHECK_NULL_VOID(pipelineContext); auto manager = pipelineContext->GetOverlayManager(); CHECK_NULL_VOID(manager); @@ -2356,7 +2354,7 @@ void DragEventActuator::ParseShadowInfo(Shadow& shadow, std::unique_ptr DragEventActuator::GetDefaultShadow() { - auto pipelineContext = PipelineContext::GetCurrentContext(); + auto pipelineContext = PipelineContext::GetCurrentContextSafelyWithCheck(); CHECK_NULL_RETURN(pipelineContext, std::nullopt); auto shadowTheme = pipelineContext->GetTheme(); CHECK_NULL_RETURN(shadowTheme, std::nullopt); @@ -2527,7 +2525,7 @@ void DragEventActuator::ResetResponseRegion() void DragEventActuator::PrepareFinalPixelMapForDragThroughTouch(RefPtr pixelMap, bool immediately) { ResetPreScaledPixelMapForDragThroughTouch(); - auto pipeline = PipelineContext::GetCurrentContext(); + auto pipeline = PipelineContext::GetCurrentContextSafelyWithCheck(); CHECK_NULL_VOID(pipeline); auto dragDropManager = pipeline->GetDragDropManager(); CHECK_NULL_VOID(dragDropManager); @@ -2584,7 +2582,7 @@ void DragEventActuator::RecordMenuWrapperNodeForDrag(int32_t targetId) auto menuWrapperNode = overlayManager->GetMenuNode(targetId); CHECK_NULL_VOID(menuWrapperNode); - auto pipeline = PipelineContext::GetCurrentContext(); + auto pipeline = PipelineContext::GetCurrentContextSafelyWithCheck(); CHECK_NULL_VOID(pipeline); auto dragDropManager = pipeline->GetDragDropManager(); CHECK_NULL_VOID(dragDropManager); diff --git a/frameworks/core/components_ng/event/event_hub.cpp b/frameworks/core/components_ng/event/event_hub.cpp index cc5b3be56ca..b2d2256d993 100644 --- a/frameworks/core/components_ng/event/event_hub.cpp +++ b/frameworks/core/components_ng/event/event_hub.cpp @@ -110,7 +110,7 @@ GetEventTargetImpl EventHub::CreateGetEventTargetImpl() const void EventHub::PostEnabledTask() { - auto pipeline = PipelineBase::GetCurrentContext(); + auto pipeline = PipelineBase::GetCurrentContextSafelyWithCheck(); CHECK_NULL_VOID(pipeline); auto taskExecutor = pipeline->GetTaskExecutor(); CHECK_NULL_VOID(taskExecutor); @@ -286,7 +286,7 @@ void EventHub::HandleInternalOnDrop(const RefPtr& info, co void EventHub::AddInnerOnAreaChangedCallback(int32_t id, OnAreaChangedFunc&& callback) { - auto pipeline = PipelineContext::GetCurrentContext(); + auto pipeline = PipelineContext::GetCurrentContextSafelyWithCheck(); CHECK_NULL_VOID(pipeline); auto frameNode = GetFrameNode(); CHECK_NULL_VOID(frameNode); @@ -418,7 +418,7 @@ void EventHub::ClearJSFrameNodeOnDisappear() void EventHub::FireOnAppear() { if (onAppear_ || onJSFrameNodeAppear_) { - auto pipeline = PipelineBase::GetCurrentContextSafely(); + auto pipeline = PipelineBase::GetCurrentContextSafelyWithCheck(); CHECK_NULL_VOID(pipeline); auto taskScheduler = pipeline->GetTaskExecutor(); CHECK_NULL_VOID(taskScheduler); diff --git a/frameworks/core/components_ng/event/focus_hub.cpp b/frameworks/core/components_ng/event/focus_hub.cpp index df3fb33aca5..a396acff2c0 100644 --- a/frameworks/core/components_ng/event/focus_hub.cpp +++ b/frameworks/core/components_ng/event/focus_hub.cpp @@ -362,7 +362,7 @@ bool FocusHub::RequestFocusImmediately(bool isJudgeRootTree) bool FocusHub::RequestFocusImmediatelyInner(bool isJudgeRootTree) { - auto context = NG::PipelineContext::GetCurrentContextSafely(); + auto context = NG::PipelineContext::GetCurrentContextSafelyWithCheck(); CHECK_NULL_RETURN(context, false); auto focusManager = context->GetOrCreateFocusManager(); CHECK_NULL_RETURN(focusManager, false); @@ -787,7 +787,7 @@ bool FocusHub::OnKeyPreIme(KeyEventInfo& info, const KeyEvent& keyEvent) auto onKeyPreIme = GetOnKeyPreIme(); if (onKeyPreIme) { bool retPreIme = onKeyPreIme(info); - auto pipeline = PipelineContext::GetCurrentContext(); + auto pipeline = PipelineContext::GetCurrentContextSafelyWithCheck(); auto eventManager = pipeline->GetEventManager(); if (eventManager) { eventManager->SetIsKeyConsumed(retPreIme); @@ -1128,7 +1128,7 @@ void FocusHub::RequestFocus() const "Can't find Node %{public}s/%{public}d on tree, please check the timing of the function call.", frameNode->GetTag().c_str(), frameNode->GetId()); } - auto context = NG::PipelineContext::GetCurrentContextSafely(); + auto context = NG::PipelineContext::GetCurrentContextSafelyWithCheck(); CHECK_NULL_VOID(context); TAG_LOGI(AceLogTag::ACE_FOCUS, "Node: %{public}s/%{public}d RequestFocus.", GetFrameName().c_str(), GetFrameId()); context->AddDirtyFocus(GetFrameNode()); @@ -1656,7 +1656,7 @@ void FocusHub::OnBlurScope() bool FocusHub::PaintFocusState(bool isNeedStateStyles) { - auto context = PipelineContext::GetCurrentContextSafely(); + auto context = PipelineContext::GetCurrentContextSafelyWithCheck(); CHECK_NULL_RETURN(context, false); auto frameNode = GetFrameNode(); CHECK_NULL_RETURN(frameNode, false); @@ -1835,7 +1835,7 @@ bool FocusHub::PaintAllFocusState() bool FocusHub::PaintInnerFocusState(const RoundRect& paintRect, bool forceUpdate) { - auto context = PipelineContext::GetCurrentContextSafely(); + auto context = PipelineContext::GetCurrentContextSafelyWithCheck(); CHECK_NULL_RETURN(context, false); auto frameNode = GetFrameNode(); CHECK_NULL_RETURN(frameNode, false); @@ -2316,7 +2316,7 @@ bool FocusHub::ScrollByOffsetToParent(const RefPtr& parentFrameNode) TAG_LOGI(AceLogTag::ACE_FOCUS, "Scroll offset: %{public}f on %{public}s/%{public}d, axis: %{public}d", moveOffset, parentFrameNode->GetTag().c_str(), parentFrameNode->GetId(), scrollAxis); auto ret = scrollFunc(parentPattern->IsReverse() ? -moveOffset : moveOffset); - auto pipeline = PipelineContext::GetCurrentContext(); + auto pipeline = PipelineContext::GetCurrentContextSafelyWithCheck(); if (pipeline) { pipeline->FlushUITasks(); } diff --git a/frameworks/core/components_ng/event/gesture_event_hub_drag.cpp b/frameworks/core/components_ng/event/gesture_event_hub_drag.cpp index 7a0ff3930ef..d0c8d9638a2 100644 --- a/frameworks/core/components_ng/event/gesture_event_hub_drag.cpp +++ b/frameworks/core/components_ng/event/gesture_event_hub_drag.cpp @@ -388,7 +388,7 @@ float GestureEventHub::GetPixelMapScale(const int32_t height, const int32_t widt } auto frameNode = GetFrameNode(); CHECK_NULL_RETURN(frameNode, scale); - auto pipeline = PipelineContext::GetCurrentContext(); + auto pipeline = frameNode->GetContextRefPtr(); CHECK_NULL_RETURN(pipeline, scale); auto dragDropManager = pipeline->GetDragDropManager(); CHECK_NULL_RETURN(dragDropManager, scale); @@ -428,7 +428,7 @@ void GestureEventHub::GenerateMousePixelMap(const GestureEvent& info) CHECK_NULL_VOID(pattern); auto dragNode = pattern->MoveDragNode(); CHECK_NULL_VOID(dragNode); - auto pipeline = PipelineContext::GetCurrentContext(); + auto pipeline = PipelineContext::GetCurrentContextSafelyWithCheck(); CHECK_NULL_VOID(pipeline); pipeline->FlushPipelineImmediately(); context = dragNode->GetRenderContext(); @@ -476,7 +476,7 @@ void GestureEventHub::HandleOnDragStart(const GestureEvent& info) HandleNotallowDrag(info); return; } - auto pipeline = PipelineContext::GetCurrentContext(); + auto pipeline = PipelineContext::GetCurrentContextSafelyWithCheck(); CHECK_NULL_VOID(pipeline); auto eventManager = pipeline->GetEventManager(); CHECK_NULL_VOID(eventManager); @@ -932,7 +932,7 @@ void GestureEventHub::HandleOnDragUpdate(const GestureEvent& info) { gestureInfoForWeb_ = std::make_shared(info); CHECK_NULL_VOID(dragDropProxy_); - auto pipeline = PipelineContext::GetCurrentContext(); + auto pipeline = PipelineContext::GetCurrentContextSafelyWithCheck(); CHECK_NULL_VOID(pipeline); auto dragDropManager = pipeline->GetDragDropManager(); if (dragDropManager->IsDragged()) { @@ -942,7 +942,7 @@ void GestureEventHub::HandleOnDragUpdate(const GestureEvent& info) void GestureEventHub::HandleOnDragEnd(const GestureEvent& info) { - auto pipeline = NG::PipelineContext::GetCurrentContext(); + auto pipeline = NG::PipelineContext::GetCurrentContextSafelyWithCheck(); const static int32_t PLATFORM_VERSION_TEN = 10; if (pipeline && (pipeline->GetMinPlatformVersion() < PLATFORM_VERSION_TEN)) { auto eventHub = eventHub_.Upgrade(); @@ -1118,7 +1118,7 @@ void GestureEventHub::SetMouseDragGatherPixelMaps() { auto frameNode = GetFrameNode(); CHECK_NULL_VOID(frameNode); - auto pipeline = PipelineContext::GetCurrentContext(); + auto pipeline = PipelineContext::GetCurrentContextSafelyWithCheck(); CHECK_NULL_VOID(pipeline); auto dragDropManager = pipeline->GetDragDropManager(); CHECK_NULL_VOID(dragDropManager); @@ -1148,7 +1148,7 @@ void GestureEventHub::SetMouseDragGatherPixelMaps() void GestureEventHub::SetNotMouseDragGatherPixelMaps() { - auto pipeline = PipelineContext::GetCurrentContext(); + auto pipeline = PipelineContext::GetCurrentContextSafelyWithCheck(); CHECK_NULL_VOID(pipeline); auto dragDropManager = pipeline->GetDragDropManager(); CHECK_NULL_VOID(dragDropManager); diff --git a/frameworks/core/components_ng/event/state_style_manager.cpp b/frameworks/core/components_ng/event/state_style_manager.cpp index afab298bf42..e58c5379585 100644 --- a/frameworks/core/components_ng/event/state_style_manager.cpp +++ b/frameworks/core/components_ng/event/state_style_manager.cpp @@ -192,7 +192,7 @@ void StateStyleManager::GetCustomNode(RefPtr& customNode, void StateStyleManager::PostPressStyleTask(uint32_t delayTime) { - auto pipeline = PipelineContext::GetCurrentContext(); + auto pipeline = PipelineContext::GetCurrentContextSafelyWithCheck(); CHECK_NULL_VOID(pipeline); auto taskExecutor = pipeline->GetTaskExecutor(); CHECK_NULL_VOID(taskExecutor); @@ -216,7 +216,7 @@ void StateStyleManager::PostPressStyleTask(uint32_t delayTime) void StateStyleManager::PostPressCancelStyleTask(uint32_t delayTime) { - auto pipeline = PipelineContext::GetCurrentContext(); + auto pipeline = PipelineContext::GetCurrentContextSafelyWithCheck(); CHECK_NULL_VOID(pipeline); auto taskExecutor = pipeline->GetTaskExecutor(); CHECK_NULL_VOID(taskExecutor); diff --git a/frameworks/core/components_ng/event/touch_event.cpp b/frameworks/core/components_ng/event/touch_event.cpp index d1afa2af079..e655cacf761 100644 --- a/frameworks/core/components_ng/event/touch_event.cpp +++ b/frameworks/core/components_ng/event/touch_event.cpp @@ -93,7 +93,7 @@ bool TouchEventActuator::TriggerTouchCallBack(const TouchEvent& point) bool TouchEventActuator::ShouldResponse() { - auto context = PipelineContext::GetCurrentContext(); + auto context = PipelineContext::GetCurrentContextSafelyWithCheck(); CHECK_NULL_RETURN(context, true); auto eventManager = context->GetEventManager(); diff --git a/frameworks/core/components_ng/gestures/recognizers/click_recognizer.cpp b/frameworks/core/components_ng/gestures/recognizers/click_recognizer.cpp index 6825b022cd4..3ef355aee59 100644 --- a/frameworks/core/components_ng/gestures/recognizers/click_recognizer.cpp +++ b/frameworks/core/components_ng/gestures/recognizers/click_recognizer.cpp @@ -213,7 +213,7 @@ void ClickRecognizer::HandleTouchDownEvent(const TouchEvent& event) firstInputTime_ = event.time; } - auto pipeline = PipelineBase::GetCurrentContext(); + auto pipeline = PipelineBase::GetCurrentContextSafelyWithCheck(); if (pipeline && pipeline->IsFormRender()) { touchDownTime_ = event.time; } @@ -305,7 +305,7 @@ void ClickRecognizer::HandleTouchUpEvent(const TouchEvent& event) { TAG_LOGI(AceLogTag::ACE_INPUTKEYFLOW, "Id:%{public}d, click %{public}d up, state: %{public}d", event.touchEventId, event.id, refereeState_); - auto pipeline = PipelineBase::GetCurrentContext(); + auto pipeline = PipelineBase::GetCurrentContextSafelyWithCheck(); // In a card scenario, determine the interval between finger pressing and finger lifting. Delete this section of // logic when the formal scenario is complete. if (pipeline && pipeline->IsFormRender() && IsFormRenderClickRejected(event)) { @@ -362,7 +362,7 @@ void ClickRecognizer::HandleTouchMoveEvent(const TouchEvent& event) InitGlobalValue(event.sourceType); // In form scenario, if move more than 20vp, reject click gesture. // Remove form scenario when formal solution is completed. - auto pipeline = PipelineBase::GetCurrentContext(); + auto pipeline = PipelineBase::GetCurrentContextSafelyWithCheck(); if (pipeline && pipeline->IsFormRender()) { Offset offset = event.GetScreenOffset() - touchPoints_[event.id].GetScreenOffset(); if (offset.GetDistance() > MAX_THRESHOLD) { @@ -393,7 +393,7 @@ void ClickRecognizer::HandleOverdueDeadline() void ClickRecognizer::DeadlineTimer(CancelableCallback& deadlineTimer, int32_t time) { - auto context = PipelineContext::GetCurrentContext(); + auto context = PipelineContext::GetCurrentContextSafelyWithCheck(); CHECK_NULL_VOID(context); auto&& callback = [weakPtr = AceType::WeakClaim(this)]() { diff --git a/frameworks/core/components_ng/gestures/recognizers/gesture_recognizer.cpp b/frameworks/core/components_ng/gestures/recognizers/gesture_recognizer.cpp index 8afc94d5d7a..3b46a35755b 100644 --- a/frameworks/core/components_ng/gestures/recognizers/gesture_recognizer.cpp +++ b/frameworks/core/components_ng/gestures/recognizers/gesture_recognizer.cpp @@ -21,7 +21,7 @@ namespace OHOS::Ace::NG { namespace { RefPtr GetCurrentEventManager() { - auto context = PipelineContext::GetCurrentContext(); + auto context = PipelineContext::GetCurrentContextSafelyWithCheck(); CHECK_NULL_RETURN(context, nullptr); return context->GetEventManager(); @@ -401,7 +401,7 @@ RefPtr NGGestureRecognizer::Dump() const void NGGestureRecognizer::AddGestureProcedure(const std::string& procedure) const { - auto context = PipelineContext::GetCurrentContext(); + auto context = PipelineContext::GetCurrentContextSafelyWithCheck(); CHECK_NULL_VOID(context); auto eventMgr = context->GetEventManager(); CHECK_NULL_VOID(eventMgr); @@ -416,7 +416,7 @@ void NGGestureRecognizer::AddGestureProcedure(const TouchEvent& point, if (!recognizer) { return; } - auto context = PipelineContext::GetCurrentContext(); + auto context = PipelineContext::GetCurrentContextSafelyWithCheck(); CHECK_NULL_VOID(context); auto eventMgr = context->GetEventManager(); CHECK_NULL_VOID(eventMgr); diff --git a/frameworks/core/components_ng/gestures/recognizers/long_press_recognizer.cpp b/frameworks/core/components_ng/gestures/recognizers/long_press_recognizer.cpp index 4935d95c8a1..c76485b2f90 100644 --- a/frameworks/core/components_ng/gestures/recognizers/long_press_recognizer.cpp +++ b/frameworks/core/components_ng/gestures/recognizers/long_press_recognizer.cpp @@ -90,7 +90,7 @@ void LongPressRecognizer::OnRejected() void LongPressRecognizer::ThumbnailTimer(int32_t time) { - auto context = PipelineContext::GetCurrentContext(); + auto context = PipelineContext::GetCurrentContextSafelyWithCheck(); CHECK_NULL_VOID(context); if (!callback_) { return; @@ -172,7 +172,7 @@ void LongPressRecognizer::HandleTouchUpEvent(const TouchEvent& event) { TAG_LOGI(AceLogTag::ACE_INPUTKEYFLOW, "Id:%{public}d, LongPress %{public}d up, state: %{public}d", event.touchEventId, event.id, refereeState_); - auto context = PipelineContext::GetCurrentContext(); + auto context = PipelineContext::GetCurrentContextSafelyWithCheck(); CHECK_NULL_VOID(context); context->RemoveGestureTask(task_); if (fingersId_.find(event.id) != fingersId_.end()) { @@ -278,7 +278,7 @@ void LongPressRecognizer::HandleOverdueDeadline(bool isCatchMode) void LongPressRecognizer::DeadlineTimer(int32_t time, bool isCatchMode) { - auto context = PipelineContext::GetCurrentContext(); + auto context = PipelineContext::GetCurrentContextSafelyWithCheck(); CHECK_NULL_VOID(context); auto&& callback = [weakPtr = AceType::WeakClaim(this), isCatchMode]() { @@ -313,7 +313,7 @@ void LongPressRecognizer::DoRepeat() void LongPressRecognizer::StartRepeatTimer() { - auto context = PipelineContext::GetCurrentContext(); + auto context = PipelineContext::GetCurrentContextSafelyWithCheck(); CHECK_NULL_VOID(context); auto&& callback = [weakPtr = AceType::WeakClaim(this)]() { @@ -329,7 +329,7 @@ void LongPressRecognizer::StartRepeatTimer() double LongPressRecognizer::ConvertPxToVp(double offset) const { - auto context = PipelineContext::GetCurrentContext(); + auto context = PipelineContext::GetCurrentContextSafelyWithCheck(); CHECK_NULL_RETURN(context, offset); double vpOffset = context->ConvertPxToVp(Dimension(offset, DimensionUnit::PX)); @@ -381,7 +381,7 @@ void LongPressRecognizer::OnResetStatus() MultiFingersRecognizer::OnResetStatus(); timer_.Cancel(); deadlineTimer_.Cancel(); - auto context = PipelineContext::GetCurrentContext(); + auto context = PipelineContext::GetCurrentContextSafelyWithCheck(); CHECK_NULL_VOID(context); context->RemoveGestureTask(task_); } diff --git a/frameworks/core/components_ng/gestures/recognizers/pan_recognizer.cpp b/frameworks/core/components_ng/gestures/recognizers/pan_recognizer.cpp index 2b4e97fd489..7950c8dcf96 100644 --- a/frameworks/core/components_ng/gestures/recognizers/pan_recognizer.cpp +++ b/frameworks/core/components_ng/gestures/recognizers/pan_recognizer.cpp @@ -54,8 +54,6 @@ RefPtr PanRecognizer::CreateGestureFromRecognizer() const PanRecognizer::PanRecognizer(const RefPtr& panGestureOption) : panGestureOption_(panGestureOption) { - auto context = PipelineContext::GetCurrentContext(); - CHECK_NULL_VOID(context); uint32_t directNum = panGestureOption->GetDirection().type; double distanceNumber = panGestureOption->GetDistance(); int32_t fingersNumber = panGestureOption->GetFingers(); @@ -427,7 +425,7 @@ void PanRecognizer::HandleTouchMoveEvent(const AxisEvent& event) return; } - auto pipeline = PipelineContext::GetCurrentContext(); + auto pipeline = PipelineContext::GetCurrentContextSafelyWithCheck(); bool isShiftKeyPressed = false; bool hasDifferentDirectionGesture = false; if (pipeline) { diff --git a/frameworks/core/components_ng/gestures/recognizers/pinch_recognizer.cpp b/frameworks/core/components_ng/gestures/recognizers/pinch_recognizer.cpp index 803e5658c25..398f9545b3f 100644 --- a/frameworks/core/components_ng/gestures/recognizers/pinch_recognizer.cpp +++ b/frameworks/core/components_ng/gestures/recognizers/pinch_recognizer.cpp @@ -72,7 +72,7 @@ void PinchRecognizer::OnRejected() bool PinchRecognizer::IsCtrlBeingPressed() { - auto pipeline = PipelineContext::GetCurrentContext(); + auto pipeline = PipelineContext::GetCurrentContextSafelyWithCheck(); CHECK_NULL_RETURN(pipeline, false); return pipeline->IsKeyInPressed(KeyCode::KEY_CTRL_LEFT) || pipeline->IsKeyInPressed(KeyCode::KEY_CTRL_RIGHT); } diff --git a/frameworks/core/components_ng/gestures/recognizers/sequenced_recognizer.cpp b/frameworks/core/components_ng/gestures/recognizers/sequenced_recognizer.cpp index 6e47d6edcb7..d49db508de2 100644 --- a/frameworks/core/components_ng/gestures/recognizers/sequenced_recognizer.cpp +++ b/frameworks/core/components_ng/gestures/recognizers/sequenced_recognizer.cpp @@ -298,7 +298,7 @@ void SequencedRecognizer::OnResetStatus() void SequencedRecognizer::DeadlineTimer() { - auto context = PipelineContext::GetCurrentContext(); + auto context = PipelineContext::GetCurrentContextSafelyWithCheck(); CHECK_NULL_VOID(context); auto callback = [weakPtr = AceType::WeakClaim(this)]() { diff --git a/frameworks/core/components_ng/gestures/recognizers/swipe_recognizer.cpp b/frameworks/core/components_ng/gestures/recognizers/swipe_recognizer.cpp index 5d6a40579e2..cc44e1e23f5 100644 --- a/frameworks/core/components_ng/gestures/recognizers/swipe_recognizer.cpp +++ b/frameworks/core/components_ng/gestures/recognizers/swipe_recognizer.cpp @@ -275,7 +275,7 @@ void SwipeRecognizer::HandleTouchMoveEvent(const AxisEvent& event) time_ = event.time; lastAxisEvent_ = event; UpdateTouchPointWithAxisEvent(event); - auto pipeline = PipelineContext::GetCurrentContext(); + auto pipeline = PipelineContext::GetCurrentContextSafelyWithCheck(); bool isShiftKeyPressed = false; bool hasDifferentDirectionGesture = false; if (pipeline) { diff --git a/frameworks/core/components_ng/manager/drag_drop/drag_drop_func_wrapper.cpp b/frameworks/core/components_ng/manager/drag_drop/drag_drop_func_wrapper.cpp index 8ed63c8d041..119c8cf4358 100644 --- a/frameworks/core/components_ng/manager/drag_drop/drag_drop_func_wrapper.cpp +++ b/frameworks/core/components_ng/manager/drag_drop/drag_drop_func_wrapper.cpp @@ -421,7 +421,7 @@ void DragDropFuncWrapper::ParseShadowInfo(Shadow& shadow, std::unique_ptr DragDropFuncWrapper::GetDefaultShadow() { - auto pipelineContext = PipelineContext::GetCurrentContext(); + auto pipelineContext = PipelineContext::GetCurrentContextSafelyWithCheck(); CHECK_NULL_RETURN(pipelineContext, std::nullopt); auto shadowTheme = pipelineContext->GetTheme(); CHECK_NULL_RETURN(shadowTheme, std::nullopt); @@ -446,7 +446,7 @@ float DragDropFuncWrapper::RadiusToSigma(float radius) std::optional DragDropFuncWrapper::BrulStyleToEffection( const std::optional& blurStyleOp) { - auto pipeline = PipelineContext::GetCurrentContext(); + auto pipeline = PipelineContext::GetCurrentContextSafelyWithCheck(); CHECK_NULL_RETURN(pipeline, std::nullopt); auto blurStyleTheme = pipeline->GetTheme(); if (!blurStyleTheme) { diff --git a/frameworks/core/components_ng/manager/drag_drop/drag_drop_manager.cpp b/frameworks/core/components_ng/manager/drag_drop/drag_drop_manager.cpp index e816b5576e5..a36a4f1881b 100644 --- a/frameworks/core/components_ng/manager/drag_drop/drag_drop_manager.cpp +++ b/frameworks/core/components_ng/manager/drag_drop/drag_drop_manager.cpp @@ -182,7 +182,7 @@ int32_t DragDropManager::GetWindowId() RefPtr DragDropManager::CreateDragRootNode(const RefPtr& customNode) { - auto pipeline = PipelineContext::GetCurrentContext(); + auto pipeline = PipelineContext::GetCurrentContextSafelyWithCheck(); CHECK_NULL_RETURN(pipeline, nullptr); auto rootNode = FrameNode::CreateFrameNodeWithTree( @@ -245,7 +245,7 @@ void DragDropManager::UpdateItemDragPosition(int32_t globalX, int32_t globalY) void DragDropManager::HideDragPreviewOverlay() { - auto pipeline = NG::PipelineContext::GetCurrentContext(); + auto pipeline = NG::PipelineContext::GetCurrentContextSafelyWithCheck(); CHECK_NULL_VOID(pipeline); auto manager = pipeline->GetOverlayManager(); CHECK_NULL_VOID(manager); @@ -367,7 +367,7 @@ RefPtr DragDropManager::FindDragFrameNodeByPosition(float globalX, fl { auto rootNode = node; if (!rootNode) { - auto pipeline = NG::PipelineContext::GetCurrentContext(); + auto pipeline = NG::PipelineContext::GetCurrentContextSafelyWithCheck(); CHECK_NULL_RETURN(pipeline, nullptr); rootNode = pipeline->GetRootElement(); } @@ -1063,7 +1063,7 @@ void DragDropManager::OnDragDrop(RefPtr& event, const RefP eventHub->HandleInternalOnDrop(event, extraParams); ClearVelocityInfo(); SetIsDragged(false); - auto pipeline = PipelineContext::GetCurrentContext(); + auto pipeline = PipelineContext::GetCurrentContextSafelyWithCheck(); CHECK_NULL_VOID(pipeline); auto dragResult = event->GetResult(); if (dragResult == DragRet::DRAG_FAIL) { @@ -1220,8 +1220,6 @@ void DragDropManager::FireOnDragEvent( } auto eventHub = frameNode->GetEventHub(); CHECK_NULL_VOID(eventHub); - auto pipeline = PipelineContext::GetCurrentContext(); - CHECK_NULL_VOID(pipeline); if (!eventHub->HasOnDrop() && !eventHub->HasOnItemDrop() && !eventHub->HasCustomerOnDrop()) { return; } @@ -1449,7 +1447,7 @@ int32_t DragDropManager::GetItemIndex( void DragDropManager::AddDataToClipboard(const std::string& extraInfo) { - auto pipeline = PipelineContext::GetCurrentContext(); + auto pipeline = PipelineContext::GetCurrentContextSafelyWithCheck(); CHECK_NULL_VOID(pipeline); if (!extraInfo.empty()) { if (!newData_) { @@ -1483,7 +1481,7 @@ void DragDropManager::AddDataToClipboard(const std::string& extraInfo) void DragDropManager::GetExtraInfoFromClipboard(std::string& extraInfo) { - auto pipeline = PipelineContext::GetCurrentContext(); + auto pipeline = PipelineContext::GetCurrentContextSafelyWithCheck(); CHECK_NULL_VOID(pipeline); if (!clipboard_) { @@ -1510,7 +1508,7 @@ void DragDropManager::GetExtraInfoFromClipboard(std::string& extraInfo) void DragDropManager::RestoreClipboardData() { - auto pipeline = PipelineContext::GetCurrentContext(); + auto pipeline = PipelineContext::GetCurrentContextSafelyWithCheck(); CHECK_NULL_VOID(pipeline); if (!clipboard_) { @@ -2181,7 +2179,7 @@ bool DragDropManager::IsUIExtensionShowPlaceholder(const RefPtr& nod { #ifdef WINDOW_SCENE_SUPPORTED CHECK_NULL_RETURN(node, true); - auto pipeline = PipelineContext::GetCurrentContext(); + auto pipeline = PipelineContext::GetCurrentContextSafelyWithCheck(); CHECK_NULL_RETURN(pipeline, true); auto manager = pipeline->GetUIExtensionManager(); CHECK_NULL_RETURN(manager, true); @@ -2227,7 +2225,7 @@ void DragDropManager::HandleUIExtensionDragEvent( RectF DragDropManager::GetMenuPreviewRect() { - auto pipelineContext = PipelineContext::GetCurrentContext(); + auto pipelineContext = PipelineContext::GetCurrentContextSafelyWithCheck(); CHECK_NULL_RETURN(pipelineContext, RectF()); auto dragDropManager = pipelineContext->GetDragDropManager(); CHECK_NULL_RETURN(dragDropManager, RectF()); diff --git a/frameworks/core/components_ng/manager/drag_drop/drag_drop_proxy.cpp b/frameworks/core/components_ng/manager/drag_drop/drag_drop_proxy.cpp index ff3dbf4216a..74f532c8f50 100644 --- a/frameworks/core/components_ng/manager/drag_drop/drag_drop_proxy.cpp +++ b/frameworks/core/components_ng/manager/drag_drop/drag_drop_proxy.cpp @@ -21,7 +21,7 @@ namespace OHOS::Ace::NG { void DragDropProxy::OnTextDragStart(const std::string& extraInfo) { - auto pipeline = PipelineContext::GetCurrentContext(); + auto pipeline = PipelineContext::GetCurrentContextSafelyWithCheck(); CHECK_NULL_VOID(pipeline); auto manager = pipeline->GetDragDropManager(); CHECK_NULL_VOID(manager); @@ -31,7 +31,7 @@ void DragDropProxy::OnTextDragStart(const std::string& extraInfo) void DragDropProxy::OnDragStart( const GestureEvent& info, const std::string& extraInfo, const RefPtr& frameNode) { - auto pipeline = PipelineContext::GetCurrentContext(); + auto pipeline = PipelineContext::GetCurrentContextSafelyWithCheck(); CHECK_NULL_VOID(pipeline); auto manager = pipeline->GetDragDropManager(); CHECK_NULL_VOID(manager); @@ -48,7 +48,7 @@ void DragDropProxy::OnDragStart( void DragDropProxy::OnDragMove(const GestureEvent& info) { - auto pipeline = PipelineContext::GetCurrentContext(); + auto pipeline = PipelineContext::GetCurrentContextSafelyWithCheck(); CHECK_NULL_VOID(pipeline); auto manager = pipeline->GetDragDropManager(); CHECK_NULL_VOID(manager); @@ -61,7 +61,7 @@ void DragDropProxy::OnDragMove(const GestureEvent& info) void DragDropProxy::OnDragEnd(const GestureEvent& info, bool isTextDragEnd) { - auto pipeline = PipelineContext::GetCurrentContext(); + auto pipeline = PipelineContext::GetCurrentContextSafelyWithCheck(); CHECK_NULL_VOID(pipeline); auto manager = pipeline->GetDragDropManager(); CHECK_NULL_VOID(manager); @@ -78,7 +78,7 @@ void DragDropProxy::OnDragEnd(const GestureEvent& info, bool isTextDragEnd) void DragDropProxy::onDragCancel() { - auto pipeline = PipelineContext::GetCurrentContext(); + auto pipeline = PipelineContext::GetCurrentContextSafelyWithCheck(); CHECK_NULL_VOID(pipeline); auto manager = pipeline->GetDragDropManager(); CHECK_NULL_VOID(manager); @@ -88,7 +88,7 @@ void DragDropProxy::onDragCancel() void DragDropProxy::OnItemDragStart(const GestureEvent& info, const RefPtr& frameNode) { - auto pipeline = PipelineContext::GetCurrentContext(); + auto pipeline = PipelineContext::GetCurrentContextSafelyWithCheck(); CHECK_NULL_VOID(pipeline); auto manager = pipeline->GetDragDropManager(); CHECK_NULL_VOID(manager); @@ -100,7 +100,7 @@ void DragDropProxy::OnItemDragStart(const GestureEvent& info, const RefPtrGetDragDropManager(); CHECK_NULL_VOID(manager); @@ -112,7 +112,7 @@ void DragDropProxy::OnItemDragMove(const GestureEvent& info, int32_t draggedInde void DragDropProxy::OnItemDragEnd(const GestureEvent& info, int32_t draggedIndex, DragType dragType) { - auto pipeline = PipelineContext::GetCurrentContext(); + auto pipeline = PipelineContext::GetCurrentContextSafelyWithCheck(); CHECK_NULL_VOID(pipeline); auto manager = pipeline->GetDragDropManager(); CHECK_NULL_VOID(manager); @@ -124,7 +124,7 @@ void DragDropProxy::OnItemDragEnd(const GestureEvent& info, int32_t draggedIndex void DragDropProxy::onItemDragCancel() { - auto pipeline = PipelineContext::GetCurrentContext(); + auto pipeline = PipelineContext::GetCurrentContextSafelyWithCheck(); CHECK_NULL_VOID(pipeline); auto manager = pipeline->GetDragDropManager(); CHECK_NULL_VOID(manager); @@ -135,7 +135,7 @@ void DragDropProxy::onItemDragCancel() void DragDropProxy::DestroyDragWindow() { - auto pipeline = PipelineContext::GetCurrentContext(); + auto pipeline = PipelineContext::GetCurrentContextSafelyWithCheck(); CHECK_NULL_VOID(pipeline); auto manager = pipeline->GetDragDropManager(); CHECK_NULL_VOID(manager); diff --git a/frameworks/core/components_ng/manager/drag_drop/utils/drag_animation_helper.cpp b/frameworks/core/components_ng/manager/drag_drop/utils/drag_animation_helper.cpp index 69a2c4eec01..86684e4d969 100644 --- a/frameworks/core/components_ng/manager/drag_drop/utils/drag_animation_helper.cpp +++ b/frameworks/core/components_ng/manager/drag_drop/utils/drag_animation_helper.cpp @@ -145,7 +145,7 @@ void DragAnimationHelper::PlayGatherAnimationBeforeLifting(const RefPtrIsNeedGather()) { return; } - auto pipeline = PipelineContext::GetCurrentContext(); + auto pipeline = PipelineContext::GetCurrentContextSafelyWithCheck(); CHECK_NULL_VOID(pipeline); auto manager = pipeline->GetOverlayManager(); CHECK_NULL_VOID(manager); @@ -262,7 +262,7 @@ void DragAnimationHelper::PlayGatherAnimation(const RefPtr& frameNode void DragAnimationHelper::ShowBadgeAnimation(const RefPtr& textNode) { - auto pipelineContext = PipelineContext::GetCurrentContext(); + auto pipelineContext = PipelineContext::GetCurrentContextSafelyWithCheck(); CHECK_NULL_VOID(pipelineContext); auto dragDropManager = pipelineContext->GetDragDropManager(); CHECK_NULL_VOID(dragDropManager); @@ -316,7 +316,7 @@ void DragAnimationHelper::CalcBadgeTextPosition(const RefPtr& menuP CHECK_NULL_VOID(manager); CHECK_NULL_VOID(textNode); CHECK_NULL_VOID(menuPattern); - auto pipelineContext = PipelineContext::GetCurrentContext(); + auto pipelineContext = PipelineContext::GetCurrentContextSafelyWithCheck(); CHECK_NULL_VOID(pipelineContext); auto dragDropManager = pipelineContext->GetDragDropManager(); CHECK_NULL_VOID(dragDropManager); @@ -331,9 +331,7 @@ void DragAnimationHelper::CalcBadgeTextPosition(const RefPtr& menuP UpdateBadgeLayoutAndRenderContext(textNode, badgeLength, childSize); auto textRenderContext = textNode->GetRenderContext(); CHECK_NULL_VOID(textRenderContext); - auto pipeline = PipelineBase::GetCurrentContext(); - CHECK_NULL_VOID(pipeline); - auto offset = CalcBadgeTextOffset(menuPattern, imageNode, pipeline, badgeLength); + auto offset = CalcBadgeTextOffset(menuPattern, imageNode, pipelineContext, badgeLength); textRenderContext->UpdatePosition(OffsetT(Dimension(offset.GetX()), Dimension(offset.GetY()))); textNode->MarkDirtyNode(NG::PROPERTY_UPDATE_MEASURE); textNode->MarkModifyDone(); @@ -343,7 +341,7 @@ void DragAnimationHelper::CalcBadgeTextPosition(const RefPtr& menuP if (context) { context->FlushUITaskWithSingleDirtyNode(textNode); } - pipeline->FlushSyncGeometryNodeTasks(); + pipelineContext->FlushSyncGeometryNodeTasks(); } void DragAnimationHelper::UpdateBadgeLayoutAndRenderContext( diff --git a/frameworks/core/components_ng/manager/post_event/post_event_manager.cpp b/frameworks/core/components_ng/manager/post_event/post_event_manager.cpp index 0fd248541f4..876a52b9716 100644 --- a/frameworks/core/components_ng/manager/post_event/post_event_manager.cpp +++ b/frameworks/core/components_ng/manager/post_event/post_event_manager.cpp @@ -67,7 +67,7 @@ bool PostEventManager::PostDownEvent(const RefPtr& targetNode, const return false; } } - auto pipelineContext = PipelineContext::GetCurrentContext(); + auto pipelineContext = PipelineContext::GetCurrentContextSafelyWithCheck(); CHECK_NULL_RETURN(pipelineContext, false); auto eventManager = pipelineContext->GetEventManager(); CHECK_NULL_RETURN(eventManager, false); @@ -123,7 +123,7 @@ void PostEventManager::HandlePostEvent(const RefPtr& targetNode, con postEventAction.touchEvent = touchEvent; lastEventMap_[touchEvent.id] = postEventAction; postEventAction_.push_back(postEventAction); - auto pipelineContext = PipelineContext::GetCurrentContext(); + auto pipelineContext = PipelineContext::GetCurrentContextSafelyWithCheck(); CHECK_NULL_VOID(pipelineContext); auto eventManager = pipelineContext->GetEventManager(); if (touchEvent.type != TouchType::DOWN && touchEvent.type != TouchType::MOVE) { diff --git a/frameworks/core/components_ng/pattern/app_bar/app_bar_view.cpp b/frameworks/core/components_ng/pattern/app_bar/app_bar_view.cpp index 7e2815bd8e4..c28f8864912 100644 --- a/frameworks/core/components_ng/pattern/app_bar/app_bar_view.cpp +++ b/frameworks/core/components_ng/pattern/app_bar/app_bar_view.cpp @@ -31,7 +31,7 @@ namespace OHOS::Ace::NG { namespace { RefPtr GetAppBarTheme() { - auto pipeline = PipelineContext::GetCurrentContext(); + auto pipeline = PipelineContext::GetCurrentContextSafelyWithCheck(); CHECK_NULL_RETURN(pipeline, nullptr); return pipeline->GetTheme(); } @@ -291,7 +291,7 @@ void AppBarView::CreateServicePanel(bool firstTry) return; } - auto pipeline = PipelineContext::GetCurrentContext(); + auto pipeline = PipelineContext::GetCurrentContextSafelyWithCheck(); CHECK_NULL_VOID(pipeline); auto overlayManager = pipeline->GetOverlayManager(); CHECK_NULL_VOID(overlayManager); @@ -340,7 +340,7 @@ void AppBarView::InitUIExtensionNode(const RefPtr& uiExtNode) std::optional AppBarView::GetAppBarRect() { - auto pipeline = PipelineContext::GetCurrentContext(); + auto pipeline = PipelineContext::GetCurrentContextSafelyWithCheck(); if (!pipeline || !pipeline->GetInstallationFree()) { return std::nullopt; } diff --git a/frameworks/core/components_ng/property/templates_parser.cpp b/frameworks/core/components_ng/property/templates_parser.cpp index d17e91e20ac..4448cf3b616 100644 --- a/frameworks/core/components_ng/property/templates_parser.cpp +++ b/frameworks/core/components_ng/property/templates_parser.cpp @@ -67,7 +67,7 @@ double ConvertVirtualSize(const std::string& val, const DimensionUnit& unit, dou ret = ret / FULL_PERCENT * size; break; case DimensionUnit::VP: { - auto pipelineContext = PipelineBase::GetCurrentContext(); + auto pipelineContext = PipelineBase::GetCurrentContextSafelyWithCheck(); if (pipelineContext) { ret = pipelineContext->NormalizeToPx(Dimension(ret, DimensionUnit::VP)); } else {