Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Make sure QML type "real" always maps to C++ type "double"
The type "real" was documented to be a single-precision float, but that's incorrect. It's always been double. However, signal parameters of type "real" would be mapped to the C++ type "qreal", which can be either float or double depending on the platform. Since JavaScript floating point numbers have double precision, QML should use the same, to avoid potential loss of precision. With this change, "real" behaves the same as the QML "double" type (which already guaranteed double precision). Even though it's redundant, "double" is kept to preserve compatibility. Added tests for the "double" type to the QML meta-object autotest, and a test for the "real" type that ensures there's no loss of precision. Change-Id: I1a77f1fd45082ff670684a935e17d1a46ea75d84 Reviewed-by: Aaron Kennedy <aaron.kennedy@nokia.com>
- Loading branch information
Kent Hansen
authored and
Qt by Nokia
committed
Mar 7, 2012
1 parent
3f3850e
commit aed15e7
Showing
8 changed files
with
66 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import Qt.test 1.0 | ||
import QtQuick 2.0 | ||
|
||
QtObject { | ||
property real test: 1234567890 | ||
property real test2 | ||
property real test3 | ||
property real test4: test3 | ||
property real test5: func() | ||
property real test6: test2 + test3 | ||
|
||
signal sig(real arg) | ||
|
||
Component.onCompleted: { | ||
test2 = 1234567890; | ||
sig(1234567890) | ||
} | ||
|
||
onSig: { test3 = arg; } | ||
|
||
function func() { return 1234567890; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import QtQuick 2.0 | ||
|
||
QtObject { | ||
property double test: 1234567890 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import QtQuick 2.0 | ||
|
||
QtObject { | ||
property real test: 21 | ||
property real test: 1234567890 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import QtQuick 2.0 | ||
|
||
QtObject { | ||
signal testSignal(double foo) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters