bool KviKvsTreeNodeHashElement::evaluateReadOnlyInObjectScope(KviKvsObject *o,KviKvsRunTimeContext * c,KviKvsVariant * pBuffer) { KviKvsVariant key; if(!m_pKey->evaluateReadOnly(c,&key))return false; QString szKey; key.asString(szKey); if(szKey.isEmpty()) { c->warning(this,__tr2qs_ctx("Hash key evaluated to empty string: fix the script","kvs")); pBuffer->setNothing(); return true; } KviKvsVariant val; if(o) { if(!m_pSource->evaluateReadOnlyInObjectScope(o,c,&val))return false; } else { if(!m_pSource->evaluateReadOnly(c,&val))return false; } if(!val.isHash()) { if(!val.isNothing()) { QString szType; val.getTypeName(szType); c->warning(this,__tr2qs_ctx("The argument of the {} subscript didn't evaluate to a hash: automatic conversion from type '%Q' supplied","kvs"),&szType); } pBuffer->setNothing(); return true; } KviKvsVariant * v = val.hash()->find(szKey); if(!v) { pBuffer->setNothing(); return true; } pBuffer->copyFrom(v); return true; }
bool KviKvsProcessAsyncOperation::trigger(CallbackEvent e, const QString & szData) { if(m_bDeletePending) return false; if(!g_pApp->windowExists(m_pData->pWnd)) { if(m_pData->iFlags & KVI_KVS_PROCESSDESCRIPTOR_KILLIFNOWINDOW) { return true; } m_pData->pWnd = g_pApp->activeConsole(); } if(m_pData->pCallback) { KviKvsVariantList params; params.setAutoDelete(true); switch(e) { case EventStdout: params.append(new KviKvsVariant(QString("stdout"))); break; case EventStderr: params.append(new KviKvsVariant(QString("stderr"))); break; case EventTerminated: params.append(new KviKvsVariant(QString("terminated"))); break; case EventStarted: params.append(new KviKvsVariant(QString("started"))); break; case EventPing: params.append(new KviKvsVariant(QString("ping"))); break; default: qDebug("Oops! Unknown trigger() CallbackEvent parameter in QProcessDescriptor::trigger()"); return false; break; } params.append(new KviKvsVariant(szData)); if(m_pData->pMagic) { KviKvsVariant * pTmp = new KviKvsVariant(); pTmp->copyFrom(m_pData->pMagic); params.append(pTmp); } KviKvsVariant retVal; int iRet = m_pData->pCallback->run(m_pData->pWnd, ¶ms, &retVal, KviKvsScript::PreserveParams, m_pExtendedRunTimeData); if(!iRet) { m_pData->pWnd->output(KVI_OUT_PARSERERROR, __tr2qs_ctx("Error triggered from process callback handler: killing process", "kvs")); return true; } if(!retVal.isNothing()) { QString sz; retVal.asString(sz); m_pProcess->write(sz.toUtf8().data()); } if(iRet & KviKvsScript::HaltEncountered) { // halt encountered: kill the process return true; } } return false; }