Merge pull request #2059 from aquanull/patch-2

Fix some Windows-only crashes
This commit is contained in:
Henrik Rydgård 2013-06-03 06:23:32 -07:00
commit 1aba33ae38
6 changed files with 30 additions and 33 deletions

View file

@ -19,16 +19,9 @@
#include <string>
#include <cstdio>
#ifdef _WIN32
namespace MainWindow {
void BrowseAndBoot(std::string defaultPath);
}
#pragma execution_character_set("utf-8")
#endif
#ifdef _MSC_VER
#define snprintf _snprintf
#pragma execution_character_set("utf-8")
#endif
#include "base/display.h"
@ -72,6 +65,13 @@ namespace MainWindow {
#include <QDir>
#endif
#ifdef _WIN32
namespace MainWindow {
extern HWND hwndMain;
void BrowseAndBoot(std::string defaultPath);
}
#endif
#if !defined(nullptr)
#define nullptr NULL
#endif
@ -251,12 +251,12 @@ void MenuScreen::render() {
}
if (UIButton(GEN_ID, vlinear, w, 0, m->T("Exit"), ALIGN_RIGHT)) {
// TODO: Save when setting changes, rather than when we quit
NativeShutdown();
// TODO: Need a more elegant way to quit
#ifdef _WIN32
ExitProcess(0);
PostMessage(MainWindow::hwndMain, WM_CLOSE, 0, 0);
#else
// TODO: Save when setting changes, rather than when we quit
NativeShutdown();
exit(0);
#endif
}

View file

@ -244,12 +244,12 @@ void CtrlDisAsmView::onPaint(WPARAM wParam, LPARAM lParam)
const char *mojs=strstr(dis2,"->$");
if (mojs)
{
for (int i=0; i<8; i++)
for (int j=0; j<8; ++j)
{
bool found=false;
for (int j=0; j<22; j++)
for (int k=0; k<22; ++k)
{
if (mojs[i+3]=="0123456789ABCDEFabcdef"[j])
if (mojs[j+3]=="0123456789ABCDEFabcdef"[k])
found=true;
}
if (!found)

View file

@ -201,11 +201,11 @@ void CtrlMemView::onPaint(WPARAM wParam, LPARAM lParam)
sprintf(temp, "%08x %08x %08x %08x ................",
memory[0],memory[1],memory[2],memory[3]);
}
for (int i=0; i<16; i++)
for (int j=0; j<16; ++j)
{
int c = (unsigned char)m[i];
int c = (unsigned char)m[j];
if (c>=32 && c<255)
temp[i+37]=c;
temp[j+37]=c;
}
}
// if (align == 16)

View file

@ -224,11 +224,11 @@ void CtrlRegisterList::onPaint(WPARAM wParam, LPARAM lParam)
// Check for any changes in the registers.
if (lastPC != cpu->GetPC())
{
for (int i = 0, n = cpu->GetNumRegsInCategory(0); i < n; ++i)
for (int j = 0, n = cpu->GetNumRegsInCategory(0); j < n; ++j)
{
u32 v = cpu->GetRegValue(0, i);
changedCat0Regs[i] = v != lastCat0Values[i];
lastCat0Values[i] = v;
u32 v = cpu->GetRegValue(0, j);
changedCat0Regs[j] = v != lastCat0Values[j];
lastCat0Values[j] = v;
}
lastPC = cpu->GetPC();
}

View file

@ -155,7 +155,6 @@ BOOL CVFPUDlg::DlgProc(UINT message, WPARAM wParam, LPARAM lParam)
int x = column * columnWidth + xStart;
Rectangle(hdc, x, y, x + columnWidth, y+rowHeight);
char temp[256];
temp_len = sprintf_s(temp, "R%i0%i", matrix, column);
TextOut(hdc,x+3,y+2,temp,temp_len);
@ -169,8 +168,6 @@ BOOL CVFPUDlg::DlgProc(UINT message, WPARAM wParam, LPARAM lParam)
{
float val = mipsr4k.v[column*32+row+matrix*4];
u32 hex = *((u32*)&val);
char temp[256];
int temp_len;
switch (mode)
{
case 0: temp_len = sprintf_s(temp,"%f",val); break;

View file

@ -390,8 +390,6 @@ namespace MainWindow
int wmId, wmEvent;
std::string fn;
I18NCategory *g = GetI18NCategory("Graphics");
switch (message)
{
case WM_CREATE:
@ -415,6 +413,9 @@ namespace MainWindow
return 0;
case WM_COMMAND:
{
I18NCategory *g = GetI18NCategory("Graphics");
wmId = LOWORD(wParam);
wmEvent = HIWORD(wParam);
// Parse the menu selections:
@ -698,22 +699,21 @@ namespace MainWindow
case ID_EMULATION_SOUND:
g_Config.bEnableSound = !g_Config.bEnableSound;
break;
case ID_HELP_OPENWEBSITE:
case ID_HELP_OPENWEBSITE:
ShellExecute(NULL, "open", "http://www.ppsspp.org/", NULL, NULL, SW_SHOWNORMAL);
break;
break;
case ID_HELP_ABOUT:
case ID_HELP_ABOUT:
DialogManager::EnableAll(FALSE);
DialogBox(hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, (DLGPROC)About);
DialogManager::EnableAll(TRUE);
break;
default:
{
MessageBox(hwndMain,"Unimplemented","Sorry",0);
}
MessageBox(hwndMain,"Unimplemented","Sorry",0);
break;
}
}
break;
case WM_KEYDOWN:
return 0;
@ -1342,7 +1342,7 @@ namespace MainWindow
} else {
int n = 1;
if (buttonCode != -1) {
for (int i = buttonCode >> 8; i > 1; i >>= 1) {
for (int j = buttonCode >> 8; j > 1; j >>= 1) {
n++;
}
snprintf(str, CONTROLS_BUTTONNAME_MAX, "%s",