mirror of
https://github.com/The-Powder-Toy/The-Powder-Toy.git
synced 2025-08-13 20:04:01 +02:00
Fix crash when trying to convert StringType to PointType
This commit is contained in:
@@ -48,6 +48,13 @@ AnyType::operator StringType()
|
|||||||
{
|
{
|
||||||
return StringType(*((std::string*)value));
|
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
|
else
|
||||||
throw InvalidConversionException(type, TypeString);
|
throw InvalidConversionException(type, TypeString);
|
||||||
|
|
||||||
@@ -61,10 +68,13 @@ AnyType::operator PointType()
|
|||||||
}
|
}
|
||||||
else if(type == TypeString)
|
else if(type == TypeString)
|
||||||
{
|
{
|
||||||
ui::Point thisPoint = *((ui::Point*)value);
|
std::stringstream pointStream(*((std::string*)value));
|
||||||
std::stringstream pointStream;
|
int x, y;
|
||||||
pointStream << thisPoint.X << "," << thisPoint.Y;
|
char comma;
|
||||||
return StringType(pointStream.str());
|
pointStream >> x >> comma >> y;
|
||||||
|
if (pointStream.fail() || comma != ',')
|
||||||
|
throw InvalidConversionException(type, TypePoint);
|
||||||
|
return PointType(ui::Point(x, y));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
throw InvalidConversionException(type, TypePoint);
|
throw InvalidConversionException(type, TypePoint);
|
||||||
|
Reference in New Issue
Block a user