Kaydet (Commit) ef8e3826 authored tarafından Maxim Monastirsky's avatar Maxim Monastirsky

fdo#86117 a11y: Exception when closing popup from ToolBox w/o separator

For some reason PopupWindowControllerImpl::WindowEventListener is getting
the VCLEVENT_WINDOW_HIDE event twice, and while processing the second one
the ToolBox no longer has an active down item, which results in a
IndexOutOfBoundsException in VCLXAccessibleToolBox::getAccessibleChild,
because ToolBox::GetItemPos(0) correctly returns TOOLBOX_ITEM_NOTFOUND.
But when a ToolBox has at least one separator, ToolBox::GetItemPos(0)
"detects" its position as the current down item, and no exception is
thrown.

Probably it just hides the bug, because it seems to me that getting
the hide event twice is the real bug here.

Change-Id: If018350dd91cd959c0c8f7d6859474f95fb8cd1e
Reviewed-on: https://gerrit.libreoffice.org/13173Reviewed-by: 's avatarMaxim Monastirsky <momonasmon@gmail.com>
Tested-by: 's avatarMaxim Monastirsky <momonasmon@gmail.com>
üst 61672791
......@@ -430,10 +430,16 @@ void VCLXAccessibleToolBox::UpdateCustomPopupItemp_Impl( vcl::Window* pWindow, b
ToolBox* pToolBox = static_cast< ToolBox* >( GetWindow() );
if( pWindow && pToolBox )
{
const sal_uInt16 nDownItem = pToolBox->GetDownItemId();
if ( !nDownItem )
// Items with ItemId == 0 are not allowed in ToolBox, which means that currently no item is in down state.
// Moreover, running GetItemPos with 0 could find a separator item if there is any.
return;
Reference< XAccessible > xChild( pWindow->GetAccessible() );
if( xChild.is() )
{
Reference< XAccessible > xChildItem( getAccessibleChild( static_cast< sal_Int32 >( pToolBox->GetItemPos( pToolBox->GetDownItemId() ) ) ) );
Reference< XAccessible > xChildItem( getAccessibleChild( static_cast< sal_Int32 >( pToolBox->GetItemPos( nDownItem ) ) ) );
VCLXAccessibleToolBoxItem* pItem = static_cast< VCLXAccessibleToolBoxItem* >( xChildItem.get() );
pItem->SetChild( xChild );
......
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