Last active
August 29, 2015 14:05
-
-
Save lbt/9d2f1c9933fed5922dfb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void SparkVariable::callFinished(QJsonDocument json) { | |
if (json.isNull()) goto cleanup; | |
if (! json.isObject()) { qDebug() << "expected a json object"; goto cleanup; } | |
QJsonObject jo = json.object(); | |
if (jo.isEmpty()) { qDebug() << "json object is empty"; goto cleanup; } | |
QJsonValue return_value = jo["return_value "]; | |
QVariant value = return_value.toVariant(); | |
qDebug() << "a function from " << m_variable << " returned " << return_value; | |
emit result(value); | |
cleanup: | |
emit busyChanged(m_busy=false); | |
return; | |
} | |
// Using lambdas : | |
void SparkVariable::callFinished(QJsonDocument json) { | |
auto cleanup = [this] () { | |
emit busyChanged(m_busy = false); | |
}; | |
if (json.isNull()) { cleanup(); return; } | |
if (! json.isObject()) { qDebug() << "expected a json object"; cleanup(); return; } | |
QJsonObject jo = json.object(); | |
if (jo.isEmpty()) { qDebug() << "json object is empty"; cleanup(); return; } | |
QJsonValue return_value = jo["return_value "]; | |
QVariant value = return_value.toVariant(); | |
qDebug() << "a function from " << m_variable << " returned " << return_value; | |
emit result(value); | |
cleanup(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment