summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Meeks <michael.meeks@collabora.com>2015-10-15 13:16:04 +0100
committerJan Holesovsky <kendy@collabora.com>2015-10-20 12:37:23 +0000
commit3184baf770d56e212e0b0699fe7a12dff9985c8e (patch)
tree8c8e2da764a56997b7802e724cb5e1596ee4d481
parentb09dbf6c718ba0b2d920988b510bfd130bc2c3f3 (diff)
tdf#94495 - protect lstbox usage post-dispose, and fix ItemWin focus.
Change-Id: I2e4d1c79f57ec048d66111ed393491b7803ee3b9 Reviewed-on: https://gerrit.libreoffice.org/19389 Reviewed-by: Adolfo Jayme Barrientos <fitojb@ubuntu.com> Reviewed-by: Jan Holesovsky <kendy@collabora.com> Tested-by: Jan Holesovsky <kendy@collabora.com>
-rw-r--r--svx/source/tbxctrls/itemwin.cxx24
-rw-r--r--vcl/source/control/lstbox.cxx20
2 files changed, 34 insertions, 10 deletions
diff --git a/svx/source/tbxctrls/itemwin.cxx b/svx/source/tbxctrls/itemwin.cxx
index 0b575c292cf7..e4e207ff7d18 100644
--- a/svx/source/tbxctrls/itemwin.cxx
+++ b/svx/source/tbxctrls/itemwin.cxx
@@ -419,16 +419,19 @@ bool SvxFillTypeBox::PreNotify( NotifyEvent& rNEvt )
{
MouseNotifyEvent nType = rNEvt.GetType();
- if ( MouseNotifyEvent::MOUSEBUTTONDOWN == nType || MouseNotifyEvent::GETFOCUS == nType )
- nCurPos = GetSelectEntryPos();
- else if ( MouseNotifyEvent::LOSEFOCUS == nType
- && Application::GetFocusWindow()
- && !IsWindowOrChild( Application::GetFocusWindow(), true ) )
+ if (!isDisposed())
{
- if ( !bSelect )
- SelectEntryPos( nCurPos );
- else
- bSelect = false;
+ if ( MouseNotifyEvent::MOUSEBUTTONDOWN == nType || MouseNotifyEvent::GETFOCUS == nType )
+ nCurPos = GetSelectEntryPos();
+ else if ( MouseNotifyEvent::LOSEFOCUS == nType
+ && Application::GetFocusWindow()
+ && !IsWindowOrChild( Application::GetFocusWindow(), true ) )
+ {
+ if ( !bSelect )
+ SelectEntryPos( nCurPos );
+ else
+ bSelect = false;
+ }
}
return FillTypeLB::PreNotify( rNEvt );
@@ -440,6 +443,9 @@ bool SvxFillTypeBox::Notify( NotifyEvent& rNEvt )
{
bool nHandled = FillTypeLB::Notify( rNEvt );
+ if (isDisposed())
+ return false;
+
if ( rNEvt.GetType() == MouseNotifyEvent::KEYINPUT )
{
const KeyEvent* pKEvt = rNEvt.GetKeyEvent();
diff --git a/vcl/source/control/lstbox.cxx b/vcl/source/control/lstbox.cxx
index 9b0d5e58d88d..1b0943b6ac48 100644
--- a/vcl/source/control/lstbox.cxx
+++ b/vcl/source/control/lstbox.cxx
@@ -982,6 +982,8 @@ void ListBox::DoubleClick()
void ListBox::Clear()
{
+ if (!mpImplLB)
+ return;
mpImplLB->Clear();
if( IsDropDownBox() )
{
@@ -1037,13 +1039,15 @@ void ListBox::RemoveEntry( sal_Int32 nPos )
Image ListBox::GetEntryImage( sal_Int32 nPos ) const
{
- if ( mpImplLB->GetEntryList()->HasEntryImage( nPos ) )
+ if ( mpImplLB && mpImplLB->GetEntryList()->HasEntryImage( nPos ) )
return mpImplLB->GetEntryList()->GetEntryImage( nPos );
return Image();
}
sal_Int32 ListBox::GetEntryPos( const OUString& rStr ) const
{
+ if (!mpImplLB)
+ return LISTBOX_ENTRY_NOTFOUND;
sal_Int32 nPos = mpImplLB->GetEntryList()->FindEntry( rStr );
if ( nPos != LISTBOX_ENTRY_NOTFOUND )
nPos = nPos - mpImplLB->GetEntryList()->GetMRUCount();
@@ -1052,6 +1056,8 @@ sal_Int32 ListBox::GetEntryPos( const OUString& rStr ) const
sal_Int32 ListBox::GetEntryPos( const void* pData ) const
{
+ if (!mpImplLB)
+ return LISTBOX_ENTRY_NOTFOUND;
sal_Int32 nPos = mpImplLB->GetEntryList()->FindEntry( pData );
if ( nPos != LISTBOX_ENTRY_NOTFOUND )
nPos = nPos - mpImplLB->GetEntryList()->GetMRUCount();
@@ -1060,11 +1066,15 @@ sal_Int32 ListBox::GetEntryPos( const void* pData ) const
OUString ListBox::GetEntry( sal_Int32 nPos ) const
{
+ if (!mpImplLB)
+ return OUString();
return mpImplLB->GetEntryList()->GetEntryText( nPos + mpImplLB->GetEntryList()->GetMRUCount() );
}
sal_Int32 ListBox::GetEntryCount() const
{
+ if (!mpImplLB)
+ return 0;
return mpImplLB->GetEntryList()->GetEntryCount() - mpImplLB->GetEntryList()->GetMRUCount();
}
@@ -1075,11 +1085,16 @@ OUString ListBox::GetSelectEntry(sal_Int32 nIndex) const
sal_Int32 ListBox::GetSelectEntryCount() const
{
+ if (!mpImplLB)
+ return 0;
return mpImplLB->GetEntryList()->GetSelectEntryCount();
}
sal_Int32 ListBox::GetSelectEntryPos( sal_Int32 nIndex ) const
{
+ if (!mpImplLB || !mpImplLB->GetEntryList())
+ return LISTBOX_ENTRY_NOTFOUND;
+
sal_Int32 nPos = mpImplLB->GetEntryList()->GetSelectEntryPos( nIndex );
if ( nPos != LISTBOX_ENTRY_NOTFOUND )
{
@@ -1107,6 +1122,9 @@ void ListBox::SelectEntry( const OUString& rStr, bool bSelect )
void ListBox::SelectEntryPos( sal_Int32 nPos, bool bSelect )
{
+ if (!mpImplLB)
+ return;
+
if ( 0 <= nPos && nPos < mpImplLB->GetEntryList()->GetEntryCount() )
{
sal_Int32 oldSelectCount = GetSelectEntryCount(), newSelectCount = 0, nCurrentPos = mpImplLB->GetCurrentPos();