input/TI: avoid UAF in destroy
This commit is contained in:
parent
97c8a2f1cf
commit
8eb3ecc755
2 changed files with 14 additions and 14 deletions
|
|
@ -22,13 +22,7 @@ void CTextInput::initCallbacks() {
|
|||
m_listeners.disable = INPUT->m_events.disable.listen([this] { onDisabled(); });
|
||||
m_listeners.commit = INPUT->m_events.onCommit.listen([this] { onCommit(); });
|
||||
m_listeners.reset = INPUT->m_events.reset.listen([this] { onReset(); });
|
||||
m_listeners.destroy = INPUT->m_events.destroy.listen([this] {
|
||||
m_listeners.surfaceUnmap.reset();
|
||||
m_listeners.surfaceDestroy.reset();
|
||||
g_pInputManager->m_relay.removeTextInput(this);
|
||||
if (!g_pInputManager->m_relay.getFocusedTextInput())
|
||||
g_pInputManager->m_relay.deactivateIME(this);
|
||||
});
|
||||
m_listeners.destroy = INPUT->m_events.destroy.listen([this] { destroy(); });
|
||||
|
||||
if (Desktop::focusState()->surface() && Desktop::focusState()->surface()->client() == INPUT->client())
|
||||
enter(Desktop::focusState()->surface());
|
||||
|
|
@ -39,16 +33,20 @@ void CTextInput::initCallbacks() {
|
|||
m_listeners.disable = INPUT->m_events.disable.listen([this] { onDisabled(); });
|
||||
m_listeners.commit = INPUT->m_events.onCommit.listen([this] { onCommit(); });
|
||||
m_listeners.reset = INPUT->m_events.reset.listen([this] { onReset(); });
|
||||
m_listeners.destroy = INPUT->m_events.destroy.listen([this] {
|
||||
m_listeners.surfaceUnmap.reset();
|
||||
m_listeners.surfaceDestroy.reset();
|
||||
g_pInputManager->m_relay.removeTextInput(this);
|
||||
if (!g_pInputManager->m_relay.getFocusedTextInput())
|
||||
g_pInputManager->m_relay.deactivateIME(this);
|
||||
});
|
||||
m_listeners.destroy = INPUT->m_events.destroy.listen([this] { destroy(); });
|
||||
}
|
||||
}
|
||||
|
||||
void CTextInput::destroy() {
|
||||
m_listeners.surfaceUnmap.reset();
|
||||
m_listeners.surfaceDestroy.reset();
|
||||
|
||||
g_pInputManager->m_relay.removeTextInput(this);
|
||||
|
||||
if (!g_pInputManager->m_relay.getFocusedTextInput())
|
||||
g_pInputManager->m_relay.deactivateIME(nullptr, false);
|
||||
}
|
||||
|
||||
void CTextInput::onEnabled(SP<CWLSurfaceResource> surfV1) {
|
||||
Log::logger->log(Log::DEBUG, "TI ENABLE");
|
||||
|
||||
|
|
|
|||
|
|
@ -39,6 +39,8 @@ class CTextInput {
|
|||
void setFocusedSurface(SP<CWLSurfaceResource> pSurface);
|
||||
void initCallbacks();
|
||||
|
||||
void destroy();
|
||||
|
||||
WP<CWLSurfaceResource> m_focusedSurface;
|
||||
int m_enterLocks = 0;
|
||||
WP<CTextInputV3> m_v3Input;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue