]> git.saurik.com Git - wxWidgets.git/commitdiff
replace more __WXDEBUG__ occurrences with wxDEBUG_LEVEL
authorVadim Zeitlin <vadim@wxwidgets.org>
Sun, 22 Mar 2009 12:53:48 +0000 (12:53 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sun, 22 Mar 2009 12:53:48 +0000 (12:53 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@59725 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

68 files changed:
include/wx/msw/msvcrt.h
src/cocoa/display.mm
src/common/cmdline.cpp
src/common/datetime.cpp
src/common/filename.cpp
src/common/fontcmn.cpp
src/common/ftp.cpp
src/common/init.cpp
src/common/intl.cpp
src/common/memory.cpp
src/common/object.cpp
src/common/sizer.cpp
src/common/string.cpp
src/common/stringops.cpp
src/common/valtext.cpp
src/common/wincmn.cpp
src/common/zipstrm.cpp
src/dfb/nonownedwnd.cpp
src/generic/wizard.cpp
src/gtk/clipbrd.cpp
src/gtk/utilsgtk.cpp
src/gtk1/clipbrd.cpp
src/gtk1/font.cpp
src/gtk1/notebook.cpp
src/gtk1/window.cpp
src/mgl/app.cpp
src/mgl/window.cpp
src/motif/app.cpp
src/motif/filedlg.cpp
src/motif/utils.cpp
src/msw/calctrl.cpp
src/msw/clipbrd.cpp
src/msw/control.cpp
src/msw/datectrl.cpp
src/msw/dc.cpp
src/msw/dcclient.cpp
src/msw/dcmemory.cpp
src/msw/dialup.cpp
src/msw/fontdlg.cpp
src/msw/listctrl.cpp
src/msw/mdi.cpp
src/msw/mediactrl.cpp
src/msw/mediactrl_am.cpp
src/msw/ole/activex.cpp
src/msw/ole/dataobj.cpp
src/msw/ole/oleutils.cpp
src/msw/ole/uuid.cpp
src/msw/pen.cpp
src/msw/printdlg.cpp
src/msw/stdpaths.cpp
src/msw/window.cpp
src/os2/app.cpp
src/os2/control.cpp
src/os2/dcclient.cpp
src/osx/carbon/app.cpp
src/osx/carbon/thread.cpp
src/osx/core/display.cpp
src/palmos/dcclient.cpp
src/propgrid/property.cpp
src/propgrid/propgrid.cpp
src/propgrid/propgridpagestate.cpp
src/richtext/richtextbuffer.cpp
src/univ/scrolbar.cpp
src/univ/textctrl.cpp
src/univ/winuniv.cpp
src/unix/threadpsx.cpp
src/x11/bitmap.cpp
src/x11/reparent.cpp

index c1413a7571a65283dd700ef3fff88fc82b85a82c..7e1e3204aa86930c53831a537961f33aa68965ae 100644 (file)
@@ -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__)
 #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
index b9135addd55cfd0dbbfa3f7f361e876c058c9122..af4c6266c441f030d4be1dfda87188fbb9c70289 100644 (file)
@@ -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]);
index ce169ac95bf14a8230dab9d703c0fd52559b2c6a..b1521082b6c012761793320c69d5241ebdf824e3 100644 (file)
@@ -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);
 
index 164cc5b7054f435f08aa5c6e59ef7959fe496502..3889adfdc5ceb1fb31622bc704b18a2adfa7f948 100644 (file)
@@ -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
index 618fdac037473344af37ebee125aa20a76a6ed47..7db00dc4a94051bc634f0001290a7ac94dcce413 100644 (file)
@@ -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);
 }
 
index 67ee5bff6440a55d221a503934e80503ced8b86d..cd65471ef36a7d502117d14c36d4f03bb52a165d 100644 (file)
 
 #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
 // ============================================================================
index 9b1cd2513b62964d71b2a02b112eeadf84ccaf04..235a29d3db85981622f0c258fffe81c482eef0ee 100644 (file)
@@ -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();
index 7af0af21578f9bf895608ffc964fa7151b08f283..a183c256f21c3af6120e9a1e9aab1d909d2aa504 100644 (file)
 #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
index 657273a324892765b9934455aa83271afe6901f9..023d7cf2ac15553da3d627a9124fd88920cc0a4f 100644 (file)
@@ -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);
index 993b39a7a92a1e08e5fe641df8a8f9ed47136005..c55af4d9bc6a41cca95c9aecc661fd6ea350a2db 100644 (file)
@@ -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 <stdarg.h>
 #include <string.h>
 
-#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
index c6e4f241a84a3015975e1e28b8bdc64a04fdb629..e04a3e4f3d45544879d2ca51d2cefab8a4779683 100644 (file)
 
 #include <string.h>
 
-#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
 
index a4c17f8b8c968e47f9d3abf68bc2f2ade98c3f18..6e4fbcb376a7047e3740d76f80de54d197b4a94e 100644 (file)
@@ -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) )
index ed7a6a8670f42d467fd72028e22a8cefdc8d4eac..f3d684f1a468832e6f2d3cf91513e45a828e46c1 100644 (file)
@@ -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
 
index d51cce4b68c1d4c761fe152e87782e66586527df..c69a18774fb8ba7713a09554e43d831c3a31828f 100644 (file)
@@ -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 };
index 59a7eaa6bb3b2caf83765c9ff6d6cfb4605d19e3..56998ee14c6724fe911f35151e0e235851c791be 100644 (file)
@@ -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)
index 2413ca4fa5d112218eb921c68083477427406df0..31bac26e06e4b9d9168ac2fcc2c964d9f663036e 100644 (file)
@@ -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)
index a3af2d62468131cf2e826a52ebe2fbdb769b994e..e353d419868d271f5a06db8e3616416144ebb062 100644 (file)
@@ -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);
index c455d5e4ffa1c9a9b3ff8082576279d64fb8280a..2c4809aee110bb586a6f83a19478adba21a5dca2 100644 (file)
@@ -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() )
index da9fb737546c2bfb99c2567a847afdd78641d0af..1ad3a17c6fac4f73ee9ad7861c0b8e2d3ea14b2d 100644 (file)
@@ -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;
index 2938ec3861228f706f606342eee9347baadc7fa1..538a80e7af18d42b5a155efd4a8afef8d56c42e8 100644 (file)
@@ -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;
index deb31eaa8ccc45e68e2f91ebc19918a8a80a7468..73d152d248200b9f042eec89a169c0d2de62aa23 100644 (file)
 #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 <stdarg.h>
 #include <string.h>
@@ -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"));
index 9559118fc56b901cc94cb0471c970d898a55add6..d17158dedde6515c01a60fe49d48360f0eeed60a 100644 (file)
@@ -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;
 
index 8257f5bf6419044d6eb3790fe5f95f2ddd3a8463..9bce28f617c7e94a0ff817cdb93b9547ec85ce94 100644 (file)
@@ -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,
index ac4155516dd93ba337a76eb89d7622f2012b86e5..1b953423e0d5ad15fa560d2d848ecda69465f196 100644 (file)
@@ -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 )
index d9c45bfa80383ed32da669cd97d6fb23d832773b..87a178d91e1d2fb938d90bcc85e072b286e2dedf 100644 (file)
@@ -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")
index eaa8a042564a6610911a152dfafb7453ca3e8309..fc87f16acb115f22ed93dd618283fff3a9e16f13 100644 (file)
@@ -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;
index ac24d5b5dcb1d7d9e76448c99f7ab6dbaee7ab15..6c2603cc69ec5523f210c39be67b300544b5ee3e 100644 (file)
@@ -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);
index 0a073548e787f54b933a7c197e97d2be88003fd3..5d1c8cad69d9b63b3e83ef03b6b688513abf8b1a 100644 (file)
@@ -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;
index 974b18b796ff56e3805dc05c66e1dbaed7da27e5..004930c5657b464a69e66a0f398c4feea464509f 100644 (file)
@@ -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;
index 4eda0e2f08a4d43c341d222d2a6e3330393da88a..4a94ff07343aa981f8562ea6b1a82a5ba9fa32bd 100644 (file)
@@ -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
index dc18f88615b44f778c05ca9f143953a958d3aa9c..842efa50c63517a4d915b4b76345690a65eb4423 100644 (file)
@@ -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;
 }
index 2369d769fb015b47c5ced071a2ac781c701010dc..b9df0c276755db21ee7645270ac8971eeda795d3 100644 (file)
@@ -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
index b3e4f5b2ec66808313ca218bd35a6bb9fabad025..06d75a9921d9c79b989ba197d1de87283c4ec012 100644 (file)
@@ -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;
     }
index 1009211b4d9dc777eca784dc1838d88b11011dbc..176d095f7cce5c43c3aeeeffb1ca194fb00fe448 100644 (file)
@@ -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;
 }
index b47befb24ee5f9935a863fe8caa6884165034c11..55724274f74fce94ed8dd520e7bc582b2f41a39c 100644 (file)
@@ -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)
index 7adb608854240daab5a559c68e718279ae821323..50ec2dca2ae6d6883ae6b2267e1ce3db5ca27387 100644 (file)
@@ -223,7 +223,7 @@ wxPaintDCImpl::wxPaintDCImpl( wxDC *owner, wxWindow *window ) :
 
         return;
     }
-#endif // __WXDEBUG__
+#endif // wxHAS_PAINT_DEBUG
 
     m_window = window;
 
index 6869e6f4e4b2f6873ede578fd7c176a7f0ad394e..d399b5157b4b85b9846c143ed744b30d73ca15f7 100644 (file)
@@ -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 )
index 66a5a034faabe0f6d0ae6a329d63db60492dd478..da0e96c243dddec9ad3681d72d4aaa5d36f25f0d 100644 (file)
@@ -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...
index 51a5bd1b2b47fbb0bb9c409176424a75d8841191..86156c2f37529d3fc087f4b9fb59146c7bb89abd 100644 (file)
@@ -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;
     }
index b102317312d3c7f79836f04a2564af17e07a0335..46e271ddffa88dac16f3b7912c1a865cf5701a2d 100644 (file)
@@ -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)
index aa931d6eaf6e414005decdb96556c0d550d700cb..1e9255d92d7cb72ecc33e4351d537d2be0aa37ad 100644 (file)
@@ -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__
         }
     }
 
index 17954f4054169217e877cd8a2e44f1eefc6b9e20..d45c50056c0657e23e064ae2af5830d0f422d788 100644 (file)
@@ -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; \
index c73fc1c38dc25a365a635584973ff65fe07f5374..3088d51ab9fbf952977f9704db52a083e182aac4 100644 (file)
@@ -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
 
 
 
index e64423522d3b912d817e6b073f0f812b6ee87942..22a97cc03b66487da2d330ac30d9c655ada3a1b6 100644 (file)
@@ -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
index ba2cb10bc83ef1fff0fff953d1da613aeab14322..07884ba7ede2f9f8609e4bb6e72e7e3380383a3e 100644 (file)
 // 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
 
index 94f134a097af38981513e4182471ff32c946d50f..3932c8d9ecef5f6c771ac8a58e7939bbc5a1c735 100644 (file)
@@ -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);
-}
-
-void wxLogRelease(const char *szInterface, ULONG cRef)
-{
-  wxLogTrace("After %s::Release: m_cRef = %d", szInterface, cRef - 1);
-}
+#endif // __CYGWIN10__
 
-#endif  // __WXDEBUG__
-
-#endif
-  // wxUSE_DRAG_AND_DROP
-
-#endif
-  // __CYGWIN10__
-
-#endif
-  // wxUSE_OLE
+#endif // wxUSE_OLE
index 76a968022261564f03f3601458bea8720c4f591c..d4079803b4708122a2d2ce48ae671daa179bbf75 100644 (file)
@@ -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"
index 034a3476e44fb6186522ec9362b17e6c21fd68c4..5daea9b6cdeb9e14adc5162a365a7848de60ff40 100644 (file)
@@ -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;
        }
 
index c7bc5edb3e4013b5b397c4b53703d204ca4241f9..f2b04942b7374bc5784145dec66711d689762706 100644 (file)
@@ -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
         {
index 3e928c146219d37af017fdae2340fcc54136b0a2..e8340f1a26a99de771d53ff906bf25f479a8129e 100644 (file)
@@ -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();
 }
index 0378499569e0fd3c007fd731069ad23cd51db11c..8bd1598490251e2de2843dfd248664cd58d809eb 100644 (file)
@@ -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)
 {
index c60a8ed3d62b8f4f8917d93132743dc826c6bd07..e6a8c71e5437beab43397c30b39ff4346944d415 100644 (file)
@@ -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);
 
index 4bbf875564dd00106d1e093114802bb3affde969..e490804a2f8b0ae440872736443669f58f741b27 100644 (file)
@@ -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;
     }
index 728e34157fdf0a142bd0732a21ef4b465f04e78e..60e225b6b613d141a09dba9830a6f1e9d4897804 100644 (file)
@@ -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;
 
index b1854d2b76b2106b5b8616750a2fbb1d816c8e5b..aca21781274c3a24f8fe9902c9e6c61264e98177 100644 (file)
@@ -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
 
index 0aa6d3939ccd18c3307ab91c4c7fbd77656e073c..f4bfdac1737aaaa185ab4aee5744fc97c135c4e0 100644 (file)
@@ -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 ) ;
 }
index 4598f001e9213dbf110abafa09b05551a8f48ebd..4160d73acf260b67926e53b96bfd584a5cd5dda4 100644 (file)
@@ -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]);
index 6a190e59384967c41c2bdd9f58fe4a3a74a77364..a3ff792c66b24c55c2f3e4668a817ab4359af767 100644 (file)
@@ -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?
index d670542dfa5e76799d2cffd65820949be4f49791..dcda1ef198c409828adf0352d24c96d2f50bff71 100644 (file)
@@ -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;
 }
index 8c6e80d786e36263cfd2768670935c73d520bfaa..d111896c389c61569164471045b54d2f32fa30e2 100644 (file)
@@ -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;
 
index 311507eb3e06a763c4dd96aea45463d64076d77a..91c82e609c8b0670bca23f9d65bb152bb2ce937d 100644 (file)
@@ -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; i<m_colWidths.size(); i++ )
         colsWidth += m_colWidths[i];
 
-#ifdef __WXDEBUG__
-    if ( debug )
-        wxLogDebug(wxT("  HasVirtualWidth: %i  colsWidth: %i"),(int)pg->HasVirtualWidth(),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; i<m_colWidths.size(); i++ )
-            wxLogDebug(wxT("col%i: %i"),i,m_colWidths[i]);
-#endif
+    for ( i=0; i<m_colWidths.size(); i++ )
+    {
+        wxLogTrace("propgrid", wxS("col%i: %i"), i, m_colWidths[i]);
+    }
 
     // Auto center splitter
     if ( !(pg->GetInternalFlags() & 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);
                     }
index 5fa710cdadc6ca834bb35fe94efd4afffda83884..82c529fa111c4b3e53f571af327a8b708f8e3fc2 100644 (file)
@@ -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
 
index ac0c110b0a4ef91ac7f47c7323c77cdb13b221a9..76a087e935776edd4bf2f45eb4a1840647039ee9 100644 (file)
 #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"
index bc625f70a7bbcb5dd31964a2104776a0503ba5c7..2edc5b0afe326c0059929b678bcceb860351e011 100644 (file)
 
 #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();
 }
index 41b166cc4d8032e0d1537e58d532b9c6d39bf734..dad230c47bf1e68ccf02609cb3771dc6026b9ee6 100644 (file)
     #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__)
index db3063e48e359dee1f9c9eb18863ded1c15cc211..9e8e6d1165e3c014db94f4711a112d19f53c7da8 100644 (file)
@@ -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;
 
index c32c1eb031dc8f37eb136e04bc9a3a6752d15963..c8b6a2d14fcb45c9b9fd5b131557be6ab82aab2a 100644 (file)
@@ -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);
 
index d6ece8ddceb5f822cac138c7847cb99262c513a7..6269a87c786632cab6b4a9aa18c7552823eddebc 100644 (file)
@@ -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;