Skip to content

Commit

Permalink
QML: Prevent QmlControlProxy log spam when using an invalid CO
Browse files Browse the repository at this point in the history
A single warning should suffice.
  • Loading branch information
Holzhaus committed May 27, 2021
1 parent 5da730f commit 6145db5
Showing 1 changed file with 5 additions and 19 deletions.
24 changes: 5 additions & 19 deletions src/skin/qml/qmlcontrolproxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,6 @@ const QString& QmlControlProxy::getKey() const {

void QmlControlProxy::setValue(double newValue) {
if (!isInitialized()) {
if (m_isComponentComplete) {
qWarning() << "QmlControlProxy: Attempted to set value" << newValue
<< "on non-initialized CO" << m_coKey;
}
emit valueChanged(kDefaultValue);
return;
}
Expand All @@ -87,22 +83,13 @@ void QmlControlProxy::setValue(double newValue) {

double QmlControlProxy::getValue() const {
if (!isInitialized()) {
if (m_isComponentComplete) {
qWarning() << "QmlControlProxy: Attempted to get value from "
"non-initialized CO"
<< m_coKey << "(returning 0)";
}
return kDefaultValue;
}
return m_pControlProxy->get();
}

void QmlControlProxy::setParameter(double newValue) {
if (!isInitialized()) {
if (m_isComponentComplete) {
qWarning() << "QmlControlProxy: Attempted to set parameter" << newValue
<< "on non-initialized CO" << m_coKey;
}
emit parameterChanged(kDefaultValue);
return;
}
Expand All @@ -113,11 +100,6 @@ void QmlControlProxy::setParameter(double newValue) {

double QmlControlProxy::getParameter() const {
if (!isInitialized()) {
if (m_isComponentComplete) {
qWarning() << "QmlControlProxy: Attempted to get parameter from "
"non-initialized CO"
<< m_coKey << "(returning 0)";
}
return kDefaultParameter;
}
return m_pControlProxy->getParameter();
Expand Down Expand Up @@ -146,9 +128,13 @@ void QmlControlProxy::reinitializeOrReset() {
return;
}

// We don't need to warn here if the control is missing, because we'll do a
// check below and print a warning anyway. If the key is invalid, this will
// still trigger an assertion because we checked the key validity above. If
// it's still invalid, that's a programming error.
std::unique_ptr<ControlProxy> pControlProxy =
std::make_unique<ControlProxy>(
m_coKey, this, ControlFlag::NoAssertIfMissing);
m_coKey, this, ControlFlag::NoWarnIfMissing);

// This should never happen, but it doesn't hurt to check.
VERIFY_OR_DEBUG_ASSERT(pControlProxy != nullptr) {
Expand Down

0 comments on commit 6145db5

Please sign in to comment.