From 84b62089b5d3751f0a2ae1e423696a8a4acac1c4 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Fri, 7 Jun 2013 20:49:28 +0200 Subject: [PATCH] Fix qqmlecmascript::sequenceConversionIndexes Fix line number and source file in generated warnings Change-Id: Id7a96f67325ad43fd88499359b41944130a46f60 Reviewed-by: Lars Knoll --- src/qml/qml/v4/qv4context.cpp | 21 --------------------- src/qml/qml/v4/qv4context_p.h | 3 --- src/qml/qml/v4/qv4sequenceobject.cpp | 9 ++++++--- 3 files changed, 6 insertions(+), 27 deletions(-) diff --git a/src/qml/qml/v4/qv4context.cpp b/src/qml/qml/v4/qv4context.cpp index 9a15c41..79553b9 100644 --- a/src/qml/qml/v4/qv4context.cpp +++ b/src/qml/qml/v4/qv4context.cpp @@ -302,27 +302,6 @@ void ExecutionContext::mark() } } -QString ExecutionContext::currentFileName() const -{ - const ExecutionContext *c = this; - while (c) { - if (const SimpleCallContext *callCtx = c->asCallContext()) { - FunctionObject *f = callCtx->function; - if (f && f->function) - return f->function->sourceFile; - } - c = c->outer; - } - return QString(); -} - -int ExecutionContext::currentLineNumber() const -{ - // ### FIXME: we may need to record the return address upon entering from - // JIT code and then look up in a map from instruction pointer to line number. - return -1; -} - void ExecutionContext::setProperty(String *name, const Value& value) { for (ExecutionContext *ctx = this; ctx; ctx = ctx->outer) { diff --git a/src/qml/qml/v4/qv4context_p.h b/src/qml/qml/v4/qv4context_p.h index 0ed74a6..1f59d27 100644 --- a/src/qml/qml/v4/qv4context_p.h +++ b/src/qml/qml/v4/qv4context_p.h @@ -148,9 +148,6 @@ struct Q_QML_EXPORT ExecutionContext void mark(); - QString currentFileName() const; - int currentLineNumber() const; - inline CallContext *asCallContext(); inline const CallContext *asCallContext() const; }; diff --git a/src/qml/qml/v4/qv4sequenceobject.cpp b/src/qml/qml/v4/qv4sequenceobject.cpp index 5358201..2f7fe99 100644 --- a/src/qml/qml/v4/qv4sequenceobject.cpp +++ b/src/qml/qml/v4/qv4sequenceobject.cpp @@ -59,8 +59,11 @@ static void generateWarning(QV4::ExecutionContext *ctx, const QString& descripti return; QQmlError retn; retn.setDescription(description); - retn.setLine(ctx->currentLineNumber()); - retn.setUrl(QUrl(ctx->currentFileName())); + + QV4::ExecutionEngine::StackFrame frame = ctx->engine->currentStackFrame(); + + retn.setLine(frame.line); + retn.setUrl(QUrl(frame.source)); QQmlEnginePrivate::warning(engine, retn); } @@ -218,7 +221,7 @@ public: { /* Qt containers have int (rather than uint) allowable indexes. */ if (index > INT_MAX) { - generateWarning(ctx, QLatin1String("Index out of range during indexed put")); + generateWarning(ctx, QLatin1String("Index out of range during indexed set")); return; } -- 2.7.4