#include "camtypes.h"
#include "camelot.h"
Go to the source code of this file.
Defines | |
#define | DEBUGBREAK {} |
Functions | |
static void | InternalAssert (const TCHAR *AssertDescription, const char *lpszFileName, INT32 nLine, BOOL UseMFC) |
void | EnsureFailedLine (const TCHAR *AssertDescription, const char *lpszFileName, INT32 nLine) |
This macro is similar to the ASSERT macro, the only difference being that a description is provided of why the failure occured. The symbol _ENSURES is defined if the ENSURE macro expands to something, else is undefined if the ENSURE macro has no effect. IMPORTANT NOTE: ENSURE is obsolete. Use ERROR2xx or ERROR3xx macros instead. | |
void AFXAPI | AfxAssertFailedLine (LPCSTR lpszFileName, INT32 nLine) |
This is a more robust version than MFC provides. |
|
Definition at line 132 of file ensure.cpp. |
|
This is a more robust version than MFC provides.
Definition at line 398 of file ensure.cpp. 00400 { 00401 #ifdef _MAC 00402 // ignore an incredibly annoying Mac assert which is something to do with rendering 00403 // the icons on our scroll bars 00404 if ( (nLine==119) && (camStrcmp(lpszFileName, "winbtn.cpp")==0) ) 00405 return FALSE; 00406 #endif 00407 00408 // must NOT use MFC for reporting this 00409 InternalAssert( _T("MFC Ensure"), lpszFileName, nLine, FALSE ); 00410 00411 #if COMPILER_REVISION >= 3 00412 return FALSE; 00413 #endif 00414 }
|
|
This macro is similar to the ASSERT macro, the only difference being that a description is provided of why the failure occured. The symbol _ENSURES is defined if the ENSURE macro expands to something, else is undefined if the ENSURE macro has no effect. IMPORTANT NOTE: ENSURE is obsolete. Use ERROR2xx or ERROR3xx macros instead.
Definition at line 372 of file ensure.cpp. 00373 { 00374 InternalAssert( AssertDescription, lpszFileName, nLine, TRUE ); 00375 }
|
|
Definition at line 135 of file ensure.cpp. 00136 { 00137 if (!UseMFC) 00138 #if defined(__WXMSW__) 00139 MessageBeep(MB_ICONASTERISK); 00140 #else 00141 ::wxBell(); 00142 #endif 00143 00144 00145 #ifdef _ENSURES 00146 00147 TCHAR sz[256]; 00148 static TCHAR BASED_CODE szTitle[] = wxT("Ensure Failed!"); 00149 00150 // In Unicode we need to convert the filename to TCHAR 00151 #if 0 != wxUSE_UNICODE 00152 TCHAR szRealFile[256]; 00153 size_t count = camMbstowcs(szRealFile, lpszFileName, 255); 00154 if (count == (size_t)-1) 00155 count = 0; 00156 szRealFile[count] = (TCHAR)0; 00157 const TCHAR* lpszRealFile = szRealFile; 00158 #else 00159 const TCHAR* lpszRealFile = lpszFileName; 00160 #endif 00161 00162 static TCHAR BASED_CODE szMessage[] = wxT("%s, File %s, Line %d"); 00163 static TCHAR BASED_CODE szMessageNoReason[] = wxT("Error %d@%s"); // note number first 00164 00165 // get app name or NULL if unknown (don't call assert) 00166 // const TCHAR *pszAppName = wxGetApp().GetAppName(); 00167 00168 if (AssertDescription != NULL) 00169 { 00170 camSnprintf(sz, 255, 00171 szMessage, 00172 AssertDescription, 00173 lpszRealFile, 00174 nLine); 00175 } 00176 else 00177 { 00178 camSnprintf(sz, 255, 00179 szMessageNoReason, 00180 nLine, 00181 lpszRealFile); 00182 } 00183 00184 #ifdef _DEBUG 00185 //PORTNOTE("other","Remove afxTraceEnabled") 00186 //#ifndef EXCLUDE_FROM_XARALX 00187 // if (afxTraceEnabled) 00188 #if defined(__WXMSW__) 00189 { 00190 // assume the debugger or auxiliary port 00191 #ifndef _MAC 00192 ::OutputDebugString(sz); 00193 ::OutputDebugString(_T(", ")); 00194 ::OutputDebugString(szTitle); 00195 ::OutputDebugString(_T("\n\r")); 00196 #else 00197 // Mac version needs them all together 00198 camStrcat(sz, _T(", ")); 00199 camStrcat(sz,szTitle); 00200 camStrcat(sz,_T("\n\r")); 00201 ::OutputDebugString(sz); 00202 #endif 00203 } 00204 #endif 00205 #endif 00206 00207 00208 if (AssertBusy > 0) 00209 { 00210 // getting assertion while inside an assertion 00211 // - it has already been traced, but 00212 // break into the debugger (or Dr Watson log) 00213 DEBUGBREAK; // else Win32s might die (just beeps) 00214 return; 00215 } 00216 00217 AssertBusy++; 00218 00219 if ( Error::IsInRenderThread() ) 00220 { 00221 TRACE( wxT("In RenderThread so clearing up system") ); 00222 Error::RenderThreadReset(); 00223 // Commented out - no problem using wx for render errors 00224 // UseMFC = FALSE; // mustn't use MFC for render errors 00225 } 00226 00227 INT32 result; 00228 00229 TCHAR RealErrorMsg[256]; 00230 00231 if (UseMFC) 00232 { 00233 // use our error handler to report ensures as it is more robust instead of MessageBox 00234 // The arrangement of buttons is the same as the exception handler dialog, not the same 00235 // as the original Ensure dialog (which was Abort/Retry/Ignore) 00236 ErrorInfo Info; 00237 00238 // try to preserve original error message 00239 camStrcpy( RealErrorMsg, Error::GetErrorString() ); 00240 00241 Error::SetErrorSerious( sz ); // set error msg (vaping any previous one) 00242 Info.ErrorMsg = 0; 00243 Info.Button[0] = _R(IDS_CONTINUE); 00244 Info.Button[1] = _R(IDS_QUIT); 00245 #ifndef EXCLUDE_FROM_XARALX 00246 if (IsWin32NT()) 00247 { 00248 #endif 00249 // only NT can cope with an Abort button 00250 Info.Button[2] = _R(IDS_ABORT); 00251 Info.Button[3] = _R(IDS_DEBUG); 00252 #ifndef EXCLUDE_FROM_XARALX 00253 } 00254 else 00255 { 00256 Info.Button[2] = _R(IDS_DEBUG); 00257 } 00258 #endif 00259 // no default button (or Help) 00260 Info.Cancel = 1; // Esc = Continue 00261 00262 result = InformGeneral( ERRORTYPE_ENSURE, &Info ); 00263 } 00264 else 00265 00266 { 00267 CamResource::DoneInit(); 00268 CCamApp::DisableSystem(); 00269 00270 // e.g. if this an MFC assert, don't use our lovely error handler becuase that itself 00271 // uses MFC. Instead we use good old MessageBox 00272 00273 #if !defined(EXCLUDE_FROM_RALPH) && !defined(EXCLUDE_FROM_XARALX) 00274 wxWindow *pParent = AfxGetApp().GetTopWindow(); 00275 PORTNOTE("other","Use CInformErrorDialog::GetSafeParent() when implemented") 00276 #ifndef EXCLUDE_FROM_XARALX 00277 CInformErrorDialog::GetSafeParent(); 00278 #endif 00279 #else 00280 wxWindow *pParent = NULL; 00281 #endif 00282 00283 wxMessageDialog Dialog( pParent, sz, szTitle, wxICON_HAND | wxYES_NO | wxCANCEL ); 00284 INT32 nCode = Dialog.ShowModal(); 00285 00286 CCamApp::EnableSystem(); 00287 00288 // convert MessageBox return value into a sane button ID 00289 switch (nCode) 00290 { 00291 case wxID_NO: 00292 result = _R(IDS_ABORT); 00293 break; 00294 case wxID_YES: 00295 result = _R(IDS_DEBUG); 00296 break; 00297 case wxID_CANCEL: 00298 default: 00299 result = _R(IDS_CONTINUE); 00300 break; 00301 } 00302 } 00303 00304 AssertBusy--; 00305 00306 if ((ResourceID)result == _R(IDS_DEBUG)) 00307 { 00308 DEBUGBREAK; 00309 } 00310 // no action on _R(IDS_CONTINUE)) 00311 else if ((ResourceID)result == _R(IDS_QUIT)) 00312 { 00313 // quit in a slightly nice way 00314 wxWindow *MainWnd = AfxGetApp().GetTopWindow(); 00315 if( MainWnd && MainWnd->IsShown() ) 00316 { 00317 MainWnd->Destroy(); 00318 } 00319 } // drop through 00320 if (((ResourceID)result == _R(IDS_ABORT)) || ((ResourceID)result == _R(IDS_QUIT))) 00321 { 00322 // if no window, try nasty exit 00323 AfxAbort(); 00324 return; // how did we get here? 00325 } 00326 00327 // if we ever get here we just carry on as if nothing happened 00328 00329 PORTNOTE("other","We can never use MFC again") 00330 #ifndef EXCLUDE_FROM_XARALX 00331 if (UseMFC) 00332 { 00333 if (RealErrorMsg[0]) 00334 Error::SetErrorSerious( RealErrorMsg ); // restore previous error msg 00335 else 00336 Error::ClearError(); 00337 } 00338 #endif 00339 #else 00340 // parameters not used if non-debug 00341 (void)lpszFileName; 00342 (void)nLine; 00343 #endif // _ENSURES 00344 00345 }
|