You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
libreoffice/0001-rhbz-1197614-Fix-calcu...

78 lines
2.9 KiB

From 97d4c1a8100c63091401736c93d6bbbb371d5b37 Mon Sep 17 00:00:00 2001
From: Stephan Bergmann <sbergman@redhat.com>
Date: Fri, 10 Apr 2015 15:06:53 +0200
Subject: [PATCH] rhbz#1197614: Fix calculation of m_bHasActive when removing
active element
Assume m_vEntries.size() == 2; assume first element (nPos == 0) is m_bActive,
gets removed, so m_nActive would have stayed at 0 and m_bHasActive at true; then
assume second element (again nPos == 0, due to the removed element) is m_bNew,
so nPos <= m_nActive is true and m_nActive gets updated to 1 (and m_bHasActive
remains true); then selectEntry(nNewPos) (nNewPos == 0) would have tried to
reset m_vEntries[1]->m_bActive but now m_vEntries.size() == 1.
Change-Id: I31d3bbe97ca99f880aa99bdea015f7c0457f8331
---
desktop/source/deployment/gui/dp_gui_extlistbox.cxx | 21 ++++++++++++++-------
1 file changed, 14 insertions(+), 7 deletions(-)
diff --git a/desktop/source/deployment/gui/dp_gui_extlistbox.cxx b/desktop/source/deployment/gui/dp_gui_extlistbox.cxx
index 260100f..b9500a1 100644
--- a/desktop/source/deployment/gui/dp_gui_extlistbox.cxx
+++ b/desktop/source/deployment/gui/dp_gui_extlistbox.cxx
@@ -1035,7 +1035,6 @@ long ExtensionBox_Impl::addEntry( const uno::Reference< deployment::XPackage > &
//access to m_nActive must be guarded
if ( !m_bInCheckMode && m_bHasActive && ( m_nActive >= nPos ) )
m_nActive += 1;
-
guard.clear();
if ( IsReallyVisible() )
@@ -1172,6 +1171,7 @@ void ExtensionBox_Impl::prepareChecking()
void ExtensionBox_Impl::checkEntries()
{
long nNewPos = -1;
+ long nChangedActivePos = -1;
long nPos = 0;
bool bNeedsUpdate = false;
@@ -1195,15 +1195,19 @@ void ExtensionBox_Impl::checkEntries()
}
else
{ // remove entry from list
+ if (nPos < nNewPos) {
+ --nNewPos;
+ }
+ if (nPos < nChangedActivePos) {
+ --nChangedActivePos;
+ }
if ( nPos < m_nActive )
m_nActive -= 1;
- else if ( ( nPos == m_nActive ) && ( nPos == (long) m_vEntries.size() - 1 ) )
+ else if ( nPos == m_nActive )
{
- m_nActive -= 1;
- if (m_nActive == -1)
- {
- m_bHasActive = false;
- }
+ nChangedActivePos = nPos;
+ m_nActive = -1;
+ m_bHasActive = false;
}
m_vRemovedEntries.push_back( *iIndex );
m_vEntries.erase( iIndex );
@@ -1219,6 +1223,9 @@ void ExtensionBox_Impl::checkEntries()
if ( nNewPos != - 1)
selectEntry( nNewPos );
+ else if (nChangedActivePos != -1) {
+ selectEntry(nChangedActivePos);
+ }
if ( bNeedsUpdate )
{
--
2.1.0