summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjacksonmj <mj-pt@jacksonmj.co.uk>2013-09-27 18:41:12 (GMT)
committer jacksonmj <mj-pt@jacksonmj.co.uk>2013-09-27 18:41:12 (GMT)
commitceca61114a946506a3596c0ea1c0d55723d10ce1 (patch)
tree90bae765a1875256550345f8f5c4c84b585fcc64
parent44b7c4f8f49ef579dcc260f6efa2e36313877910 (diff)
downloadpowder-ceca61114a946506a3596c0ea1c0d55723d10ce1.zip
powder-ceca61114a946506a3596c0ea1c0d55723d10ce1.tar.gz
Fix crash when trying to convert StringType to PointType
-rw-r--r--src/cat/TPTSTypes.cpp18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/cat/TPTSTypes.cpp b/src/cat/TPTSTypes.cpp
index 87d1097..0a3e940 100644
--- a/src/cat/TPTSTypes.cpp
+++ b/src/cat/TPTSTypes.cpp
@@ -48,6 +48,13 @@ AnyType::operator StringType()
{
return StringType(*((std::string*)value));
}
+ else if (type == TypePoint && value)
+ {
+ ui::Point thisPoint = *((ui::Point*)value);
+ std::stringstream pointStream;
+ pointStream << thisPoint.X << "," << thisPoint.Y;
+ return StringType(pointStream.str());
+ }
else
throw InvalidConversionException(type, TypeString);
@@ -61,10 +68,13 @@ AnyType::operator PointType()
}
else if(type == TypeString)
{
- ui::Point thisPoint = *((ui::Point*)value);
- std::stringstream pointStream;
- pointStream << thisPoint.X << "," << thisPoint.Y;
- return StringType(pointStream.str());
+ std::stringstream pointStream(*((std::string*)value));
+ int x, y;
+ char comma;
+ pointStream >> x >> comma >> y;
+ if (pointStream.fail() || comma != ',')
+ throw InvalidConversionException(type, TypePoint);
+ return PointType(ui::Point(x, y));
}
else
throw InvalidConversionException(type, TypePoint);