diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-04-16 08:28:16 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-04-16 10:42:01 +0200 |
commit | 0973e1f4e727a3204c843398bcb0e6a411b1a02d (patch) | |
tree | 954d190ad385f5bb9a3ab2d763403468f0f66b62 /dbaccess | |
parent | 914f6385d98f8c898102c971a4d5b0eb9f075ef0 (diff) |
follow on for tdf#116981
the previous commit 235d61890512894e27f4f81e38a325eee3c67b30, fixed just
exactly the problem reported in tdf#116981.
This commit fixes similar issues that may exist elsewhere.
To recap, this started as a regression from
commit 433fc2214c980abd82fa6240f45e634a53a3c61c (patch)
sal_uIntPtr->sal_Int32 in MultiSelection
Previously, MultiSelection stored it's values internally as sal_uIntPtr,
but returned them as long in FirstSelected(), NextSelected(),
and SFX_ENDOFSELECTION was defined to be ULONG_MAX.
On 64-bit Linux, sal_uIntPtr is typedefed to sal_uInt64, and ULONG_MAX
is 2^64, which means that previously, the SFX_ENDOFSELECTION value was
being converted from 2^64 to -2^63 when it was returned, which was why
these loop worked.
So convert SFX_ENDOFSELECTION to SAL_MIN_INT32, so we get a large
negative value which can never be a valid index, and which works more
like it did before the regression.
Also fix as many loops as I can find, to check against
SFX_ENDOFSELECTION explicitly.
Change-Id: I947d43dbe23a08105be3d849e33d7e774a8a19fa
Reviewed-on: https://gerrit.libreoffice.org/52934
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'dbaccess')
-rw-r--r-- | dbaccess/source/ui/browser/unodatbr.cxx | 2 | ||||
-rw-r--r-- | dbaccess/source/ui/tabledesign/TEditControl.cxx | 10 |
2 files changed, 6 insertions, 6 deletions
diff --git a/dbaccess/source/ui/browser/unodatbr.cxx b/dbaccess/source/ui/browser/unodatbr.cxx index aff8900255e6..ade472fe704a 100644 --- a/dbaccess/source/ui/browser/unodatbr.cxx +++ b/dbaccess/source/ui/browser/unodatbr.cxx @@ -1915,7 +1915,7 @@ void SbaTableQueryBrowser::Execute(sal_uInt16 nId, const Sequence< PropertyValue aSelection.realloc(pSelection->GetSelectCount()); long nIdx = pSelection->FirstSelected(); Any* pSelectionNos = aSelection.getArray(); - while (nIdx >= 0) + while (nIdx != SFX_ENDOFSELECTION) { *pSelectionNos++ <<= static_cast<sal_Int32>(nIdx + 1); nIdx = pSelection->NextSelected(); diff --git a/dbaccess/source/ui/tabledesign/TEditControl.cxx b/dbaccess/source/ui/tabledesign/TEditControl.cxx index f47a308e3db4..f68fc597d516 100644 --- a/dbaccess/source/ui/tabledesign/TEditControl.cxx +++ b/dbaccess/source/ui/tabledesign/TEditControl.cxx @@ -715,7 +715,7 @@ void OTableEditorCtrl::CopyRows() std::vector< std::shared_ptr<OTableRow> > vClipboardList; vClipboardList.reserve(GetSelectRowCount()); - for( long nIndex=FirstSelectedRow(); nIndex >= 0 && nIndex < static_cast<long>(m_pRowList->size()); nIndex=NextSelectedRow() ) + for( long nIndex=FirstSelectedRow(); nIndex != SFX_ENDOFSELECTION; nIndex=NextSelectedRow() ) { pRow = (*m_pRowList)[nIndex]; OSL_ENSURE(pRow,"OTableEditorCtrl::CopyRows: Row is NULL!"); @@ -814,7 +814,7 @@ void OTableEditorCtrl::DeleteRows() long nIndex = FirstSelectedRow(); nOldDataPos = nIndex; - while( nIndex >= 0 && nIndex < static_cast<long>(m_pRowList->size()) ) + while( nIndex != SFX_ENDOFSELECTION ) { // Remove rows m_pRowList->erase( m_pRowList->begin()+nIndex ); @@ -1120,7 +1120,7 @@ bool OTableEditorCtrl::IsCopyAllowed() // If one of the selected rows is empty, Copy is not possible std::shared_ptr<OTableRow> pRow; long nIndex = FirstSelectedRow(); - while( nIndex >= 0 && nIndex < static_cast<long>(m_pRowList->size()) ) + while( nIndex != SFX_ENDOFSELECTION ) { pRow = (*m_pRowList)[nIndex]; if( !pRow->GetActFieldDescr() ) @@ -1278,7 +1278,7 @@ bool OTableEditorCtrl::IsPrimaryKeyAllowed( long /*nRow*/ ) // - DROP is not permitted (see above) and the column is not Required (not null flag is not set). long nIndex = FirstSelectedRow(); std::shared_ptr<OTableRow> pRow; - while( nIndex >= 0 && nIndex < static_cast<long>(m_pRowList->size()) ) + while( nIndex != SFX_ENDOFSELECTION ) { pRow = (*m_pRowList)[nIndex]; OFieldDescription* pFieldDescr = pRow->GetActFieldDescr(); @@ -1513,7 +1513,7 @@ void OTableEditorCtrl::SetPrimaryKey( bool bSet ) if( bSet ) { long nIndex = FirstSelectedRow(); - while( nIndex >= 0 && nIndex < static_cast<long>(m_pRowList->size()) ) + while( nIndex != SFX_ENDOFSELECTION ) { // Set the key std::shared_ptr<OTableRow> pRow = (*m_pRowList)[nIndex]; |