From c6f672257bd2ae98f4fd7a6a273b2d1d3e944baa Mon Sep 17 00:00:00 2001 From: Vaxry Date: Sat, 1 Feb 2025 15:08:30 +0000 Subject: desktop: move popup and subsurface ctors to factories makes sure m_pSelf is set before we do anything like possibly adding children fixes #9275 supersedes #9276 --- src/desktop/Popup.cpp | 45 +++++++++++++++++++++++++++++---------------- 1 file changed, 29 insertions(+), 16 deletions(-) (limited to 'src/desktop/Popup.cpp') diff --git a/src/desktop/Popup.cpp b/src/desktop/Popup.cpp index dea94f55..20ff49d7 100644 --- a/src/desktop/Popup.cpp +++ b/src/desktop/Popup.cpp @@ -12,23 +12,37 @@ #include "../render/OpenGL.hpp" #include -CPopup::CPopup(PHLWINDOW pOwner) : m_pWindowOwner(pOwner) { - initAllSignals(); +SP CPopup::create(PHLWINDOW pOwner) { + auto popup = SP(new CPopup()); + popup->m_pWindowOwner = pOwner; + popup->m_pSelf = popup; + popup->initAllSignals(); + return popup; } -CPopup::CPopup(PHLLS pOwner) : m_pLayerOwner(pOwner) { - initAllSignals(); +SP CPopup::create(PHLLS pOwner) { + auto popup = SP(new CPopup()); + popup->m_pLayerOwner = pOwner; + popup->m_pSelf = popup; + popup->initAllSignals(); + return popup; } -CPopup::CPopup(SP popup, WP pOwner) : - m_pWindowOwner(pOwner->m_pWindowOwner), m_pLayerOwner(pOwner->m_pLayerOwner), m_pParent(pOwner), m_pResource(popup) { - m_pWLSurface = CWLSurface::create(); - m_pWLSurface->assign(popup->surface->surface.lock(), this); - - m_vLastSize = popup->surface->current.geometry.size(); - reposition(); - - initAllSignals(); +SP CPopup::create(SP resource, WP pOwner) { + auto popup = SP(new CPopup()); + popup->m_pResource = resource; + popup->m_pWindowOwner = pOwner->m_pWindowOwner; + popup->m_pLayerOwner = pOwner->m_pLayerOwner; + popup->m_pParent = pOwner; + popup->m_pSelf = popup; + popup->m_pWLSurface = CWLSurface::create(); + popup->m_pWLSurface->assign(resource->surface->surface.lock(), popup.get()); + + popup->m_vLastSize = resource->surface->current.geometry.size(); + popup->reposition(); + + popup->initAllSignals(); + return popup; } CPopup::~CPopup() { @@ -59,7 +73,7 @@ void CPopup::initAllSignals() { } void CPopup::onNewPopup(SP popup) { - const auto& POPUP = m_vChildren.emplace_back(makeShared(popup, m_pSelf)); + const auto& POPUP = m_vChildren.emplace_back(CPopup::create(popup, m_pSelf)); POPUP->m_pSelf = POPUP; Debug::log(LOG, "New popup at {:x}", (uintptr_t)POPUP); } @@ -91,8 +105,7 @@ void CPopup::onMap() { g_pInputManager->simulateMouseMovement(); - m_pSubsurfaceHead = makeUnique(m_pSelf); - m_pSubsurfaceHead->m_pSelf = m_pSubsurfaceHead; + m_pSubsurfaceHead = CSubsurface::create(m_pSelf); //unconstrain(); sendScale(); -- cgit v1.2.3