QStringRef: preserve null-ness when converting to QAnyStringView


Like for the conversion to QStringView, the conversion to
QAnyStringView was hitting the QASV{container} ctor, which doesn't
deal with QString(Ref)'s funny isNull()-but-data()-!=-nullptr
bug^Wpolicy, leading to null-ness being lost in the conversion.

At some point, it didn't even compile (cf. QTBUG-122797), though this
author could not reproduce the issue after fixing QTBUG-122798.

Fix by providing an implicit conversion operator to
QAnyStringView. This fixes the issue for conversion, but if a user
forces construction (e.g. using QAnyStringView{sr}), then the
QASV{container} ctor is still chosen, and still breaks
null-less. QStringView has the same problem, at the moment.

Fixing that requires changes in QtBase, so guard dependent code with
a macro that a fixed QtCore will set, incl. in QStringRef::operator
QASV() itself.

[ChangeLog][QtCore5Compat][QStringRef] Fixed missing conversion to
QAnyStringView.

Task-number: QTBUG-122797
Pick-to: 6.9 6.8 6.5
Change-Id: Ic848332e8f9e052d1359fa4532131e93e1b5c13c
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
commit5f94627eda523112116917ca08e6d0ab281bd5ea
parent63add2fdd8bdb21744aa9e0791be69901e9e4ce7
authorMarc Mutz <marc.mutz@qt.io>
committerAhmad Samir <a.samirh78@gmail.com>
commit timeSun, 15 Dec 2024 13:41:17 +0000