summaryrefslogtreecommitdiff
path: root/fpdfsdk/pwl/cpwl_wnd.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'fpdfsdk/pwl/cpwl_wnd.cpp')
-rw-r--r--fpdfsdk/pwl/cpwl_wnd.cpp20
1 files changed, 11 insertions, 9 deletions
diff --git a/fpdfsdk/pwl/cpwl_wnd.cpp b/fpdfsdk/pwl/cpwl_wnd.cpp
index 1c1512e296..4e4abd2017 100644
--- a/fpdfsdk/pwl/cpwl_wnd.cpp
+++ b/fpdfsdk/pwl/cpwl_wnd.cpp
@@ -86,19 +86,21 @@ class CPWL_MsgControl : public CFX_Observable<CPWL_MsgControl> {
void SetFocus(CPWL_Wnd* pWnd) {
m_aKeyboardPath.clear();
- if (pWnd) {
- m_pMainKeyboardWnd = pWnd;
- CPWL_Wnd* pParent = pWnd;
- while (pParent) {
- m_aKeyboardPath.push_back(pParent);
- pParent = pParent->GetParentWindow();
- }
- pWnd->OnSetFocus();
+ if (!pWnd)
+ return;
+
+ m_pMainKeyboardWnd = pWnd;
+ CPWL_Wnd* pParent = pWnd;
+ while (pParent) {
+ m_aKeyboardPath.push_back(pParent);
+ pParent = pParent->GetParentWindow();
}
+ // Note, pWnd may get destroyed in the OnSetFocus call.
+ pWnd->OnSetFocus();
}
void KillFocus() {
- ObservedPtr observed_ptr = ObservedPtr(this);
+ ObservedPtr observed_ptr(this);
if (!m_aKeyboardPath.empty())
if (CPWL_Wnd* pWnd = m_aKeyboardPath[0])
pWnd->OnKillFocus();