From 65640ee6af9dd2729afa8b28f9a3133fdf0896a4 Mon Sep 17 00:00:00 2001 From: liquidcaesium Date: Fri, 27 Sep 2013 18:52:47 +0300 Subject: [PATCH 1/2] Decimal number support --- src/cat/TPTScriptInterface.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cat/TPTScriptInterface.cpp b/src/cat/TPTScriptInterface.cpp index 6519aec4e..87e058467 100644 --- a/src/cat/TPTScriptInterface.cpp +++ b/src/cat/TPTScriptInterface.cpp @@ -146,7 +146,7 @@ int TPTScriptInterface::parseNumber(char * stringData) } else { - return atoi(stringData); + return atof(stringData); } return currentNumber; } From ceca61114a946506a3596c0ea1c0d55723d10ce1 Mon Sep 17 00:00:00 2001 From: jacksonmj Date: Fri, 27 Sep 2013 19:41:12 +0100 Subject: [PATCH 2/2] Fix crash when trying to convert StringType to PointType --- src/cat/TPTSTypes.cpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/cat/TPTSTypes.cpp b/src/cat/TPTSTypes.cpp index 87d10972c..0a3e940c9 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);