From bafbf3b872103409370fbda43a2ce3ad153a33f4 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Tue, 13 Oct 2015 11:06:45 +0200 Subject: Provide a simpler and safer version of qdtoa() The new version returns a QString instead of a char * that has to be manually free()'d by the user. Also, it does away with most of the parameters so that we can replace the implementation with something saner without mapping all those modes between the implementations. Change-Id: I42ff95648e7955b9e74eb0f459a1fdedc1ad7efb Reviewed-by: Thiago Macieira --- src/corelib/tools/qlocale_tools.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/corelib/tools/qlocale_tools.cpp') diff --git a/src/corelib/tools/qlocale_tools.cpp b/src/corelib/tools/qlocale_tools.cpp index 03b911c4b3..dd58e7ff9f 100644 --- a/src/corelib/tools/qlocale_tools.cpp +++ b/src/corelib/tools/qlocale_tools.cpp @@ -2614,4 +2614,14 @@ static char *_qdtoa( NEEDS_VOLATILE double d, int mode, int ndigits, int *decpt, return s0; } +QString qdtoa(qreal d, int *decpt, int *sign) +{ + char *result = 0; + char *constResult = 0; + constResult = qdtoa(d, 0, 0, decpt, sign, 0, &result); + const QString ret(QString::fromLatin1(result ? result : constResult)); + free(result); + return ret; +} + QT_END_NAMESPACE -- cgit v1.2.3