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>
Mon, 19 Nov 2018 19:47:49 +0000 (20:47 +0100)
commit95848fd9232d92f388e0e533adb15f6ba9d2d492
tree7c04011272858d4c6dd8a95f022abc65187faf42
parent07c41b7cebcc87a313a5bfccd50a7949d126180a
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.
src/common/serializers/serializers.cpp