QStringRef: fix lost null-ness when converting to QStringView


When QStringRef was moved out of QtCore, QStringRef (which needs the
same special isNull() handling that QString also needs, due to the
never-nullptr data() bug^Wpolicy) was dropped from QStringView's
if_qstring_like constraint, and the replacement QStringRef::operator
QStringView() didn't take the issue into account for all cases:

A QStringRef with a nullptr string() will create a null QStringView,
but a likewise isNull() QStringRef constructed over an isNull()
QString will create a non-null QStringView (over
QStringRef::data()::_empty).

Fix by checking for QStringRef::isNull() instead of just !m_string in
operator QStringView().

Amends 80ffb97660907ab9a8d844b6c720e7c7fec0eb59.

[ChangeLog][QtCore5Compat][QStringRef] Fixed a Qt 6 regression where
conversion to QStringView would no longer preserve nullness.

Task-number: QTBUG-122798
Pick-to: 6.9 6.8 6.5
Change-Id: Ie28e02c6553271a2cb6e8e6816de8c79b8c84b31
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
commit63add2fdd8bdb21744aa9e0791be69901e9e4ce7
parent6d80b76e9e2130c868d6b8dc3d8c15d3c5c26d49
authorMarc Mutz <marc.mutz@qt.io>
committerMarc Mutz <marc.mutz@qt.io>
commit timeThu, 12 Dec 2024 15:43:17 +0100