Commit 172f5a5a authored by Aurindam Jana's avatar Aurindam Jana
Browse files

QmlJSScriptConsole: Evaluating Expressions



Check if the entered expression can be evaluated before
sending to to the declarative engine or v8 engine.

Change-Id: I277abd191a72c66629a51ca2d1c49c8893573bf2
Reviewed-by: default avatarChristiaan Janssen <christiaan.janssen@nokia.com>
parent a51120b7
......@@ -447,7 +447,7 @@ void QmlJSScriptConsole::displayPrompt()
void QmlJSScriptConsole::handleReturnKey()
{
QString currentScript = getCurrentScript();
bool evaluateScript = false;
bool scriptEvaluated = false;
//Check if string is only white spaces
if (currentScript.trimmed().isEmpty()) {
......@@ -456,31 +456,40 @@ void QmlJSScriptConsole::handleReturnKey()
cur.insertText(_("\n"));
setTextCursor(cur);
displayPrompt();
evaluateScript = true;
scriptEvaluated = true;
}
if (!evaluateScript && !d->inferiorStopped) {
if (!d->adapter.isNull()) {
QDeclarativeEngineDebug *engineDebug = d->adapter.data()->engineDebugClient();
int id = d->adapter.data()->currentSelectedDebugId();
if (engineDebug && id != -1) {
QDeclarativeDebugExpressionQuery *query =
engineDebug->queryExpressionResult(id, currentScript, this);
connect(query, SIGNAL(stateChanged(QmlJsDebugClient::QDeclarativeDebugQuery::State)),
this, SLOT(onStateChanged(QmlJsDebugClient::QDeclarativeDebugQuery::State)));
evaluateScript = true;
if (!scriptEvaluated) {
//check if it can be evaluated
if (d->canEvaluateScript(currentScript)) {
//Select the engine for evaluation based on
//inferior state
if (!d->inferiorStopped) {
if (!d->adapter.isNull()) {
QDeclarativeEngineDebug *engineDebug = d->adapter.data()->engineDebugClient();
int id = d->adapter.data()->currentSelectedDebugId();
if (engineDebug && id != -1) {
QDeclarativeDebugExpressionQuery *query =
engineDebug->queryExpressionResult(id, currentScript, this);
connect(query, SIGNAL(stateChanged(QmlJsDebugClient::QDeclarativeDebugQuery::State)),
this, SLOT(onStateChanged(QmlJsDebugClient::QDeclarativeDebugQuery::State)));
scriptEvaluated = true;
}
}
}
}
}
if (!evaluateScript) {
if (d->canEvaluateScript(currentScript)) {
emit evaluateExpression(currentScript);
} else {
QPlainTextEdit::appendPlainText(QString());
moveCursor(QTextCursor::EndOfLine);
if (!scriptEvaluated) {
emit evaluateExpression(currentScript);
scriptEvaluated = true;
}
}
}
if (!scriptEvaluated) {
QPlainTextEdit::appendPlainText(QString());
moveCursor(QTextCursor::EndOfLine);
}
}
void QmlJSScriptConsole::handleUpKey()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment