don't recreate wxLog target from ~wxLog (adaptation of changes in trunk r49587)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@49589 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2007-11-01 20:35:45 +00:00
parent 1c26a14208
commit 645bd39e5d
2 changed files with 16 additions and 7 deletions

View File

@@ -263,8 +263,7 @@ protected:
virtual void DoLogString(const wxChar *szString, time_t t);
// log a line containing the number of times the previous message was
// repeated
// returns: the number
// repeated and returns this number (which can be 0)
static unsigned DoLogNumberOfRepeats();
private:
@@ -294,6 +293,11 @@ private:
static wxTraceMask ms_ulTraceMask; // controls wxLogTrace behaviour
static wxArrayString ms_aTraceMasks; // more powerful filter for wxLogTrace
// this is the replacement of DoLogNumberOfRepeats() (which has to be kept
// to avoid breaking ABI in this version)
unsigned LogLastRepetitionCountIfNeeded();
};
// ----------------------------------------------------------------------------

View File

@@ -285,12 +285,17 @@ wxCRIT_SECT_DECLARE(gs_prevCS);
/* static */
unsigned wxLog::DoLogNumberOfRepeats()
{
wxLog * const pLogger = GetActiveTarget();
return pLogger ? pLogger->LogLastRepetitionCountIfNeeded() : 0u;
}
unsigned wxLog::LogLastRepetitionCountIfNeeded()
{
wxCRIT_SECT_LOCKER(lock, gs_prevCS);
long retval = ms_prevCounter;
wxLog *pLogger = GetActiveTarget();
if ( pLogger && ms_prevCounter > 0 )
if ( ms_prevCounter > 0 )
{
wxString msg;
#if wxUSE_INTL
@@ -303,14 +308,14 @@ unsigned wxLog::DoLogNumberOfRepeats()
#endif
ms_prevCounter = 0;
ms_prevString.clear();
pLogger->DoLog(ms_prevLevel, msg.c_str(), ms_prevTimeStamp);
DoLog(ms_prevLevel, msg.c_str(), ms_prevTimeStamp);
}
return retval;
}
wxLog::~wxLog()
{
wxLog::DoLogNumberOfRepeats();
LogLastRepetitionCountIfNeeded();
}
/* static */
@@ -334,7 +339,7 @@ void wxLog::OnLog(wxLogLevel level, const wxChar *szString, time_t t)
return;
}
DoLogNumberOfRepeats();
pLogger->LogLastRepetitionCountIfNeeded();
// reset repetition counter for a new message
ms_prevString = szString;