Kaydet (Commit) 1fd5509a authored tarafından Stephan Bergmann's avatar Stephan Bergmann

Replace GetAppData(SHL_ERR) with an rtl::Static

Change-Id: I3932afa803ceb6429d4e5cf63af59131307d5c6e
üst 99769c53
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
// 7 (SHL_SV) removed // 7 (SHL_SV) removed
// 8 (SHL_SVT) removed // 8 (SHL_SVT) removed
#define SHL_SVDDE 9 #define SHL_SVDDE 9
#define SHL_ERR 10 // 10 (SHL_ERR) removed
//11 (SHL_IPC) removed //11 (SHL_IPC) removed
//12 (SHL_SVX) removed //12 (SHL_SVX) removed
//13 (SHL_ITEM) removed //13 (SHL_ITEM) removed
......
...@@ -18,7 +18,6 @@ ...@@ -18,7 +18,6 @@
*/ */
#include <limits.h> #include <limits.h>
#include <tools/shl.hxx>
#include <tools/debug.hxx> #include <tools/debug.hxx>
#include <tools/errinf.hxx> #include <tools/errinf.hxx>
#include <rtl/strbuf.hxx> #include <rtl/strbuf.hxx>
...@@ -42,10 +41,10 @@ public: ...@@ -42,10 +41,10 @@ public:
DynamicErrorInfo *ppDcr[ERRCODE_DYNAMIC_COUNT]; DynamicErrorInfo *ppDcr[ERRCODE_DYNAMIC_COUNT];
sal_uInt16 nNextDcr; sal_uInt16 nNextDcr;
EDcrData(); EDcrData();
static EDcrData *GetData();
}; };
struct TheEDcrData: public rtl::Static<EDcrData, TheEDcrData> {};
class EDcr_Impl class EDcr_Impl
{ {
sal_uIntPtr lErrId; sal_uIntPtr lErrId;
...@@ -70,40 +69,27 @@ EDcrData::EDcrData() ...@@ -70,40 +69,27 @@ EDcrData::EDcrData()
ppDcr[n]=0; ppDcr[n]=0;
} }
EDcrData *EDcrData::GetData()
{
EDcrData **ppDat=reinterpret_cast<EDcrData **>(GetAppData(SHL_ERR));
if(!*ppDat)
{
return (*ppDat=new EDcrData);
}
else
return *ppDat;
}
void EDcr_Impl::RegisterEDcr(DynamicErrorInfo *pDcr) void EDcr_Impl::RegisterEDcr(DynamicErrorInfo *pDcr)
{ {
// Register dynamic identifier // Register dynamic identifier
EDcrData* pData=EDcrData::GetData(); EDcrData& pData=TheEDcrData::get();
lErrId= (((sal_uIntPtr)pData->nNextDcr + 1) << ERRCODE_DYNAMIC_SHIFT) + lErrId= (((sal_uIntPtr)pData.nNextDcr + 1) << ERRCODE_DYNAMIC_SHIFT) +
pDcr->GetErrorCode(); pDcr->GetErrorCode();
DynamicErrorInfo **ppDcr=pData->ppDcr; DynamicErrorInfo **ppDcr=pData.ppDcr;
sal_uInt16 nNext=pData->nNextDcr; sal_uInt16 nNext=pData.nNextDcr;
if(ppDcr[nNext]) if(ppDcr[nNext])
{ {
delete ppDcr[nNext]; delete ppDcr[nNext];
} }
ppDcr[nNext]=pDcr; ppDcr[nNext]=pDcr;
if(++pData->nNextDcr>=ERRCODE_DYNAMIC_COUNT) if(++pData.nNextDcr>=ERRCODE_DYNAMIC_COUNT)
pData->nNextDcr=0; pData.nNextDcr=0;
} }
void EDcr_Impl::UnRegisterEDcr(DynamicErrorInfo *pDcr) void EDcr_Impl::UnRegisterEDcr(DynamicErrorInfo *pDcr)
{ {
DynamicErrorInfo **ppDcr=TheEDcrData::get().ppDcr;
EDcrData* pData=EDcrData::GetData();
DynamicErrorInfo **ppDcr=pData->ppDcr;
sal_uIntPtr lIdx=( sal_uIntPtr lIdx=(
((sal_uIntPtr)(*pDcr) & ERRCODE_DYNAMIC_MASK)>>ERRCODE_DYNAMIC_SHIFT)-1; ((sal_uIntPtr)(*pDcr) & ERRCODE_DYNAMIC_MASK)>>ERRCODE_DYNAMIC_SHIFT)-1;
DBG_ASSERT(ppDcr[lIdx]==pDcr,"ErrHdl: Error nicht gefunden"); DBG_ASSERT(ppDcr[lIdx]==pDcr,"ErrHdl: Error nicht gefunden");
...@@ -147,7 +133,7 @@ DynamicErrorInfo::~DynamicErrorInfo() ...@@ -147,7 +133,7 @@ DynamicErrorInfo::~DynamicErrorInfo()
ErrorInfo* EDcr_Impl::GetDynamicErrorInfo(sal_uIntPtr lId) ErrorInfo* EDcr_Impl::GetDynamicErrorInfo(sal_uIntPtr lId)
{ {
sal_uIntPtr lIdx=((lId & ERRCODE_DYNAMIC_MASK)>>ERRCODE_DYNAMIC_SHIFT)-1; sal_uIntPtr lIdx=((lId & ERRCODE_DYNAMIC_MASK)>>ERRCODE_DYNAMIC_SHIFT)-1;
DynamicErrorInfo* pDcr=EDcrData::GetData()->ppDcr[lIdx]; DynamicErrorInfo* pDcr=TheEDcrData::get().ppDcr[lIdx];
if(pDcr && (sal_uIntPtr)(*pDcr)==lId) if(pDcr && (sal_uIntPtr)(*pDcr)==lId)
return pDcr; return pDcr;
else else
...@@ -192,8 +178,7 @@ struct ErrorContextImpl ...@@ -192,8 +178,7 @@ struct ErrorContextImpl
ErrorContext::ErrorContext(vcl::Window *pWinP) ErrorContext::ErrorContext(vcl::Window *pWinP)
{ {
pImpl = new ErrorContextImpl(); pImpl = new ErrorContextImpl();
EDcrData *pData=EDcrData::GetData(); ErrorContext *&pHdl = TheEDcrData::get().pFirstCtx;
ErrorContext *&pHdl = pData->pFirstCtx;
pImpl->pWin = pWinP; pImpl->pWin = pWinP;
pImpl->pNext = pHdl; pImpl->pNext = pHdl;
pHdl = this; pHdl = this;
...@@ -201,7 +186,7 @@ ErrorContext::ErrorContext(vcl::Window *pWinP) ...@@ -201,7 +186,7 @@ ErrorContext::ErrorContext(vcl::Window *pWinP)
ErrorContext::~ErrorContext() ErrorContext::~ErrorContext()
{ {
ErrorContext **ppCtx=&(EDcrData::GetData()->pFirstCtx); ErrorContext **ppCtx=&(TheEDcrData::get().pFirstCtx);
while(*ppCtx && *ppCtx!=this) while(*ppCtx && *ppCtx!=this)
ppCtx=&((*ppCtx)->pImpl->pNext); ppCtx=&((*ppCtx)->pImpl->pNext);
if(*ppCtx) if(*ppCtx)
...@@ -211,23 +196,23 @@ ErrorContext::~ErrorContext() ...@@ -211,23 +196,23 @@ ErrorContext::~ErrorContext()
ErrorContext *ErrorContext::GetContext() ErrorContext *ErrorContext::GetContext()
{ {
return EDcrData::GetData()->pFirstCtx; return TheEDcrData::get().pFirstCtx;
} }
ErrorHandler::ErrorHandler() ErrorHandler::ErrorHandler()
{ {
pImpl=new ErrHdl_Impl; pImpl=new ErrHdl_Impl;
EDcrData *pData=EDcrData::GetData(); EDcrData &pData=TheEDcrData::get();
ErrorHandler *&pHdl=pData->pFirstHdl; ErrorHandler *&pHdl=pData.pFirstHdl;
pImpl->pNext=pHdl; pImpl->pNext=pHdl;
pHdl=this; pHdl=this;
if(!pData->pDsp) if(!pData.pDsp)
RegisterDisplay(&aDspFunc); RegisterDisplay(&aDspFunc);
} }
ErrorHandler::~ErrorHandler() ErrorHandler::~ErrorHandler()
{ {
ErrorHandler **ppHdl=&(EDcrData::GetData()->pFirstHdl); ErrorHandler **ppHdl=&(TheEDcrData::get().pFirstHdl);
while(*ppHdl && *ppHdl!=this) while(*ppHdl && *ppHdl!=this)
ppHdl=&((*ppHdl)->pImpl->pNext); ppHdl=&((*ppHdl)->pImpl->pNext);
if(*ppHdl) if(*ppHdl)
...@@ -242,16 +227,16 @@ vcl::Window* ErrorContext::GetParent() ...@@ -242,16 +227,16 @@ vcl::Window* ErrorContext::GetParent()
void ErrorHandler::RegisterDisplay(WindowDisplayErrorFunc *aDsp) void ErrorHandler::RegisterDisplay(WindowDisplayErrorFunc *aDsp)
{ {
EDcrData *pData=EDcrData::GetData(); EDcrData &pData=TheEDcrData::get();
pData->bIsWindowDsp=true; pData.bIsWindowDsp=true;
pData->pDsp = reinterpret_cast< DisplayFnPtr >(aDsp); pData.pDsp = reinterpret_cast< DisplayFnPtr >(aDsp);
} }
void ErrorHandler::RegisterDisplay(BasicDisplayErrorFunc *aDsp) void ErrorHandler::RegisterDisplay(BasicDisplayErrorFunc *aDsp)
{ {
EDcrData *pData=EDcrData::GetData(); EDcrData &pData=TheEDcrData::get();
pData->bIsWindowDsp=false; pData.bIsWindowDsp=false;
pData->pDsp = reinterpret_cast< DisplayFnPtr >(aDsp); pData.pDsp = reinterpret_cast< DisplayFnPtr >(aDsp);
} }
/** Handles an error. /** Handles an error.
...@@ -279,7 +264,7 @@ sal_uInt16 ErrorHandler::HandleError_Impl( ...@@ -279,7 +264,7 @@ sal_uInt16 ErrorHandler::HandleError_Impl(
OUString aAction; OUString aAction;
if(!lId || lId == ERRCODE_ABORT) if(!lId || lId == ERRCODE_ABORT)
return 0; return 0;
EDcrData *pData=EDcrData::GetData(); EDcrData &pData=TheEDcrData::get();
ErrorInfo *pInfo=ErrorInfo::GetErrorInfo(lId); ErrorInfo *pInfo=ErrorInfo::GetErrorInfo(lId);
ErrorContext *pCtx=ErrorContext::GetContext(); ErrorContext *pCtx=ErrorContext::GetContext();
if(pCtx) if(pCtx)
...@@ -308,7 +293,7 @@ sal_uInt16 ErrorHandler::HandleError_Impl( ...@@ -308,7 +293,7 @@ sal_uInt16 ErrorHandler::HandleError_Impl(
nErrFlags = nDynFlags; nErrFlags = nDynFlags;
} }
if(ErrHdl_Impl::CreateString(pData->pFirstHdl,pInfo,aErr,nErrFlags)) if(ErrHdl_Impl::CreateString(pData.pFirstHdl,pInfo,aErr,nErrFlags))
{ {
if (bJustCreateString) if (bJustCreateString)
{ {
...@@ -317,7 +302,7 @@ sal_uInt16 ErrorHandler::HandleError_Impl( ...@@ -317,7 +302,7 @@ sal_uInt16 ErrorHandler::HandleError_Impl(
} }
else else
{ {
if(!pData->pDsp) if(!pData.pDsp)
{ {
OStringBuffer aStr("Action: "); OStringBuffer aStr("Action: ");
aStr.append(OUStringToOString(aAction, RTL_TEXTENCODING_ASCII_US)); aStr.append(OUStringToOString(aAction, RTL_TEXTENCODING_ASCII_US));
...@@ -328,16 +313,16 @@ sal_uInt16 ErrorHandler::HandleError_Impl( ...@@ -328,16 +313,16 @@ sal_uInt16 ErrorHandler::HandleError_Impl(
else else
{ {
delete pInfo; delete pInfo;
if(!pData->bIsWindowDsp) if(!pData.bIsWindowDsp)
{ {
(*reinterpret_cast<BasicDisplayErrorFunc*>(pData->pDsp))(aErr,aAction); (*reinterpret_cast<BasicDisplayErrorFunc*>(pData.pDsp))(aErr,aAction);
return 0; return 0;
} }
else else
{ {
if (nFlags != USHRT_MAX) if (nFlags != USHRT_MAX)
nErrFlags = nFlags; nErrFlags = nFlags;
return (*reinterpret_cast<WindowDisplayErrorFunc*>(pData->pDsp))( return (*reinterpret_cast<WindowDisplayErrorFunc*>(pData.pDsp))(
pParent, nErrFlags, aErr, aAction); pParent, nErrFlags, aErr, aAction);
} }
} }
......
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