mirror of https://github.com/stella-emu/stella.git
More fixes for issues reported by Coverity.
This commit is contained in:
parent
93ba74ad44
commit
382a39a6c7
|
@ -420,7 +420,7 @@ string PhysicalJoystickHandler::getMappingDesc(Event::Type event, EventMode mode
|
|||
case JoyHat::DOWN: buf << "/down"; break;
|
||||
case JoyHat::LEFT: buf << "/left"; break;
|
||||
case JoyHat::RIGHT: buf << "/right"; break;
|
||||
case JoyHat::CENTER: break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -178,7 +178,7 @@ class RewindManager
|
|||
// We do nothing on object instantiation or copy
|
||||
// The goal of LinkedObjectPool is to not do any allocations at all
|
||||
RewindState() : cycles(0) { }
|
||||
RewindState(const RewindState&) { }
|
||||
RewindState(const RewindState& rs) : cycles(rs.cycles) { }
|
||||
|
||||
// Output object info; used for debugging only
|
||||
friend ostream& operator<<(ostream& os, const RewindState& s) {
|
||||
|
|
|
@ -125,19 +125,22 @@ int main(int argc, char* argv[])
|
|||
}
|
||||
else
|
||||
{
|
||||
const string& result = theOSystem->createConsole(romnode);
|
||||
if(result != EmptyString)
|
||||
return Cleanup();
|
||||
|
||||
if(theOSystem->settings().getBool("takesnapshot"))
|
||||
try
|
||||
{
|
||||
try {
|
||||
theOSystem->logMessage("Taking snapshots with 'takesnapshot' ...", 2);
|
||||
const string& result = theOSystem->createConsole(romnode);
|
||||
if(result != EmptyString)
|
||||
return Cleanup();
|
||||
|
||||
if(theOSystem->settings().getBool("takesnapshot"))
|
||||
{
|
||||
for(int i = 0; i < 30; ++i) theOSystem->frameBuffer().update();
|
||||
theOSystem->png().takeSnapshot();
|
||||
} catch(const runtime_error& e) {
|
||||
cout << e.what() << endl;
|
||||
return Cleanup();
|
||||
}
|
||||
}
|
||||
catch(const runtime_error& e)
|
||||
{
|
||||
theOSystem->logMessage(e.what(), 0);
|
||||
return Cleanup();
|
||||
}
|
||||
|
||||
|
|
|
@ -735,7 +735,7 @@ string CartDebug::loadListFile()
|
|||
|
||||
getline(in, line);
|
||||
|
||||
if(line.length() == 0 || line[0] == '-')
|
||||
if(!in.good() || line == "" || line[0] == '-')
|
||||
continue;
|
||||
else // Search for constants
|
||||
{
|
||||
|
@ -798,6 +798,7 @@ string CartDebug::loadSymbolFile()
|
|||
int value = -1;
|
||||
|
||||
getline(in, label);
|
||||
if(!in.good()) continue;
|
||||
stringstream buf(label);
|
||||
buf >> label >> hex >> value;
|
||||
|
||||
|
|
|
@ -64,11 +64,15 @@ void DrivingWidget::loadConfig()
|
|||
if(myController.read(Controller::Two)) gray += 2;
|
||||
|
||||
for(myGrayIndex = 0; myGrayIndex < 4; ++myGrayIndex)
|
||||
{
|
||||
if(ourGrayTable[myGrayIndex] == gray)
|
||||
{
|
||||
setValue(myGrayIndex);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
myFire->setState(!myController.read(Controller::Six));
|
||||
setValue();
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
@ -81,13 +85,13 @@ void DrivingWidget::handleCommand(
|
|||
myGrayIndex = (myGrayIndex + 1) % 4;
|
||||
myController.set(Controller::One, (ourGrayTable[myGrayIndex] & 0x1) != 0);
|
||||
myController.set(Controller::Two, (ourGrayTable[myGrayIndex] & 0x2) != 0);
|
||||
setValue();
|
||||
setValue(myGrayIndex);
|
||||
break;
|
||||
case kGrayDownCmd:
|
||||
myGrayIndex = myGrayIndex == 0 ? 3 : myGrayIndex - 1;
|
||||
myController.set(Controller::One, (ourGrayTable[myGrayIndex] & 0x1) != 0);
|
||||
myController.set(Controller::Two, (ourGrayTable[myGrayIndex] & 0x2) != 0);
|
||||
setValue();
|
||||
setValue(myGrayIndex);
|
||||
break;
|
||||
case kFireCmd:
|
||||
myController.set(Controller::Six, !myFire->getState());
|
||||
|
@ -96,9 +100,9 @@ void DrivingWidget::handleCommand(
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void DrivingWidget::setValue()
|
||||
void DrivingWidget::setValue(int idx)
|
||||
{
|
||||
int grayCode = ourGrayTable[myGrayIndex];
|
||||
int grayCode = ourGrayTable[idx];
|
||||
// FIXME * 8 = a nasty hack, because the DataGridWidget does not support 2 digit binary output
|
||||
myGrayValue->setList(0, (grayCode & 0b01) + (grayCode & 0b10) * 8);
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ class DrivingWidget : public ControllerWidget
|
|||
void loadConfig() override;
|
||||
void handleCommand(CommandSender* sender, int cmd, int data, int id) override;
|
||||
|
||||
void setValue();
|
||||
void setValue(int idx);
|
||||
|
||||
// Following constructors and assignment operators not supported
|
||||
DrivingWidget() = delete;
|
||||
|
|
|
@ -127,7 +127,7 @@ TiaWidget::TiaWidget(GuiObject* boss, const GUI::Font& lfont,
|
|||
2*fontWidth, fontHeight,
|
||||
rowLabel[row], TextAlign::Left);
|
||||
|
||||
for(uInt32 col = 0; col < 5 - row; ++col)
|
||||
for(uInt32 col = 0; col < 5 - row; ++col, ++idx)
|
||||
{
|
||||
myCollision[idx] = new CheckboxWidget(boss, lfont, collX, collY, "", CheckboxWidget::kCheckActionCmd);
|
||||
myCollision[idx]->setTarget(this);
|
||||
|
@ -149,7 +149,6 @@ TiaWidget::TiaWidget(GuiObject* boss, const GUI::Font& lfont,
|
|||
colLabel[col], TextAlign::Left);
|
||||
|
||||
collX += myCollision[idx]->getWidth() + 10;
|
||||
idx++;
|
||||
}
|
||||
collX = xpos + lwidth + 5;
|
||||
collY += lineHeight+3;
|
||||
|
|
|
@ -719,35 +719,42 @@ void EventHandler::setComboMap()
|
|||
replace(list.begin(), list.end(), ':', ' ');
|
||||
istringstream buf(list);
|
||||
|
||||
// Get combo count, which should be the first int in the list
|
||||
// If it isn't, then we treat the entire list as invalid
|
||||
string key;
|
||||
buf >> key;
|
||||
if(atoi(key.c_str()) == kComboSize)
|
||||
{
|
||||
// Fill the combomap table with events for as long as they exist
|
||||
int combocount = 0;
|
||||
while(buf >> key && combocount < kComboSize)
|
||||
{
|
||||
// Each event in a comboevent is separated by a comma
|
||||
replace(key.begin(), key.end(), ',', ' ');
|
||||
istringstream buf2(key);
|
||||
|
||||
int eventcount = 0;
|
||||
while(buf2 >> key && eventcount < kEventsPerCombo)
|
||||
{
|
||||
myComboTable[combocount][eventcount] = Event::Type(atoi(key.c_str()));
|
||||
++eventcount;
|
||||
}
|
||||
++combocount;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Erase the 'combo' array
|
||||
// Erase the 'combo' array
|
||||
auto ERASE_ALL = [&]() {
|
||||
for(int i = 0; i < kComboSize; ++i)
|
||||
for(int j = 0; j < kEventsPerCombo; ++j)
|
||||
myComboTable[i][j] = Event::NoType;
|
||||
};
|
||||
|
||||
// Get combo count, which should be the first int in the list
|
||||
// If it isn't, then we treat the entire list as invalid
|
||||
if(!buf.good())
|
||||
ERASE_ALL();
|
||||
else
|
||||
{
|
||||
string key;
|
||||
buf >> key;
|
||||
if(atoi(key.c_str()) == kComboSize)
|
||||
{
|
||||
// Fill the combomap table with events for as long as they exist
|
||||
int combocount = 0;
|
||||
while(buf >> key && combocount < kComboSize)
|
||||
{
|
||||
// Each event in a comboevent is separated by a comma
|
||||
replace(key.begin(), key.end(), ',', ' ');
|
||||
istringstream buf2(key);
|
||||
|
||||
int eventcount = 0;
|
||||
while(buf2 >> key && eventcount < kEventsPerCombo)
|
||||
{
|
||||
myComboTable[combocount][eventcount] = Event::Type(atoi(key.c_str()));
|
||||
++eventcount;
|
||||
}
|
||||
++combocount;
|
||||
}
|
||||
}
|
||||
else
|
||||
ERASE_ALL();
|
||||
}
|
||||
|
||||
saveComboMapping();
|
||||
|
|
|
@ -166,11 +166,13 @@ void TIA::reset()
|
|||
mySound.reset();
|
||||
myDelayQueue.reset();
|
||||
|
||||
if (myFrameManager) myFrameManager->reset();
|
||||
|
||||
myCyclesAtFrameStart = 0;
|
||||
|
||||
frameReset(); // Recalculate the size of the display
|
||||
if (myFrameManager)
|
||||
{
|
||||
myFrameManager->reset();
|
||||
frameReset(); // Recalculate the size of the display
|
||||
}
|
||||
|
||||
// Must be done last, after all other items have reset
|
||||
enableFixedColors(mySettings.getBool(mySettings.getBool("dev.settings") ? "dev.debugcolors" : "plr.debugcolors"));
|
||||
|
|
Loading…
Reference in New Issue