Moved SysMessage() from the video plugin into the main app, so the GUI and non-GUI executable can handle it in a different way. This fixes a crash in DolphinNoGUI when SysMessage() was called and tried to use a non-initialized wxWidgets.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@489 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Maarten ter Huurne 2008-09-10 01:01:28 +00:00
parent 38ff37539d
commit 54c2a07de5
9 changed files with 39 additions and 19 deletions

View File

@ -22,6 +22,7 @@
#endif
#include "CPUDetect.h"
#include "Globals.h"
#include "Host.h"
#include "Common.h"
#include "IniFile.h"
#include "Main.h"
@ -274,3 +275,16 @@ void Host_UpdateStatusBar(const char* _pText)
wxPostEvent(main_frame, event);
}
void Host_SysMessage(const char *fmt, ...)
{
va_list list;
char msg[512];
va_start(list, fmt);
vsprintf(msg, fmt, list);
va_end(list);
if (msg[strlen(msg)-1] == '\n') msg[strlen(msg)-1] = 0;
wxMessageBox(wxString::FromAscii(msg));
}

View File

@ -6,6 +6,7 @@
#endif
#include "Globals.h"
#include "Host.h"
#include "Common.h"
#include "ISOFile.h"
#include "CPUDetect.h"
@ -59,6 +60,23 @@ void Host_SetWaitCursor(bool enable){}
void Host_UpdateStatusBar(const char* _pText){}
void Host_SysMessage(const char *fmt, ...)
{
va_list list;
char msg[512];
va_start(list, fmt);
vsprintf(msg, fmt, list);
va_end(list);
size_t len = strlen(msg);
if (msg[len - 1] != '\n') {
msg[len - 1] = '\n';
msg[len] = '\0';
}
fprintf(stderr, msg);
}
// Include SDL header so it can hijack main().
#include <SDL.h>

View File

@ -13,6 +13,7 @@ typedef void (*TSetPEToken)(const unsigned short _token, const int _bSetTokenA
typedef void (*TSetPEFinish)(void);
typedef unsigned char* (*TGetMemoryPointer)(const unsigned int _iAddress);
typedef void (*TVideoLog)(const char* _pMessage, BOOL _bBreak);
typedef void (*TSysMessage)(const char *fmt, ...);
typedef void (*TRequestWindowSize)(int _iWidth, int _iHeight, BOOL _bFullscreen);
typedef void (*TCopiedToXFB)(void);
typedef BOOL (*TPeekMessages)(void);
@ -50,6 +51,7 @@ typedef struct
TSetPEFinish pSetPEFinish;
TGetMemoryPointer pGetMemoryPointer;
TVideoLog pLog;
TSysMessage pSysMessage;
TRequestWindowSize pRequestWindowSize;
TCopiedToXFB pCopiedToXFB;
TPeekMessages pPeekMessages;

View File

@ -217,7 +217,7 @@ bool OpenGL_Create(SVideoInitialize &_VideoInitialize, int _iwidth, int _iheight
if (g_VideoInitialize.pWindowHandle == NULL)
{
SysMessage("failed to create window");
g_VideoInitialize.pSysMessage("failed to create window");
return false;
}

View File

@ -252,16 +252,3 @@ void __Log(int type, const char *fmt, ...)
WriteConsole(hConsole, Msg, (DWORD)strlen(Msg), &tmp, 0);
#endif
}
void SysMessage(const char *fmt, ...)
{
va_list list;
char msg[512];
va_start(list, fmt);
vsprintf(msg, fmt, list);
va_end(list);
if (msg[strlen(msg)-1] == '\n') msg[strlen(msg)-1] = 0;
wxMessageBox(wxString::FromAscii(msg));
}

View File

@ -221,7 +221,6 @@ extern Statistics stats;
void DebugLog(const char* _fmt, ...);
void __Log(const char *format, ...);
void __Log(int type, const char *format, ...);
void SysMessage(const char *fmt, ...);
void HandleGLError();
void InitLUTs();

View File

@ -181,10 +181,10 @@ bool FifoCommandRunnable(void)
"This means one of the following:\n"
"* The emulated GPU got desynced, disabling dual core can help\n"
"* Command stream corrupted by some spurious memory bug\n"
"* This really is an unknown opcode (unlikely)\n\n"
"* This really is an unknown opcode (unlikely)\n"
"* Some other sort of bug\n\n"
"Dolphin will now likely crash or hang. Enjoy.", Cmd);
SysMessage(szTemp);
g_VideoInitialize.pSysMessage(szTemp);
g_VideoInitialize.pLog(szTemp, TRUE);
}
break;

View File

@ -424,7 +424,7 @@ void Renderer::ReinitView(int nNewWidth, int nNewHeight)
if (!OpenGL_Create(g_VideoInitialize, nNewWidth, nNewHeight)) {//nNewWidth&~7, nNewHeight&~7) ) {
ERROR_LOG("Failed to recreate, reverting to old settings\n");
if (!OpenGL_Create(g_VideoInitialize, oldwidth, oldheight)) {
SysMessage("Failed to revert, exiting...\n");
g_VideoInitialize.pSysMessage("Failed to revert, exiting...\n");
// TODO - don't takedown the entire emu
exit(0);
}

View File

@ -392,7 +392,7 @@ void VertexLoader::ProcessFormat()
{
char temp[256];
sprintf(temp,"%i %i %i", m_VtxDesc.Normal, m_VtxAttr.NormalFormat, m_VtxAttr.NormalElements);
SysMessage("VertexLoader_Normal::GetFunction returned zero!");
g_VideoInitialize.pSysMessage("VertexLoader_Normal::GetFunction returned zero!");
}
WriteCall(pFunc);