Kaydet (Commit) f22006dc authored tarafından Luboš Luňák's avatar Luboš Luňák

fix stupid over-optimization

There's so little to be gained by storing pointers to simple
or refcounted types instead of using an instance. At least
SwTxtNode::GetMinMaxSize() and SwTxtNode::GetScalingOfSelectedText()
pass string temporaries to SwDrawTextInfo, so keeping a pointer
is clearly broken, and MSVC manages to optimize the code enough
to crash because of this. As all the pointers point to const references
and are accesses using const references as well, there shouldn't
be any harm in making a copy.
This fixes smoketest crash on Windows.

Change-Id: I7d7cb42e175a2e64fe9c84c98c0d0204a0c25c13
üst a43cc9ec
...@@ -42,12 +42,12 @@ class SwDrawTextInfo ...@@ -42,12 +42,12 @@ class SwDrawTextInfo
OutputDevice* pOut; OutputDevice* pOut;
ViewShell* pSh; ViewShell* pSh;
const SwScriptInfo* pScriptInfo; const SwScriptInfo* pScriptInfo;
const Point* pPos; Point pPos;
const OUString* pText; OUString pText;
const SwWrongList* pWrong; const SwWrongList* pWrong;
const SwWrongList* pGrammarCheck; const SwWrongList* pGrammarCheck;
const SwWrongList* pSmartTags; const SwWrongList* pSmartTags;
const Size* pSize; Size pSize;
SwFont *pFnt; SwFont *pFnt;
SwUnderlineFont* pUnderFnt; SwUnderlineFont* pUnderFnt;
xub_StrLen* pHyphPos; xub_StrLen* pHyphPos;
...@@ -111,7 +111,7 @@ public: ...@@ -111,7 +111,7 @@ public:
pSh = pS; pSh = pS;
pOut = &rO; pOut = &rO;
pScriptInfo = pSI; pScriptInfo = pSI;
pText = &rSt; pText = rSt;
nIdx = nI; nIdx = nI;
nLen = nL; nLen = nL;
nKern = 0; nKern = 0;
...@@ -129,11 +129,9 @@ public: ...@@ -129,11 +129,9 @@ public:
// These values are initialized but have to be set explicitly via their // These values are initialized but have to be set explicitly via their
// Set-function before they may be accessed by their Get-function: // Set-function before they may be accessed by their Get-function:
pPos = 0;
pWrong = 0; pWrong = 0;
pGrammarCheck = 0; pGrammarCheck = 0;
pSmartTags = 0; pSmartTags = 0;
pSize = 0;
pFnt = 0; pFnt = 0;
pHyphPos = 0; pHyphPos = 0;
nLeft = 0; nLeft = 0;
...@@ -192,7 +190,7 @@ public: ...@@ -192,7 +190,7 @@ public:
#ifdef DBG_UTIL #ifdef DBG_UTIL
OSL_ENSURE( m_bPos, "DrawTextInfo: Undefined Position" ); OSL_ENSURE( m_bPos, "DrawTextInfo: Undefined Position" );
#endif #endif
return *pPos; return pPos;
} }
xub_StrLen *GetHyphPos() const xub_StrLen *GetHyphPos() const
...@@ -205,7 +203,7 @@ public: ...@@ -205,7 +203,7 @@ public:
const OUString &GetText() const const OUString &GetText() const
{ {
return *pText; return pText;
} }
const SwWrongList* GetWrong() const const SwWrongList* GetWrong() const
...@@ -234,7 +232,7 @@ public: ...@@ -234,7 +232,7 @@ public:
#ifdef DBG_UTIL #ifdef DBG_UTIL
OSL_ENSURE( m_bSize, "DrawTextInfo: Undefined Size" ); OSL_ENSURE( m_bSize, "DrawTextInfo: Undefined Size" );
#endif #endif
return *pSize; return pSize;
} }
SwFont* GetFont() const SwFont* GetFont() const
...@@ -402,7 +400,7 @@ public: ...@@ -402,7 +400,7 @@ public:
void SetPos( const Point &rNew ) void SetPos( const Point &rNew )
{ {
pPos = &rNew; pPos = rNew;
#ifdef DBG_UTIL #ifdef DBG_UTIL
m_bPos = true; m_bPos = true;
#endif #endif
...@@ -418,7 +416,7 @@ public: ...@@ -418,7 +416,7 @@ public:
void SetText( const OUString &rNew ) void SetText( const OUString &rNew )
{ {
pText = &rNew; pText = rNew;
} }
void SetWrong( const SwWrongList* pNew ) void SetWrong( const SwWrongList* pNew )
...@@ -444,7 +442,7 @@ public: ...@@ -444,7 +442,7 @@ public:
void SetSize( const Size &rNew ) void SetSize( const Size &rNew )
{ {
pSize = &rNew; pSize = rNew;
#ifdef DBG_UTIL #ifdef DBG_UTIL
m_bSize = true; m_bSize = true;
#endif #endif
......
...@@ -1163,17 +1163,17 @@ void SwDrawTextInfo::Shift( sal_uInt16 nDir ) ...@@ -1163,17 +1163,17 @@ void SwDrawTextInfo::Shift( sal_uInt16 nDir )
switch ( nDir ) switch ( nDir )
{ {
case 0 : case 0 :
((Point*)pPos)->X() += GetSize().Width(); pPos.X() += GetSize().Width();
break; break;
case 900 : case 900 :
OSL_ENSURE( ((Point*)pPos)->Y() >= GetSize().Width(), "Going underground" ); OSL_ENSURE( pPos.Y() >= GetSize().Width(), "Going underground" );
((Point*)pPos)->Y() -= GetSize().Width(); pPos.Y() -= GetSize().Width();
break; break;
case 1800 : case 1800 :
((Point*)pPos)->X() -= GetSize().Width(); pPos.X() -= GetSize().Width();
break; break;
case 2700 : case 2700 :
((Point*)pPos)->Y() += GetSize().Width(); pPos.Y() += GetSize().Width();
break; break;
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment