diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2017-03-17 17:49:44 +0100 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2017-03-21 13:10:50 +0000 |
commit | 1bc9e17636f5fd0a4c86cba379f0060fe894b1bb (patch) | |
tree | 37a7e1aedd724bee854b36f1eb9535f0984ed3af | |
parent | 4db21fe60e9a852298e12d7fce7b5d2bbde7443e (diff) |
V4 Debugger: Encode NaN and +/-Infinity as strings
JSON doesn't have numerical values for those. However, as we give the
type of each item in a separate field, we can just use strings here and
the result will still not clash with actual strings.
Task-number: QTBUG-47880
Change-Id: I85ffa008890a8a9e6894dd3151f7dc6b527ed5e1
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
-rw-r--r-- | src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.cpp b/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.cpp index 8075b7c067..b4b95f6713 100644 --- a/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.cpp +++ b/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.cpp @@ -187,10 +187,19 @@ const QV4::Object *collectProperty(const QV4::ScopedValue &value, QV4::Execution case QV4::Value::Integer_Type: dict.insert(valueKey, value->integerValue()); return 0; - default: // double - dict.insert(valueKey, value->doubleValue()); + default: {// double + const double val = value->doubleValue(); + if (qIsFinite(val)) + dict.insert(valueKey, val); + else if (qIsNaN(val)) + dict.insert(valueKey, QStringLiteral("NaN")); + else if (val < 0) + dict.insert(valueKey, QStringLiteral("-Infinity")); + else + dict.insert(valueKey, QStringLiteral("Infinity")); return 0; } + } } QJsonObject QV4DataCollector::lookupRef(Ref ref, bool deep) |