From 2708c03f6e013d4445cc986481464ab44e6d668e Mon Sep 17 00:00:00 2001 From: aquanull Date: Mon, 3 Jun 2013 20:30:12 +0800 Subject: [PATCH] Work around occasional GetI18NCategory() failure in WndProc(). Also fix some variable-shadowing. --- Windows/Debugger/CtrlDisAsmView.cpp | 6 +++--- Windows/Debugger/CtrlMemView.cpp | 6 +++--- Windows/Debugger/CtrlRegisterList.cpp | 8 ++++---- Windows/Debugger/Debugger_VFPUDlg.cpp | 3 --- Windows/WndMainWindow.cpp | 18 +++++++++--------- 5 files changed, 19 insertions(+), 22 deletions(-) diff --git a/Windows/Debugger/CtrlDisAsmView.cpp b/Windows/Debugger/CtrlDisAsmView.cpp index 67c3f83329..b57871f5d3 100644 --- a/Windows/Debugger/CtrlDisAsmView.cpp +++ b/Windows/Debugger/CtrlDisAsmView.cpp @@ -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) diff --git a/Windows/Debugger/CtrlMemView.cpp b/Windows/Debugger/CtrlMemView.cpp index 0436a23f6b..267a28fa16 100644 --- a/Windows/Debugger/CtrlMemView.cpp +++ b/Windows/Debugger/CtrlMemView.cpp @@ -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) diff --git a/Windows/Debugger/CtrlRegisterList.cpp b/Windows/Debugger/CtrlRegisterList.cpp index 37b355cbde..2e80c32ecb 100644 --- a/Windows/Debugger/CtrlRegisterList.cpp +++ b/Windows/Debugger/CtrlRegisterList.cpp @@ -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(); } diff --git a/Windows/Debugger/Debugger_VFPUDlg.cpp b/Windows/Debugger/Debugger_VFPUDlg.cpp index 558c3cbfd1..4e25eff3f3 100644 --- a/Windows/Debugger/Debugger_VFPUDlg.cpp +++ b/Windows/Debugger/Debugger_VFPUDlg.cpp @@ -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; diff --git a/Windows/WndMainWindow.cpp b/Windows/WndMainWindow.cpp index 5ca843cff2..01f1be8fef 100644 --- a/Windows/WndMainWindow.cpp +++ b/Windows/WndMainWindow.cpp @@ -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",