Kaydet (Commit) 7c50bdb2 authored tarafından Michael Meeks's avatar Michael Meeks Kaydeden (comit) Andras Timar

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/17038Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst ce400bd2
...@@ -49,13 +49,13 @@ namespace svt ...@@ -49,13 +49,13 @@ namespace svt
struct DialogController_Data struct DialogController_Data
{ {
vcl::Window& rInstigator; VclPtr<vcl::Window> xInstigator;
::std::vector< VclPtr<vcl::Window> > aConcernedWindows; ::std::vector< VclPtr<vcl::Window> > aConcernedWindows;
PWindowEventFilter pEventFilter; PWindowEventFilter pEventFilter;
PWindowOperator pOperator; PWindowOperator pOperator;
DialogController_Data( vcl::Window& _rInstigator, const PWindowEventFilter _pEventFilter, const PWindowOperator _pOperator ) DialogController_Data( vcl::Window& _xInstigator, const PWindowEventFilter _pEventFilter, const PWindowOperator _pOperator )
:rInstigator( _rInstigator ) :xInstigator( &_xInstigator )
,pEventFilter( _pEventFilter ) ,pEventFilter( _pEventFilter )
,pOperator( _pOperator ) ,pOperator( _pOperator )
{ {
...@@ -66,14 +66,14 @@ namespace svt ...@@ -66,14 +66,14 @@ namespace svt
//= DialogController //= DialogController
DialogController::DialogController( vcl::Window& _rInstigator, const PWindowEventFilter& _pEventFilter, DialogController::DialogController( vcl::Window& _xInstigator, const PWindowEventFilter& _pEventFilter,
const PWindowOperator& _pOperator ) 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(), DBG_ASSERT( m_pImpl->pEventFilter.get() && m_pImpl->pOperator.get(),
"DialogController::DialogController: invalid filter and/or operator!" ); "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 ...@@ -85,7 +85,9 @@ namespace svt
void DialogController::reset() 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->aConcernedWindows.clear();
m_pImpl->pEventFilter.reset(); m_pImpl->pEventFilter.reset();
m_pImpl->pOperator.reset(); m_pImpl->pOperator.reset();
......
...@@ -249,7 +249,8 @@ void Window::AddEventListener( const Link<>& rEventListener ) ...@@ -249,7 +249,8 @@ void Window::AddEventListener( const Link<>& rEventListener )
void Window::RemoveEventListener( 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 ) void Window::AddChildEventListener( const Link<>& rEventListener )
...@@ -259,7 +260,8 @@ void Window::AddChildEventListener( const Link<>& rEventListener ) ...@@ -259,7 +260,8 @@ void Window::AddChildEventListener( const Link<>& rEventListener )
void Window::RemoveChildEventListener( 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 ) ImplSVEvent * Window::PostUserEvent( const Link<>& rLink, void* pCaller, bool bReferenceLink )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment