From 5bc54c878f012e7a2569c2e3cee87be90a38af21 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Sun, 28 Feb 2016 12:24:15 +0100 Subject: QIBusEngineDesc: initialize all members when deserializing from older versions De-duplicated code using, as suggested in previous review, strategic gotos. Change-Id: I4550dd8eff99789a41d8bb0b015bc4f51e3969fe Reviewed-by: Takao Fujiwara Reviewed-by: Lars Knoll --- .../platforminputcontexts/ibus/qibustypes.cpp | 38 ++++++++++++---------- 1 file changed, 21 insertions(+), 17 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforminputcontexts/ibus/qibustypes.cpp b/src/plugins/platforminputcontexts/ibus/qibustypes.cpp index 9462bad335..cc62fef6bb 100644 --- a/src/plugins/platforminputcontexts/ibus/qibustypes.cpp +++ b/src/plugins/platforminputcontexts/ibus/qibustypes.cpp @@ -346,30 +346,34 @@ void QIBusEngineDesc::deserializeFrom(const QDBusArgument &argument) argument >> setup; // Previous IBusEngineDesc supports the arguments between engine_name // and setup. - if (argument.currentSignature() == "") { - argument.endStructure(); - return; - } + if (argument.currentSignature() == "") + goto olderThanV2; argument >> layout_variant; argument >> layout_option; // Previous IBusEngineDesc supports the arguments between engine_name // and layout_option. - if (argument.currentSignature() == "") { - argument.endStructure(); - return; - } + if (argument.currentSignature() == "") + goto olderThanV3; argument >> version; - if (argument.currentSignature() == "") { - argument.endStructure(); - return; - } + if (argument.currentSignature() == "") + goto olderThanV4; argument >> textdomain; - if (argument.currentSignature() == "") { - argument.endStructure(); - return; - } + if (argument.currentSignature() == "") + goto olderThanV5; argument >> iconpropkey; - + // <-- insert new member streaming here (1/2) + goto newest; +olderThanV2: + layout_variant.clear(); + layout_option.clear(); +olderThanV3: + version.clear(); +olderThanV4: + textdomain.clear(); +olderThanV5: + iconpropkey.clear(); + // <-- insert new members here (2/2) +newest: argument.endStructure(); } -- cgit v1.2.3