mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-15 17:55:34 +08:00
refs #450 Corrected emission of log messages from value cache validation.
This commit is contained in:
@@ -105,6 +105,9 @@ namespace BlackMisc
|
|||||||
return std::all_of(classCategories.begin(), classCategories.end(), [this](const CLogCategory & cat) { return m_categories.contains(cat); });
|
return std::all_of(classCategories.begin(), classCategories.end(), [this](const CLogCategory & cat) { return m_categories.contains(cat); });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! Mark the message as potentially already handled
|
||||||
|
void markAsRedundant() { this->m_redundant = true; }
|
||||||
|
|
||||||
//! Mark the message as having been handled by the given object
|
//! Mark the message as having been handled by the given object
|
||||||
void markAsHandledBy(const QObject *object) const;
|
void markAsHandledBy(const QObject *object) const;
|
||||||
|
|
||||||
|
|||||||
@@ -207,7 +207,11 @@ namespace BlackMisc
|
|||||||
element.m_value = m_cache->getValue(key);
|
element.m_value = m_cache->getValue(key);
|
||||||
|
|
||||||
auto error = validate(element, element.m_value);
|
auto error = validate(element, element.m_value);
|
||||||
if (! error.isEmpty()) { element.m_value = defaultValue; }
|
if (! error.isEmpty())
|
||||||
|
{
|
||||||
|
CLogMessage::preformatted(error);
|
||||||
|
element.m_value = defaultValue;
|
||||||
|
}
|
||||||
return element;
|
return element;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -240,6 +244,11 @@ namespace BlackMisc
|
|||||||
emit valuesWantToCache({ { element.m_key, value } });
|
emit valuesWantToCache({ { element.m_key, value } });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CLogMessage::preformatted(error);
|
||||||
|
error.markAsRedundant();
|
||||||
|
}
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -314,15 +323,15 @@ namespace BlackMisc
|
|||||||
{
|
{
|
||||||
if (! value.isValid())
|
if (! value.isValid())
|
||||||
{
|
{
|
||||||
return CLogMessage(this).warning("Uninitialized value for %1") << element.m_key;
|
return CStatusMessage(this, CStatusMessage::SeverityWarning, "Uninitialized value for " + element.m_key);
|
||||||
}
|
}
|
||||||
else if (value.userType() != element.m_metaType)
|
else if (value.userType() != element.m_metaType)
|
||||||
{
|
{
|
||||||
return CLogMessage(this).error("Expected %1, got %2 for %3") << QMetaType::typeName(element.m_metaType) << value.typeName() << element.m_key;
|
return CStatusMessage(this, CStatusMessage::SeverityError, QString("Expected ") + QMetaType::typeName(element.m_metaType) + " but got " + value.typeName() + " for " + element.m_key);
|
||||||
}
|
}
|
||||||
else if (element.m_validator && ! element.m_validator(value))
|
else if (element.m_validator && ! element.m_validator(value))
|
||||||
{
|
{
|
||||||
return CLogMessage(this).error("%1 is not valid for %2") << value << element.m_key;
|
return CStatusMessage(this, CStatusMessage::SeverityError, value.toQString() + " is not valid for " + element.m_key);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ namespace BlackMisc
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
qWarning() << "Unsupported CVariant type for toJson";
|
qWarning() << "Unsupported CVariant type for toJson:" << m_v.typeName() << "(" << m_v.userType() << ")";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (const Private::CVariantException &ex)
|
catch (const Private::CVariantException &ex)
|
||||||
|
|||||||
Reference in New Issue
Block a user