aboutsummaryrefslogtreecommitdiff
path: root/lib/csapi/banning.cpp
diff options
context:
space:
mode:
authorAlexey Rusakov <Kitsune-Ral@users.sf.net>2022-09-10 10:43:59 +0200
committerAlexey Rusakov <Kitsune-Ral@users.sf.net>2022-09-10 20:38:01 +0200
commit20f01303b40df8b7710dfa560940a7c71c1e9c19 (patch)
tree970f570f76747b00bc3f2d7f6f1f947a5feb6cff /lib/csapi/banning.cpp
parentd890cc09dd6cd096423271ce47ca4ac86d2e9e41 (diff)
downloadlibquotient-20f01303b40df8b7710dfa560940a7c71c1e9c19.tar.gz
libquotient-20f01303b40df8b7710dfa560940a7c71c1e9c19.zip
Adjust converters.h logic to support Qt 6.4
There's a bit convoluted stack of calls involved here, worth laying out. C++ containers are loaded from JSON containers by calling fromJson<> on each element of the JSON container, specialised by the element type of the C++ container. If that element type is not itself an object (e.g., QString), the respective specialisation of fromJson<> is supposed to kick-in and override the default template that delegates the conversion to JsonConverter (which in turn falls back to JsonObjectConverter unless specialised for that type). Because template functions cannot be partially specialised, that specialised overload for, say, QString, is not complete: it accepts QJsonValue but anything except QJsonValue will hit the generic overload instead. That makes the whole fromJson<> machinery quite sensitive to the exact JSON type passed to it; but as of Qt 5, the types actually presented to fromJson() were limited to QJsonValue and QJsonDocument (okay, QJsonObject and QJsonArray could also be there but the QJsonObject case is trivial for JsonConverter and containers loaded from QJsonArray are all caught with JsonArrayConverter). Qt 6 started returning (const) QJsonValueRef from `QJson*::const_iterator::operator*()` - meaning that whenever a simple type (like, again, QString) is loaded within the bigger container, the "wrong" fromJson() gets called. To fix this, JsonObjectUnpacker gained a dedicated function to unpack QJsonValueRef. QJsonValueRef is an old name existing since Qt 5.15 - no big pain. However, in Qt 6.4 QJsonValueConstRef is getting introduced for the same purpose. It's possible to wrap the *Ref overloads in some #if/#else brackets but at that point it becomes easier to just produce QJsonValue from whatever QJson* iterators dereference to.
Diffstat (limited to 'lib/csapi/banning.cpp')
0 files changed, 0 insertions, 0 deletions