summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Meeks <michael.meeks@collabora.com>2015-07-14 12:51:04 +0100
committerMichael Meeks <michael.meeks@collabora.com>2015-07-14 21:13:16 +0000
commit46e1e1292ac801598e1f43657a1320c45ef8776d (patch)
tree1ecc3170d08af7fd70b1ce12f3a888f310c46d8b
parent11fb5b5cce6ebb857bd6ede39815b37256db3e1f (diff)
tdf#92706 - avoid dbaccess wizard crash.
Hold a VclPtr on the window, make reset cleaner, and don't crash removing listeners from disposed windows. Change-Id: I3efb71117fc45562d5c740578f5e33dabb2684fe Reviewed-on: https://gerrit.libreoffice.org/17039 Reviewed-by: Michael Meeks <michael.meeks@collabora.com> Tested-by: Michael Meeks <michael.meeks@collabora.com>
-rw-r--r--svtools/source/misc/dialogcontrolling.cxx18
-rw-r--r--vcl/source/window/event.cxx6
2 files changed, 14 insertions, 10 deletions
diff --git a/svtools/source/misc/dialogcontrolling.cxx b/svtools/source/misc/dialogcontrolling.cxx
index b381c43d4bd7..ca6280410007 100644
--- a/svtools/source/misc/dialogcontrolling.cxx
+++ b/svtools/source/misc/dialogcontrolling.cxx
@@ -49,13 +49,13 @@ namespace svt
struct DialogController_Data
{
- vcl::Window& rInstigator;
- ::std::vector< VclPtr<vcl::Window> > aConcernedWindows;
+ VclPtr<vcl::Window> xInstigator;
+ ::std::vector< VclPtr<vcl::Window> > aConcernedWindows;
PWindowEventFilter pEventFilter;
PWindowOperator pOperator;
- DialogController_Data( vcl::Window& _rInstigator, const PWindowEventFilter _pEventFilter, const PWindowOperator _pOperator )
- :rInstigator( _rInstigator )
+ DialogController_Data( vcl::Window& _xInstigator, const PWindowEventFilter _pEventFilter, const PWindowOperator _pOperator )
+ :xInstigator( &_xInstigator )
,pEventFilter( _pEventFilter )
,pOperator( _pOperator )
{
@@ -66,14 +66,14 @@ namespace svt
//= DialogController
- DialogController::DialogController( vcl::Window& _rInstigator, const PWindowEventFilter& _pEventFilter,
+ DialogController::DialogController( vcl::Window& _xInstigator, const PWindowEventFilter& _pEventFilter,
const PWindowOperator& _pOperator )
- :m_pImpl( new DialogController_Data( _rInstigator, _pEventFilter, _pOperator ) )
+ :m_pImpl( new DialogController_Data( _xInstigator, _pEventFilter, _pOperator ) )
{
DBG_ASSERT( m_pImpl->pEventFilter.get() && m_pImpl->pOperator.get(),
"DialogController::DialogController: invalid filter and/or operator!" );
- m_pImpl->rInstigator.AddEventListener( LINK( this, DialogController, OnWindowEvent ) );
+ m_pImpl->xInstigator->AddEventListener( LINK( this, DialogController, OnWindowEvent ) );
}
@@ -85,7 +85,9 @@ namespace svt
void DialogController::reset()
{
- m_pImpl->rInstigator.RemoveEventListener( LINK( this, DialogController, OnWindowEvent ) );
+ if (m_pImpl->xInstigator)
+ m_pImpl->xInstigator->RemoveEventListener( LINK( this, DialogController, OnWindowEvent ) );
+ m_pImpl->xInstigator.clear();
m_pImpl->aConcernedWindows.clear();
m_pImpl->pEventFilter.reset();
m_pImpl->pOperator.reset();
diff --git a/vcl/source/window/event.cxx b/vcl/source/window/event.cxx
index 61c11ab20bdd..852cc0c56938 100644
--- a/vcl/source/window/event.cxx
+++ b/vcl/source/window/event.cxx
@@ -249,7 +249,8 @@ void Window::AddEventListener( const Link<>& rEventListener )
void Window::RemoveEventListener( const Link<>& rEventListener )
{
- mpWindowImpl->maEventListeners.removeListener( rEventListener );
+ if (mpWindowImpl)
+ mpWindowImpl->maEventListeners.removeListener( rEventListener );
}
void Window::AddChildEventListener( const Link<>& rEventListener )
@@ -259,7 +260,8 @@ void Window::AddChildEventListener( const Link<>& rEventListener )
void Window::RemoveChildEventListener( const Link<>& rEventListener )
{
- mpWindowImpl->maChildEventListeners.removeListener( rEventListener );
+ if (mpWindowImpl)
+ mpWindowImpl->maChildEventListeners.removeListener( rEventListener );
}
ImplSVEvent * Window::PostUserEvent( const Link<>& rLink, void* pCaller, bool bReferenceLink )