tdf#96888 - Kill internal vcl dog-tags ...

Removed some more uses of ImplDelData

Change-Id: I5f9a5579f0e2ddf3c82aa1b8cdb8afcb02d2f6ea
Reviewed-on: https://gerrit.libreoffice.org/21816
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
diff --git a/vcl/source/app/help.cxx b/vcl/source/app/help.cxx
index 19570ce..a41c666 100644
--- a/vcl/source/app/help.cxx
+++ b/vcl/source/app/help.cxx
@@ -342,9 +342,9 @@ void HelpTextWindow::SetHelpText( const OUString& rHelpText )

void HelpTextWindow::ImplShow()
{
    ImplDelData aDogTag( this );
    VclPtr<HelpTextWindow> xWindow( this );
    Show( true, ShowFlags::NoActivate );
    if( !aDogTag.IsDead() )
    if( !xWindow->IsDisposed() )
    Update();
}

diff --git a/vcl/source/app/vclevent.cxx b/vcl/source/app/vclevent.cxx
index f0c28176..f1bf0f7 100644
--- a/vcl/source/app/vclevent.cxx
+++ b/vcl/source/app/vclevent.cxx
@@ -51,9 +51,8 @@ void VclEventListeners::Call( VclSimpleEvent& rEvent ) const
    std::vector<Link<VclSimpleEvent&,void>>::const_iterator aEnd( aCopy.end() );
    if( dynamic_cast<const VclWindowEvent*>( &rEvent ) != nullptr )
    {
        VclWindowEvent* pWinEvent = static_cast<VclWindowEvent*>(&rEvent);
        ImplDelData aDel( pWinEvent->GetWindow() );
        while ( aIter != aEnd && ! aDel.IsDead() )
        VclPtr<vcl::Window> xWin((static_cast<VclWindowEvent*>(&rEvent))->GetWindow());
        while ( aIter != aEnd && xWin && ! xWin->IsDisposed() )
        {
            Link<VclSimpleEvent&,void> &rLink = *aIter;
            // check this hasn't been removed in some re-enterancy scenario fdo#47368
diff --git a/vcl/source/window/mouse.cxx b/vcl/source/window/mouse.cxx
index 7adc5bb..1032bb5 100644
--- a/vcl/source/window/mouse.cxx
+++ b/vcl/source/window/mouse.cxx
@@ -203,7 +203,7 @@ void Window::ImplGrabFocus( GetFocusFlags nFlags )

    // some event listeners do really bad stuff
    // => prepare for the worst
    ImplDelData aDogTag( this );
    VclPtr<vcl::Window> xWindow( this );

    // Currently the client window should always get the focus
    // Should the border window at some point be focusable
@@ -312,8 +312,7 @@ void Window::ImplGrabFocus( GetFocusFlags nFlags )
            }
        }

        vcl::Window* pOldFocusWindow = pSVData->maWinData.mpFocusWin;
        ImplDelData aOldFocusDel( pOldFocusWindow );
        VclPtr<vcl::Window> pOldFocusWindow = pSVData->maWinData.mpFocusWin;

        pSVData->maWinData.mpFocusWin = this;

@@ -348,7 +347,7 @@ void Window::ImplGrabFocus( GetFocusFlags nFlags )
        }

        // call Get- and LoseFocus
        if ( pOldFocusWindow && ! aOldFocusDel.IsDead() )
        if ( pOldFocusWindow && ! pOldFocusWindow->IsDisposed() )
        {
            if ( pOldFocusWindow->IsTracking() &&
                 (pSVData->maWinData.mnTrackFlags & StartTrackingFlags::FocusCancel) )
@@ -378,15 +377,15 @@ void Window::ImplGrabFocus( GetFocusFlags nFlags )
                // notify the new focus window so it can restore the inner focus
                // eg, toolboxes can select their recent active item
                if( pOldFocusWindow &&
                    ! aOldFocusDel.IsDead() &&
                    ! pOldFocusWindow->IsDisposed() &&
                    ( pOldFocusWindow->GetDialogControlFlags() & DialogControlFlags::FloatWinPopupModeEndCancel ) )
                    mpWindowImpl->mnGetFocusFlags |= GetFocusFlags::FloatWinPopupModeEndCancel;
                NotifyEvent aNEvt( MouseNotifyEvent::GETFOCUS, this );
                if ( !ImplCallPreNotify( aNEvt ) && !aDogTag.IsDead() )
                if ( !ImplCallPreNotify( aNEvt ) && !xWindow->IsDisposed() )
                    CompatGetFocus();
                if( !aDogTag.IsDead() )
                    ImplCallActivateListeners( (pOldFocusWindow && ! aOldFocusDel.IsDead()) ? pOldFocusWindow : nullptr );
                if( !aDogTag.IsDead() )
                if( !xWindow->IsDisposed() )
                    ImplCallActivateListeners( (pOldFocusWindow && ! pOldFocusWindow->IsDisposed()) ? pOldFocusWindow : nullptr );
                if( !xWindow->IsDisposed() )
                {
                    mpWindowImpl->mnGetFocusFlags = GetFocusFlags::NONE;
                    mpWindowImpl->mbInFocusHdl = false;
diff --git a/vcl/source/window/paint.cxx b/vcl/source/window/paint.cxx
index 17e5477..44aeb97 100644
--- a/vcl/source/window/paint.cxx
+++ b/vcl/source/window/paint.cxx
@@ -1324,7 +1324,7 @@ void Window::Update()
    // if there is something to paint, trigger a Paint
    if ( pUpdateWindow->mpWindowImpl->mnPaintFlags & (IMPL_PAINT_PAINT | IMPL_PAINT_PAINTCHILDREN) )
    {
        ImplDelData aDogTag(this);
        VclPtr<vcl::Window> xWindow(this);

        // trigger an update also for system windows on top of us,
        // otherwise holes would remain
@@ -1337,7 +1337,7 @@ void Window::Update()

        pUpdateWindow->ImplCallPaint(nullptr, pUpdateWindow->mpWindowImpl->mnPaintFlags);

        if (aDogTag.IsDead())
        if (xWindow->IsDisposed())
           return;
        bFlush = true;
    }
diff --git a/vcl/source/window/scrwnd.cxx b/vcl/source/window/scrwnd.cxx
index b438d1e..cd8cbb5 100644
--- a/vcl/source/window/scrwnd.cxx
+++ b/vcl/source/window/scrwnd.cxx
@@ -373,9 +373,9 @@ IMPL_LINK_NOARG_TYPED(ImplWheelWindow, ImplScrollHdl, Timer *, void)
        if ( !ImplCallPreNotify( aNCmdEvt ) )
        {
            const sal_uInt64 nTime = tools::Time::GetSystemTicks();
            ImplDelData aDel( this );
            VclPtr<ImplWheelWindow> xWin(this);
            pWindow->Command( aCEvt );
            if( aDel.IsDead() )
            if( xWin->IsDisposed() )
                return;
            mnRepaintTime = std::max( tools::Time::GetSystemTicks() - nTime, (sal_uInt64)1 );
            ImplRecalcScrollValues();
diff --git a/vcl/source/window/syschild.cxx b/vcl/source/window/syschild.cxx
index d0c8e8c..f451c38 100644
--- a/vcl/source/window/syschild.cxx
+++ b/vcl/source/window/syschild.cxx
@@ -52,10 +52,9 @@ using namespace ::com::sun::star;
long ImplSysChildProc( void* pInst, SalObject* /* pObject */,
                       sal_uInt16 nEvent, const void* /* pEvent */ )
{
    SystemChildWindow* pWindow = static_cast<SystemChildWindow*>(pInst);
    VclPtr<SystemChildWindow> pWindow = static_cast<SystemChildWindow*>(pInst);
    long nRet = 0;

    ImplDelData aDogTag( pWindow );
    switch ( nEvent )
    {
        case SALOBJ_EVENT_GETFOCUS:
@@ -65,12 +64,12 @@ long ImplSysChildProc( void* pInst, SalObject* /* pObject */,
            pWindow->ImplGetFrameData()->mbSysObjFocus = true;
            pWindow->ImplGetFrameData()->mbInSysObjToTopHdl = true;
            pWindow->ToTop( ToTopFlags::NoGrabFocus );
            if( aDogTag.IsDead() )
            if( pWindow->IsDisposed() )
                break;
            pWindow->ImplGetFrameData()->mbInSysObjToTopHdl = false;
            pWindow->ImplGetFrameData()->mbInSysObjFocusHdl = true;
            pWindow->GrabFocus();
            if( aDogTag.IsDead() )
            if( pWindow->IsDisposed() )
                break;
            pWindow->ImplGetFrameData()->mbInSysObjFocusHdl = false;
            break;
@@ -92,10 +91,10 @@ long ImplSysChildProc( void* pInst, SalObject* /* pObject */,
                pWindow->ToTop( ToTopFlags::NoGrabFocus );
            else
                pWindow->ToTop();
            if( aDogTag.IsDead() )
            if( pWindow->IsDisposed() )
                break;
            pWindow->GrabFocus();
            if( aDogTag.IsDead() )
            if( pWindow->IsDisposed() )
                break;
            pWindow->ImplGetFrameData()->mbInSysObjToTopHdl = false;
            break;
diff --git a/vcl/source/window/winproc.cxx b/vcl/source/window/winproc.cxx
index e484f7d..1b27777 100644
--- a/vcl/source/window/winproc.cxx
+++ b/vcl/source/window/winproc.cxx
@@ -1084,11 +1084,10 @@ static bool ImplHandleKey( vcl::Window* pWindow, MouseNotifyEvent nSVEvent,
        pChild = pWindow->GetParent();

        // call handler
        ImplDelData aChildDelData( pChild );
        KeyEvent    aKEvt( (sal_Unicode)nCharCode, aKeyCode, nRepeat );
        NotifyEvent aNEvt( nSVEvent, pChild, &aKEvt );
        bool bPreNotify = ImplCallPreNotify( aNEvt );
        if ( aChildDelData.IsDead() )
        if ( pChild->IsDisposed() )
            return true;

        if ( !bPreNotify )
@@ -1104,9 +1103,9 @@ static bool ImplHandleKey( vcl::Window* pWindow, MouseNotifyEvent nSVEvent,
                pChild->KeyUp( aKEvt );
            }

            if( !aChildDelData.IsDead() )
            if( !pChild->IsDisposed() )
                aNEvt.GetWindow()->ImplNotifyKeyMouseCommandEventListeners( aNEvt );
            if ( aChildDelData.IsDead() )
            if ( pChild->IsDisposed() )
                return true;
        }

@@ -1296,7 +1295,6 @@ static bool ImplCallWheelCommand( const VclPtr<vcl::Window>& pWindow, const Poin
    Point               aCmdMousePos = pWindow->ImplFrameToOutput( rPos );
    CommandEvent        aCEvt( aCmdMousePos, CommandEventId::Wheel, true, pWheelData );
    NotifyEvent         aNCmdEvt( MouseNotifyEvent::COMMAND, pWindow, &aCEvt );
    ImplDelData         aDelData( pWindow );
    bool bPreNotify = ImplCallPreNotify( aNCmdEvt );
    if ( pWindow->IsDisposed() )
        return false;
@@ -1351,13 +1349,12 @@ public:

bool HandleGestureEventBase::Setup()
{
    ImplDelData aDogTag( m_pWindow );

    if (m_pSVData->maWinData.mpAutoScrollWin)
        m_pSVData->maWinData.mpAutoScrollWin->EndAutoScroll();
    if (m_pSVData->maHelpData.mpHelpWin)
        ImplDestroyHelpWindow( true );
    if (aDogTag.IsDead())
    if (m_pWindow->IsDisposed())
        return false;
    return true;
}