summaryrefslogtreecommitdiff
path: root/fpdfsdk/pwl/cpwl_edit.cpp
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2017-09-19 13:46:08 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-09-19 17:57:30 +0000
commit6f960347f8474a202d8dd99063bf8ce584896baf (patch)
treebddfcc4e3cfe629d769807965cbf28145f874f4f /fpdfsdk/pwl/cpwl_edit.cpp
parent2d510f7dc4d6c30cdecef09c5e68c47e98de6ffb (diff)
downloadpdfium-6f960347f8474a202d8dd99063bf8ce584896baf.tar.xz
Setting focus on a widget may destroy the widget
When a widget has focus set, this can trigger an Invalidation call which can trigger a page and annotation reload. This reload can destroy the current widget we're handling. This CL adds ObservedPtrs as needed so we can make sure the widgets are still alive after we've done the Invalidation. Bug: chromium:765921 Change-Id: I51cd24aa1ebd96abe9478efef5130a4e568dac1a Reviewed-on: https://pdfium-review.googlesource.com/14290 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'fpdfsdk/pwl/cpwl_edit.cpp')
-rw-r--r--fpdfsdk/pwl/cpwl_edit.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/fpdfsdk/pwl/cpwl_edit.cpp b/fpdfsdk/pwl/cpwl_edit.cpp
index c71dbe4be0..0b74a1896e 100644
--- a/fpdfsdk/pwl/cpwl_edit.cpp
+++ b/fpdfsdk/pwl/cpwl_edit.cpp
@@ -331,16 +331,24 @@ bool CPWL_Edit::OnRButtonUp(const CFX_PointF& point, uint32_t nFlag) {
}
void CPWL_Edit::OnSetFocus() {
+ ObservedPtr observed_ptr(this);
SetEditCaret(true);
+ if (!observed_ptr)
+ return;
+
if (!IsReadOnly()) {
- if (CPWL_Wnd::FocusHandlerIface* pFocusHandler = GetFocusHandler())
+ if (CPWL_Wnd::FocusHandlerIface* pFocusHandler = GetFocusHandler()) {
pFocusHandler->OnSetFocus(this);
+ if (!observed_ptr)
+ return;
+ }
}
m_bFocus = true;
}
void CPWL_Edit::OnKillFocus() {
- ObservedPtr observed_ptr = ObservedPtr(this);
+ ObservedPtr observed_ptr(this);
+
CPWL_ScrollBar* pScroll = GetVScrollBar();
if (pScroll && pScroll->IsVisible()) {
pScroll->SetVisible(false);