2 Copyright (C) 1999-2007 id Software, Inc. and contributors.
3 For a list of contributors, see the accompanying CONTRIBUTORS file.
5 This file is part of GtkRadiant.
7 GtkRadiant is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 GtkRadiant is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GtkRadiant; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 #if defined (__linux__) || defined (__APPLE__)
33 For abnormal program terminations
39 FIXME the prompt wether to do prefs dialog, may not even be possible
40 if the crash happens before the game is loaded
43 void Error (const char *error, ...)
48 va_start (argptr,error);
49 vsprintf (text, error,argptr);
54 #if defined (__linux__) || defined (__APPLE__)
57 strcat( text, "errno: " );
58 strcat( text, strerror (errno));
64 if (GetLastError() != 0)
68 FORMAT_MESSAGE_ALLOCATE_BUFFER |
69 FORMAT_MESSAGE_FROM_SYSTEM |
70 FORMAT_MESSAGE_IGNORE_INSERTS,
73 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
78 strcat( text, "GetLastError: " );
80 Gtk will only crunch 0<=char<=127
81 this is a bit hackish, but I didn't find useful functions in win32 API for this
82 http://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=516
84 TCHAR *scan, *next = (TCHAR*)lpMsgBuf;
88 text[strlen(text)+1] = '\0';
89 if ((scan[0] >= 0) && (scan[0] <= 127))
90 text[strlen(text)] = scan[0];
92 text[strlen(text)] = '?';
93 next = CharNext(scan);
94 } while (next != scan);
96 LocalFree( lpMsgBuf );
100 // we need to have a current context to call glError()
101 if (g_qeglobals_gui.d_glBase != NULL)
103 // qglGetError .. can record several errors, clears after calling
104 //++timo TODO: be able to deal with several errors if necessary, for now I'm just warning about pending error messages
105 // NOTE: forget that, most boards don't seem to follow the OpenGL standard
106 GLenum iGLError = qglGetError();
107 if (iGLError != GL_NO_ERROR)
109 // use our own gluErrorString
110 strcat( text, "qgluErrorString: " );
111 strcat( text, (char*)qgluErrorString( iGLError ) );
112 strcat( text, "\n" );
116 strcat (text, "An unrecoverable error has occured.\n"
117 "Would you like to edit Preferences before exiting Radiant?");
121 if (gtk_MessageBox(NULL, text, "Error", MB_YESNO) == IDYES)
123 Sys_Printf("Doing prefs..\n");
124 g_PrefsDlg.LoadPrefs ();
125 g_PrefsDlg.DoModal();
130 g_PrefsDlg.Destroy ();
131 g_dlgSurface.Destroy ();
132 g_dlgFind.Destroy ();
134 // force close logging if necessary
135 g_PrefsDlg.mGamesDialog.m_bLogConsole = false;
141 void WINAPI Error (char *error, ...)
146 va_start (argptr,error);
147 vsprintf (text, error,argptr);
150 Error((const char *)text);