serializers: Fix quint16 deserialization, remove code duplication
authorManuel Nickschas <sputnick@quassel-irc.org>
Sun, 18 Nov 2018 22:18:47 +0000 (23:18 +0100)
committerManuel Nickschas <sputnick@quassel-irc.org>
Tue, 20 Nov 2018 20:32:22 +0000 (21:32 +0100)
commitc81e540aeea2b9787fbb09e2896d3e5c5adf0bbd
treee959e89f985c15ed8a7b229553430c3158a2cc79
parent98cf856e5cccb789b4b89fbfb42e882129b80334
serializers: Fix quint16 deserialization, remove code duplication

Fix a bug where a quint16 would be deserialized into a QVariant
of type Int (instead of UShort). This broke the sync of
autoReconnectRetries in the network settings, because the slot's
signature didn't match the type of the QVariant.

The issue was caused by QVariant not having a constructor for
quint16, thus casting it into an int. Fix this by using
QVariant::fromValue(), which handles the type correctly.

Use the opportunity to remove much of the code duplication in the
deserialization code by providing and using a template function,
avoiding potential other issues with using QVariant's constructor.

(cherry picked from commit 95848fd9232d92f388e0e533adb15f6ba9d2d492)
src/common/serializers/serializers.cpp