From 8fba261fb6584169c5788326dd49e91bc9babda5 Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Fri, 26 Oct 2018 21:27:41 +0000 Subject: Remove pParentWnd field entirely from CreateParams. Put it into CPWL_Wnd directly, and set/clear it when a child is added/removed from a parent. Change-Id: I7a8cd0cf22dbd6173e64bec5d844df56ad373722 Reviewed-on: https://pdfium-review.googlesource.com/c/44692 Reviewed-by: Lei Zhang Commit-Queue: Tom Sepez --- fpdfsdk/pwl/cpwl_wnd.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'fpdfsdk/pwl/cpwl_wnd.cpp') diff --git a/fpdfsdk/pwl/cpwl_wnd.cpp b/fpdfsdk/pwl/cpwl_wnd.cpp index d5d2102997..66e5cfa0b6 100644 --- a/fpdfsdk/pwl/cpwl_wnd.cpp +++ b/fpdfsdk/pwl/cpwl_wnd.cpp @@ -173,9 +173,8 @@ void CPWL_Wnd::Destroy() { delete pChild; } } - if (m_CreationParams.pParentWnd) - m_CreationParams.pParentWnd->RemoveChild(this); - + if (m_pParent) + m_pParent->RemoveChild(this); m_bCreated = false; } DestroyMsgControl(); @@ -379,10 +378,14 @@ bool CPWL_Wnd::OnMouseWheel(short zDelta, } void CPWL_Wnd::AddChild(CPWL_Wnd* pWnd) { + ASSERT(!pWnd->m_pParent); + pWnd->m_pParent = this; m_Children.push_back(pWnd); } void CPWL_Wnd::RemoveChild(CPWL_Wnd* pWnd) { + ASSERT(pWnd->m_pParent == this); + pWnd->m_pParent = nullptr; for (auto it = m_Children.rbegin(); it != m_Children.rend(); ++it) { if (*it && *it == pWnd) { m_Children.erase(std::next(it).base()); @@ -492,7 +495,6 @@ void CPWL_Wnd::CreateVScrollBar(const CreateParams& cp) { scp.dwFlags = PWS_CHILD | PWS_BACKGROUND | PWS_AUTOTRANSPARENT | PWS_NOREFRESHCLIP; - scp.pParentWnd = this; scp.sBackgroundColor = PWL_DEFAULT_WHITECOLOR; scp.eCursorType = FXCT_ARROW; scp.nTransparency = PWL_SCROLLBAR_TRANSPARENCY; -- cgit v1.2.3