Base: Quantity: return std::string

This commit is contained in:
Ladislav Michl
2024-07-13 13:07:27 +02:00
committed by Yorik van Havre
parent c11b37e312
commit 2ea8a633ac
58 changed files with 573 additions and 592 deletions

View File

@@ -2294,7 +2294,7 @@ Py::Object FunctionExpression::evaluate(const Expression *expr, int f, const std
return Py::String(args[0]->getPyValue().as_string());
case PARSEQUANT: {
auto quantity_text = args[0]->getPyValue().as_string();
auto quantity_object = Quantity::parse(QString::fromStdString(quantity_text));
auto quantity_object = Quantity::parse(quantity_text);
return Py::asObject(new QuantityPy(new Quantity(quantity_object)));
}
case TRANSLATIONM: {

View File

@@ -1621,10 +1621,10 @@ void PropertyString::setPathValue(const ObjectIdentifier& path, const boost::any
setValue(std::to_string(App::any_cast<float>(value)));
}
else if (value.type() == typeid(Quantity)) {
setValue(boost::any_cast<Quantity>(value).getUserString().toUtf8().constData());
setValue(boost::any_cast<Quantity>(value).getUserString().c_str());
}
else if (value.type() == typeid(std::string)) {
setValue(boost::any_cast<const std::string&>(value));
setValue(boost::any_cast<const std::string &>(value));
}
else {
Base::PyGILStateLocker lock;

View File

@@ -68,7 +68,7 @@ Base::Quantity PropertyQuantity::createQuantityFromPy(PyObject* value)
Base::Quantity quant;
if (PyUnicode_Check(value)) {
quant = Quantity::parse(QString::fromUtf8(PyUnicode_AsUTF8(value)));
quant = Quantity::parse(PyUnicode_AsUTF8(value));
}
else if (PyFloat_Check(value)) {
quant = Quantity(PyFloat_AsDouble(value), _Unit);