From 3516256c28c29d13e9092e7bb3ea3b417d3bb6df Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Fri, 9 Jun 2017 01:04:52 -0700 Subject: Implement CPWL_ComboBox::OnDestroy() to manage unowned pointers. CPWL_ComboBox's unowned pointers to other CPWL_Wnds need to be released at the right time. Also release the unowned pointer for CPWL_Wnd's vertical scroll bar at the right time. BUG=729041 Change-Id: I06a1da35fcb18dae8faf9cd4fbc0b75d38f115b0 Reviewed-on: https://pdfium-review.googlesource.com/6418 Commit-Queue: dsinclair Reviewed-by: dsinclair --- fpdfsdk/pdfwindow/cpwl_combo_box.cpp | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'fpdfsdk/pdfwindow/cpwl_combo_box.cpp') diff --git a/fpdfsdk/pdfwindow/cpwl_combo_box.cpp b/fpdfsdk/pdfwindow/cpwl_combo_box.cpp index 42786806d0..b69f98906e 100644 --- a/fpdfsdk/pdfwindow/cpwl_combo_box.cpp +++ b/fpdfsdk/pdfwindow/cpwl_combo_box.cpp @@ -182,14 +182,7 @@ bool CPWL_CBButton::OnLButtonUp(const CFX_PointF& point, uint32_t nFlag) { return true; } -CPWL_ComboBox::CPWL_ComboBox() - : m_pEdit(nullptr), - m_pButton(nullptr), - m_pList(nullptr), - m_bPopup(false), - m_bBottom(true), - m_nSelectItem(-1), - m_pFillerNotify(nullptr) {} +CPWL_ComboBox::CPWL_ComboBox() {} CPWL_ComboBox::~CPWL_ComboBox() {} @@ -202,6 +195,17 @@ void CPWL_ComboBox::OnCreate(PWL_CREATEPARAM& cp) { cp.dwFlags &= ~PWS_VSCROLL; } +void CPWL_ComboBox::OnDestroy() { + // Until cleanup takes place in the virtual destructor for CPWL_Wnd + // subclasses, implement the virtual OnDestroy method that does the + // cleanup first, then invokes the superclass OnDestroy ... gee, + // like a dtor would. + m_pList.Release(); + m_pButton.Release(); + m_pEdit.Release(); + CPWL_Wnd::OnDestroy(); +} + void CPWL_ComboBox::SetFocus() { if (m_pEdit) m_pEdit->SetFocus(); -- cgit v1.2.3