summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2011-09-19 23:33:09 +0200
committerStephan Bergmann <sbergman@redhat.com>2011-09-19 23:33:09 +0200
commite1945ba903faa567d90addaf13a0eb8a2f688d15 (patch)
treeb0c90468cc0951d4b5eab025067b64d2dfa0bd2c /sw
parent79fdb70baf70aeb492437ef85de7f02ad4234f21 (diff)
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.
Diffstat (limited to 'sw')
-rw-r--r--sw/inc/index.hxx12
-rw-r--r--sw/source/core/bastyp/index.cxx4
-rw-r--r--sw/source/core/bastyp/init.cxx4
-rw-r--r--sw/source/core/crsr/crsrsh.cxx2
4 files changed, 9 insertions, 13 deletions
diff --git a/sw/inc/index.hxx b/sw/inc/index.hxx
index 551e31df3af8..2a3a79231712 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 84db722b15c2..bff5760ca3f7 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 1e3e5dc7d2e1..72e6ec4f92fd 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 6278e620a865..8a8cd4ef75c8 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();
}
/**