[Libreoffice-commits] core.git: include/vcl vcl/qa vcl/source
Noel (via logerrit)
logerrit at kemper.freedesktop.org
Mon May 31 13:20:15 UTC 2021
include/vcl/vclreferencebase.hxx | 8 ++++++--
include/vcl/window.hxx | 3 ++-
vcl/qa/cppunit/lifecycle.cxx | 4 ++--
vcl/source/app/vclevent.cxx | 5 ++---
vcl/source/window/window.cxx | 33 ++++++++++++++-------------------
5 files changed, 26 insertions(+), 27 deletions(-)
New commits:
commit 9abedad72c73ad83b66f3f8d261efdc5ce889683
Author: Noel <noel.grandin at collabora.co.uk>
AuthorDate: Sun Mar 28 10:28:45 2021 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Mon May 31 15:19:31 2021 +0200
Drop Window::IsDisposed
in favour of the isDisposed in the VclReferenceBase base class,
so we have one flag for this instead of two.
Change-Id: Ib3d6ba750f95f21996bab2838af4c56295a13f4c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113249
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/include/vcl/vclreferencebase.hxx b/include/vcl/vclreferencebase.hxx
index b7dc2b9183a2..2ba39026a362 100644
--- a/include/vcl/vclreferencebase.hxx
+++ b/include/vcl/vclreferencebase.hxx
@@ -22,11 +22,14 @@
#include <vcl/dllapi.h>
#include <osl/interlck.h>
+class VclBuilder;
+
class VCL_DLLPUBLIC VclReferenceBase
{
mutable oslInterlockedCount mnRefCnt;
template<typename T> friend class VclPtr;
+ friend class ::VclBuilder; // needed by ::delete_by_window(vcl::Window *pWindow)
public:
void acquire() const
@@ -54,14 +57,15 @@ private:
protected:
VclReferenceBase();
-protected:
virtual ~VclReferenceBase();
-protected:
+ // This is only supposed to be called from disposeOnce
virtual void dispose();
public:
+ // This is normally supposed to be called from VclPtr::disposeAndClear
void disposeOnce();
+
bool isDisposed() const { return mbDisposed; }
};
diff --git a/include/vcl/window.hxx b/include/vcl/window.hxx
index 9d8c5ae954c5..1cdb347a486e 100644
--- a/include/vcl/window.hxx
+++ b/include/vcl/window.hxx
@@ -60,6 +60,7 @@ class VCLXWindow;
class VclWindowEvent;
class AllSettings;
class InputContext;
+class VclEventListeners;
enum class ImplPaintFlags;
enum class VclEventId;
enum class PointerStyle;
@@ -472,6 +473,7 @@ class VCL_DLLPUBLIC Window : public virtual VclReferenceBase
friend class ::ImplBorderWindow;
friend class ::PaintHelper;
friend class ::LifecycleTest;
+ friend class ::VclEventListeners;
// TODO: improve missing functionality
// only required because of SetFloatingMode()
@@ -796,7 +798,6 @@ public:
bool IsMenuFloatingWindow() const;
bool IsToolbarFloatingWindow() const;
bool IsTopWindow() const;
- bool IsDisposed() const;
SystemWindow* GetSystemWindow() const;
/// Can the widget derived from this Window do the double-buffering via RenderContext properly?
diff --git a/vcl/qa/cppunit/lifecycle.cxx b/vcl/qa/cppunit/lifecycle.cxx
index ee706178bad2..853cef3828e4 100644
--- a/vcl/qa/cppunit/lifecycle.cxx
+++ b/vcl/qa/cppunit/lifecycle.cxx
@@ -294,9 +294,9 @@ void LifecycleTest::testToolkit()
// test UNO dispose
css::uno::Reference<css::lang::XComponent> xWinComponent = xWindow;
CPPUNIT_ASSERT(xWinComponent.is());
- CPPUNIT_ASSERT(!pVclWin->getRef()->IsDisposed());
+ CPPUNIT_ASSERT(!pVclWin->getRef()->isDisposed());
xWinComponent->dispose();
- CPPUNIT_ASSERT(pVclWin->getRef()->IsDisposed());
+ CPPUNIT_ASSERT(pVclWin->getRef()->isDisposed());
// test UNO cleanup
xWinComponent.clear();
diff --git a/vcl/source/app/vclevent.cxx b/vcl/source/app/vclevent.cxx
index 8d2142fa4821..af6ff02a15a8 100644
--- a/vcl/source/app/vclevent.cxx
+++ b/vcl/source/app/vclevent.cxx
@@ -35,9 +35,8 @@ void VclEventListeners::Call( VclSimpleEvent& rEvent ) const
if (VclWindowEvent* pWindowEvent = dynamic_cast<VclWindowEvent*>(&rEvent))
{
VclPtr<vcl::Window> xWin(pWindowEvent->GetWindow());
- // see tdf#142549 before changing IsDisposed() to isDisposed(), maybe !xWin->mpWindowImpl
- // or special case VclEventId::ObjectDying ?
- while ( aIter != aEnd && (!xWin || !xWin->IsDisposed()) )
+ // checking mpWindowImpl to see if disposal is complete yet
+ while ( aIter != aEnd && (!xWin || xWin->mpWindowImpl) )
{
Link<VclSimpleEvent&,void> &rLink = *aIter;
// check this hasn't been removed in some re-enterancy scenario fdo#47368
diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx
index fa3cb12133d5..5c9d7c431437 100644
--- a/vcl/source/window/window.cxx
+++ b/vcl/source/window/window.cxx
@@ -134,17 +134,12 @@ namespace
}
#endif
-bool Window::IsDisposed() const
-{
- return !mpWindowImpl;
-}
-
void Window::dispose()
{
assert( mpWindowImpl );
assert( !mpWindowImpl->mbInDispose ); // should only be called from disposeOnce()
assert( (!mpWindowImpl->mpParent ||
- !mpWindowImpl->mpParent->IsDisposed()) &&
+ mpWindowImpl->mpParent->mpWindowImpl) &&
"vcl::Window child should have its parent disposed first" );
// remove Key and Mouse events issued by Application::PostKey/MouseEvent
@@ -1736,7 +1731,7 @@ void Window::ImplNewInputContext()
{
ImplSVData* pSVData = ImplGetSVData();
vcl::Window* pFocusWin = pSVData->mpWinData->mpFocusWin;
- if ( !pFocusWin || !pFocusWin->mpWindowImpl || pFocusWin->IsDisposed() )
+ if ( !pFocusWin || !pFocusWin->mpWindowImpl || pFocusWin->isDisposed() )
return;
// Is InputContext changed?
@@ -1845,7 +1840,7 @@ void Window::GetFocus()
{
VclPtr<vcl::Window> xWindow(this);
mpWindowImpl->mpLastFocusWindow->GrabFocus();
- if( xWindow->IsDisposed() )
+ if( xWindow->isDisposed() )
return;
}
@@ -2187,7 +2182,7 @@ vcl::Font Window::GetPointFont(vcl::RenderContext const & rRenderContext) const
void Window::Show(bool bVisible, ShowFlags nFlags)
{
- if ( IsDisposed() || mpWindowImpl->mbVisible == bVisible )
+ if ( isDisposed() || mpWindowImpl->mbVisible == bVisible )
return;
VclPtr<vcl::Window> xWindow(this);
@@ -2198,7 +2193,7 @@ void Window::Show(bool bVisible, ShowFlags nFlags)
if ( !bVisible )
{
ImplHideAllOverlaps();
- if( xWindow->IsDisposed() )
+ if( xWindow->isDisposed() )
return;
if ( mpWindowImpl->mpBorderWindow )
@@ -2224,7 +2219,7 @@ void Window::Show(bool bVisible, ShowFlags nFlags)
vcl::Region aInvRegion = mpWindowImpl->maWinClipRegion;
- if( xWindow->IsDisposed() )
+ if( xWindow->isDisposed() )
return;
bRealVisibilityChanged = mpWindowImpl->mbReallyVisible;
@@ -2360,7 +2355,7 @@ void Window::Show(bool bVisible, ShowFlags nFlags)
bool bNoActivate(nFlags & (ShowFlags::NoActivate|ShowFlags::NoFocusChange));
mpWindowImpl->mpFrame->Show( true, bNoActivate );
}
- if( xWindow->IsDisposed() )
+ if( xWindow->isDisposed() )
return;
// Query the correct size of the window, if we are waiting for
@@ -2378,13 +2373,13 @@ void Window::Show(bool bVisible, ShowFlags nFlags)
mpWindowImpl->mpFrameData->mpBuffer->SetOutputSizePixel(GetOutputSizePixel());
}
- if( xWindow->IsDisposed() )
+ if( xWindow->isDisposed() )
return;
ImplShowAllOverlaps();
}
- if( xWindow->IsDisposed() )
+ if( xWindow->isDisposed() )
return;
// the SHOW/HIDE events also serve as indicators to send child creation/destroy events to the access bridge
@@ -2394,7 +2389,7 @@ void Window::Show(bool bVisible, ShowFlags nFlags)
// now only notify with a NULL data pointer, for all other clients except the access bridge.
if ( !bRealVisibilityChanged )
CallEventListeners( mpWindowImpl->mbVisible ? VclEventId::WindowShow : VclEventId::WindowHide );
- if( xWindow->IsDisposed() )
+ if( xWindow->isDisposed() )
return;
}
@@ -2413,7 +2408,7 @@ Size Window::GetSizePixel() const
VclPtr<vcl::Window> xWindow( const_cast<Window*>(this) );
mpWindowImpl->mpFrameData->maResizeIdle.Stop();
mpWindowImpl->mpFrameData->maResizeIdle.Invoke( nullptr );
- if( xWindow->IsDisposed() )
+ if( xWindow->isDisposed() )
return Size(0,0);
}
@@ -2432,7 +2427,7 @@ void Window::GetBorder( sal_Int32& rLeftBorder, sal_Int32& rTopBorder,
void Window::Enable( bool bEnable, bool bChild )
{
- if ( IsDisposed() )
+ if ( isDisposed() )
return;
if ( !bEnable )
@@ -3396,7 +3391,7 @@ void Window::ImplCallDeactivateListeners( vcl::Window *pNew )
{
VclPtr<vcl::Window> xWindow(this);
CallEventListeners( VclEventId::WindowDeactivate, pNew );
- if( xWindow->IsDisposed() )
+ if( xWindow->isDisposed() )
return;
// #100759#, avoid walking the wrong frame's hierarchy
@@ -3414,7 +3409,7 @@ void Window::ImplCallActivateListeners( vcl::Window *pOld )
VclPtr<vcl::Window> xWindow(this);
CallEventListeners( VclEventId::WindowActivate, pOld );
- if( xWindow->IsDisposed() )
+ if( xWindow->isDisposed() )
return;
if ( ImplGetParent() )
More information about the Libreoffice-commits
mailing list