summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qlocale_tools.cpp
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@theqtcompany.com>2015-10-13 11:06:45 +0200
committerUlf Hermann <ulf.hermann@theqtcompany.com>2015-10-20 08:38:01 +0000
commitbafbf3b872103409370fbda43a2ce3ad153a33f4 (patch)
treeb1a97c1c4435d0ed7670e44f1b6c1c8dcdc4f11d /src/corelib/tools/qlocale_tools.cpp
parent52d5b272394f5d1fd84d5c44af78e3b87d264766 (diff)
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 <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/tools/qlocale_tools.cpp')
-rw-r--r--src/corelib/tools/qlocale_tools.cpp10
1 files changed, 10 insertions, 0 deletions
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