Date: prev next · Thread: first prev next last
2011 Archives by date, by thread · List index


Here are revised patches as per Eike's comments.

They fix fdo#40701, which is a crasher, a regression and a "most
annoying 3.4 bug".

*0001-fdo-40701-*
fixes the root cause of the bug, which caused
void DbGridControl::EnableHandle(sal_Bool bEnable)
{
    RemoveColumn(0);
    m_bHandle = bEnable;
    InsertHandleColumn();
}
to misfunction: RemoveColumn(0) silently did not remove the column, so
the call to InsertHandleColumn() added a second Handle Column, which
confused the code in other places.

There are two versions of it:
 * The one suggested by Eike
 * The one preferred by me

Either one will fix fdo#40701, but I consider mine more robust, and
it corresponds to what I did in master. See previous message(s) in
this thread for details on that.

0002-FmXGridPeer-getByIndex-Error-checking-of-pGrid-GetMo.patch
fixes the reason the bug was a crasher instead of just "broken
feature, nothing happens when "Find Record" button is clicked".

Although patch 0001 removes the known way of triggering the crash, I'd
find it still find it relevant to apply the "don't crash" protection
in 0002.

-- 
Lionel
From 22ad763cb67766c1f97b0d843dc5fe054022f70d Mon Sep 17 00:00:00 2001
From: Lionel Elie Mamane <lionel@mamane.lu>
Date: Mon, 12 Sep 2011 00:00:33 +0200
Subject: [PATCH] fdo#40701: DbGridControl::RemoveColumn even if no corresponding Model column

That case crops up when nId==0 i.e. the Handle column
---
 svx/source/fmcomp/gridctrl.cxx |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/svx/source/fmcomp/gridctrl.cxx b/svx/source/fmcomp/gridctrl.cxx
index bb666bc..eaf6a31 100644
--- a/svx/source/fmcomp/gridctrl.cxx
+++ b/svx/source/fmcomp/gridctrl.cxx
@@ -1722,12 +1722,12 @@ sal_uInt16 DbGridControl::AppendColumn(const XubString& rName, sal_uInt16 
nWidth
 //------------------------------------------------------------------------------
 void DbGridControl::RemoveColumn(sal_uInt16 nId)
 {
+    DbGridControl_Base::RemoveColumn(nId);
+
     sal_uInt16 nIndex = GetModelColumnPos(nId);
     if (nIndex == GRID_COLUMN_NOT_FOUND)
         return;
 
-    DbGridControl_Base::RemoveColumn(nId);
-
     delete m_aColumns[ nIndex ];
     DbGridColumns::iterator it = m_aColumns.begin();
     ::std::advance( it, nIndex );
-- 
1.7.2.5

From 6b8724640fdd5a08f028978d04532f5e9059cb6e Mon Sep 17 00:00:00 2001
From: Lionel Elie Mamane <lionel@mamane.lu>
Date: Mon, 12 Sep 2011 00:00:33 +0200
Subject: [PATCH 1/2] fdo#40701: DbGridControl::RemoveColumn on handle column

The handle column (nId == 0) is not a Model column (not in
m_aColumns), but it should still be deleted from base class
(from the view columns).
---
 svx/source/fmcomp/gridctrl.cxx |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/svx/source/fmcomp/gridctrl.cxx b/svx/source/fmcomp/gridctrl.cxx
index bb666bc..c425029 100644
--- a/svx/source/fmcomp/gridctrl.cxx
+++ b/svx/source/fmcomp/gridctrl.cxx
@@ -1723,11 +1723,13 @@ sal_uInt16 DbGridControl::AppendColumn(const XubString& rName, sal_uInt16 
nWidth
 void DbGridControl::RemoveColumn(sal_uInt16 nId)
 {
     sal_uInt16 nIndex = GetModelColumnPos(nId);
+
+    if (nIndex != GRID_COLUMN_NOT_FOUND || nId == 0)
+        DbGridControl_Base::RemoveColumn(nId);
+
     if (nIndex == GRID_COLUMN_NOT_FOUND)
         return;
 
-    DbGridControl_Base::RemoveColumn(nId);
-
     delete m_aColumns[ nIndex ];
     DbGridColumns::iterator it = m_aColumns.begin();
     ::std::advance( it, nIndex );
-- 
1.7.2.5

From 43de7ca913a071a231cf6ca34ef3a609de498808 Mon Sep 17 00:00:00 2001
From: Lionel Elie Mamane <lionel@mamane.lu>
Date: Sun, 11 Sep 2011 23:40:09 +0200
Subject: [PATCH 2/2] FmXGridPeer::getByIndex: Error checking of pGrid->GetModelColumnPos(nId) call

Fixes crash of fdo#40701, but not broken feature
---
 svx/source/fmcomp/fmgridif.cxx |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/svx/source/fmcomp/fmgridif.cxx b/svx/source/fmcomp/fmgridif.cxx
index 3080d77..a4146a9 100644
--- a/svx/source/fmcomp/fmgridif.cxx
+++ b/svx/source/fmcomp/fmgridif.cxx
@@ -2442,6 +2442,9 @@ Any FmXGridPeer::getByIndex(sal_Int32 _nIndex) throw( 
IndexOutOfBoundsException,
     // get the list position
     sal_uInt16 nPos = pGrid->GetModelColumnPos(nId);
 
+    if ( nPos == GRID_COLUMN_NOT_FOUND )
+        return aElement;
+
     DbGridColumn* pCol = pGrid->GetColumns().at( nPos );
     Reference< ::com::sun::star::awt::XControl >  xControl(pCol->GetCell());
     aElement <<= xControl;
-- 
1.7.2.5


Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.