QLatin1String: add default ctor

A pending change in uic depends on this.

[ChangeLog][QtCore][QLatin1String] Added default constructor.

Change-Id: Ie6f5dfc7b38683a488b0ff7f31404800ef5ee188
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Marc Mutz 2015-10-18 15:50:05 +02:00
parent 21b1a492ed
commit dd8351b654
3 changed files with 17 additions and 0 deletions

View File

@ -8225,6 +8225,12 @@ QString &QString::setRawData(const QChar *unicode, int size)
\sa QString, QLatin1Char, {QStringLiteral()}{QStringLiteral}
*/
/*! \fn QLatin1String::QLatin1String()
\since 5.6
Constructs a QLatin1String object that stores a nullptr.
*/
/*! \fn QLatin1String::QLatin1String(const char *str)
Constructs a QLatin1String object that stores \a str.

View File

@ -83,6 +83,7 @@ template <typename T> class QVector;
class QLatin1String
{
public:
Q_DECL_CONSTEXPR inline QLatin1String() Q_DECL_NOTHROW : m_size(0), m_data(Q_NULLPTR) {}
Q_DECL_CONSTEXPR inline explicit QLatin1String(const char *s) : m_size(s ? int(strlen(s)) : 0), m_data(s) {}
Q_DECL_CONSTEXPR inline explicit QLatin1String(const char *s, int sz) : m_size(sz), m_data(s) {}
inline explicit QLatin1String(const QByteArray &s) : m_size(s.size()), m_data(s.constData()) {}

View File

@ -46,6 +46,16 @@ private Q_SLOTS:
void tst_QLatin1String::nullString()
{
// default ctor
{
QLatin1String l1;
QCOMPARE(static_cast<const void*>(l1.data()), static_cast<const void*>(Q_NULLPTR));
QCOMPARE(l1.size(), 0);
QString s = l1;
QVERIFY(s.isNull());
}
// from nullptr
{
const char *null = Q_NULLPTR;