Commit 82a523f6 authored by hjk's avatar hjk

Relax use of QT_NO_CAST_FROM_ASCII to QT_RESTRICTED_CAST_FROM_ASCII

This is an opt-in trade-off between type safety and user
code convenience.

QT_NO_CAST_FROM_ASCII is highly beneficial to avoid unintended
conversions from 8 bit data with potentially "unsuitable"
encodings to QString. However, it has the undesirable side-effect
to require user code to wrap character and string literals
in QLatin1Char(...) and QLatin1String(...) or use similar
construction, cluttering the code significantly.

QT_RESTRICTED_CAST_FROM_ASCII macro works almost as
QT_NO_CAST_FROM_ASCII, except that it enables the QChar(char)
constructor and adds an additional QString(const char (&ch)[N])
constructor that matches C++ string literals, but no arbitrary
character pointers.

This avoids a significant share of the need to clutter the
user code by only a slight relaxation of the type-safety.

Change-Id: I64e0430bb1352edcedf7e19ee25c16408727084c
Reviewed-by: Orgad Shaneh's avatarOrgad Shaneh <orgads@gmail.com>
Reviewed-by: default avatarEike Ziller <eike.ziller@theqtcompany.com>
parent 05fbef78
......@@ -150,7 +150,7 @@ exists($$IDE_LIBRARY_PATH): LIBS *= -L$$IDE_LIBRARY_PATH # library path from ou
DEFINES += IDE_LIBRARY_BASENAME=\\\"$$IDE_LIBRARY_BASENAME\\\"
}
DEFINES += QT_CREATOR QT_NO_CAST_TO_ASCII QT_NO_CAST_FROM_ASCII
DEFINES += QT_CREATOR QT_NO_CAST_TO_ASCII QT_RESTRICTED_CAST_FROM_ASCII
!macx:DEFINES += QT_USE_FAST_OPERATOR_PLUS QT_USE_FAST_CONCATENATION
unix {
......
......@@ -56,7 +56,7 @@ Project {
"QT_CREATOR",
'IDE_LIBRARY_BASENAME="' + libDirName + '"',
"QT_NO_CAST_TO_ASCII",
"QT_NO_CAST_FROM_ASCII"
"QT_RESTRICTED_CAST_FROM_ASCII"
].concat(testsEnabled ? ["WITH_TESTS"] : [])
qbsSearchPaths: "qbs"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment