WAGE: Avoid calling method of nullptr

This commit is contained in:
Willem Jan Palenstijn 2017-12-08 02:00:42 +01:00 committed by Eugene Sandulenko
parent 257a99bdb8
commit f35cb961f2
2 changed files with 12 additions and 5 deletions

View File

@ -125,7 +125,7 @@ public:
void setDesignBounds(Common::Rect *bounds);
Common::String toString() { return _name; }
Common::String toString() const { return _name; }
};
class Chr : public Designed {

View File

@ -56,6 +56,13 @@
namespace Wage {
static Common::String toString(const Designed *d) {
if (!d)
return "<NULL>";
else
return d->toString();
}
Common::String Script::Operand::toString() {
switch(_type) {
case NUMBER:
@ -64,13 +71,13 @@ Common::String Script::Operand::toString() {
case TEXT_INPUT:
return *_value.string;
case OBJ:
return _value.obj->toString();
return Wage::toString(_value.obj);
case CHR:
return _value.chr->toString();
return Wage::toString(_value.chr);
case SCENE:
return _value.scene->toString();
return Wage::toString(_value.scene);
case CLICK_INPUT:
return _value.inputClick->toString();
return Wage::toString(_value.inputClick);
default:
error("Unhandled operand type: _type");
}