From 1918ec27d7772dea1393f213a3770d8dcb7497e2 Mon Sep 17 00:00:00 2001 From: Jan Holthuis Date: Sun, 30 Aug 2020 15:30:59 +0200 Subject: [PATCH] controllers/controllerengine: Add more DEBUG_ASSERTs on --controllerDebug --- src/controllers/controllerengine.cpp | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/controllers/controllerengine.cpp b/src/controllers/controllerengine.cpp index 809d60d3edc..58e104025fc 100644 --- a/src/controllers/controllerengine.cpp +++ b/src/controllers/controllerengine.cpp @@ -86,12 +86,16 @@ void ControllerEngine::callFunctionOnObjects(QList scriptFunctionPrefix QScriptValue prefix = global.property(prefixName); if (!prefix.isValid() || !prefix.isObject()) { qWarning() << "ControllerEngine: No" << prefixName << "object in script"; + // Throw a debug assertion if controllerDebug is enabled + DEBUG_ASSERT(!ControllerDebug::enabled()); continue; } QScriptValue init = prefix.property(function); if (!init.isValid() || !init.isFunction()) { qWarning() << "ControllerEngine:" << prefixName << "has no" << function << " method"; + // Throw a debug assertion if controllerDebug is enabled + DEBUG_ASSERT(!ControllerDebug::enabled()); continue; } controllerDebug("ControllerEngine: Executing" << prefixName << "." << function); @@ -443,22 +447,28 @@ bool ControllerEngine::internalExecute(QScriptValue thisObject, } if (functionObject.isError()) { - qDebug() << "ControllerEngine::internalExecute:" - << functionObject.toString(); + qWarning() << "ControllerEngine::internalExecute:" + << functionObject.toString(); + // Throw a debug assertion if controllerDebug is enabled + DEBUG_ASSERT(!ControllerDebug::enabled()); return false; } // If it's not a function, we're done. if (!functionObject.isFunction()) { - qDebug() << "ControllerEngine::internalExecute:" - << functionObject.toVariant() << "Not a function"; + qWarning() << "ControllerEngine::internalExecute:" + << functionObject.toVariant() << "Not a function"; + // Throw a debug assertion if controllerDebug is enabled + DEBUG_ASSERT(!ControllerDebug::enabled()); return false; } // If it does happen to be a function, call it. QScriptValue rc = functionObject.call(thisObject, args); if (!rc.isValid()) { - qDebug() << "QScriptValue is not a function or ..."; + qWarning() << "QScriptValue is not a function or ..."; + // Throw a debug assertion if controllerDebug is enabled + DEBUG_ASSERT(!ControllerDebug::enabled()); return false; } @@ -636,6 +646,8 @@ ControlObjectScript* ControllerEngine::getControlObjectScript(const QString& gro if (!key.isValid()) { qWarning() << "ControllerEngine: Requested control with invalid key" << key; + // Throw a debug assertion if controllerDebug is enabled + DEBUG_ASSERT(!ControllerDebug::enabled()); return nullptr; }