[Libreoffice-commits] .: sw/inc sw/source
Stephan Bergmann
sbergmann at kemper.freedesktop.org
Mon Sep 19 14:35:39 PDT 2011
sw/inc/index.hxx | 12 ++++++------
sw/source/core/bastyp/index.cxx | 4 ++--
sw/source/core/bastyp/init.cxx | 4 ----
sw/source/core/crsr/crsrsh.cxx | 2 +-
4 files changed, 9 insertions(+), 13 deletions(-)
New commits:
commit e1945ba903faa567d90addaf13a0eb8a2f688d15
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Mon Sep 19 23:33:09 2011 +0200
Do not delete SwIndexReg::pEmptyIndexArray while SwXTextCursor instances can still reference it.
Found during termination of sw/qa/unoapi soffice.bin run under Valgrind/memcheck.
diff --git a/sw/inc/index.hxx b/sw/inc/index.hxx
index 551e31d..2a3a792 100644
--- a/sw/inc/index.hxx
+++ b/sw/inc/index.hxx
@@ -29,6 +29,8 @@
#define _INDEX_HXX
#include <limits.h>
+
+#include "rtl/instance.hxx"
#include <tools/solar.h>
#include <tools/rtti.hxx> // for RTTI of SwIndexReg
#include <tools/string.hxx> // for xub_StrLen
@@ -117,12 +119,6 @@ class SwIndexReg
const SwIndex *pFirst, *pLast, *pMiddle;
- // A global array for holding indices that need to be "swapped" temporarily
- // or do not know a valid array (SwPaM/SwPosition!).
- friend void _InitCore();
- friend void _FinitCore();
- static SwIndexReg* pEmptyIndexArray;
-
protected:
virtual void Update( SwIndex const & rPos, const xub_StrLen nChangeLen,
const bool bNegative = false, const bool bDelete = false );
@@ -142,6 +138,10 @@ public:
void MoveTo( SwIndexReg& rArr );
};
+// A global array for holding indices that need to be "swapped" temporarily or
+// do not know a valid array (SwPaM/SwPosition!):
+struct EmptyIndexArray: rtl::Static< SwIndexReg, EmptyIndexArray > {};
+
#if !defined(OSL_DEBUG_LEVEL) || OSL_DEBUG_LEVEL < 2
inline xub_StrLen SwIndex::operator++()
diff --git a/sw/source/core/bastyp/index.cxx b/sw/source/core/bastyp/index.cxx
index 84db722..bff5760 100644
--- a/sw/source/core/bastyp/index.cxx
+++ b/sw/source/core/bastyp/index.cxx
@@ -48,7 +48,7 @@ SwIndex::SwIndex(SwIndexReg *const pArr, xub_StrLen const nIdx)
{
if( !pArray )
{
- pArray = SwIndexReg::pEmptyIndexArray;
+ pArray = &EmptyIndexArray::get();
nIndex = 0; // steht immer auf 0 !!!
}
@@ -225,7 +225,7 @@ SwIndex& SwIndex::Assign( SwIndexReg* pArr, xub_StrLen nIdx )
{
if( !pArr )
{
- pArr = SwIndexReg::pEmptyIndexArray;
+ pArr = &EmptyIndexArray::get();
nIdx = 0; // steht immer auf 0 !!!
}
diff --git a/sw/source/core/bastyp/init.cxx b/sw/source/core/bastyp/init.cxx
index 1e3e5dc..72e6ec4 100644
--- a/sw/source/core/bastyp/init.cxx
+++ b/sw/source/core/bastyp/init.cxx
@@ -430,7 +430,6 @@ sal_uInt16* SwAttrPool::pVersionMap4 = 0;
// #i18732#
sal_uInt16* SwAttrPool::pVersionMap5 = 0;
sal_uInt16* SwAttrPool::pVersionMap6 = 0;
-SwIndexReg* SwIndexReg::pEmptyIndexArray = 0;
const sal_Char* pMarkToTable = "table";
const sal_Char* pMarkToFrame = "frame";
@@ -725,8 +724,6 @@ void _InitCore()
SwSelPaintRects::pMapMode = new MapMode;
SwFntObj::pPixMap = new MapMode;
- SwIndexReg::pEmptyIndexArray = new SwIndexReg;
-
pGlobalOLEExcludeList = new SvPtrarr;
const SvxSwAutoFmtFlags& rAFlags = SvxAutoCorrCfg::Get().GetAutoCorrect()->GetSwFlags();
@@ -813,7 +810,6 @@ void _FinitCore()
::ClearFEShellTabCols();
- delete SwIndexReg::pEmptyIndexArray;
delete[] SwAttrPool::pVersionMap1;
delete[] SwAttrPool::pVersionMap2;
delete[] SwAttrPool::pVersionMap3;
diff --git a/sw/source/core/crsr/crsrsh.cxx b/sw/source/core/crsr/crsrsh.cxx
index 6278e62..8a8cd4e 100644
--- a/sw/source/core/crsr/crsrsh.cxx
+++ b/sw/source/core/crsr/crsrsh.cxx
@@ -3164,7 +3164,7 @@ const SwStartNode* lcl_NodeContext( const SwNode& rNode )
bool lcl_PosOk(const SwPosition & aPos)
{
return NULL != aPos.nNode.GetNode().GetCntntNode() &&
- SwIndexReg::pEmptyIndexArray != aPos.nContent.GetIdxReg();
+ &EmptyIndexArray::get() != aPos.nContent.GetIdxReg();
}
/**
More information about the Libreoffice-commits
mailing list