示例#1
0
	virtual void DoAddCustomContext(wxXmlNode * nodeRoot)
	{
		wxString			strMessage;

#if FALSE == wxUSE_UNICODE
		TCHAR*			pszCDrawVer = GDraw_GetSvnVersion();
#else
		TCHAR			pszCDrawVer[32];
		camMbstowcs( pszCDrawVer, GDraw_GetSvnVersion(), 31 );
#endif
		// Add the applications version information
		wxXmlNode *nodeVersion = new wxXmlNode(wxXML_ELEMENT_NODE, _T("camelot"));
		nodeVersion->AddProperty(_T("xtremeversion"), wxString(g_pszAppVersion));
		nodeVersion->AddProperty(_T("xaradrawversion"), wxString::Format(_T("%d.03d"), HIWORD(GDraw_GetVersion()), LOWORD(GDraw_GetVersion())));
		nodeVersion->AddProperty(_T("xaradrawrevision"), pszCDrawVer);
		nodeRoot->AddChild(nodeVersion);
	}
示例#2
0
文件: ensure.cpp 项目: vata/xarino
static void InternalAssert(const TCHAR * AssertDescription, const char * lpszFileName, INT32 nLine, BOOL UseMFC)
{
	if (!UseMFC)
#if defined(__WXMSW__)
		MessageBeep(MB_ICONASTERISK);
#else
		::wxBell();
#endif


#ifdef _ENSURES

	TCHAR				sz[256];
	static TCHAR BASED_CODE szTitle[] = wxT("Ensure Failed!");

	// In Unicode we need to convert the filename to TCHAR
#if 0 != wxUSE_UNICODE
	TCHAR szRealFile[256];
	size_t count = camMbstowcs(szRealFile, lpszFileName, 255);
	if (count == (size_t)-1)
		count = 0;
	szRealFile[count] = (TCHAR)0;
	const TCHAR* lpszRealFile = szRealFile;
#else
	const TCHAR* lpszRealFile = lpszFileName;
#endif

	static TCHAR BASED_CODE szMessage[] = wxT("%s, File %s, Line %d");
	static TCHAR BASED_CODE szMessageNoReason[] = wxT("Error %d@%s");			// note number first

	// get app name or NULL if unknown (don't call assert)
//	const TCHAR		   *pszAppName = wxGetApp().GetAppName();

	if (AssertDescription != NULL)
	{
		camSnprintf(sz, 255,
			szMessage,                       
			AssertDescription, 
			lpszRealFile, 
			nLine);    
	}
	else   
	{
		camSnprintf(sz, 255,
			szMessageNoReason,
			nLine,
			lpszRealFile);
	}
	
#ifdef _DEBUG
//PORTNOTE("other","Remove afxTraceEnabled")
//#ifndef EXCLUDE_FROM_XARALX
//	if (afxTraceEnabled)
#if defined(__WXMSW__)
	{
		// assume the debugger or auxiliary port
		#ifndef _MAC
		::OutputDebugString(sz);
		::OutputDebugString(_T(", "));
		::OutputDebugString(szTitle);
		::OutputDebugString(_T("\n\r"));
		#else
		// Mac version needs them all together
		camStrcat(sz, _T(", "));
		camStrcat(sz,szTitle);
		camStrcat(sz,_T("\n\r"));
		::OutputDebugString(sz);
		#endif
	}
#endif
#endif


	if (AssertBusy > 0)
	{
		// getting assertion while inside an assertion
		//  - it has already been traced, but 
		// break into the debugger (or Dr Watson log)
		DEBUGBREAK;									// else Win32s might die (just beeps)
		return;
	}

	AssertBusy++;

	if ( Error::IsInRenderThread() )
	{
		TRACE( wxT("In RenderThread so clearing up system") );
		Error::RenderThreadReset();
													// Commented out - no problem using wx for render errors
//		UseMFC = FALSE;								// mustn't use MFC for render errors 
	}

	INT32					result;

	TCHAR				RealErrorMsg[256];

	if (UseMFC)
	{
		// use our error handler to report ensures as it is more robust instead of MessageBox
		// The arrangement of buttons is the same as the exception handler dialog, not the same
		// as the original Ensure dialog (which was Abort/Retry/Ignore)
		ErrorInfo Info;

		// try to preserve original error message
		camStrcpy( RealErrorMsg, Error::GetErrorString() );

		Error::SetErrorSerious( sz );			// set error msg (vaping any previous one)
		Info.ErrorMsg = 0;
		Info.Button[0] = _R(IDS_CONTINUE);
		Info.Button[1] = _R(IDS_QUIT);
#ifndef EXCLUDE_FROM_XARALX
		if (IsWin32NT())
		{
#endif
			// only NT can cope with an Abort button
			Info.Button[2] = _R(IDS_ABORT);
			Info.Button[3] = _R(IDS_DEBUG);
#ifndef EXCLUDE_FROM_XARALX
		}
		else
		{
			Info.Button[2] = _R(IDS_DEBUG);
		}
#endif
													// no default button (or Help)
		Info.Cancel = 1;							// Esc = Continue

		result = InformGeneral( ERRORTYPE_ENSURE, &Info );
	}
	else

	{
		CamResource::DoneInit();
		CCamApp::DisableSystem();

		// e.g. if this an MFC assert, don't use our lovely error handler becuase that itself
		// uses MFC. Instead we use good old MessageBox

#if !defined(EXCLUDE_FROM_RALPH) && !defined(EXCLUDE_FROM_XARALX)
		wxWindow	   *pParent = AfxGetApp().GetTopWindow(); 
PORTNOTE("other","Use CInformErrorDialog::GetSafeParent() when implemented")
#ifndef EXCLUDE_FROM_XARALX
		CInformErrorDialog::GetSafeParent();
#endif
#else
		wxWindow	   *pParent = NULL;
#endif

		wxMessageDialog	Dialog( pParent, sz, szTitle, wxICON_HAND | wxYES_NO | wxCANCEL );
		INT32 nCode = Dialog.ShowModal();

		CCamApp::EnableSystem();

		// convert MessageBox return value into a sane button ID
		switch (nCode)
		{
			case wxID_NO:
				result = _R(IDS_ABORT);
				break;
			case wxID_YES:
				result = _R(IDS_DEBUG);
				break;
			case wxID_CANCEL:
			default:
				result = _R(IDS_CONTINUE);
				break;
		}
	}

	AssertBusy--;

	if ((ResourceID)result == _R(IDS_DEBUG))
	{
		DEBUGBREAK;
	}
	// no action on _R(IDS_CONTINUE))
	else if ((ResourceID)result == _R(IDS_QUIT))
	{
		// quit in a slightly nice way
		wxWindow *MainWnd = AfxGetApp().GetTopWindow();
		if( MainWnd && MainWnd->IsShown() )
		{
			MainWnd->Destroy();
		}
	} // drop through
	if (((ResourceID)result == _R(IDS_ABORT)) || ((ResourceID)result == _R(IDS_QUIT)))
	{
		// if no window, try nasty exit
		AfxAbort();
		return; // how did we get here?
	}

	// if we ever get here we just carry on as if nothing happened

PORTNOTE("other","We can never use MFC again")
#ifndef EXCLUDE_FROM_XARALX
	if (UseMFC)
	{
		if (RealErrorMsg[0])
			Error::SetErrorSerious( RealErrorMsg );		// restore previous error msg
		else
			Error::ClearError();
	} 
#endif
#else
	// parameters not used if non-debug
	(void)lpszFileName;
	(void)nLine;
#endif // _ENSURES

}