Based on discussion around T107 and slack

* Use CJsonScope scope("MetaData") for stacktrace
* added Q_UNUSED(scope) to avoid QtC warnings
This commit is contained in:
Klaus Basan
2017-07-14 15:13:57 +02:00
committed by Mathew Sutcliffe
parent c4db854fad
commit 94c9886c35
8 changed files with 21 additions and 3 deletions

View File

@@ -69,6 +69,7 @@ namespace BlackMisc
CAircraftEngine engine; CAircraftEngine engine;
int number = e.toInt(); int number = e.toInt();
CJsonScope scope(e); CJsonScope scope(e);
Q_UNUSED(scope);
engine.convertFromJson(json.value(e).toObject()); engine.convertFromJson(json.value(e).toObject());
engine.setNumber(number); engine.setNumber(number);
push_back(engine); push_back(engine);

View File

@@ -129,6 +129,7 @@ namespace BlackMisc
for (auto i = array.begin(); i != array.end(); ++i) for (auto i = array.begin(); i != array.end(); ++i)
{ {
CJsonScope scope("containerbase", index++); CJsonScope scope("containerbase", index++);
Q_UNUSED(scope);
QJsonValueRef ref = (*i); QJsonValueRef ref = (*i);
T val; T val;
ref >> val; ref >> val;

View File

@@ -273,10 +273,12 @@ namespace BlackMisc
Value val; Value val;
{ {
CJsonScope scope("associativecontainerbase", 2 * index); CJsonScope scope("associativecontainerbase", 2 * index);
Q_UNUSED(scope);
jsonKey >> key; jsonKey >> key;
} }
{ {
CJsonScope scope("associativecontainerbase", 2 * index++ + 1); CJsonScope scope("associativecontainerbase", 2 * index++ + 1);
Q_UNUSED(scope);
jsonValue >> val; jsonValue >> val;
} }
m_impl.insert(std::move(key), std::move(val)); m_impl.insert(std::move(key), std::move(val));

View File

@@ -379,6 +379,7 @@ namespace BlackMisc
else else
{ {
CJsonScope scope(member.latin1Name()); CJsonScope scope(member.latin1Name());
Q_UNUSED(scope);
value >> member.in(*this->derived()); value >> member.in(*this->derived());
} }
}); });

View File

@@ -749,14 +749,17 @@ namespace BlackMisc
if (distributors.isUndefined()) { throw CJsonException("Missing 'distributors'"); } if (distributors.isUndefined()) { throw CJsonException("Missing 'distributors'"); }
{ {
CJsonScope scope("aircraftIcaos"); CJsonScope scope("aircraftIcaos");
Q_UNUSED(scope);
helper.getTable<CAircraftIcaoCode>().convertFromJson(aircraftIcaos.toObject()); helper.getTable<CAircraftIcaoCode>().convertFromJson(aircraftIcaos.toObject());
} }
{ {
CJsonScope scope("liveries"); CJsonScope scope("liveries");
Q_UNUSED(scope);
helper.getTable<CLivery>().convertFromJson(liveries.toObject()); helper.getTable<CLivery>().convertFromJson(liveries.toObject());
} }
{ {
CJsonScope scope("distributors"); CJsonScope scope("distributors");
Q_UNUSED(scope);
helper.getTable<CDistributor>().convertFromJson(distributors.toObject()); helper.getTable<CDistributor>().convertFromJson(distributors.toObject());
} }
@@ -764,6 +767,7 @@ namespace BlackMisc
for (auto i = array.begin(); i != array.end(); ++i) for (auto i = array.begin(); i != array.end(); ++i)
{ {
CJsonScope scope("containerbase", index++); CJsonScope scope("containerbase", index++);
Q_UNUSED(scope);
CAircraftModel value; CAircraftModel value;
value.convertFromMemoizedJson(i->toObject(), helper); value.convertFromMemoizedJson(i->toObject(), helper);
insert(value); insert(value);

View File

@@ -29,8 +29,8 @@ namespace BlackMisc
if (! json.contains("MetaData")) { throw CJsonException("Missing 'MetaData'"); } if (! json.contains("MetaData")) { throw CJsonException("Missing 'MetaData'"); }
// json data is already validated by CPluginManagerSimulator // json data is already validated by CPluginManagerSimulator
//! \todo for RW See T107, remove, change code? CJsonScope scope("MetaData");
// CJsonScope scope("MetaData"); Q_UNUSED(scope);
CValueObject::convertFromJson(json["MetaData"].toObject()); CValueObject::convertFromJson(json["MetaData"].toObject());
m_valid = true; m_valid = true;
} }

View File

@@ -39,6 +39,7 @@ namespace BlackMisc
{ {
const QString key = it.key(); const QString key = it.key();
CJsonScope scope(key); CJsonScope scope(key);
Q_UNUSED(scope);
CVariant value; CVariant value;
value.convertFromJson(it.value().toObject()); value.convertFromJson(it.value().toObject());
implementationOf(*this).insert(cend(), key, value); implementationOf(*this).insert(cend(), key, value);
@@ -53,6 +54,7 @@ namespace BlackMisc
auto value = json.value(key); auto value = json.value(key);
if (value.isUndefined()) { continue; } if (value.isUndefined()) { continue; }
CJsonScope scope(key); CJsonScope scope(key);
Q_UNUSED(scope);
CVariant var; CVariant var;
var.convertFromJson(value.toObject()); var.convertFromJson(value.toObject());
insert(key, var); insert(key, var);
@@ -82,6 +84,7 @@ namespace BlackMisc
{ {
const QString key = it.key(); const QString key = it.key();
CJsonScope scope(key); CJsonScope scope(key);
Q_UNUSED(scope);
CVariant value; CVariant value;
value.convertFromMemoizedJson(it.value().toObject()); value.convertFromMemoizedJson(it.value().toObject());
implementationOf(*this).insert(cend(), key, value); implementationOf(*this).insert(cend(), key, value);
@@ -96,6 +99,7 @@ namespace BlackMisc
auto value = json.value(key); auto value = json.value(key);
if (value.isUndefined()) { continue; } if (value.isUndefined()) { continue; }
CJsonScope scope(key); CJsonScope scope(key);
Q_UNUSED(scope);
CVariant var; CVariant var;
var.convertFromMemoizedJson(value.toObject()); var.convertFromMemoizedJson(value.toObject());
insert(key, var); insert(key, var);
@@ -110,6 +114,7 @@ namespace BlackMisc
{ {
const QString key = it.key(); const QString key = it.key();
CJsonScope scope(key); CJsonScope scope(key);
Q_UNUSED(scope);
CVariant value; CVariant value;
auto message = value.convertFromJsonNoThrow(it.value().toObject(), categories, prefix); auto message = value.convertFromJsonNoThrow(it.value().toObject(), categories, prefix);
if (message.isSuccess()) { implementationOf(*this).insert(cend(), key, value); } if (message.isSuccess()) { implementationOf(*this).insert(cend(), key, value); }
@@ -127,6 +132,7 @@ namespace BlackMisc
auto value = json.value(key); auto value = json.value(key);
if (value.isUndefined()) { continue; } if (value.isUndefined()) { continue; }
CJsonScope scope(key); CJsonScope scope(key);
Q_UNUSED(scope);
CVariant var; CVariant var;
auto message = var.convertFromJsonNoThrow(value.toObject(), categories, prefix); auto message = var.convertFromJsonNoThrow(value.toObject(), categories, prefix);
if (message.isSuccess()) { insert(key, var); } if (message.isSuccess()) { insert(key, var); }
@@ -143,6 +149,7 @@ namespace BlackMisc
{ {
const QString key = it.key(); const QString key = it.key();
CJsonScope scope(key); CJsonScope scope(key);
Q_UNUSED(scope);
CVariant value; CVariant value;
auto message = value.convertFromMemoizedJsonNoThrow(it.value().toObject(), categories, prefix); auto message = value.convertFromMemoizedJsonNoThrow(it.value().toObject(), categories, prefix);
if (message.isSuccess()) { implementationOf(*this).insert(cend(), key, value); } if (message.isSuccess()) { implementationOf(*this).insert(cend(), key, value); }
@@ -160,6 +167,7 @@ namespace BlackMisc
auto value = json.value(key); auto value = json.value(key);
if (value.isUndefined()) { continue; } if (value.isUndefined()) { continue; }
CJsonScope scope(key); CJsonScope scope(key);
Q_UNUSED(scope);
CVariant var; CVariant var;
auto message = var.convertFromMemoizedJsonNoThrow(value.toObject(), categories, prefix); auto message = var.convertFromMemoizedJsonNoThrow(value.toObject(), categories, prefix);
if (message.isSuccess()) { insert(key, var); } if (message.isSuccess()) { insert(key, var); }

View File

@@ -29,7 +29,8 @@ namespace BlackMisc
if (! json.contains("MetaData")) { throw CJsonException("Missing 'MetaData'"); } if (! json.contains("MetaData")) { throw CJsonException("Missing 'MetaData'"); }
// json data is already validated by CPluginManagerWeatherData // json data is already validated by CPluginManagerWeatherData
CJsonScope scope("MetaData"); CJsonScope scope("MetaData"); // for stack trace
Q_UNUSED(scope);
CValueObject::convertFromJson(json["MetaData"].toObject()); CValueObject::convertFromJson(json["MetaData"].toObject());
m_valid = true; m_valid = true;
} }