From 2e587bb9ec1de95af31e7ccf1e5e0818ff752b0f Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 18 Sep 2009 14:04:22 +0000 Subject: [PATCH] Use wxASSERT() instead of assert() in wx code. This is more consistent and ensures that all asserts in wxWidgets are controlled by a single wxDEBUG_LEVEL setting instead of also relying on NDEBUG as standard assert() macro does. See #11155. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@61959 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/common/object.cpp | 8 ++++---- src/generic/regiong.cpp | 38 +++++++++++++++++++------------------- src/osx/carbon/font.cpp | 10 +++++----- 3 files changed, 28 insertions(+), 28 deletions(-) diff --git a/src/common/object.cpp b/src/common/object.cpp index 57825a52c5..c21fdf02f4 100644 --- a/src/common/object.cpp +++ b/src/common/object.cpp @@ -55,10 +55,10 @@ const wxClassInfo* wxObject::ms_classParents[] = { NULL } ; (wxObjectConstructorFn) 0 , NULL,NULL,0 , 0 , 0 , wxVariantOfPtrToObjectConverterwxObject , wxVariantToObjectConverterwxObject , wxObjectToVariantConverterwxObject); - template<> void wxStringReadValue(const wxString & , wxObject * & ){assert(0) ;} - template<> void wxStringWriteValue(wxString & , wxObject* const & ){assert(0) ;} - template<> void wxStringReadValue(const wxString & , wxObject & ){assert(0) ;} - template<> void wxStringWriteValue(wxString & , wxObject const & ){assert(0) ;} + template<> void wxStringReadValue(const wxString & , wxObject * & ){ wxFAIL_MSG("unreachable"); } + template<> void wxStringWriteValue(wxString & , wxObject* const & ){ wxFAIL_MSG("unreachable"); } + template<> void wxStringReadValue(const wxString & , wxObject & ){ wxFAIL_MSG("unreachable"); } + template<> void wxStringWriteValue(wxString & , wxObject const & ){ wxFAIL_MSG("unreachable"); } wxClassTypeInfo s_typeInfo(wxT_OBJECT_PTR , &wxObject::ms_classInfo , NULL , NULL , typeid(wxObject*).name() ) ; wxClassTypeInfo s_typeInfowxObject(wxT_OBJECT , &wxObject::ms_classInfo , NULL , NULL , typeid(wxObject).name() ) ; #else diff --git a/src/generic/regiong.cpp b/src/generic/regiong.cpp index fc29ab59fd..67190870b9 100644 --- a/src/generic/regiong.cpp +++ b/src/generic/regiong.cpp @@ -685,7 +685,7 @@ miSetExtents (Region pReg) pExtents->x2 = pBoxEnd->x2; pExtents->y2 = pBoxEnd->y2; - assert(pExtents->y1 < pExtents->y2); + wxASSERT_LEVEL_2(pExtents->y1 < pExtents->y2); while (pBox <= pBoxEnd) { if (pBox->x1 < pExtents->x1) @@ -698,7 +698,7 @@ miSetExtents (Region pReg) } pBox++; } - assert(pExtents->x1 < pExtents->x2); + wxASSERT_LEVEL_2(pExtents->x1 < pExtents->x2); } bool REGION:: @@ -789,7 +789,7 @@ miIntersectO ( */ if (x1 < x2) { - assert(y1rects); pNextRect->x1 = x1; @@ -798,7 +798,7 @@ miIntersectO ( pNextRect->y2 = y2; pReg->numRects += 1; pNextRect++; - assert(pReg->numRects <= pReg->size); + wxASSERT_LEVEL_2(pReg->numRects <= pReg->size); } /* @@ -1379,11 +1379,11 @@ miUnionNonO ( pNextRect = &pReg->rects[pReg->numRects]; - assert(y1 < y2); + wxASSERT_LEVEL_2(y1 < y2); while (r != rEnd) { - assert(r->x1 < r->x2); + wxASSERT_LEVEL_2(r->x1 < r->x2); MEMCHECK(pReg, pNextRect, pReg->rects); pNextRect->x1 = r->x1; pNextRect->y1 = y1; @@ -1392,7 +1392,7 @@ miUnionNonO ( pReg->numRects += 1; pNextRect++; - assert(pReg->numRects<=pReg->size); + wxASSERT_LEVEL_2(pReg->numRects<=pReg->size); r++; } return 0; /* lint */ @@ -1439,7 +1439,7 @@ miUnionO ( if (pNextRect[-1].x2 < r->x2) \ { \ pNextRect[-1].x2 = r->x2; \ - assert(pNextRect[-1].x1numRects += 1; \ pNextRect += 1; \ } \ - assert(pReg->numRects<=pReg->size);\ + wxASSERT_LEVEL_2(pReg->numRects<=pReg->size);\ r++; - assert (y1x1 < r2->x1) @@ -1580,11 +1580,11 @@ miSubtractNonO1 ( pNextRect = &pReg->rects[pReg->numRects]; - assert(y1x1x2); + wxASSERT_LEVEL_2(r->x1x2); MEMCHECK(pReg, pNextRect, pReg->rects); pNextRect->x1 = r->x1; pNextRect->y1 = y1; @@ -1593,7 +1593,7 @@ miSubtractNonO1 ( pReg->numRects += 1; pNextRect++; - assert(pReg->numRects <= pReg->size); + wxASSERT_LEVEL_2(pReg->numRects <= pReg->size); r++; } @@ -1630,7 +1630,7 @@ miSubtractO ( x1 = r1->x1; - assert(y1rects[pReg->numRects]; while ((r1 != r1End) && (r2 != r2End)) @@ -1673,7 +1673,7 @@ miSubtractO ( * Left part of subtrahend covers part of minuend: add uncovered * part of minuend to region and skip to next subtrahend. */ - assert(x1x1); + wxASSERT_LEVEL_2(x1x1); MEMCHECK(pReg, pNextRect, pReg->rects); pNextRect->x1 = x1; pNextRect->y1 = y1; @@ -1682,7 +1682,7 @@ miSubtractO ( pReg->numRects += 1; pNextRect++; - assert(pReg->numRects<=pReg->size); + wxASSERT_LEVEL_2(pReg->numRects<=pReg->size); x1 = r2->x2; if (x1 >= r1->x2) @@ -1716,7 +1716,7 @@ miSubtractO ( pNextRect->y2 = y2; pReg->numRects += 1; pNextRect++; - assert(pReg->numRects<=pReg->size); + wxASSERT_LEVEL_2(pReg->numRects<=pReg->size); } r1++; if (r1 != r1End) @@ -1729,7 +1729,7 @@ miSubtractO ( */ while (r1 != r1End) { - assert(x1x2); + wxASSERT_LEVEL_2(x1x2); MEMCHECK(pReg, pNextRect, pReg->rects); pNextRect->x1 = x1; pNextRect->y1 = y1; @@ -1738,7 +1738,7 @@ miSubtractO ( pReg->numRects += 1; pNextRect++; - assert(pReg->numRects<=pReg->size); + wxASSERT_LEVEL_2(pReg->numRects<=pReg->size); r1++; if (r1 != r1End) diff --git a/src/osx/carbon/font.cpp b/src/osx/carbon/font.cpp index 8ee911dc85..29ff06fe94 100644 --- a/src/osx/carbon/font.cpp +++ b/src/osx/carbon/font.cpp @@ -877,11 +877,11 @@ static CTFontDescriptorRef wxMacCreateCTFontDescriptor(CFStringRef iFamilyName, CTFontDescriptorRef descriptor = NULL; CFMutableDictionaryRef attributes; - assert(iFamilyName != NULL); + wxASSERT(iFamilyName != NULL); // Create a mutable dictionary to hold our attributes. attributes = CFDictionaryCreateMutable(kCFAllocatorDefault, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); - check(attributes != NULL); + wxASSERT(attributes != NULL); if (attributes != NULL) { // Add a family name to our attributes. @@ -895,13 +895,13 @@ static CTFontDescriptorRef wxMacCreateCTFontDescriptor(CFStringRef iFamilyName, // Create the traits dictionary. symTraits = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &iTraits); - check(symTraits != NULL); + wxASSERT(symTraits != NULL); if (symTraits != NULL) { // Create a dictionary to hold our traits values. traits = CFDictionaryCreateMutable(kCFAllocatorDefault, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); - check(traits != NULL); + wxASSERT(traits != NULL); if (traits != NULL) { // Add the symbolic traits value to the traits dictionary. @@ -916,7 +916,7 @@ static CTFontDescriptorRef wxMacCreateCTFontDescriptor(CFStringRef iFamilyName, } // Create the font descriptor with our attributes descriptor = CTFontDescriptorCreateWithAttributes(attributes); - check(descriptor != NULL); + wxASSERT(descriptor != NULL); CFRelease(attributes); } -- 2.45.2