Kaydet (Commit) 6f382467 authored tarafından Lionel Elie Mamane's avatar Lionel Elie Mamane Kaydeden (comit) Caolán McNamara

make FmXGridCell more disposed-safe

fixes a segfault (crash) in these conditions:

* the form's AfterInsert StarBasic script does a reload() of the form

* the insert happens by clicking into a cell which has
  scripts linked to the events FocusLost and FocusGained.
  The case that led to discovering this involved a ListBox whose
  RecordSource changes when focus is gained or lost.

Then there was a race condition between the cell's dispose (from the
form's reload()) and the _old_ cell's FocusLost being executed.
NewStyleUNOScript::invoke would then call
xControl->getModel
with xControl being the involved cell,
leading FmXGridCell::getModel() to call m_pColumn->getModel()
with m_pColumn == NULL.

Change-Id: Ifb4402d37ee4faec80087ffccabe102acc016d60
Reviewed-on: https://gerrit.libreoffice.org/18669Tested-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 3660e3c8
......@@ -3255,6 +3255,7 @@ Reference< XInterface > FmXGridCell::getContext() throw( RuntimeException, std:
Reference< ::com::sun::star::awt::XControlModel > FmXGridCell::getModel() throw( ::com::sun::star::uno::RuntimeException, std::exception )
{
checkDisposed(OComponentHelper::rBHelper.bDisposed);
return Reference< ::com::sun::star::awt::XControlModel > (m_pColumn->getModel(), UNO_QUERY);
}
......@@ -3262,12 +3263,14 @@ Reference< ::com::sun::star::awt::XControlModel > FmXGridCell::getModel() throw
sal_Bool FmXGridCell::getLock() throw( RuntimeException, std::exception )
{
checkDisposed(OComponentHelper::rBHelper.bDisposed);
return m_pColumn->isLocked();
}
void FmXGridCell::setLock(sal_Bool _bLock) throw( RuntimeException, std::exception )
{
checkDisposed(OComponentHelper::rBHelper.bDisposed);
if (getLock() == _bLock)
return;
else
......@@ -3322,60 +3325,70 @@ void SAL_CALL FmXGridCell::setFocus( ) throw (RuntimeException, std::exception)
void SAL_CALL FmXGridCell::addWindowListener( const Reference< awt::XWindowListener >& _rxListener ) throw (RuntimeException, std::exception)
{
checkDisposed(OComponentHelper::rBHelper.bDisposed);
m_aWindowListeners.addInterface( _rxListener );
}
void SAL_CALL FmXGridCell::removeWindowListener( const Reference< awt::XWindowListener >& _rxListener ) throw (RuntimeException, std::exception)
{
checkDisposed(OComponentHelper::rBHelper.bDisposed);
m_aWindowListeners.removeInterface( _rxListener );
}
void SAL_CALL FmXGridCell::addFocusListener( const Reference< awt::XFocusListener >& _rxListener ) throw (RuntimeException, std::exception)
{
checkDisposed(OComponentHelper::rBHelper.bDisposed);
m_aFocusListeners.addInterface( _rxListener );
}
void SAL_CALL FmXGridCell::removeFocusListener( const Reference< awt::XFocusListener >& _rxListener ) throw (RuntimeException, std::exception)
{
checkDisposed(OComponentHelper::rBHelper.bDisposed);
m_aFocusListeners.removeInterface( _rxListener );
}
void SAL_CALL FmXGridCell::addKeyListener( const Reference< awt::XKeyListener >& _rxListener ) throw (RuntimeException, std::exception)
{
checkDisposed(OComponentHelper::rBHelper.bDisposed);
m_aKeyListeners.addInterface( _rxListener );
}
void SAL_CALL FmXGridCell::removeKeyListener( const Reference< awt::XKeyListener >& _rxListener ) throw (RuntimeException, std::exception)
{
checkDisposed(OComponentHelper::rBHelper.bDisposed);
m_aKeyListeners.removeInterface( _rxListener );
}
void SAL_CALL FmXGridCell::addMouseListener( const Reference< awt::XMouseListener >& _rxListener ) throw (RuntimeException, std::exception)
{
checkDisposed(OComponentHelper::rBHelper.bDisposed);
m_aMouseListeners.addInterface( _rxListener );
}
void SAL_CALL FmXGridCell::removeMouseListener( const Reference< awt::XMouseListener >& _rxListener ) throw (RuntimeException, std::exception)
{
checkDisposed(OComponentHelper::rBHelper.bDisposed);
m_aMouseListeners.removeInterface( _rxListener );
}
void SAL_CALL FmXGridCell::addMouseMotionListener( const Reference< awt::XMouseMotionListener >& _rxListener ) throw (RuntimeException, std::exception)
{
checkDisposed(OComponentHelper::rBHelper.bDisposed);
m_aMouseMotionListeners.addInterface( _rxListener );
}
void SAL_CALL FmXGridCell::removeMouseMotionListener( const Reference< awt::XMouseMotionListener >& _rxListener ) throw (RuntimeException, std::exception)
{
checkDisposed(OComponentHelper::rBHelper.bDisposed);
m_aMouseMotionListeners.removeInterface( _rxListener );
}
......@@ -3405,12 +3418,14 @@ IMPL_LINK( FmXGridCell, OnWindowEvent, VclWindowEvent*, _pEvent )
void FmXGridCell::onFocusGained( const awt::FocusEvent& _rEvent )
{
checkDisposed(OComponentHelper::rBHelper.bDisposed);
m_aFocusListeners.notifyEach( &awt::XFocusListener::focusGained, _rEvent );
}
void FmXGridCell::onFocusLost( const awt::FocusEvent& _rEvent )
{
checkDisposed(OComponentHelper::rBHelper.bDisposed);
m_aFocusListeners.notifyEach( &awt::XFocusListener::focusLost, _rEvent );
}
......
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