From: Seungho Baek Date: Mon, 13 May 2024 05:21:08 +0000 (+0900) Subject: Revert "[Tizen] Fix Crash when the InsertText event is executed multiple times betwee... X-Git-Tag: accepted/tizen/unified/20240516.163531~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0c2a3bccd40a4339e1289925fd09e2378d4efb76;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git Revert "[Tizen] Fix Crash when the InsertText event is executed multiple times between Relayout." This reverts commit 3bbcad13da05e143a6f8dff587fc4eefa4c5d342. --- diff --git a/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Controller.cpp b/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Controller.cpp index 774cce1..6a3a84a 100644 --- a/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Controller.cpp +++ b/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Controller.cpp @@ -1362,44 +1362,3 @@ int UtcDaliTextControllerDeleteSurroundings(void) END_TEST; } - -int UtcDaliTextControllerMultipleInsert(void) -{ - tet_infoline(" UtcDaliTextControllerMultipleInsert"); - ToolkitTestApplication application; - - // Creates a text controller. - ControllerPtr controller = Controller::New(); - - ConfigureTextField(controller); - - // Get the implementation of the text controller - Controller::Impl& mImpl = Controller::Impl::GetImplementation(*controller.Get()); - - DALI_TEST_EQUALS(EventData::INACTIVE, mImpl.mEventData->mState, TEST_LOCATION); - - InputMethodContext inputMethodContext = InputMethodContext::New(); - - // When maid thread is busy, multiple event might be executed. - InputMethodContext::EventData imfEvent1 = InputMethodContext::EventData(InputMethodContext::PRE_EDIT, "A", 0, 1); - InputMethodContext::EventData imfEvent2 = InputMethodContext::EventData(InputMethodContext::PRE_EDIT, "AAAAA", 0, 5); - controller->OnInputMethodContextEvent(inputMethodContext, imfEvent1); - controller->OnInputMethodContextEvent(inputMethodContext, imfEvent2); - - // Perform a relayout - const Size size(application.GetScene().GetSize()); - - application.SendNotification(); - application.Render(); - - controller->Relayout(size); - - std::string text; - controller->GetText(text); - - DALI_TEST_EQUALS("AAAAA", text, TEST_LOCATION); - - tet_result(TET_PASS); - - END_TEST; -} diff --git a/dali-toolkit/internal/text/controller/text-controller-event-handler.cpp b/dali-toolkit/internal/text/controller/text-controller-event-handler.cpp index 99cc227..8044923 100644 --- a/dali-toolkit/internal/text/controller/text-controller-event-handler.cpp +++ b/dali-toolkit/internal/text/controller/text-controller-event-handler.cpp @@ -768,13 +768,13 @@ bool Controller::EventHandler::DeleteEvent(Controller& controller, int keyCode) else if((controller.mImpl->mEventData->mPrimaryCursorPosition > 0) && (keyCode == Dali::DALI_KEY_BACKSPACE)) { // Remove the character before the current cursor position - removed = TextUpdater::RemoveText(controller, -1, 1, UPDATE_INPUT_STYLE, false); + removed = TextUpdater::RemoveText(controller, -1, 1, UPDATE_INPUT_STYLE); } else if((controller.mImpl->mEventData->mPrimaryCursorPosition < controller.mImpl->mModel->mLogicalModel->mText.Count()) && (keyCode == Dali::DevelKey::DALI_KEY_DELETE)) { // Remove the character after the current cursor position - removed = TextUpdater::RemoveText(controller, 0, 1, UPDATE_INPUT_STYLE, false); + removed = TextUpdater::RemoveText(controller, 0, 1, UPDATE_INPUT_STYLE); } if(removed) @@ -825,8 +825,7 @@ InputMethodContext::CallbackData Controller::EventHandler::OnInputMethodContextE const bool textDeleted = TextUpdater::RemoveText(controller, inputMethodContextEvent.cursorOffset, inputMethodContextEvent.numberOfChars, - DONT_UPDATE_INPUT_STYLE, - false); + DONT_UPDATE_INPUT_STYLE); if(textDeleted) { diff --git a/dali-toolkit/internal/text/controller/text-controller-text-updater.cpp b/dali-toolkit/internal/text/controller/text-controller-text-updater.cpp index 59da80a..2ceee77 100644 --- a/dali-toolkit/internal/text/controller/text-controller-text-updater.cpp +++ b/dali-toolkit/internal/text/controller/text-controller-text-updater.cpp @@ -208,8 +208,7 @@ void Controller::TextUpdater::InsertText(Controller& controller, const std::stri removedPrevious = RemoveText(controller, -static_cast(eventData->mPrimaryCursorPosition - eventData->mPreEditStartPosition), eventData->mPreEditLength, - DONT_UPDATE_INPUT_STYLE, - true); + DONT_UPDATE_INPUT_STYLE); eventData->mPrimaryCursorPosition = eventData->mPreEditStartPosition; eventData->mPreEditLength = 0u; @@ -496,8 +495,7 @@ bool Controller::TextUpdater::RemoveText( Controller& controller, int cursorOffset, int numberOfCharacters, - UpdateInputStyleType type, - bool isDeletingPreEdit) + UpdateInputStyleType type) { bool removed = false; bool removeAll = false; @@ -610,10 +608,7 @@ bool Controller::TextUpdater::RemoveText( if(removeAll) { impl.ClearPreEditFlag(); - if(!isDeletingPreEdit) - { - textUpdateInfo.mNumberOfCharactersToAdd = 0; - } + textUpdateInfo.mNumberOfCharactersToAdd = 0; } // Updates the text style runs by removing characters. Runs with no characters are removed. diff --git a/dali-toolkit/internal/text/controller/text-controller-text-updater.h b/dali-toolkit/internal/text/controller/text-controller-text-updater.h index 319697f..47403f6 100644 --- a/dali-toolkit/internal/text/controller/text-controller-text-updater.h +++ b/dali-toolkit/internal/text/controller/text-controller-text-updater.h @@ -63,10 +63,9 @@ struct Controller::TextUpdater * @param[in] cursorOffset Start position from the current cursor position to start deleting characters. * @param[in] numberOfCharacters The number of characters to delete from the cursorOffset. * @param[in] type Whether to update the input style. - * @param[in] isDeletingPreEdit Whether to remove pre-edit when inserting text. * @return True if the remove was successful. */ - static bool RemoveText(Controller& controller, int cursorOffset, int numberOfCharacters, UpdateInputStyleType type, bool isDeletingPreEdit); + static bool RemoveText(Controller& controller, int cursorOffset, int numberOfCharacters, UpdateInputStyleType type); /** * @brief Checks if text is selected and if so removes it.