From 783c53fbd2e291d49cb286f7134e098dc84eec03 Mon Sep 17 00:00:00 2001 From: Tobias Hunger Date: Wed, 20 Jun 2012 15:36:42 +0200 Subject: [PATCH] Device: Simplify code a bit Simplify the code a bit, now that Core::Id uses utf8 conversion from/to QString. Also make sure to not trigger warnings on invalid data. Change-Id: Iccc523161fbcb89148a76684353e96ac875c24c7 Reviewed-by: Daniel Teske --- src/plugins/projectexplorer/devicesupport/idevice.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/plugins/projectexplorer/devicesupport/idevice.cpp b/src/plugins/projectexplorer/devicesupport/idevice.cpp index b8c984f6a4d..eecefc60306 100644 --- a/src/plugins/projectexplorer/devicesupport/idevice.cpp +++ b/src/plugins/projectexplorer/devicesupport/idevice.cpp @@ -261,12 +261,15 @@ Core::Id IDevice::invalidId() Core::Id IDevice::typeFromMap(const QVariantMap &map) { - return Core::Id(map.value(QLatin1String(TypeKey)).toByteArray().constData()); + const QString idStr = map.value(QLatin1String(TypeKey)).toString(); + if (idStr.isEmpty()) + return Core::Id(); + return Core::Id(idStr); } Core::Id IDevice::idFromMap(const QVariantMap &map) { - return Core::Id(map.value(QLatin1String(IdKey)).toByteArray().constData()); + return Core::Id(map.value(QLatin1String(IdKey)).toString()); } void IDevice::fromMap(const QVariantMap &map) @@ -293,7 +296,7 @@ QVariantMap IDevice::toMap() const { QVariantMap map; map.insert(QLatin1String(DisplayNameKey), d->displayName); - map.insert(QLatin1String(TypeKey), d->type.name()); + map.insert(QLatin1String(TypeKey), d->type.toString()); map.insert(QLatin1String(IdKey), d->id.name()); map.insert(QLatin1String(OriginKey), d->origin);