Signed-off-by: ma-shaoyin <mashaoyin1@huawei.com>

Changes to be committed:
This commit is contained in:
ma-shaoyin 2022-11-18 15:57:33 +08:00
parent f33853cba3
commit 5259bb1a91
2 changed files with 14 additions and 2 deletions

View File

@ -99,6 +99,7 @@ private:
void Initialize();
void WorkThread();
void QuitWorkThread();
void OnInitialInput(Message *msg);
void OnStartInput(Message *msg);

View File

@ -46,12 +46,12 @@ InputMethodAbility::InputMethodAbility() : stop_(false)
InputMethodAbility::~InputMethodAbility()
{
IMSA_HILOGI("InputMethodAbility::~InputMethodAbility");
instance_ = nullptr;
QuitWorkThread();
if (msgHandler) {
delete msgHandler;
msgHandler = nullptr;
}
stop_ = true;
instance_ = nullptr;
}
sptr<InputMethodAbility> InputMethodAbility::GetInstance()
@ -196,6 +196,7 @@ void InputMethodAbility::WorkThread()
break;
}
default: {
IMSA_HILOGD("the message is %{public}d.", msg->msgId_);
break;
}
}
@ -574,5 +575,15 @@ void InputMethodAbility::BindServiceAndClient()
sptr<IInputMethodAgent> inputMethodAgent = sptr(new InputMethodAgentProxy(inputMethodAgentStub));
mImms->SetCoreAndAgent(stub, inputMethodAgent);
}
void InputMethodAbility::QuitWorkThread()
{
stop_ = true;
Message *msg = new Message(MessageID::MSG_ID_QUIT_WORKER_THREAD, nullptr);
msgHandler->SendMessage(msg);
if (workThreadHandler.joinable()) {
workThreadHandler.join();
}
}
} // namespace MiscServices
} // namespace OHOS