From 477621c4891875ec0fe5c1784859452d8ade62ab Mon Sep 17 00:00:00 2001 From: Arthur Moore Date: Wed, 11 Mar 2015 00:54:22 -0400 Subject: [PATCH] Fixed errors preventing clang from compiling Also did some changed the whitespace of the affected functions. --- debian-build.sh | 2 + src/wx/guiinit.cpp | 155 +++++++++++++++++++++++++-------------------- 2 files changed, 88 insertions(+), 69 deletions(-) diff --git a/debian-build.sh b/debian-build.sh index d8d6098f..86a87c05 100755 --- a/debian-build.sh +++ b/debian-build.sh @@ -19,5 +19,7 @@ fi mkdir "$BUILD_DIRECTORY" cd build # cmake -DCMAKE_BUILD_TYPE=Debug .. +#scan-build cmake -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang .. cmake .. make +#scan-build make diff --git a/src/wx/guiinit.cpp b/src/wx/guiinit.cpp index bfabe4f7..32fd2b6c 100644 --- a/src/wx/guiinit.cpp +++ b/src/wx/guiinit.cpp @@ -520,65 +520,76 @@ public: // It might be safest to only support desc edits, and force the // user to re-enter codes to change them int ncodes = isgb ? gbCheatNumber : cheatsNumber; - if(ncodes > id + 1) { - wxString codes[ncodes - id - 1]; - wxString descs[ncodes - id - 1]; - bool checked[ncodes - id - 1]; - bool v3[ncodes - id - 1]; - for(int i = id + 1; i < ncodes; i++) { - codes[i - id - 1] = wxString(isgb ? - gbCheatList[i].cheatCode : - cheatsList[i].codestring, - wxConvLibc); - descs[i - id - 1] = wxString(isgb ? - gbCheatList[i].cheatDesc : - cheatsList[i].desc, - wxConvUTF8); - checked[i - id - 1] = isgb ? gbCheatList[i].enabled : - cheatsList[i].enabled; - v3[i - id - 1] = isgb ? false : cheatsList[i].code == 257; - } - for(int i = ncodes - 1; i >= id; i--) { - list->DeleteItem(i); - if(isgb) - gbCheatRemove(i); - else - cheatsDelete(i, cheatsList[i].enabled); - } - AddCheat(); - if(!ochecked) { - if(isgb) - gbCheatDisable(id); - else - cheatsDisable(id); - } - for(int i = id + 1; i < ncodes; i++) { - ce_codes = codes[i - id - 1]; - ce_desc = descs[i - id - 1]; - if(isgb) { - if(ce_codes.find(wxT('-')) == wxString::npos) - ce_type = 0; - else - ce_type = 1; - } else { - if(ce_codes.find(wxT(':')) != wxString::npos) - ce_type = 0; - else if(ce_codes.find(wxT(' ')) == wxString::npos) { - ce_type = 1; - if(v3[i - id - 1]) - ce_codes.insert(8, 1, wxT(' ')); - } else - ce_type = 2; - } - AddCheat(); - if(!checked[i - id - 1]) { - if(isgb) - gbCheatDisable(i); - else - cheatsDisable(i); - } - } - } else { + if(ncodes > id + 1) + { + std::vector codes; + std::vector descs; + bool checked[ncodes - id - 1]; + bool v3[ncodes - id - 1]; + for(int i = id + 1; i < ncodes; i++) { + codes[i - id - 1] = wxString(isgb ? + gbCheatList[i].cheatCode : + cheatsList[i].codestring, + wxConvLibc); + descs[i - id - 1] = wxString(isgb ? + gbCheatList[i].cheatDesc : + cheatsList[i].desc, + wxConvUTF8); + checked[i - id - 1] = isgb ? gbCheatList[i].enabled : + cheatsList[i].enabled; + v3[i - id - 1] = isgb ? false : cheatsList[i].code == 257; + } + for(int i = ncodes - 1; i >= id; i--) { + list->DeleteItem(i); + if(isgb) + gbCheatRemove(i); + else + cheatsDelete(i, cheatsList[i].enabled); + } + AddCheat(); + if(!ochecked) { + if(isgb) + gbCheatDisable(id); + else + cheatsDisable(id); + } + for(int i = id + 1; i < ncodes; i++) { + ce_codes = codes[i - id - 1]; + ce_desc = descs[i - id - 1]; + if(isgb) + { + if(ce_codes.find(wxT('-')) == wxString::npos) + ce_type = 0; + else + ce_type = 1; + } + else + { + if(ce_codes.find(wxT(':')) != wxString::npos) + ce_type = 0; + else if(ce_codes.find(wxT(' ')) == wxString::npos) + { + ce_type = 1; + if(v3[i - id - 1]) + ce_codes.insert(8, 1, wxT(' ')); + } + else + { + ce_type = 2; + } + } + AddCheat(); + if(!checked[i - id - 1]) + { + if(isgb) + gbCheatDisable(i); + else + cheatsDisable(i); + } + } + } + else + { list->DeleteItem(id); if(isgb) gbCheatRemove(id); @@ -3188,16 +3199,22 @@ void MainFrame::set_global_accels() if(!accels[i].GetMenuItem()) len++; if(len) { - wxAcceleratorEntry tab[len]; - for(int i = 0, j = 0; i < accels.size(); i++) - if(!accels[i].GetMenuItem()) - tab[j++] = accels[i]; - wxAcceleratorTable atab(len, tab); - // set the table on the panel, where focus usually is - // otherwise accelerators are lost sometimes - panel->SetAcceleratorTable(atab); - } else - panel->SetAcceleratorTable(wxNullAcceleratorTable); + wxAcceleratorEntry * tab = new wxAcceleratorEntry[len]; + for(int i = 0, j = 0; i < accels.size(); i++) + { + if(!accels[i].GetMenuItem()) + tab[j++] = accels[i]; + } + wxAcceleratorTable atab(len, tab); + // set the table on the panel, where focus usually is + // otherwise accelerators are lost sometimes + panel->SetAcceleratorTable(atab); + delete tab; + } + else + { + panel->SetAcceleratorTable(wxNullAcceleratorTable); + } // save recent accels for(int i = 0; i < 10; i++)