From: Vadim Zeitlin Date: Mon, 22 Jun 1998 22:17:39 +0000 (+0000) Subject: wxCHECK/wxCHECK_RET changes X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/1311c7a9bbaefda6b68eee5c32c3309f163a8861?hp=a539b39f6b88cc4a258d451cb96e074618e583b9 wxCHECK/wxCHECK_RET changes git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@132 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/include/wx/dynarray.h b/include/wx/dynarray.h index c7d94ac6d4..a73954ae73 100644 --- a/include/wx/dynarray.h +++ b/include/wx/dynarray.h @@ -184,7 +184,8 @@ public: \ void Remove(uint uiIndex) { wxBaseArray::Remove(uiIndex); } \ void Remove(T Item) \ { int iIndex = Index(Item); \ - wxCHECK( iIndex != NOT_FOUND ); \ + wxCHECK2_MSG( iIndex != NOT_FOUND, return, \ + "removing inexisting element in wxArray::Remove" ); \ wxBaseArray::Remove((uint)iIndex); } \ \ void Sort(CMPFUNC##T fCmp) { wxBaseArray::Sort((CMPFUNC)fCmp); } \ diff --git a/src/common/dynarray.cpp b/src/common/dynarray.cpp index eb67d34504..ee700fbb0c 100644 --- a/src/common/dynarray.cpp +++ b/src/common/dynarray.cpp @@ -179,7 +179,7 @@ void wxBaseArray::Add(long lItem) // add item at the given position void wxBaseArray::Insert(long lItem, uint uiIndex) { - wxCHECK( uiIndex <= m_uiCount ); + wxCHECK_RET( uiIndex <= m_uiCount, "bad index in wxArray::Insert" ); Grow(); @@ -192,7 +192,7 @@ void wxBaseArray::Insert(long lItem, uint uiIndex) // removes item from array (by index) void wxBaseArray::Remove(uint uiIndex) { - wxCHECK( uiIndex <= m_uiCount ); + wxCHECK_RET( uiIndex <= m_uiCount, "bad index in wxArray::Remove" ); memmove(&m_pItems[uiIndex], &m_pItems[uiIndex + 1], (m_uiCount - uiIndex - 1)*sizeof(long)); @@ -204,7 +204,8 @@ void wxBaseArray::Remove(long lItem) { int iIndex = Index(lItem); - wxCHECK( iIndex != NOT_FOUND ); + wxCHECK_RET( iIndex != NOT_FOUND, + "removing inexistent item in wxArray::Remove" ); Remove((uint)iIndex); } diff --git a/src/common/file.cpp b/src/common/file.cpp index 9f2093cccd..e6a8a9c878 100644 --- a/src/common/file.cpp +++ b/src/common/file.cpp @@ -190,7 +190,7 @@ bool wxFile::Close() // read off_t wxFile::Read(void *pBuf, off_t nCount) { - wxCHECK_RET( (pBuf != NULL) && IsOpened(), 0 ); + wxCHECK( (pBuf != NULL) && IsOpened(), 0 ); int iRc = ::read(m_fd, pBuf, nCount); if ( iRc == -1 ) { @@ -204,7 +204,7 @@ off_t wxFile::Read(void *pBuf, off_t nCount) // write bool wxFile::Write(const void *pBuf, uint nCount) { - wxCHECK_RET( (pBuf != NULL) && IsOpened(), 0 ); + wxCHECK( (pBuf != NULL) && IsOpened(), 0 ); int iRc = ::write(m_fd, pBuf, nCount); if ( iRc == -1 ) { diff --git a/src/common/filefn.cpp b/src/common/filefn.cpp index a85dae4c69..b47d856e66 100644 --- a/src/common/filefn.cpp +++ b/src/common/filefn.cpp @@ -1066,7 +1066,7 @@ static struct _find_t wxFileStruc; static wxString wxFileSpec = ""; static int wxFindFileFlags; -char *wxFindFirstFile(const wxString& spec, int flags) +char *wxFindFirstFile(const char *spec, int flags) { wxFileSpec = spec; wxFindFileFlags = flags; /* MATTHEW: [5] Remember flags */ @@ -1284,7 +1284,8 @@ bool wxEndsWithPathSeparator(const char *pszFileName) bool wxFindFileInPath(wxString *pStr, const char *pszPath, const char *pszFile) { // we assume that it's not empty - wxCHECK_RET( Strlen(pszFile) != 0, FALSE); + wxCHECK_MSG( !IsEmpty(pszFile), FALSE, + "empty file name in wxFindFileInPath"); // skip path separator in the beginning of the file name if present if ( wxIsPathSeparator(*pszFile) ) diff --git a/src/msw/frame.cpp b/src/msw/frame.cpp index 55889420fa..ce0c0b0edf 100644 --- a/src/msw/frame.cpp +++ b/src/msw/frame.cpp @@ -381,7 +381,8 @@ wxStatusBar *wxFrame::OnCreateStatusBar(const int number) bool wxFrame::CreateStatusBar(const int number) { // VZ: calling CreateStatusBar twice is an error - why anyone would do it? - wxCHECK_RET( m_frameStatusBar == NULL, FALSE ); + wxCHECK_MSG( m_frameStatusBar == NULL, FALSE, + "recreating status bar in wxFrame" ); m_frameStatusBar = OnCreateStatusBar(number); if ( m_frameStatusBar ) @@ -395,14 +396,14 @@ bool wxFrame::CreateStatusBar(const int number) void wxFrame::SetStatusText(const wxString& text, const int number) { - wxCHECK( m_frameStatusBar != NULL ); + wxCHECK_RET( m_frameStatusBar != NULL, "no statusbar to set text for" ); m_frameStatusBar->SetStatusText(text, number); } void wxFrame::SetStatusWidths(const int n, const int *widths_field) { - wxCHECK( m_frameStatusBar != NULL ); + wxCHECK_RET( m_frameStatusBar != NULL, "no statusbar to set widths for" ); m_frameStatusBar->SetStatusWidths(n, widths_field); PositionStatusBar(); diff --git a/src/msw/menu.cpp b/src/msw/menu.cpp index 1004cd16e8..d3dcc65044 100644 --- a/src/msw/menu.cpp +++ b/src/msw/menu.cpp @@ -139,7 +139,7 @@ void wxMenu::Break(void) // function appends a new item or submenu to the menu void wxMenu::Append(wxMenuItem *pItem) { - wxCHECK( pItem != NULL ); + wxCHECK_RET( pItem != NULL, "can't append NULL item to the menu" ); m_menuItems.Append(pItem); @@ -269,7 +269,7 @@ void wxMenu::Delete(int id) void wxMenu::Enable(int Id, bool Flag) { wxMenuItem *item = FindItemForId(Id); - wxCHECK( item != NULL ); + wxCHECK_RET( item != NULL, "can't enable non-existing menu item" ); item->Enable(Flag); } @@ -277,7 +277,7 @@ void wxMenu::Enable(int Id, bool Flag) bool wxMenu::Enabled(int Id) const { wxMenuItem *item = FindItemForId(Id); - wxCHECK_RET( item != NULL, FALSE ); + wxCHECK( item != NULL, FALSE ); return item->IsEnabled(); } @@ -285,7 +285,7 @@ bool wxMenu::Enabled(int Id) const void wxMenu::Check(int Id, bool Flag) { wxMenuItem *item = FindItemForId(Id); - wxCHECK( item != NULL ); + wxCHECK_RET( item != NULL, "can't get status of non-existing menu item" ); item->Check(Flag); } @@ -293,7 +293,7 @@ void wxMenu::Check(int Id, bool Flag) bool wxMenu::Checked(int Id) const { wxMenuItem *item = FindItemForId(Id); - wxCHECK_RET( item != NULL, FALSE ); + wxCHECK( item != NULL, FALSE ); return item->IsChecked(); } diff --git a/src/msw/menuitem.cpp b/src/msw/menuitem.cpp index 8d7d27379b..3cde928232 100644 --- a/src/msw/menuitem.cpp +++ b/src/msw/menuitem.cpp @@ -134,7 +134,7 @@ void wxMenuItem::Enable(bool bDoEnable) void wxMenuItem::Check(bool bDoCheck) { - wxCHECK ( IsCheckable() ); + wxCHECK_RET( IsCheckable(), "only checkable items may be checked" ); if ( m_bChecked != bDoCheck ) { CheckMenuItem((HMENU)m_pParentMenu->GetHMenu(), m_idItem, diff --git a/src/msw/registry.cpp b/src/msw/registry.cpp index ffd1e6fa2d..713ca417c3 100644 --- a/src/msw/registry.cpp +++ b/src/msw/registry.cpp @@ -122,7 +122,7 @@ const size_t wxRegKey::nStdKeys = WXSIZEOF(aStdKeys); const char *wxRegKey::GetStdKeyName(uint key) { // return empty string if key is invalid - wxCHECK_RET( key < nStdKeys, "" ); + wxCHECK_MSG( key < nStdKeys, "", "invalid key in wxRegKey::GetStdKeyName" ); return aStdKeys[key].szName; } @@ -130,7 +130,7 @@ const char *wxRegKey::GetStdKeyName(uint key) const char *wxRegKey::GetStdKeyShortName(uint key) { // return empty string if key is invalid - wxCHECK_RET( key < nStdKeys, "" ); + wxCHECK( key < nStdKeys, "" ); return aStdKeys[key].szShortName; }