From 7a7969ae8a1f90c28dab711bc548b7c5ed117abb Mon Sep 17 00:00:00 2001 From: thrust26 Date: Thu, 6 Feb 2020 20:12:37 +0100 Subject: [PATCH] fix stoi exception for Display_PPBlend --- src/emucore/Console.cxx | 8 +++++++- src/emucore/TIASurface.cxx | 6 +++++- src/gui/GameInfoDialog.cxx | 9 ++++++++- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/emucore/Console.cxx b/src/emucore/Console.cxx index b18cf0098..867eee9d9 100644 --- a/src/emucore/Console.cxx +++ b/src/emucore/Console.cxx @@ -583,7 +583,13 @@ void Console::togglePhosphor() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void Console::changePhosphor(int direction) { - int blend = stoi(myProperties.get(PropType::Display_PPBlend)); + int blend = 0; + + try + { + blend = stoi(myProperties.get(PropType::Display_PPBlend)); + } + catch (...) {} if(direction == +1) // increase blend { diff --git a/src/emucore/TIASurface.cxx b/src/emucore/TIASurface.cxx index 95e22fa65..b99f33be0 100644 --- a/src/emucore/TIASurface.cxx +++ b/src/emucore/TIASurface.cxx @@ -91,7 +91,11 @@ void TIASurface::initialize(const Console& console, } else { - p_blend = stoi(console.properties().get(PropType::Display_PPBlend)); + try + { + p_blend = stoi(console.properties().get(PropType::Display_PPBlend)); + } + catch (...) {} enable = console.properties().get(PropType::Display_Phosphor) == "YES"; } enablePhosphor(enable, p_blend); diff --git a/src/gui/GameInfoDialog.cxx b/src/gui/GameInfoDialog.cxx index 3929268ad..9ed16a231 100644 --- a/src/gui/GameInfoDialog.cxx +++ b/src/gui/GameInfoDialog.cxx @@ -460,7 +460,14 @@ void GameInfoDialog::loadEmulationProperties(const Properties& props) myPPBlend->setEnabled(!alwaysPhosphor && usePhosphor); const string& blend = props.get(PropType::Display_PPBlend); - myPPBlend->setValue(stoi(blend)); + try + { + myPPBlend->setValue(stoi(blend)); + } + catch (...) + { + myPPBlend->setValue(0); + } // set vertical center Int32 vcenter = stoi(props.get(PropType::Display_VCenter));