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

tdf#94495 - protect lstbox usage post-dispose, and fix ItemWin focus.

Change-Id: I2e4d1c79f57ec048d66111ed393491b7803ee3b9
Reviewed-on: https://gerrit.libreoffice.org/19387Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
(cherry picked from commit 87f3db9b)
üst fb2ad67f
...@@ -419,6 +419,8 @@ bool SvxFillTypeBox::PreNotify( NotifyEvent& rNEvt ) ...@@ -419,6 +419,8 @@ bool SvxFillTypeBox::PreNotify( NotifyEvent& rNEvt )
{ {
MouseNotifyEvent nType = rNEvt.GetType(); MouseNotifyEvent nType = rNEvt.GetType();
if (!isDisposed())
{
if ( MouseNotifyEvent::MOUSEBUTTONDOWN == nType || MouseNotifyEvent::GETFOCUS == nType ) if ( MouseNotifyEvent::MOUSEBUTTONDOWN == nType || MouseNotifyEvent::GETFOCUS == nType )
nCurPos = GetSelectEntryPos(); nCurPos = GetSelectEntryPos();
else if ( MouseNotifyEvent::LOSEFOCUS == nType else if ( MouseNotifyEvent::LOSEFOCUS == nType
...@@ -430,6 +432,7 @@ bool SvxFillTypeBox::PreNotify( NotifyEvent& rNEvt ) ...@@ -430,6 +432,7 @@ bool SvxFillTypeBox::PreNotify( NotifyEvent& rNEvt )
else else
bSelect = false; bSelect = false;
} }
}
return FillTypeLB::PreNotify( rNEvt ); return FillTypeLB::PreNotify( rNEvt );
} }
...@@ -440,6 +443,9 @@ bool SvxFillTypeBox::Notify( NotifyEvent& rNEvt ) ...@@ -440,6 +443,9 @@ bool SvxFillTypeBox::Notify( NotifyEvent& rNEvt )
{ {
bool nHandled = FillTypeLB::Notify( rNEvt ); bool nHandled = FillTypeLB::Notify( rNEvt );
if (isDisposed())
return false;
if ( rNEvt.GetType() == MouseNotifyEvent::KEYINPUT ) if ( rNEvt.GetType() == MouseNotifyEvent::KEYINPUT )
{ {
const KeyEvent* pKEvt = rNEvt.GetKeyEvent(); const KeyEvent* pKEvt = rNEvt.GetKeyEvent();
......
...@@ -982,6 +982,8 @@ void ListBox::DoubleClick() ...@@ -982,6 +982,8 @@ void ListBox::DoubleClick()
void ListBox::Clear() void ListBox::Clear()
{ {
if (!mpImplLB)
return;
mpImplLB->Clear(); mpImplLB->Clear();
if( IsDropDownBox() ) if( IsDropDownBox() )
{ {
...@@ -1037,13 +1039,15 @@ void ListBox::RemoveEntry( sal_Int32 nPos ) ...@@ -1037,13 +1039,15 @@ void ListBox::RemoveEntry( sal_Int32 nPos )
Image ListBox::GetEntryImage( sal_Int32 nPos ) const Image ListBox::GetEntryImage( sal_Int32 nPos ) const
{ {
if ( mpImplLB->GetEntryList()->HasEntryImage( nPos ) ) if ( mpImplLB && mpImplLB->GetEntryList()->HasEntryImage( nPos ) )
return mpImplLB->GetEntryList()->GetEntryImage( nPos ); return mpImplLB->GetEntryList()->GetEntryImage( nPos );
return Image(); return Image();
} }
sal_Int32 ListBox::GetEntryPos( const OUString& rStr ) const sal_Int32 ListBox::GetEntryPos( const OUString& rStr ) const
{ {
if (!mpImplLB)
return LISTBOX_ENTRY_NOTFOUND;
sal_Int32 nPos = mpImplLB->GetEntryList()->FindEntry( rStr ); sal_Int32 nPos = mpImplLB->GetEntryList()->FindEntry( rStr );
if ( nPos != LISTBOX_ENTRY_NOTFOUND ) if ( nPos != LISTBOX_ENTRY_NOTFOUND )
nPos = nPos - mpImplLB->GetEntryList()->GetMRUCount(); nPos = nPos - mpImplLB->GetEntryList()->GetMRUCount();
...@@ -1052,6 +1056,8 @@ sal_Int32 ListBox::GetEntryPos( const OUString& rStr ) const ...@@ -1052,6 +1056,8 @@ sal_Int32 ListBox::GetEntryPos( const OUString& rStr ) const
sal_Int32 ListBox::GetEntryPos( const void* pData ) const sal_Int32 ListBox::GetEntryPos( const void* pData ) const
{ {
if (!mpImplLB)
return LISTBOX_ENTRY_NOTFOUND;
sal_Int32 nPos = mpImplLB->GetEntryList()->FindEntry( pData ); sal_Int32 nPos = mpImplLB->GetEntryList()->FindEntry( pData );
if ( nPos != LISTBOX_ENTRY_NOTFOUND ) if ( nPos != LISTBOX_ENTRY_NOTFOUND )
nPos = nPos - mpImplLB->GetEntryList()->GetMRUCount(); nPos = nPos - mpImplLB->GetEntryList()->GetMRUCount();
...@@ -1060,11 +1066,15 @@ sal_Int32 ListBox::GetEntryPos( const void* pData ) const ...@@ -1060,11 +1066,15 @@ sal_Int32 ListBox::GetEntryPos( const void* pData ) const
OUString ListBox::GetEntry( sal_Int32 nPos ) const OUString ListBox::GetEntry( sal_Int32 nPos ) const
{ {
if (!mpImplLB)
return OUString();
return mpImplLB->GetEntryList()->GetEntryText( nPos + mpImplLB->GetEntryList()->GetMRUCount() ); return mpImplLB->GetEntryList()->GetEntryText( nPos + mpImplLB->GetEntryList()->GetMRUCount() );
} }
sal_Int32 ListBox::GetEntryCount() const sal_Int32 ListBox::GetEntryCount() const
{ {
if (!mpImplLB)
return 0;
return mpImplLB->GetEntryList()->GetEntryCount() - mpImplLB->GetEntryList()->GetMRUCount(); return mpImplLB->GetEntryList()->GetEntryCount() - mpImplLB->GetEntryList()->GetMRUCount();
} }
...@@ -1075,11 +1085,16 @@ OUString ListBox::GetSelectEntry(sal_Int32 nIndex) const ...@@ -1075,11 +1085,16 @@ OUString ListBox::GetSelectEntry(sal_Int32 nIndex) const
sal_Int32 ListBox::GetSelectEntryCount() const sal_Int32 ListBox::GetSelectEntryCount() const
{ {
if (!mpImplLB)
return 0;
return mpImplLB->GetEntryList()->GetSelectEntryCount(); return mpImplLB->GetEntryList()->GetSelectEntryCount();
} }
sal_Int32 ListBox::GetSelectEntryPos( sal_Int32 nIndex ) const sal_Int32 ListBox::GetSelectEntryPos( sal_Int32 nIndex ) const
{ {
if (!mpImplLB || !mpImplLB->GetEntryList())
return LISTBOX_ENTRY_NOTFOUND;
sal_Int32 nPos = mpImplLB->GetEntryList()->GetSelectEntryPos( nIndex ); sal_Int32 nPos = mpImplLB->GetEntryList()->GetSelectEntryPos( nIndex );
if ( nPos != LISTBOX_ENTRY_NOTFOUND ) if ( nPos != LISTBOX_ENTRY_NOTFOUND )
{ {
...@@ -1107,6 +1122,9 @@ void ListBox::SelectEntry( const OUString& rStr, bool bSelect ) ...@@ -1107,6 +1122,9 @@ void ListBox::SelectEntry( const OUString& rStr, bool bSelect )
void ListBox::SelectEntryPos( sal_Int32 nPos, bool bSelect ) void ListBox::SelectEntryPos( sal_Int32 nPos, bool bSelect )
{ {
if (!mpImplLB)
return;
if ( 0 <= nPos && nPos < mpImplLB->GetEntryList()->GetEntryCount() ) if ( 0 <= nPos && nPos < mpImplLB->GetEntryList()->GetEntryCount() )
{ {
sal_Int32 oldSelectCount = GetSelectEntryCount(), newSelectCount = 0, nCurrentPos = mpImplLB->GetCurrentPos(); sal_Int32 oldSelectCount = GetSelectEntryCount(), newSelectCount = 0, nCurrentPos = mpImplLB->GetCurrentPos();
......
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