QDataStream: prevent accidental streaming of pointers

It doesn't make sense to stream a pointer, but it can happen by
accident because ds << ptr will select the operator<<(bool) overload.
Disable the out-stream operator for pointers by having a better match.

Reading a pointer from a QDataStream doesn't work, as a pointer
can't bind to e.g. a bool non-const reference.

[ChangeLog][QtCore][QDataStream] Streaming of arbitrary pointers
using QDataStream has been disabled. Note that such streaming happened
through the streaming operator for bool.

Change-Id: I4c98a33b52aae85e441f5a096efd404fbbf1e95f
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
bb10
Giuseppe D'Angelo 2023-09-15 11:40:41 +02:00
parent b0ba5c78ee
commit 2fd4a86dc5
1 changed files with 1 additions and 0 deletions

View File

@ -157,6 +157,7 @@ public:
QDataStream &operator<<(const char *str);
QDataStream &operator<<(char16_t c);
QDataStream &operator<<(char32_t c);
QDataStream &operator<<(const volatile void *) = delete;
QDataStream &readBytes(char *&, uint &len);