Fix qqmlecmascript::sequenceConversionIndexes
authorSimon Hausmann <simon.hausmann@digia.com>
Fri, 7 Jun 2013 18:49:28 +0000 (20:49 +0200)
committerLars Knoll <lars.knoll@digia.com>
Sat, 8 Jun 2013 20:36:38 +0000 (22:36 +0200)
Fix line number and source file in generated warnings

Change-Id: Id7a96f67325ad43fd88499359b41944130a46f60
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
src/qml/qml/v4/qv4context.cpp
src/qml/qml/v4/qv4context_p.h
src/qml/qml/v4/qv4sequenceobject.cpp

index 9a15c41..79553b9 100644 (file)
@@ -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) {
index 0ed74a6..1f59d27 100644 (file)
@@ -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;
 };
index 5358201..2f7fe99 100644 (file)
@@ -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;
         }