From ff8dc7aef4dcd22d6359d22dcd5c59cdd51a4fff Mon Sep 17 00:00:00 2001 From: w00574628 Date: Thu, 21 Nov 2024 19:41:40 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BE=93=E5=85=A5=E6=B3=95=E4=BA=8B=E5=8A=A1?= =?UTF-8?q?=E5=90=8C=E6=AD=A5=E5=A2=9E=E5=BC=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wulehui --- .../session/host/src/keyboard_session.cpp | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/window_scene/session/host/src/keyboard_session.cpp b/window_scene/session/host/src/keyboard_session.cpp index 3dd4f9323b..1f721b9ee3 100644 --- a/window_scene/session/host/src/keyboard_session.cpp +++ b/window_scene/session/host/src/keyboard_session.cpp @@ -533,12 +533,18 @@ void KeyboardSession::RelayoutKeyBoard() void KeyboardSession::OpenKeyboardSyncTransaction() { - if (isKeyboardSyncTransactionOpen_) { - TLOGI(WmsLogTag::WMS_KEYBOARD, "Keyboard sync transaction is already open"); - return; - } - isKeyboardSyncTransactionOpen_ = true; - auto task = []() { + auto task = [weakThis = wptr(this)]() { + auto session = weakThis.promote(); + if (!session) { + TLOGNE(WmsLogTag::WMS_KEYBOARD, "keyboard session is null"); + return WSError::WS_ERROR_DESTROYED_OBJECT; + } + if (session->isKeyboardSyncTransactionOpen_) { + TLOGNI(WmsLogTag::WMS_KEYBOARD, "Keyboard sync transaction is already open"); + return WSError::WS_OK; + } + TLOGNI(WmsLogTag::WMS_KEYBOARD, "Open keyboard sync"); + session->isKeyboardSyncTransactionOpen_ = true; auto transactionController = RSSyncTransactionController::GetInstance(); if (transactionController) { transactionController->OpenSyncTransaction(); @@ -551,14 +557,14 @@ void KeyboardSession::OpenKeyboardSyncTransaction() void KeyboardSession::CloseKeyboardSyncTransaction(const WSRect& keyboardPanelRect, bool isKeyboardShow, bool isRotating) { - TLOGI(WmsLogTag::WMS_KEYBOARD, "keyboardPanelRect: %{public}s, isKeyboardShow: %{public}d, isRotating: %{public}d", - keyboardPanelRect.ToString().c_str(), isKeyboardShow, isRotating); auto task = [weakThis = wptr(this), keyboardPanelRect, isKeyboardShow, isRotating]() { auto session = weakThis.promote(); if (!session) { TLOGE(WmsLogTag::WMS_KEYBOARD, "keyboard session is null"); return WSError::WS_ERROR_DESTROYED_OBJECT; } + TLOGNI(WmsLogTag::WMS_KEYBOARD, "Close keyboard sync, isKeyboardShow: %{public}d, isRotating: %{public}d", + isKeyboardShow, isRotating); std::shared_ptr rsTransaction = nullptr; if (!isRotating && session->isKeyboardSyncTransactionOpen_) { rsTransaction = session->GetRSTransaction();