diff --git a/include/wx/msw/msvcrt.h b/include/wx/msw/msvcrt.h index c1413a7571..7e1e3204aa 100644 --- a/include/wx/msw/msvcrt.h +++ b/include/wx/msw/msvcrt.h @@ -14,7 +14,8 @@ // used like this: // wxCrtSetDbgFlag(_CRTDBG_LEAK_CHECK_DF); // to turn on memory leak checks for programs compiled with Microsoft Visual -// C++ (5.0+). The macro will expand to nothing under other compilers. +// C++ (5.0+). The macro will not be defined under other compilers or if it +// can't be used with MSVC for whatever reason. #ifndef _MSW_MSVCRT_H_ #define _MSW_MSVCRT_H_ @@ -22,7 +23,7 @@ // use debug CRT functions for memory leak detections in VC++ 5.0+ in debug // builds #undef wxUSE_VC_CRTDBG -#if defined(__WXDEBUG__) && defined(__VISUALC__) && (__VISUALC__ >= 1000) \ +#if defined(_DEBUG) && defined(__VISUALC__) && (__VISUALC__ >= 1000) \ && !defined(UNDER_CE) // it doesn't combine well with wxWin own memory debugging methods #if !wxUSE_GLOBAL_MEMORY_OPERATORS && !wxUSE_MEMORY_TRACING && !defined(__NO_VC_CRTDBG__) @@ -31,11 +32,6 @@ #endif #ifdef wxUSE_VC_CRTDBG - // VC++ uses this macro as debug/release mode indicator - #ifndef _DEBUG - #define _DEBUG - #endif - // Need to undef new if including crtdbg.h which may redefine new itself #ifdef new #undef new diff --git a/src/cocoa/display.mm b/src/cocoa/display.mm index b9135addd5..af4c6266c4 100644 --- a/src/cocoa/display.mm +++ b/src/cocoa/display.mm @@ -76,12 +76,8 @@ protected: unsigned wxDisplayFactoryMacOSX::GetCount() { CGDisplayCount count; -#ifdef __WXDEBUG__ - CGDisplayErr err = -#endif - CGGetActiveDisplayList(0, NULL, &count); - - wxASSERT(err == CGDisplayNoErr); + CGDisplayErr err = CGGetActiveDisplayList(0, NULL, &count); + wxCHECK_MSG( err != CGDisplayNoErr, 0, "CGGetActiveDisplayList() failed" ); return count; } @@ -126,12 +122,9 @@ wxDisplayImpl *wxDisplayFactoryMacOSX::CreateDisplay(unsigned n) CGDisplayCount theCount = GetCount(); CGDirectDisplayID* theIDs = new CGDirectDisplayID[theCount]; -#ifdef __WXDEBUG__ - CGDisplayErr err = -#endif - CGGetActiveDisplayList(theCount, theIDs, &theCount); + CGDisplayErr err = CGGetActiveDisplayList(theCount, theIDs, &theCount); + wxCHECK_MSG( err != CGDisplayNoErr, NULL, "CGGetActiveDisplayList() failed" ); - wxASSERT( err == CGDisplayNoErr ); wxASSERT( n < theCount ); wxDisplayImplMacOSX *display = new wxDisplayImplMacOSX(n, theIDs[n]); diff --git a/src/common/cmdline.cpp b/src/common/cmdline.cpp index ce169ac95b..b1521082b6 100644 --- a/src/common/cmdline.cpp +++ b/src/common/cmdline.cpp @@ -74,7 +74,6 @@ struct wxCmdLineOption int fl) { // wxCMD_LINE_USAGE_TEXT uses only description, shortName and longName is empty - #ifdef __WXDEBUG__ if ( k != wxCMD_LINE_USAGE_TEXT ) { wxASSERT_MSG @@ -95,8 +94,6 @@ struct wxCmdLineOption wxT("Long option contains invalid characters") ); } - #endif // __WXDEBUG__ - kind = k; @@ -450,7 +447,7 @@ void wxCmdLineParser::AddParam(const wxString& desc, { // do some consistency checks: a required parameter can't follow an // optional one and nothing should follow a parameter with MULTIPLE flag -#ifdef __WXDEBUG__ +#if wxDEBUG_LEVEL if ( !m_data->m_paramDesc.IsEmpty() ) { wxCmdLineParam& param = m_data->m_paramDesc.Last(); @@ -464,7 +461,7 @@ void wxCmdLineParser::AddParam(const wxString& desc, _T("a required parameter can't follow an optional one") ); } } -#endif // Debug +#endif // wxDEBUG_LEVEL wxCmdLineParam *param = new wxCmdLineParam(desc, type, flags); diff --git a/src/common/datetime.cpp b/src/common/datetime.cpp index 164cc5b705..3889adfdc5 100644 --- a/src/common/datetime.cpp +++ b/src/common/datetime.cpp @@ -308,14 +308,15 @@ static const long MILLISECONDS_PER_DAY = 86400000l; // (i.e. JDN(Jan 1, 1970) = 2440587.5) static const long EPOCH_JDN = 2440587l; -// used only in asserts -#ifdef __WXDEBUG__ +// these values are only used in asserts so don't define them if asserts are +// disabled to avoid warnings about unused static variables +#if wxDEBUG_LEVEL // the date of JDN -0.5 (as we don't work with fractional parts, this is the // reference date for us) is Nov 24, 4714BC static const int JDN_0_YEAR = -4713; static const int JDN_0_MONTH = wxDateTime::Nov; static const int JDN_0_DAY = 24; -#endif // __WXDEBUG__ +#endif // wxDEBUG_LEVEL // the constants used for JDN calculations static const long JDN_OFFSET = 32046l; @@ -350,8 +351,8 @@ wxDateTime::Country wxDateTime::ms_country = wxDateTime::Country_Unknown; // private functions // ---------------------------------------------------------------------------- -// debugger helper: shows what the date really is -#ifdef __WXDEBUG__ +// debugger helper: this function can be called from a debugger to show what +// the date really is extern const char *wxDumpDate(const wxDateTime* dt) { static char buf[128]; @@ -363,7 +364,6 @@ extern const char *wxDumpDate(const wxDateTime* dt) return buf; } -#endif // Debug // get the number of days in the given month of the given year static inline diff --git a/src/common/filename.cpp b/src/common/filename.cpp index 618fdac037..7db00dc4a9 100644 --- a/src/common/filename.cpp +++ b/src/common/filename.cpp @@ -472,9 +472,8 @@ void wxFileName::Assign(const wxString& fullpathOrig, wxString volume, path, name, ext; bool hasExt; - // do some consistency checks in debug mode: the name should be really just - // the filename and the path should be really just a path -#ifdef __WXDEBUG__ + // do some consistency checks: the name should be really just the filename + // and the path should be really just a path wxString volDummy, pathDummy, nameDummy, extDummy; SplitPath(fullname, &volDummy, &pathDummy, &name, &ext, &hasExt, format); @@ -487,12 +486,6 @@ void wxFileName::Assign(const wxString& fullpathOrig, wxASSERT_MSG( nameDummy.empty() && extDummy.empty(), _T("the path shouldn't contain file name nor extension") ); -#else // !__WXDEBUG__ - SplitPath(fullname, NULL /* no volume */, NULL /* no path */, - &name, &ext, &hasExt, format); - SplitPath(fullpath, &volume, &path, NULL, NULL, format); -#endif // __WXDEBUG__/!__WXDEBUG__ - Assign(volume, path, name, ext, hasExt, format); } diff --git a/src/common/fontcmn.cpp b/src/common/fontcmn.cpp index 67ee5bff64..cd65471ef3 100644 --- a/src/common/fontcmn.cpp +++ b/src/common/fontcmn.cpp @@ -45,6 +45,32 @@ #include "wx/tokenzr.h" +// debugger helper: this function can be called from a debugger to show what +// the date really is +extern const char *wxDumpFont(const wxFont *font) +{ + static char buf[256]; + + const wxFontWeight weight = font->GetWeight(); + + wxString s; + s.Printf(wxS("%s-%s-%s-%d-%d"), + font->GetFaceName(), + weight == wxFONTWEIGHT_NORMAL + ? _T("normal") + : weight == wxFONTWEIGHT_BOLD + ? _T("bold") + : _T("light"), + font->GetStyle() == wxFONTSTYLE_NORMAL + ? _T("regular") + : _T("italic"), + font->GetPointSize(), + font->GetEncoding()); + + wxStrlcpy(buf, s, WXSIZEOF(buf)); + return buf; +} + // ============================================================================ // implementation // ============================================================================ diff --git a/src/common/ftp.cpp b/src/common/ftp.cpp index 9b1cd2513b..235a29d3db 100644 --- a/src/common/ftp.cpp +++ b/src/common/ftp.cpp @@ -245,7 +245,6 @@ char wxFTP::SendCommand(const wxString& command) return 0; } -#ifdef __WXDEBUG__ // don't show the passwords in the logs (even in debug ones) wxString cmd, password; if ( command.Upper().StartsWith(_T("PASS "), &password) ) @@ -258,7 +257,6 @@ char wxFTP::SendCommand(const wxString& command) } LogRequest(cmd); -#endif // __WXDEBUG__ m_lastError = wxPROTO_NOERR; return GetResult(); diff --git a/src/common/init.cpp b/src/common/init.cpp index 7af0af2157..a183c256f2 100644 --- a/src/common/init.cpp +++ b/src/common/init.cpp @@ -37,20 +37,22 @@ #include "wx/scopedptr.h" #include "wx/except.h" -#if defined(__WXMSW__) && defined(__WXDEBUG__) +#if defined(__WXMSW__) #include "wx/msw/msvcrt.h" - static struct EnableMemLeakChecking - { - EnableMemLeakChecking() + #ifdef wxCrtSetDbgFlag + static struct EnableMemLeakChecking { - // do check for memory leaks on program exit (another useful flag - // is _CRTDBG_DELAY_FREE_MEM_DF which doesn't free deallocated - // memory which may be used to simulate low-memory condition) - wxCrtSetDbgFlag(_CRTDBG_LEAK_CHECK_DF); - } - } gs_enableLeakChecks; -#endif // __WXMSW__ && __WXDEBUG__ + EnableMemLeakChecking() + { + // check for memory leaks on program exit (another useful flag + // is _CRTDBG_DELAY_FREE_MEM_DF which doesn't free deallocated + // memory which may be used to simulate low-memory condition) + wxCrtSetDbgFlag(_CRTDBG_LEAK_CHECK_DF); + } + } gs_enableLeakChecks; + #endif // wxCrtSetDbgFlag +#endif // __WXMSW__ // ---------------------------------------------------------------------------- // private classes diff --git a/src/common/intl.cpp b/src/common/intl.cpp index 657273a324..023d7cf2ac 100644 --- a/src/common/intl.cpp +++ b/src/common/intl.cpp @@ -105,34 +105,6 @@ static const size_t LEN_FULL = LEN_LANG + 1 + LEN_SUBLANG; // 1 for '_' // global functions // ---------------------------------------------------------------------------- -#ifdef __WXDEBUG__ - -// small class to suppress the translation erros until exit from current scope -class NoTransErr -{ -public: - NoTransErr() { ms_suppressCount++; } - ~NoTransErr() { ms_suppressCount--; } - - static bool Suppress() { return ms_suppressCount > 0; } - -private: - static size_t ms_suppressCount; -}; - -size_t NoTransErr::ms_suppressCount = 0; - -#else // !Debug - -class NoTransErr -{ -public: - NoTransErr() { } -~NoTransErr() { } -}; - -#endif // Debug/!Debug - static wxLocale *wxSetLocale(wxLocale *pLocale); namespace @@ -1210,16 +1182,8 @@ bool wxMsgCatalogFile::Load(const wxString& szDirPrefix, const wxString& szName, << GetFullSearchPath(ExtractLang(szDirPrefix)); } - // don't give translation errors here because the wxstd catalog might - // not yet be loaded (and it's normal) - // - // (we're using an object because we have several return paths) - - NoTransErr noTransErr; - wxLogVerbose(_("looking for catalog '%s' in path '%s'."), - szName, searchPath.c_str()); - wxLogTrace(TRACE_I18N, wxS("Looking for \"%s.mo\" in \"%s\""), - szName, searchPath.c_str()); + wxLogTrace(TRACE_I18N, wxS("Looking for \"%s.mo\" in search path \"%s\""), + szName, searchPath); wxFileName fn(szName); fn.SetExt(wxS("mo")); @@ -2442,18 +2406,11 @@ const wxString& wxLocale::GetString(const wxString& origString, if ( trans == NULL ) { -#ifdef __WXDEBUG__ - if ( !NoTransErr::Suppress() ) - { - NoTransErr noTransErr; - - wxLogTrace(TRACE_I18N, - wxS("string \"%s\"[%ld] not found in %slocale '%s'."), - origString, (long)n, - wxString::Format(wxS("domain '%s' "), domain).c_str(), - m_strLocale.c_str()); - } -#endif // __WXDEBUG__ + wxLogTrace(TRACE_I18N, + wxS("string \"%s\"[%ld] not found in %slocale '%s'."), + origString, (long)n, + wxString::Format(wxS("domain '%s' "), domain).c_str(), + m_strLocale.c_str()); if (n == size_t(-1)) return GetUntranslatedString(origString); diff --git a/src/common/memory.cpp b/src/common/memory.cpp index 993b39a7a9..c55af4d9bc 100644 --- a/src/common/memory.cpp +++ b/src/common/memory.cpp @@ -16,7 +16,7 @@ #pragma hdrstop #endif -#if (defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING) || wxUSE_DEBUG_CONTEXT +#if wxUSE_MEMORY_TRACING || wxUSE_DEBUG_CONTEXT #include "wx/memory.h" @@ -46,7 +46,7 @@ #include #include -#if wxUSE_THREADS && defined(__WXDEBUG__) +#if wxUSE_THREADS #define USE_THREADSAFE_MEMORY_ALLOCATION 1 #else #define USE_THREADSAFE_MEMORY_ALLOCATION 0 @@ -575,18 +575,13 @@ void wxDebugContext::TraverseList (PmSFV func, wxMemStruct *from) */ bool wxDebugContext::PrintList (void) { -#ifdef __WXDEBUG__ TraverseList ((PmSFV)&wxMemStruct::PrintNode, (checkPoint ? checkPoint->m_next : NULL)); return true; -#else - return false; -#endif } bool wxDebugContext::Dump(void) { -#ifdef __WXDEBUG__ { const wxChar* appName = wxT("application"); wxString appNameStr; @@ -608,12 +603,8 @@ bool wxDebugContext::Dump(void) OutputDumpLine(wxEmptyString); return true; -#else - return false; -#endif } -#ifdef __WXDEBUG__ struct wxDebugStatsStruct { long instanceCount; @@ -638,11 +629,9 @@ static wxDebugStatsStruct *InsertStatsStruct(wxDebugStatsStruct *head, wxDebugSt st->next = head; return st; } -#endif bool wxDebugContext::PrintStatistics(bool detailed) { -#ifdef __WXDEBUG__ { const wxChar* appName = wxT("application"); wxString appNameStr; @@ -729,10 +718,6 @@ bool wxDebugContext::PrintStatistics(bool detailed) OutputDumpLine(wxEmptyString); return true; -#else - (void)detailed; - return false; -#endif } bool wxDebugContext::PrintClasses(void) @@ -902,7 +887,6 @@ static MemoryCriticalSection memLocker; #endif // USE_THREADSAFE_MEMORY_ALLOCATION -#ifdef __WXDEBUG__ #if !(defined(__WXMSW__) && (defined(WXUSINGDLL) || defined(WXMAKINGDLL_BASE))) #if wxUSE_GLOBAL_MEMORY_OPERATORS void * operator new (size_t size, wxChar * fileName, int lineNum) @@ -1049,8 +1033,6 @@ void wxDebugFree(void * buf, bool WXUNUSED(isVect) ) free((char *)st); } -#endif // __WXDEBUG__ - // Trace: send output to the current debugging stream void wxTrace(const wxChar * ...) { @@ -1167,4 +1149,4 @@ void wxDebugContextDumpDelayCounter::DoDump() // least one cleanup counter object static wxDebugContextDumpDelayCounter wxDebugContextDumpDelayCounter_One; -#endif // (defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING) || wxUSE_DEBUG_CONTEXT +#endif // wxUSE_MEMORY_TRACING || wxUSE_DEBUG_CONTEXT diff --git a/src/common/object.cpp b/src/common/object.cpp index c6e4f241a8..e04a3e4f3d 100644 --- a/src/common/object.cpp +++ b/src/common/object.cpp @@ -26,14 +26,14 @@ #include -#if defined(__WXDEBUG__) || wxUSE_DEBUG_CONTEXT +#if wxUSE_DEBUG_CONTEXT #if defined(__VISAGECPP__) #define DEBUG_PRINTF(NAME) { static int raz=0; \ printf( #NAME " %i\n",raz); fflush(stdout); raz++; } #else #define DEBUG_PRINTF(NAME) #endif -#endif // __WXDEBUG__ || wxUSE_DEBUG_CONTEXT +#endif // wxUSE_DEBUG_CONTEXT // we must disable optimizations for VC.NET because otherwise its too eager // linker discards wxClassInfo objects in release build thus breaking many, @@ -103,7 +103,7 @@ bool wxObject::IsKindOf(const wxClassInfo *info) const return (thisInfo) ? thisInfo->IsKindOf(info) : false ; } -#if defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING && defined( new ) +#if wxUSE_MEMORY_TRACING && defined( new ) #undef new #endif @@ -225,11 +225,11 @@ void wxClassInfo::Register() sm_classTable = classTable; } -#ifdef __WXDEBUG__ +#if wxDEBUG_LEVEL // reentrance guard - see note above static int entry = 0; wxASSERT_MSG(++entry == 1, _T("wxClassInfo::Register() reentrance")); -#endif +#endif // wxDEBUG_LEVEL // Using IMPLEMENT_DYNAMIC_CLASS() macro twice (which may happen if you // link any object module twice mistakenly, or link twice against wx shared @@ -246,9 +246,9 @@ void wxClassInfo::Register() sm_classTable->Put(m_className, (wxObject *)this); -#ifdef __WXDEBUG__ +#if wxDEBUG_LEVEL --entry; -#endif +#endif // wxDEBUG_LEVEL } void wxClassInfo::Unregister() @@ -266,7 +266,7 @@ void wxClassInfo::Unregister() wxObject *wxCreateDynamicObject(const wxString& name) { -#if defined(__WXDEBUG__) || wxUSE_DEBUG_CONTEXT +#if wxUSE_DEBUG_CONTEXT DEBUG_PRINTF(wxObject *wxCreateDynamicObject) #endif @@ -338,7 +338,7 @@ void wxObjectRefData::DecRef() void wxObject::Ref(const wxObject& clone) { -#if defined(__WXDEBUG__) || wxUSE_DEBUG_CONTEXT +#if wxUSE_DEBUG_CONTEXT DEBUG_PRINTF(wxObject::Ref) #endif diff --git a/src/common/sizer.cpp b/src/common/sizer.cpp index a4c17f8b8c..6e4fbcb376 100644 --- a/src/common/sizer.cpp +++ b/src/common/sizer.cpp @@ -1813,7 +1813,7 @@ DoAdjustForGrowables(int delta, void wxFlexGridSizer::AdjustForGrowables(const wxSize& sz) { -#ifdef __WXDEBUG__ +#if wxDEBUG_LEVEL // by the time this function is called, the sizer should be already fully // initialized and hence the number of its columns and rows is known and we // can check that all indices in m_growableCols/Rows are valid (see also @@ -1841,7 +1841,7 @@ void wxFlexGridSizer::AdjustForGrowables(const wxSize& sz) } } } -#endif // __WXDEBUG__ +#endif // wxDEBUG_LEVEL if ( (m_flexDirection & wxHORIZONTAL) || (m_growMode != wxFLEX_GROWMODE_NONE) ) diff --git a/src/common/string.cpp b/src/common/string.cpp index ed7a6a8670..f3d684f1a4 100644 --- a/src/common/string.cpp +++ b/src/common/string.cpp @@ -105,7 +105,7 @@ static wxStrCacheInitializer gs_stringCacheInit; // gdb seems to be unable to display thread-local variables correctly, at least // not my 6.4.98 version under amd64, so provide this debugging helper to do it -#ifdef __WXDEBUG__ +#if wxDEBUG_LEVEL >= 2 struct wxStrCacheDumper { @@ -130,7 +130,7 @@ struct wxStrCacheDumper void wxDumpStrCache() { wxStrCacheDumper::ShowAll(); } -#endif // __WXDEBUG__ +#endif // wxDEBUG_LEVEL >= 2 #ifdef wxPROFILE_STRING_CACHE diff --git a/src/common/stringops.cpp b/src/common/stringops.cpp index d51cce4b68..c69a18774f 100644 --- a/src/common/stringops.cpp +++ b/src/common/stringops.cpp @@ -272,7 +272,7 @@ wxStringOperationsUtf8::DecodeNonAsciiChar(wxStringImpl::const_iterator i) // mask to extract lead byte's value ('x' bits above), by sequence's length: static const unsigned char s_leadValueMask[4] = { 0x7F, 0x1F, 0x0F, 0x07 }; -#ifdef __WXDEBUG__ +#if wxDEBUG_LEVEL // mask and value of lead byte's most significant bits, by length: static const unsigned char s_leadMarkerMask[4] = { 0x80, 0xE0, 0xF0, 0xF8 }; static const unsigned char s_leadMarkerVal[4] = { 0x00, 0xC0, 0xE0, 0xF0 }; diff --git a/src/common/valtext.cpp b/src/common/valtext.cpp index 59a7eaa6bb..56998ee14c 100644 --- a/src/common/valtext.cpp +++ b/src/common/valtext.cpp @@ -76,7 +76,7 @@ void wxTextValidator::SetStyle(long style) { m_validatorStyle = style; -#ifdef __WXDEBUG__ +#if wxDEBUG_LEVEL int check; check = (int)HasFlag(wxFILTER_ALPHA) + (int)HasFlag(wxFILTER_ALPHANUMERIC) + (int)HasFlag(wxFILTER_DIGITS) + (int)HasFlag(wxFILTER_NUMERIC); @@ -93,7 +93,7 @@ void wxTextValidator::SetStyle(long style) (int)HasFlag(wxFILTER_EXCLUDE_LIST) + (int)HasFlag(wxFILTER_EXCLUDE_CHAR_LIST); wxASSERT_MSG(check <= 1, "Using both an include/exclude list may lead to unexpected results"); -#endif +#endif // wxDEBUG_LEVEL } bool wxTextValidator::Copy(const wxTextValidator& val) diff --git a/src/common/wincmn.cpp b/src/common/wincmn.cpp index 2413ca4fa5..31bac26e06 100644 --- a/src/common/wincmn.cpp +++ b/src/common/wincmn.cpp @@ -1152,19 +1152,22 @@ void wxWindowBase::PushEventHandler(wxEvtHandler *handlerToPush) SetEventHandler(handlerToPush); -#ifdef __WXDEBUG__ +#if wxDEBUG_LEVEL // final checks of the operations done above: wxASSERT_MSG( handlerToPush->GetPreviousHandler() == NULL, - "the first handler of the wxWindow stack should have no previous handlers set" ); + "the first handler of the wxWindow stack should " + "have no previous handlers set" ); wxASSERT_MSG( handlerToPush->GetNextHandler() != NULL, - "the first handler of the wxWindow stack should have non-NULL next handler" ); + "the first handler of the wxWindow stack should " + "have non-NULL next handler" ); wxEvtHandler* pLast = handlerToPush; - while (pLast && pLast != this) + while ( pLast && pLast != this ) pLast = pLast->GetNextHandler(); wxASSERT_MSG( pLast->GetNextHandler() == NULL, - "the last handler of the wxWindow stack should have this window as next handler" ); -#endif + "the last handler of the wxWindow stack should " + "have this window as next handler" ); +#endif // wxDEBUG_LEVEL } wxEvtHandler *wxWindowBase::PopEventHandler(bool deleteHandler) diff --git a/src/common/zipstrm.cpp b/src/common/zipstrm.cpp index a3af2d6246..e353d41986 100644 --- a/src/common/zipstrm.cpp +++ b/src/common/zipstrm.cpp @@ -125,7 +125,7 @@ static inline wxUint16 CrackUint16(const char *m) // static wxFileOffset QuietSeek(wxInputStream& stream, wxFileOffset pos) { -#if defined(__WXDEBUG__) && wxUSE_LOG +#if wxUSE_LOG wxLogLevel level = wxLog::GetLogLevel(); wxLog::SetLogLevel(wxLOG_Debug - 1); wxFileOffset result = stream.SeekI(pos); diff --git a/src/dfb/nonownedwnd.cpp b/src/dfb/nonownedwnd.cpp index c455d5e4ff..2c4809aee1 100644 --- a/src/dfb/nonownedwnd.cpp +++ b/src/dfb/nonownedwnd.cpp @@ -301,16 +301,12 @@ void wxNonOwnedWindow::HandleQueuedPaintRequests() // blit the entire back buffer to front soon m_isPainting = true; -#ifdef __WXDEBUG__ int requestsCount = 0; -#endif wxRect request; while ( m_toPaint->GetNext(request) ) { -#ifdef __WXDEBUG__ requestsCount++; -#endif wxRect clipped(request); clipped.Intersect(winRect); if ( clipped.IsEmpty() ) diff --git a/src/generic/wizard.cpp b/src/generic/wizard.cpp index da9fb73754..1ad3a17c6f 100644 --- a/src/generic/wizard.cpp +++ b/src/generic/wizard.cpp @@ -214,11 +214,6 @@ wxSize wxWizardSizer::CalcMin() wxSize wxWizardSizer::GetMaxChildSize() { -#if !defined(__WXDEBUG__) - if ( m_childSize.IsFullySpecified() ) - return m_childSize; -#endif - wxSize maxOfMin; for ( wxSizerItemList::compatibility_iterator childNode = m_children.GetFirst(); @@ -230,21 +225,6 @@ wxSize wxWizardSizer::GetMaxChildSize() maxOfMin.IncTo(SiblingSize(child)); } - // No longer applicable since we may change sizes when size adaptation is done -#if 0 -#ifdef __WXDEBUG__ - if ( m_childSize.IsFullySpecified() && m_childSize != maxOfMin ) - { - wxFAIL_MSG( _T("Size changed in wxWizard::GetPageAreaSizer()") - _T("after RunWizard().\n") - _T("Did you forget to call GetSizer()->Fit(this) ") - _T("for some page?")) ; - - return m_childSize; - } -#endif // __WXDEBUG__ -#endif - if ( m_owner->m_started ) { m_childSize = maxOfMin; diff --git a/src/gtk/clipbrd.cpp b/src/gtk/clipbrd.cpp index 2938ec3861..538a80e7af 100644 --- a/src/gtk/clipbrd.cpp +++ b/src/gtk/clipbrd.cpp @@ -144,14 +144,12 @@ targets_selection_received( GtkWidget *WXUNUSED(widget), } } -#ifdef __WXDEBUG__ // it's not really a format, of course, but we can reuse its GetId() method // to format this atom as string wxDataFormat clip(selection_data->selection); wxLogTrace( TRACE_CLIPBOARD, wxT("Received available formats for clipboard %s"), clip.GetId().c_str() ); -#endif // __WXDEBUG__ // the atoms we received, holding a list of targets (= formats) const GdkAtom * const atoms = (GdkAtom *)selection_data->data; @@ -283,7 +281,6 @@ selection_handler( GtkWidget *WXUNUSED(widget), wxDataFormat format( selection_data->target ); -#ifdef __WXDEBUG__ wxLogTrace(TRACE_CLIPBOARD, _T("clipboard data in format %s, GtkSelectionData is target=%s type=%s selection=%s timestamp=%u"), format.GetId().c_str(), @@ -292,7 +289,6 @@ selection_handler( GtkWidget *WXUNUSED(widget), wxString::FromAscii(wxGtkString(gdk_atom_name(selection_data->selection))).c_str(), GPOINTER_TO_UINT( signal_data ) ); -#endif // __WXDEBUG__ if ( !data->IsSupportedFormat( format ) ) return; @@ -387,14 +383,12 @@ async_targets_selection_received( GtkWidget *WXUNUSED(widget), } } -#ifdef __WXDEBUG__ // it's not really a format, of course, but we can reuse its GetId() method // to format this atom as string wxDataFormat clip(selection_data->selection); wxLogTrace( TRACE_CLIPBOARD, wxT("Received available formats for clipboard %s"), clip.GetId().c_str() ); -#endif // __WXDEBUG__ // the atoms we received, holding a list of targets (= formats) const GdkAtom * const atoms = (GdkAtom *)selection_data->data; diff --git a/src/gtk/utilsgtk.cpp b/src/gtk/utilsgtk.cpp index deb31eaa8c..73d152d248 100644 --- a/src/gtk/utilsgtk.cpp +++ b/src/gtk/utilsgtk.cpp @@ -26,12 +26,12 @@ #include "wx/gtk/private/timer.h" #include "wx/evtloop.h" -#ifdef __WXDEBUG__ +#if wxDEBUG_LEVEL #include "wx/gtk/assertdlg_gtk.h" #if wxUSE_STACKWALKER #include "wx/stackwalk.h" #endif // wxUSE_STACKWALKER -#endif // __WXDEBUG__ +#endif // wxDEBUG_LEVEL #include #include @@ -328,9 +328,7 @@ void wxGUIAppTraits::SetLocale() } #endif -#ifdef __WXDEBUG__ - -#if wxUSE_STACKWALKER +#if wxDEBUG_LEVEL && wxUSE_STACKWALKER // private helper class class StackDump : public wxStackWalker @@ -379,13 +377,15 @@ extern "C" } } -#endif // wxUSE_STACKWALKER +#endif // wxDEBUG_LEVEL && wxUSE_STACKWALKER bool wxGUIAppTraits::ShowAssertDialog(const wxString& msg) { - // under GTK2 we prefer to use a dialog widget written using directly GTK+; - // in fact we cannot use a dialog written using wxWidgets: it would need - // the wxWidgets idle processing to work correctly! +#if wxDEBUG_LEVEL + // under GTK2 we prefer to use a dialog widget written using directly in + // GTK+ as use a dialog written using wxWidgets would need the wxWidgets + // idle processing to work correctly which might not be the case when + // assert happens GtkWidget *dialog = gtk_assert_dialog_new(); gtk_assert_dialog_set_message(GTK_ASSERT_DIALOG(dialog), msg.mb_str()); @@ -426,10 +426,13 @@ bool wxGUIAppTraits::ShowAssertDialog(const wxString& msg) gtk_widget_destroy(dialog); return returnCode; +#else // !wxDEBUG_LEVEL + // this function is never called in this case + wxUnusedVar(msg); + return false; +#endif // wxDEBUG_LEVEL/!wxDEBUG_LEVEL } -#endif // __WXDEBUG__ - wxString wxGUIAppTraits::GetDesktopEnvironment() const { wxString de = wxSystemOptions::GetOption(_T("gtk.desktop")); diff --git a/src/gtk1/clipbrd.cpp b/src/gtk1/clipbrd.cpp index 9559118fc5..d17158dedd 100644 --- a/src/gtk1/clipbrd.cpp +++ b/src/gtk1/clipbrd.cpp @@ -92,12 +92,10 @@ targets_selection_received( GtkWidget *WXUNUSED(widget), g_free(atom_name); } -#ifdef __WXDEBUG__ wxDataFormat clip( selection_data->selection ); wxLogTrace( TRACE_CLIPBOARD, wxT("selection received for targets, clipboard %s"), clip.GetId().c_str() ); -#endif // __WXDEBUG__ // the atoms we received, holding a list of targets (= formats) GdkAtom *atoms = (GdkAtom *)selection_data->data; @@ -266,7 +264,6 @@ selection_handler( GtkWidget *WXUNUSED(widget), wxDataFormat format( selection_data->target ); -#ifdef __WXDEBUG__ wxLogTrace(TRACE_CLIPBOARD, _T("clipboard data in format %s, GtkSelectionData is target=%s type=%s selection=%s timestamp=%u"), format.GetId().c_str(), @@ -275,7 +272,6 @@ selection_handler( GtkWidget *WXUNUSED(widget), wxString::FromAscii(gdk_atom_name(selection_data->selection)).c_str(), GPOINTER_TO_UINT( signal_data ) ); -#endif if (!data->IsSupportedFormat( format )) return; diff --git a/src/gtk1/font.cpp b/src/gtk1/font.cpp index 8257f5bf64..9bce28f617 100644 --- a/src/gtk1/font.cpp +++ b/src/gtk1/font.cpp @@ -97,26 +97,6 @@ public: // and this one also modifies all the other font data fields void SetNativeFontInfo(const wxNativeFontInfo& info); - // debugger helper: shows what the font really is - // - // VZ: I need this as my gdb either shows wildly wrong values or crashes - // when I ask it to "p fontRefData" :-( -#if defined(__WXDEBUG__) - void Dump() const - { - wxPrintf(_T("%s-%s-%s-%d-%d\n"), - m_faceName.c_str(), - m_weight == wxFONTWEIGHT_NORMAL - ? _T("normal") - : m_weight == wxFONTWEIGHT_BOLD - ? _T("bold") - : _T("light"), - m_style == wxFONTSTYLE_NORMAL ? _T("regular") : _T("italic"), - m_pointSize, - m_encoding); - } -#endif // Debug - protected: // common part of all ctors void Init(int pointSize, diff --git a/src/gtk1/notebook.cpp b/src/gtk1/notebook.cpp index ac4155516d..1b953423e0 100644 --- a/src/gtk1/notebook.cpp +++ b/src/gtk1/notebook.cpp @@ -430,15 +430,13 @@ int wxNotebook::DoSetSelection( size_t page, int flags ) m_selection = page; gtk_notebook_set_page( GTK_NOTEBOOK(m_widget), page ); -#ifdef __WXDEBUG__ - if ( !(flags & SetSelection_SendEvent) ) - { - // gtk_notebook_set_current_page will emit the switch-page signal which will be - // caught by our gtk_notebook_page_change_callback which should have reset the - // flag to false: - wxASSERT(!m_skipNextPageChangeEvent); - } -#endif // __WXDEBUG__ + // gtk_notebook_set_current_page is supposed to emit the switch-page signal + // which should be caught by our gtk_notebook_page_change_callback which + // should have reset the flag to false, check it: + wxASSERT_LEVEL_2( + (flags & SetSelection_SendEvent) || !m_skipNextPageChangeEvent, + "internal error in selection events generation" + ); wxNotebookPage *client = GetPage(page); if ( client ) diff --git a/src/gtk1/window.cpp b/src/gtk1/window.cpp index d9c45bfa80..87a178d91e 100644 --- a/src/gtk1/window.cpp +++ b/src/gtk1/window.cpp @@ -49,7 +49,7 @@ #include "wx/fontutil.h" -#ifdef __WXDEBUG__ +#if wxDEBUG_LEVEL #include "wx/thread.h" #endif @@ -236,16 +236,13 @@ extern bool g_mainThreadLocked; // debug //----------------------------------------------------------------------------- -#ifdef __WXDEBUG__ - #if wxUSE_THREADS -# define DEBUG_MAIN_THREAD if (wxThread::IsMain() && g_mainThreadLocked) printf("gui reentrance"); +# define DEBUG_MAIN_THREAD \ + wxASSERT_MSG( !g_mainThreadLocked || !wxThread::IsMain(), \ + "GUI reentrancy detected" ) #else # define DEBUG_MAIN_THREAD #endif -#else -#define DEBUG_MAIN_THREAD -#endif // Debug // the trace mask used for the focus debugging messages #define TRACE_FOCUS _T("focus") diff --git a/src/mgl/app.cpp b/src/mgl/app.cpp index eaa8a04256..fc87f16acb 100644 --- a/src/mgl/app.cpp +++ b/src/mgl/app.cpp @@ -202,13 +202,12 @@ bool wxApp::OnInitGui() if ( !wxAppBase::OnInitGui() ) return false; -#ifdef __WXDEBUG__ // MGL redirects stdout and stderr to physical console, so lets redirect - // it to file in debug build. Do it only when WXSTDERR environment variable is set + // it to file if WXSTDERR environment variable is set to be able to see + // wxLogDebug() output wxString redirect; if ( wxGetEnv(wxT("WXSTDERR"), &redirect) ) freopen(redirect.mb_str(), "wt", stderr); -#endif // __WXDEBUG__ wxLog *oldLog = wxLog::SetActiveTarget(new wxLogGui); if ( oldLog ) delete oldLog; diff --git a/src/mgl/window.cpp b/src/mgl/window.cpp index ac24d5b5dc..6c2603cc69 100644 --- a/src/mgl/window.cpp +++ b/src/mgl/window.cpp @@ -1139,7 +1139,7 @@ void wxWindowMGL::HandlePaint(MGLDevCtx *dc) return; } -#ifdef __WXDEBUG__ +#if wxDEBUG_LEVEL >= 2 // FIXME_MGL -- debugging stuff, to be removed! static int debugPaintEvents = -1; if ( debugPaintEvents == -1 ) @@ -1150,7 +1150,7 @@ void wxWindowMGL::HandlePaint(MGLDevCtx *dc) dc->fillRect(-1000,-1000,2000,2000); wxMilliSleep(50); } -#endif +#endif // wxDEBUG_LEVEL >= 2 MGLRegion clip; dc->getClipRegion(clip); diff --git a/src/motif/app.cpp b/src/motif/app.cpp index 0a073548e7..5d1c8cad69 100644 --- a/src/motif/app.cpp +++ b/src/motif/app.cpp @@ -68,7 +68,6 @@ wxHashTable *wxWidgetHashTable = NULL; IMPLEMENT_DYNAMIC_CLASS(wxApp, wxEvtHandler) -#ifdef __WXDEBUG__ extern "C" { typedef int (*XErrorHandlerFunc)(Display *, XErrorEvent *); @@ -86,7 +85,6 @@ static int wxXErrorHandler(Display *dpy, XErrorEvent *xevent) } } -#endif // __WXDEBUG__ bool wxApp::Initialize(int& argc_, wxChar **argv_) { @@ -251,10 +249,8 @@ bool wxApp::Initialize(int& argc_, wxChar **argv_) } m_initialDisplay = (WXDisplay*) dpy; -#ifdef __WXDEBUG__ // install the X error handler gs_pfnXErrorHandler = XSetErrorHandler(wxXErrorHandler); -#endif // __WXDEBUG__ // Add general resize proc XtActionsRec rec; diff --git a/src/motif/filedlg.cpp b/src/motif/filedlg.cpp index 974b18b796..004930c565 100644 --- a/src/motif/filedlg.cpp +++ b/src/motif/filedlg.cpp @@ -88,10 +88,9 @@ void wxFileSelOk(Widget WXUNUSED(fs), XtPointer WXUNUSED(client_data), XmFileSel static wxString ParseWildCard( const wxString& wild ) { -#ifdef __WXDEBUG__ - static const wxChar* msg = - _T("Motif file dialog does not understand this ") - _T("wildcard syntax"); +#if wxDEBUG_LEVEL + static const char *msg = + "Motif file dialog does not understand this wildcard syntax"; #endif wxArrayString wildDescriptions, wildFilters; diff --git a/src/motif/utils.cpp b/src/motif/utils.cpp index 4eda0e2f08..4a94ff0734 100644 --- a/src/motif/utils.cpp +++ b/src/motif/utils.cpp @@ -375,7 +375,6 @@ void wxAllocColor(Display *d,Colormap cmp,XColor *xc) } } -#ifdef __WXDEBUG__ wxString wxGetXEventName(XEvent& event) { #if wxUSE_NANOX @@ -401,7 +400,6 @@ wxString wxGetXEventName(XEvent& event) return str; #endif } -#endif // ---------------------------------------------------------------------------- // accelerators diff --git a/src/msw/calctrl.cpp b/src/msw/calctrl.cpp index dc18f88615..842efa50c6 100644 --- a/src/msw/calctrl.cpp +++ b/src/msw/calctrl.cpp @@ -230,7 +230,7 @@ bool wxCalendarCtrl::SetDate(const wxDateTime& dt) wxDateTime wxCalendarCtrl::GetDate() const { -#ifdef __WXDEBUG__ +#if wxDEBUG_LEVEL SYSTEMTIME st; if ( !MonthCal_GetCurSel(GetHwnd(), &st) ) { @@ -242,7 +242,7 @@ wxDateTime wxCalendarCtrl::GetDate() const wxDateTime dt(st); wxASSERT_MSG( dt == m_date, "mismatch between data and control" ); -#endif // __WXDEBUG__ +#endif // wxDEBUG_LEVEL return m_date; } diff --git a/src/msw/clipbrd.cpp b/src/msw/clipbrd.cpp index 2369d769fb..b9df0c2767 100644 --- a/src/msw/clipbrd.cpp +++ b/src/msw/clipbrd.cpp @@ -770,7 +770,7 @@ bool wxClipboard::GetData( wxDataObject& data ) // enumerate all explicit formats on the clipboard. // note that this does not include implicit / synthetic (automatically // converted) formats. -#ifdef __WXDEBUG__ +#if wxDEBUG_LEVEL >= 2 // get the format enumerator IEnumFORMATETC *pEnumFormatEtc = NULL; hr = pDataObject->EnumFormatEtc(DATADIR_GET, &pEnumFormatEtc); @@ -803,7 +803,7 @@ bool wxClipboard::GetData( wxDataObject& data ) pEnumFormatEtc->Release(); } -#endif // Debug +#endif // wxDEBUG_LEVEL >= 2 STGMEDIUM medium; // stop at the first valid format found on the clipboard diff --git a/src/msw/control.cpp b/src/msw/control.cpp index b3e4f5b2ec..06d75a9921 100644 --- a/src/msw/control.cpp +++ b/src/msw/control.cpp @@ -143,13 +143,11 @@ bool wxControl::MSWCreateControl(const wxChar *classname, if ( !m_hWnd ) { -#ifdef __WXDEBUG__ wxLogLastError(wxString::Format ( _T("CreateWindowEx(\"%s\", flags=%08lx, ex=%08lx)"), classname, style, exstyle )); -#endif // __WXDEBUG__ return false; } diff --git a/src/msw/datectrl.cpp b/src/msw/datectrl.cpp index 1009211b4d..176d095f7c 100644 --- a/src/msw/datectrl.cpp +++ b/src/msw/datectrl.cpp @@ -205,7 +205,7 @@ void wxDatePickerCtrl::SetValue(const wxDateTime& dt) wxDateTime wxDatePickerCtrl::GetValue() const { -#ifdef __WXDEBUG__ +#if wxDEBUG_LEVEL wxDateTime dt; SYSTEMTIME st; if ( DateTime_GetSystemtime(GetHwnd(), &st) == GDT_VALID ) @@ -216,7 +216,7 @@ wxDateTime wxDatePickerCtrl::GetValue() const wxASSERT_MSG( m_date.IsValid() == dt.IsValid() && (!dt.IsValid() || dt == m_date), _T("bug in wxDatePickerCtrl: m_date not in sync") ); -#endif // __WXDEBUG__ +#endif // wxDEBUG_LEVEL return m_date; } diff --git a/src/msw/dc.cpp b/src/msw/dc.cpp index b47befb24e..55724274f7 100644 --- a/src/msw/dc.cpp +++ b/src/msw/dc.cpp @@ -457,12 +457,10 @@ void wxMSWDCImpl::SelectOldObjects(WXHDC dc) if (m_oldBitmap) { ::SelectObject((HDC) dc, (HBITMAP) m_oldBitmap); -#ifdef __WXDEBUG__ if (m_selectedBitmap.IsOk()) { m_selectedBitmap.SetSelectedInto(NULL); } -#endif } m_oldBitmap = 0; if (m_oldPen) diff --git a/src/msw/dcclient.cpp b/src/msw/dcclient.cpp index 7adb608854..50ec2dca2a 100644 --- a/src/msw/dcclient.cpp +++ b/src/msw/dcclient.cpp @@ -223,7 +223,7 @@ wxPaintDCImpl::wxPaintDCImpl( wxDC *owner, wxWindow *window ) : return; } -#endif // __WXDEBUG__ +#endif // wxHAS_PAINT_DEBUG m_window = window; diff --git a/src/msw/dcmemory.cpp b/src/msw/dcmemory.cpp index 6869e6f4e4..d399b5157b 100644 --- a/src/msw/dcmemory.cpp +++ b/src/msw/dcmemory.cpp @@ -106,9 +106,7 @@ void wxMemoryDCImpl::DoSelect( const wxBitmap& bitmap ) ::SelectObject(GetHdc(), (HBITMAP) m_oldBitmap); if ( m_selectedBitmap.Ok() ) { -#ifdef __WXDEBUG__ m_selectedBitmap.SetSelectedInto(NULL); -#endif m_selectedBitmap = wxNullBitmap; } } @@ -123,9 +121,7 @@ void wxMemoryDCImpl::DoSelect( const wxBitmap& bitmap ) if ( !hBmp ) return; -#ifdef __WXDEBUG__ m_selectedBitmap.SetSelectedInto(GetOwner()); -#endif hBmp = (WXHBITMAP)::SelectObject(GetHdc(), (HBITMAP)hBmp); if ( !hBmp ) diff --git a/src/msw/dialup.cpp b/src/msw/dialup.cpp index 66a5a034fa..da0e96c243 100644 --- a/src/msw/dialup.cpp +++ b/src/msw/dialup.cpp @@ -1269,7 +1269,6 @@ static DWORD wxRasMonitorThread(wxRasThreadData *data) // fall through case WAIT_FAILED: -#ifdef __WXDEBUG__ // using wxLogLastError() from here is dangerous: we risk to // deadlock the main thread if wxLog sends output to GUI DWORD err = GetLastError(); @@ -1280,7 +1279,6 @@ static DWORD wxRasMonitorThread(wxRasThreadData *data) err, wxSysErrorMsg(err) ); -#endif // __WXDEBUG__ // no sense in continuing, who knows if the handles we're // waiting for even exist yet... diff --git a/src/msw/fontdlg.cpp b/src/msw/fontdlg.cpp index 51a5bd1b2b..86156c2f37 100644 --- a/src/msw/fontdlg.cpp +++ b/src/msw/fontdlg.cpp @@ -112,17 +112,12 @@ int wxFontDialog::ShowModal() } else { - // common dialog failed - why? -#ifdef __WXDEBUG__ DWORD dwErr = CommDlgExtendedError(); if ( dwErr != 0 ) { - // this msg is only for developers - wxLogError(wxT("Common dialog failed with error code %0lx."), - dwErr); + wxLogError(_("Common dialog failed with error code %0lx."), dwErr); } //else: it was just cancelled -#endif return wxID_CANCEL; } diff --git a/src/msw/listctrl.cpp b/src/msw/listctrl.cpp index b102317312..46e271ddff 100644 --- a/src/msw/listctrl.cpp +++ b/src/msw/listctrl.cpp @@ -402,15 +402,15 @@ WXDWORD wxListCtrl::MSWGetStyle(long style, WXDWORD *exstyle) const wstyle |= LVS_SHAREIMAGELISTS | LVS_SHOWSELALWAYS; -#ifdef __WXDEBUG__ +#if wxDEBUG_LEVEL size_t nModes = 0; #define MAP_MODE_STYLE(wx, ms) \ if ( style & (wx) ) { wstyle |= (ms); nModes++; } -#else // !__WXDEBUG__ +#else // !wxDEBUG_LEVEL #define MAP_MODE_STYLE(wx, ms) \ if ( style & (wx) ) wstyle |= (ms); -#endif // __WXDEBUG__ +#endif // wxDEBUG_LEVEL/!wxDEBUG_LEVEL MAP_MODE_STYLE(wxLC_ICON, LVS_ICON) MAP_MODE_STYLE(wxLC_SMALL_ICON, LVS_SMALLICON) diff --git a/src/msw/mdi.cpp b/src/msw/mdi.cpp index aa931d6eaf..1e9255d92d 100644 --- a/src/msw/mdi.cpp +++ b/src/msw/mdi.cpp @@ -1424,11 +1424,9 @@ void MDISetMenu(wxWindow *win, HMENU hmenuFrame, HMENU hmenuWindow) (WPARAM)hmenuFrame, (LPARAM)hmenuWindow) ) { -#ifdef __WXDEBUG__ DWORD err = ::GetLastError(); if ( err ) wxLogApiError(_T("SendMessage(WM_MDISETMENU)"), err); -#endif // __WXDEBUG__ } } diff --git a/src/msw/mediactrl.cpp b/src/msw/mediactrl.cpp index 17954f4054..d45c50056c 100644 --- a/src/msw/mediactrl.cpp +++ b/src/msw/mediactrl.cpp @@ -1480,7 +1480,7 @@ public: wxTimer* m_pTimer; wxSize m_bestSize; -#ifdef __WXDEBUG__ +#if wxDEBUG_LEVEL wxDynamicLibrary m_dllQuartz; LPAMGETERRORTEXT m_lpAMGetErrorText; wxString GetErrorString(HRESULT hrdsv); @@ -1942,7 +1942,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxAMMediaBackend, wxMediaBackend) //--------------------------------------------------------------------------- // Usual debugging macros //--------------------------------------------------------------------------- -#ifdef __WXDEBUG__ +#if wxDEBUG_LEVEL #define MAX_ERROR_TEXT_LEN 160 // Get the error string for Active Movie @@ -2213,7 +2213,7 @@ bool wxAMMediaBackend::CreateControl(wxControl* ctrl, wxWindow* parent, { // First get the AMGetErrorText procedure in // debug mode for more meaningful messages -#ifdef __WXDEBUG__ +#if wxDEBUG_LEVEL if ( m_dllQuartz.Load(_T("quartz.dll"), wxDL_VERBATIM) ) { m_lpAMGetErrorText = (LPAMGETERRORTEXT) @@ -2778,7 +2778,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxMCIMediaBackend, wxMediaBackend) // Usual debugging macros for MCI returns //--------------------------------------------------------------------------- -#ifdef __WXDEBUG__ +#if wxDEBUG_LEVEL #define wxMCIVERIFY(arg) \ { \ DWORD nRet; \ diff --git a/src/msw/mediactrl_am.cpp b/src/msw/mediactrl_am.cpp index c73fc1c38d..3088d51ab9 100644 --- a/src/msw/mediactrl_am.cpp +++ b/src/msw/mediactrl_am.cpp @@ -1478,11 +1478,12 @@ public: #endif wxSize m_bestSize; // Cached size -#ifdef __WXDEBUG__ // Stuff for getting useful debugging strings + // Stuff for getting useful debugging strings +#if wxDEBUG_LEVEL wxDynamicLibrary m_dllQuartz; LPAMGETERRORTEXT m_lpAMGetErrorText; wxString GetErrorString(HRESULT hrdsv); -#endif // __WXDEBUG__ +#endif // wxDEBUG_LEVEL wxEvtHandler* m_evthandler; friend class wxAMMediaEvtHandler; @@ -1527,7 +1528,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxAMMediaBackend, wxMediaBackend) //--------------------------------------------------------------------------- // Usual debugging macros //--------------------------------------------------------------------------- -#ifdef __WXDEBUG__ +#if wxDEBUG_LEVEL #define MAX_ERROR_TEXT_LEN 160 // Get the error string for Active Movie @@ -1614,13 +1615,13 @@ bool wxAMMediaBackend::CreateControl(wxControl* ctrl, wxWindow* parent, { // First get the AMGetErrorText procedure in debug // mode for more meaningful messages -#ifdef __WXDEBUG__ +#if wxDEBUG_LEVEL if ( m_dllQuartz.Load(_T("quartz.dll"), wxDL_VERBATIM) ) { m_lpAMGetErrorText = (LPAMGETERRORTEXT) m_dllQuartz.GetSymbolAorW(wxT("AMGetErrorText")); } -#endif // __WXDEBUG__ +#endif // wxDEBUG_LEVEL diff --git a/src/msw/ole/activex.cpp b/src/msw/ole/activex.cpp index e64423522d..22a97cc03b 100644 --- a/src/msw/ole/activex.cpp +++ b/src/msw/ole/activex.cpp @@ -904,13 +904,9 @@ wxActiveXContainer::~wxActiveXContainer() } // VZ: we might want to really report an error instead of just asserting here -#ifdef __WXDEBUG__ - #define CHECK_HR(hr) \ - wxASSERT_MSG( SUCCEEDED(hr), \ +#define CHECK_HR(hr) \ + wxASSERT_LEVEL_2_MSG( SUCCEEDED(hr), \ wxString::Format("HRESULT = %X", (unsigned)(hr)) ) -#else - #define CHECK_HR(hr) wxUnusedVar(hr) -#endif //--------------------------------------------------------------------------- // wxActiveXContainer::CreateActiveX diff --git a/src/msw/ole/dataobj.cpp b/src/msw/ole/dataobj.cpp index ba2cb10bc8..07884ba7ed 100644 --- a/src/msw/ole/dataobj.cpp +++ b/src/msw/ole/dataobj.cpp @@ -61,11 +61,11 @@ // functions // ---------------------------------------------------------------------------- -#ifdef __WXDEBUG__ +#if wxDEBUG_LEVEL static const wxChar *GetTymedName(DWORD tymed); -#else // !Debug +#else // !wxDEBUG_LEVEL #define GetTymedName(tymed) wxEmptyString -#endif // Debug/!Debug +#endif // wxDEBUG_LEVEL/!wxDEBUG_LEVEL // ---------------------------------------------------------------------------- // wxIEnumFORMATETC interface implementation @@ -719,7 +719,7 @@ void* wxDataObject::SetSizeInBuffer( void* buffer, size_t size, return p; } -#ifdef __WXDEBUG__ +#if wxDEBUG_LEVEL const wxChar *wxDataObject::GetFormatName(wxDataFormat format) { @@ -764,7 +764,7 @@ const wxChar *wxDataObject::GetFormatName(wxDataFormat format) #endif // VC++ } -#endif // Debug +#endif // wxDEBUG_LEVEL // ---------------------------------------------------------------------------- // wxBitmapDataObject supports CF_DIB format @@ -1264,7 +1264,7 @@ void wxURLDataObject::SetURL(const wxString& url) // private functions // ---------------------------------------------------------------------------- -#ifdef __WXDEBUG__ +#if wxDEBUG_LEVEL static const wxChar *GetTymedName(DWORD tymed) { @@ -1305,12 +1305,10 @@ void wxDataObject::SetAutoDelete() { } -#ifdef __WXDEBUG__ const wxChar *wxDataObject::GetFormatName(wxDataFormat WXUNUSED(format)) { return NULL; } -#endif // __WXDEBUG__ #endif // wxUSE_DATAOBJ diff --git a/src/msw/ole/oleutils.cpp b/src/msw/ole/oleutils.cpp index 94f134a097..3932c8d9ec 100644 --- a/src/msw/ole/oleutils.cpp +++ b/src/msw/ole/oleutils.cpp @@ -130,7 +130,7 @@ wxBasicString::~wxBasicString() // Debug support // ---------------------------------------------------------------------------- -#if defined(__WXDEBUG__) && ( ( defined(__VISUALC__) && (__VISUALC__ > 1000) ) || defined(__MWERKS__) ) +#if wxDEBUG_LEVEL && ( ( defined(__VISUALC__) && (__VISUALC__ > 1000) ) || defined(__MWERKS__) ) static wxString GetIidName(REFIID riid) { // an association between symbolic name and numeric value of an IID @@ -258,31 +258,10 @@ void wxLogRelease(const wxChar *szInterface, ULONG cRef) wxLogTrace(wxTRACE_OleCalls, wxT("After %s::Release: m_cRef = %d"), szInterface, cRef - 1); } -#elif defined(__WXDEBUG__) && defined(__VISUALC__) && (__VISUALC__ <= 1000) +#endif // wxDEBUG_LEVEL -// For VC++ 4 -void wxLogQueryInterface(const char *szInterface, REFIID riid) -{ - wxLogTrace("%s::QueryInterface", szInterface); -} +#endif // wxUSE_DRAG_AND_DROP -void wxLogAddRef(const char *szInterface, ULONG cRef) -{ - wxLogTrace("After %s::AddRef: m_cRef = %d", szInterface, cRef + 1); -} +#endif // __CYGWIN10__ -void wxLogRelease(const char *szInterface, ULONG cRef) -{ - wxLogTrace("After %s::Release: m_cRef = %d", szInterface, cRef - 1); -} - -#endif // __WXDEBUG__ - -#endif - // wxUSE_DRAG_AND_DROP - -#endif - // __CYGWIN10__ - -#endif - // wxUSE_OLE +#endif // wxUSE_OLE diff --git a/src/msw/ole/uuid.cpp b/src/msw/ole/uuid.cpp index 76a9680222..d4079803b4 100644 --- a/src/msw/ole/uuid.cpp +++ b/src/msw/ole/uuid.cpp @@ -20,7 +20,7 @@ #pragma hdrstop #endif -#if wxUSE_OLE && ( wxUSE_DRAG_AND_DROP || (defined(__WXDEBUG__) && wxUSE_DATAOBJ) ) +#if wxUSE_OLE && (wxUSE_DRAG_AND_DROP || wxUSE_DATAOBJ) #ifndef WX_PRECOMP #include "wx/msw/wrapwin.h" diff --git a/src/msw/pen.cpp b/src/msw/pen.cpp index 034a3476e4..5daea9b6cd 100644 --- a/src/msw/pen.cpp +++ b/src/msw/pen.cpp @@ -373,11 +373,9 @@ bool wxPenRefData::Alloc() default: lb.lbStyle = BS_SOLID; -#ifdef __WXDEBUG__ // this should be unnecessary (it's unused) but suppresses the // Purify messages about uninitialized memory read lb.lbHatch = 0; -#endif break; } diff --git a/src/msw/printdlg.cpp b/src/msw/printdlg.cpp index c7bc5edb3e..f2b04942b7 100644 --- a/src/msw/printdlg.cpp +++ b/src/msw/printdlg.cpp @@ -46,7 +46,6 @@ // wxWindowsPrintNativeData //---------------------------------------------------------------------------- -#ifdef __WXDEBUG__ static wxString wxGetPrintDlgError() { DWORD err = CommDlgExtendedError(); @@ -79,7 +78,6 @@ static wxString wxGetPrintDlgError() } return msg; } -#endif // __WXDEBUG__ static HGLOBAL wxCreateDevNames(const wxString& driverName, @@ -366,11 +364,7 @@ bool wxWindowsPrintNativeData::TransferFrom( const wxPrintData &data ) pd.hDevMode = NULL; pd.hDevNames = NULL; -#ifdef __WXDEBUG__ - wxString str(wxT("Printing error: ")); - str += wxGetPrintDlgError(); - wxLogDebug(str); -#endif // __WXDEBUG__ + wxLogDebug(wxT("Printing error: ") + wxGetPrintDlgError()); } else { diff --git a/src/msw/stdpaths.cpp b/src/msw/stdpaths.cpp index 3e928c1462..e8340f1a26 100644 --- a/src/msw/stdpaths.cpp +++ b/src/msw/stdpaths.cpp @@ -250,8 +250,8 @@ wxString wxStandardPaths::GetAppDir() { wxFileName fn(wxGetFullModuleName()); - // allow running the apps directly from build directory in debug builds -#ifdef __WXDEBUG__ + // allow running the apps directly from build directory in MSVC debug builds +#ifdef _DEBUG wxString lastdir; if ( fn.GetDirCount() ) { @@ -260,7 +260,7 @@ wxString wxStandardPaths::GetAppDir() if ( lastdir.Matches(_T("debug*")) || lastdir.Matches(_T("vc*msw*")) ) fn.RemoveLastDir(); } -#endif // __WXDEBUG__ +#endif // _DEBUG return fn.GetPath(); } diff --git a/src/msw/window.cpp b/src/msw/window.cpp index 0378499569..8bd1598490 100644 --- a/src/msw/window.cpp +++ b/src/msw/window.cpp @@ -222,9 +222,9 @@ LRESULT WXDLLEXPORT APIENTRY _EXPORT wxWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); -#ifdef __WXDEBUG__ +#if wxDEBUG_LEVEL >= 2 const wxChar *wxGetMessageName(int message); -#endif //__WXDEBUG__ +#endif // wxDEBUG_LEVEL >= 2 void wxRemoveHandleAssociation(wxWindowMSW *win); extern void wxAssociateWinWithHandle(HWND hWnd, wxWindowMSW *win); @@ -638,13 +638,12 @@ void wxWindowMSW::SetFocus() HWND hWnd = GetHwnd(); wxCHECK_RET( hWnd, _T("can't set focus to invalid window") ); -#if !defined(__WXMICROWIN__) && !defined(__WXWINCE__) +#if !defined(__WXWINCE__) ::SetLastError(0); #endif if ( !::SetFocus(hWnd) ) { -#if defined(__WXDEBUG__) && !defined(__WXMICROWIN__) // was there really an error? DWORD dwRes = ::GetLastError(); if ( dwRes ) @@ -655,7 +654,6 @@ void wxWindowMSW::SetFocus() wxLogApiError(_T("SetFocus"), dwRes); } } -#endif // Debug } } @@ -2655,12 +2653,13 @@ wxWindowCreationHook::~wxWindowCreationHook() // Main window proc LRESULT WXDLLEXPORT APIENTRY _EXPORT wxWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { - // trace all messages - useful for the debugging -#ifdef __WXDEBUG__ + // trace all messages: useful for the debugging but noticeably slows down + // the code so don't do it by default +#if wxDEBUG_LEVEL >= 2 wxLogTrace(wxTraceMessages, wxT("Processing %s(hWnd=%p, wParam=%08lx, lParam=%08lx)"), wxGetMessageName(message), hWnd, (long)wParam, lParam); -#endif // __WXDEBUG__ +#endif // wxDEBUG_LEVEL >= 2 wxWindowMSW *wnd = wxFindWinFromHandle(hWnd); @@ -3512,10 +3511,10 @@ WXLRESULT wxWindowMSW::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM l if ( !processed ) { -#ifdef __WXDEBUG__ +#if wxDEBUG_LEVEL >= 2 wxLogTrace(wxTraceMessages, wxT("Forwarding %s to DefWindowProc."), wxGetMessageName(message)); -#endif // __WXDEBUG__ +#endif // wxDEBUG_LEVEL >= 2 rc.result = MSWDefWindowProc(message, wParam, lParam); } @@ -3539,20 +3538,24 @@ void wxAssociateWinWithHandle(HWND hwnd, wxWindowMSW *win) wxCHECK_RET( hwnd != (HWND)NULL, wxT("attempt to add a NULL hwnd to window list ignored") ); -#ifdef __WXDEBUG__ +#if wxDEBUG_LEVEL WindowHandles::const_iterator i = gs_windowHandles.find(hwnd); if ( i != gs_windowHandles.end() ) { if ( i->second != win ) { - wxLogDebug(wxT("HWND %p already associated with another window (%s)"), - hwnd, win->GetClassInfo()->GetClassName()); + wxFAIL_MSG( + wxString::Format( + wxT("HWND %p already associated with another window (%s)"), + hwnd, win->GetClassInfo()->GetClassName() + ) + ); } //else: this actually happens currently because we associate the window // with its HWND during creation (if we create it) and also when // SubclassWin() is called later, this is ok } -#endif // __WXDEBUG__ +#endif // wxDEBUG_LEVEL gs_windowHandles[hwnd] = (wxWindow *)win; } @@ -6357,7 +6360,7 @@ void wxSetKeyboardHook(bool doIt) #endif // !__WXMICROWIN__ -#ifdef __WXDEBUG__ +#if wxDEBUG_LEVEL > =2 const wxChar *wxGetMessageName(int message) { switch ( message ) @@ -6826,7 +6829,7 @@ const wxChar *wxGetMessageName(int message) return s_szBuf.c_str(); } } -#endif //__WXDEBUG__ +#endif // wxDEBUG_LEVEL >= 2 static TEXTMETRIC wxGetTextMetrics(const wxWindowMSW *win) { diff --git a/src/os2/app.cpp b/src/os2/app.cpp index c60a8ed3d6..e6a8c71e54 100644 --- a/src/os2/app.cpp +++ b/src/os2/app.cpp @@ -235,9 +235,7 @@ bool wxApp::Initialize(int& argc, wxChar **argv) // Some people may wish to use this, but // probably it shouldn't be here by default. -#ifdef __WXDEBUG__ // wxRedirectIOToConsole(); -#endif wxWinHandleHash = new wxWinHashTable(wxKEY_INTEGER, 100); diff --git a/src/os2/control.cpp b/src/os2/control.cpp index 4bbf875564..e490804a2f 100644 --- a/src/os2/control.cpp +++ b/src/os2/control.cpp @@ -147,9 +147,7 @@ bool wxControl::OS2CreateControl( const wxChar* zClassname, if ( !m_hWnd ) { -#ifdef __WXDEBUG__ wxLogError(wxT("Failed to create a control of class '%s'"), zClassname); -#endif // DEBUG return false; } diff --git a/src/os2/dcclient.cpp b/src/os2/dcclient.cpp index 728e34157f..60e225b6b6 100644 --- a/src/os2/dcclient.cpp +++ b/src/os2/dcclient.cpp @@ -314,7 +314,7 @@ wxPaintDCImpl::wxPaintDCImpl( wxDC *owner, wxWindow *pCanvas) : wxFAIL_MSG( wxT("wxPaintDC may be created only in EVT_PAINT handler!") ); return; } -#endif // __WXDEBUG__ +#endif // wxHAS_PAINT_DEBUG m_pCanvas = pCanvas; diff --git a/src/osx/carbon/app.cpp b/src/osx/carbon/app.cpp index b1854d2b76..aca2178127 100644 --- a/src/osx/carbon/app.cpp +++ b/src/osx/carbon/app.cpp @@ -732,7 +732,7 @@ pascal OSStatus wxMacAppEventHandler( EventHandlerCallRef handler , EventRef eve DEFINE_ONE_SHOT_HANDLER_GETTER( wxMacAppEventHandler ) #endif -#if defined( __WXDEBUG__ ) && wxOSX_USE_COCOA_OR_CARBON +#if wxDEBUG_LEVEL && wxOSX_USE_COCOA_OR_CARBON pascal static void wxMacAssertOutputHandler(OSType WXUNUSED(componentSignature), @@ -778,7 +778,7 @@ wxMacAssertOutputHandler(OSType WXUNUSED(componentSignature), #endif } -#endif //__WXDEBUG__ +#endif // wxDEBUG_LEVEL extern "C" void macPostedEventCallback(void *WXUNUSED(unused)) { @@ -789,7 +789,7 @@ bool wxApp::Initialize(int& argc, wxChar **argv) { // Mac-specific -#if defined( __WXDEBUG__ ) && wxOSX_USE_COCOA_OR_CARBON +#if wxDEBUG_LEVEL && wxOSX_USE_COCOA_OR_CARBON InstallDebugAssertOutputHandler( NewDebugAssertOutputHandlerUPP( wxMacAssertOutputHandler ) ); #endif diff --git a/src/osx/carbon/thread.cpp b/src/osx/carbon/thread.cpp index 0aa6d3939c..f4bfdac173 100644 --- a/src/osx/carbon/thread.cpp +++ b/src/osx/carbon/thread.cpp @@ -848,7 +848,6 @@ wxThread::~wxThread() g_numberOfThreads--; -#ifdef __WXDEBUG__ m_critsect.Enter(); // check that the thread either exited or couldn't be created @@ -861,7 +860,6 @@ wxThread::~wxThread() } m_critsect.Leave(); -#endif wxDELETE( m_internal ) ; } diff --git a/src/osx/core/display.cpp b/src/osx/core/display.cpp index 4598f001e9..4160d73acf 100644 --- a/src/osx/core/display.cpp +++ b/src/osx/core/display.cpp @@ -86,12 +86,9 @@ protected: unsigned wxDisplayFactoryMacOSX::GetCount() { CGDisplayCount count; -#ifdef __WXDEBUG__ - CGDisplayErr err = -#endif - CGGetActiveDisplayList(0, NULL, &count); + CGDisplayErr err = CGGetActiveDisplayList(0, NULL, &count); - wxASSERT(err == CGDisplayNoErr); + wxCHECK_MSG( err != CGDisplayNoErr, 0, "CGGetActiveDisplayList() failed" ); return count; } @@ -136,12 +133,9 @@ wxDisplayImpl *wxDisplayFactoryMacOSX::CreateDisplay(unsigned n) CGDisplayCount theCount = GetCount(); CGDirectDisplayID* theIDs = new CGDirectDisplayID[theCount]; -#ifdef __WXDEBUG__ - CGDisplayErr err = -#endif - CGGetActiveDisplayList(theCount, theIDs, &theCount); + CGDisplayErr err = CGGetActiveDisplayList(theCount, theIDs, &theCount); + wxCHECK_MSG( err != CGDisplayNoErr, NULL, "CGGetActiveDisplayList() failed" ); - wxASSERT( err == CGDisplayNoErr ); wxASSERT( n < theCount ); wxDisplayImplMacOSX *display = new wxDisplayImplMacOSX(n, theIDs[n]); diff --git a/src/palmos/dcclient.cpp b/src/palmos/dcclient.cpp index 6a190e5938..a3ff792c66 100644 --- a/src/palmos/dcclient.cpp +++ b/src/palmos/dcclient.cpp @@ -55,22 +55,6 @@ struct WXDLLEXPORT wxPaintDCInfo WX_DEFINE_OBJARRAY(wxArrayDCInfo) -// ---------------------------------------------------------------------------- -// macros -// ---------------------------------------------------------------------------- - -// ---------------------------------------------------------------------------- -// global variables -// ---------------------------------------------------------------------------- - -#ifdef __WXDEBUG__ - // a global variable which we check to verify that wxPaintDC are only - // created in response to WM_PAINT message - doing this from elsewhere is a - // common programming error among wxWidgets programmers and might lead to - // very subtle and difficult to debug refresh/repaint bugs. - int g_isPainting = 0; -#endif // __WXDEBUG__ - // =========================================================================== // implementation // =========================================================================== @@ -192,15 +176,6 @@ wxPaintDCImpl::wxPaintDCImpl( wxDC *owner, wxWindow *window ) : { wxCHECK_RET( window, wxT("NULL canvas in wxPaintDCImpl ctor") ); -#ifdef __WXDEBUG__ - if ( g_isPainting <= 0 ) - { - wxFAIL_MSG( wxT("wxPaintDCImpl may be created only in EVT_PAINT handler!") ); - - return; - } -#endif // __WXDEBUG__ - m_window = window; // do we have a DC for this window in the cache? diff --git a/src/propgrid/property.cpp b/src/propgrid/property.cpp index d670542dfa..dcda1ef198 100644 --- a/src/propgrid/property.cpp +++ b/src/propgrid/property.cpp @@ -959,14 +959,8 @@ bool wxPGProperty::StringToValue( wxVariant& variant, const wxString& text, int int propagatedFlags = argFlags & (wxPG_REPORT_ERROR|wxPG_PROGRAMMATIC_VALUE); -#ifdef __WXDEBUG__ - bool debug_print = false; -#endif - -#ifdef __WXDEBUG__ - if ( debug_print ) - wxLogDebug(wxT(">> %s.StringToValue('%s')"),GetLabel().c_str(),text.c_str()); -#endif + wxLogTrace("propgrid", + wxT(">> %s.StringToValue('%s')"), GetLabel(), text); wxString::const_iterator it = text.begin(); wxUniChar a; @@ -998,11 +992,9 @@ bool wxPGProperty::StringToValue( wxVariant& variant, const wxString& text, int wxVariant variant(child->GetValue()); wxString childName = child->GetBaseName(); - #ifdef __WXDEBUG__ - if ( debug_print ) - wxLogDebug(wxT("token = '%s', child = %s"), - token.c_str(), childName.c_str()); - #endif + wxLogTrace("propgrid", + wxT("token = '%s', child = %s"), + token, childName); // Add only if editable or setting programmatically if ( (argFlags & wxPG_PROGRAMMATIC_VALUE) || @@ -2505,12 +2497,8 @@ IMPLEMENT_DYNAMIC_CLASS(wxPGRootProperty, wxPGProperty) wxPGRootProperty::wxPGRootProperty( const wxString& name ) : wxPGProperty() { -#ifdef __WXDEBUG__ m_name = name; m_label = m_name; -#else - wxUnusedVar(name); -#endif SetParentalType(0); m_depth = 0; } diff --git a/src/propgrid/propgrid.cpp b/src/propgrid/propgrid.cpp index 8c6e80d786..d111896c38 100644 --- a/src/propgrid/propgrid.cpp +++ b/src/propgrid/propgrid.cpp @@ -627,11 +627,10 @@ wxPropertyGrid::~wxPropertyGrid() m_tlp->RemoveEventHandler(handler); delete handler; -#ifdef __WXDEBUG__ - if ( IsEditorsValueModified() ) - ::wxMessageBox(wxS("Most recent change in property editor was lost!!!\n\n(if you don't want this to happen, close your frames and dialogs using Close(false).)"), - wxS("wxPropertyGrid Debug Warning") ); -#endif + wxASSERT_MSG( !IsEditorsValueModified(), + wxS("Most recent change in property editor was lost!!! ") + wxS("(if you don't want this to happen, close your frames ") + wxS("and dialogs using Close(false).)") ); #if wxPG_DOUBLE_BUFFER if ( m_doubleBuffer ) @@ -3749,16 +3748,10 @@ void wxPropertyGrid::RecalculateVirtualSize( int forceXPos ) m_pState->EnsureVirtualHeight(); -#ifdef __WXDEBUG__ - int by1 = m_pState->GetVirtualHeight(); - int by2 = m_pState->GetActualVirtualHeight(); - if ( by1 != by2 ) - { - wxString s = wxString::Format(wxT("VirtualHeight=%i, ActualVirtualHeight=%i, should match!"), by1, by2); - wxFAIL_MSG(s.c_str()); - wxLogDebug(s); - } -#endif + wxASSERT_LEVEL_2_MSG( + m_pState->GetVirtualHeight() == m_pState->GetActualVirtualHeight(), + "VirtualHeight and ActualVirtualHeight should match" + ); m_iFlags |= wxPG_FL_RECALCULATING_VIRTUAL_SIZE; diff --git a/src/propgrid/propgridpagestate.cpp b/src/propgrid/propgridpagestate.cpp index 311507eb3e..91c82e609c 100644 --- a/src/propgrid/propgridpagestate.cpp +++ b/src/propgrid/propgridpagestate.cpp @@ -936,10 +936,6 @@ void wxPropertyGridPageState::CheckColumnWidths( int widthChange ) wxPropertyGrid* pg = GetGrid(); -#ifdef __WXDEBUG__ - const bool debug = false; -#endif - unsigned int i; unsigned int lastColumn = m_colWidths.size() - 1; int width = m_width; @@ -949,10 +945,9 @@ void wxPropertyGridPageState::CheckColumnWidths( int widthChange ) // Column to reduce, if needed. Take last one that exceeds minimum width. int reduceCol = -1; -#ifdef __WXDEBUG__ - if ( debug ) - wxLogDebug(wxT("ColumnWidthCheck (virtualWidth: %i, clientWidth: %i)"), width, clientWidth); -#endif + wxLogTrace("propgrid", + wxS("ColumnWidthCheck (virtualWidth: %i, clientWidth: %i)"), + width, clientWidth); // // Check min sizes @@ -975,10 +970,9 @@ void wxPropertyGridPageState::CheckColumnWidths( int widthChange ) for ( i=0; iHasVirtualWidth(),colsWidth); -#endif + wxLogTrace("propgrid", + wxS(" HasVirtualWidth: %i colsWidth: %i"), + (int)pg->HasVirtualWidth(), colsWidth); // Then mode-based requirement if ( !pg->HasVirtualWidth() ) @@ -989,10 +983,9 @@ void wxPropertyGridPageState::CheckColumnWidths( int widthChange ) if ( colsWidth < width ) { // Increase column -#ifdef __WXDEBUG__ - if ( debug ) - wxLogDebug(wxT(" Adjust last column to %i"), m_colWidths[lastColumn] + widthHigher); -#endif + wxLogTrace("propgrid", + wxS(" Adjust last column to %i"), + m_colWidths[lastColumn] + widthHigher); m_colWidths[lastColumn] = m_colWidths[lastColumn] + widthHigher; } else if ( colsWidth > width ) @@ -1000,10 +993,10 @@ void wxPropertyGridPageState::CheckColumnWidths( int widthChange ) // Reduce column if ( reduceCol != -1 ) { - #ifdef __WXDEBUG__ - if ( debug ) - wxLogDebug(wxT(" Reduce column %i (by %i)"), reduceCol, -widthHigher); - #endif + wxLogTrace("propgrid", + wxT(" Reduce column %i (by %i)"), + reduceCol, -widthHigher); + // Reduce widest column, and recheck m_colWidths[reduceCol] = m_colWidths[reduceCol] + widthHigher; CheckColumnWidths(); @@ -1025,11 +1018,10 @@ void wxPropertyGridPageState::CheckColumnWidths( int widthChange ) pg->RecalculateVirtualSize(); } -#ifdef __WXDEBUG__ - if ( debug ) - for ( i=0; iGetInternalFlags() & wxPG_FL_DONT_CENTER_SPLITTER) && @@ -1424,13 +1416,12 @@ void wxPropertyGridPageState::DoSetPropertyValues( const wxVariantList& list, wx } else { - #ifdef __WXDEBUG__ - if ( wxStrcmp(current->GetType(), p->GetValue().GetType()) != 0) - { - wxLogDebug(wxT("wxPropertyGridPageState::DoSetPropertyValues Warning: Setting value of property \"%s\" from variant"), - p->GetName().c_str()); - } - #endif + wxASSERT_LEVEL_2_MSG( + wxStrcmp(current->GetType(), p->GetValue().GetType()) == 0, + wxString::Format( + wxS("setting value of property \"%s\" from variant"), + p->GetName().c_str()) + ); p->SetValue(*current); } diff --git a/src/richtext/richtextbuffer.cpp b/src/richtext/richtextbuffer.cpp index 5fa710cdad..82c529fa11 100644 --- a/src/richtext/richtextbuffer.cpp +++ b/src/richtext/richtextbuffer.cpp @@ -2854,7 +2854,7 @@ bool wxRichTextParagraphLayoutBox::DoNumberList(const wxRichTextRange& range, co bool withUndo = ((flags & wxRICHTEXT_SETSTYLE_WITH_UNDO) != 0); // bool applyMinimal = ((flags & wxRICHTEXT_SETSTYLE_OPTIMIZE) != 0); -#ifdef __WXDEBUG__ +#if wxDEBUG_LEVEL bool specifyLevel = ((flags & wxRICHTEXT_SETSTYLE_SPECIFY_LEVEL) != 0); #endif diff --git a/src/univ/scrolbar.cpp b/src/univ/scrolbar.cpp index ac0c110b0a..76a087e935 100644 --- a/src/univ/scrolbar.cpp +++ b/src/univ/scrolbar.cpp @@ -40,11 +40,9 @@ #include "wx/univ/inphand.h" #include "wx/univ/theme.h" -#define WXDEBUG_SCROLLBAR - -#ifndef __WXDEBUG__ - #undef WXDEBUG_SCROLLBAR -#endif // !__WXDEBUG__ +#if wxDEBUG_LEVEL >= 2 + #define WXDEBUG_SCROLLBAR +#endif #if defined(WXDEBUG_SCROLLBAR) && defined(__WXMSW__) && !defined(__WXMICROWIN__) #include "wx/msw/private.h" diff --git a/src/univ/textctrl.cpp b/src/univ/textctrl.cpp index bc625f70a7..2edc5b0afe 100644 --- a/src/univ/textctrl.cpp +++ b/src/univ/textctrl.cpp @@ -149,16 +149,13 @@ #include "wx/cmdproc.h" -// turn extra wxTextCtrl-specific debugging on/off -#define WXDEBUG_TEXT +#if wxDEBUG_LEVEL >= 2 + // turn extra wxTextCtrl-specific debugging on/off + #define WXDEBUG_TEXT -// turn wxTextCtrl::Replace() debugging on (slows down code a *lot*!) -#define WXDEBUG_TEXT_REPLACE - -#ifndef __WXDEBUG__ - #undef WXDEBUG_TEXT - #undef WXDEBUG_TEXT_REPLACE -#endif + // turn wxTextCtrl::Replace() debugging on (slows down code a *lot*!) + #define WXDEBUG_TEXT_REPLACE +#endif // wxDEBUG_LEVEL >= 2 // wxStringTokenize only needed for debug checks #ifdef WXDEBUG_TEXT_REPLACE @@ -4765,11 +4762,11 @@ void wxTextCtrl::OnChar(wxKeyEvent& event) } #endif } -#ifdef __WXDEBUG__ +#if wxDEBUG_LEVEL >= 2 // Ctrl-R refreshes the control in debug mode else if ( event.ControlDown() && event.GetKeyCode() == 'r' ) Refresh(); -#endif // __WXDEBUG__ +#endif // wxDEBUG_LEVEL >= 2 event.Skip(); } diff --git a/src/univ/winuniv.cpp b/src/univ/winuniv.cpp index 41b166cc4d..dad230c47b 100644 --- a/src/univ/winuniv.cpp +++ b/src/univ/winuniv.cpp @@ -45,11 +45,9 @@ #include "wx/caret.h" #endif // wxUSE_CARET -// turn Refresh() debugging on/off -#define WXDEBUG_REFRESH - -#ifndef __WXDEBUG__ - #undef WXDEBUG_REFRESH +#if wxDEBUG_LEVEL >= 2 + // turn Refresh() debugging on/off + #define WXDEBUG_REFRESH #endif #if defined(WXDEBUG_REFRESH) && defined(__WXMSW__) && !defined(__WXMICROWIN__) diff --git a/src/unix/threadpsx.cpp b/src/unix/threadpsx.cpp index db3063e48e..9e8e6d1165 100644 --- a/src/unix/threadpsx.cpp +++ b/src/unix/threadpsx.cpp @@ -1624,7 +1624,6 @@ bool wxThread::TestDestroy() wxThread::~wxThread() { -#ifdef __WXDEBUG__ m_critsect.Enter(); // check that the thread either exited or couldn't be created @@ -1636,7 +1635,6 @@ wxThread::~wxThread() } m_critsect.Leave(); -#endif // __WXDEBUG__ delete m_internal; diff --git a/src/x11/bitmap.cpp b/src/x11/bitmap.cpp index c32c1eb031..c8b6a2d14f 100644 --- a/src/x11/bitmap.cpp +++ b/src/x11/bitmap.cpp @@ -1475,7 +1475,7 @@ bool wxXPMDataHandler::Create(wxBitmap *bitmap, const void* bits, M_BMPHANDLERDATA->m_bpp = bpp; // mono as well? -#if __WXDEBUG__ +#if wxDEBUG_LEVEL unsigned int depthRet; int xRet, yRet; unsigned int widthRet, heightRet, borderWidthRet; @@ -1483,7 +1483,7 @@ bool wxXPMDataHandler::Create(wxBitmap *bitmap, const void* bits, &widthRet, &heightRet, &borderWidthRet, &depthRet); wxASSERT_MSG( bpp == (int)depthRet, wxT("colour depth mismatch") ); -#endif +#endif // wxDEBUG_LEVEL XpmFreeAttributes(&xpmAttr); diff --git a/src/x11/reparent.cpp b/src/x11/reparent.cpp index d6ece8ddce..6269a87c78 100644 --- a/src/x11/reparent.cpp +++ b/src/x11/reparent.cpp @@ -152,11 +152,6 @@ bool wxReparenter::WaitAndReparent(wxWindow* newParent, wxAdoptedWindow* toRepar if (!WM_STATE) WM_STATE = XInternAtom(display, "WM_STATE", False); -#ifdef __WXDEBUG__ - if (!windowName.empty()) - wxLogDebug(_T("Waiting for window %s"), windowName.c_str()); -#endif - sm_done = false; wxEventLoop eventLoop;