aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron Kennedy <aaron.kennedy@nokia.com>2011-06-15 14:19:22 +1000
committerAaron Kennedy <aaron.kennedy@nokia.com>2011-06-15 14:19:22 +1000
commite25c7140aa2a01fa68df1fe0dc6037bdd7919a8c (patch)
treefb9dff7fe0047b7a92e26a281bf4522593e3be00
parente906e35e873fd62cc0259fb476044c89c6291c0e (diff)
Fix autotests
-rw-r--r--src/declarative/qml/qdeclarativecontext.cpp8
-rw-r--r--src/declarative/qml/qdeclarativecontext_p.h3
-rw-r--r--src/declarative/qml/qdeclarativeengine.cpp1
-rw-r--r--src/declarative/qml/qdeclarativevme.cpp15
-rw-r--r--src/declarative/qml/v8/qv8contextwrapper.cpp19
-rw-r--r--src/declarative/qml/v8/qv8engine.cpp14
-rw-r--r--src/declarative/qml/v8/qv8include.cpp1
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp6
-rw-r--r--tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp1
-rw-r--r--tests/auto/declarative/qdeclarativeinstruction/tst_qdeclarativeinstruction.cpp3
10 files changed, 49 insertions, 22 deletions
diff --git a/src/declarative/qml/qdeclarativecontext.cpp b/src/declarative/qml/qdeclarativecontext.cpp
index 2b96d8fbc0..c2c21d30fb 100644
--- a/src/declarative/qml/qdeclarativecontext.cpp
+++ b/src/declarative/qml/qdeclarativecontext.cpp
@@ -497,16 +497,16 @@ QObject *QDeclarativeContextPrivate::context_at(QDeclarativeListProperty<QObject
QDeclarativeContextData::QDeclarativeContextData()
-: parent(0), engine(0), isInternal(false), ownedByParent(false), isJSContext(false), publicContext(0),
- propertyNames(0), contextObject(0), imports(0), childContexts(0), nextChild(0), prevChild(0),
+: parent(0), engine(0), isInternal(false), ownedByParent(false), isJSContext(false), isPragmaLibraryContext(false),
+ publicContext(0), propertyNames(0), contextObject(0), imports(0), childContexts(0), nextChild(0), prevChild(0),
expressions(0), contextObjects(0), contextGuards(0), idValues(0), idValueCount(0), optimizedBindings(0),
linkedContext(0), componentAttached(0)
{
}
QDeclarativeContextData::QDeclarativeContextData(QDeclarativeContext *ctxt)
-: parent(0), engine(0), isInternal(false), ownedByParent(false), isJSContext(false), publicContext(ctxt),
- propertyNames(0), contextObject(0), imports(0), childContexts(0), nextChild(0), prevChild(0),
+: parent(0), engine(0), isInternal(false), ownedByParent(false), isJSContext(false), isPragmaLibraryContext(false),
+ publicContext(ctxt), propertyNames(0), contextObject(0), imports(0), childContexts(0), nextChild(0), prevChild(0),
expressions(0), contextObjects(0), contextGuards(0), idValues(0), idValueCount(0), optimizedBindings(0),
linkedContext(0), componentAttached(0)
{
diff --git a/src/declarative/qml/qdeclarativecontext_p.h b/src/declarative/qml/qdeclarativecontext_p.h
index 93b9d3b41e..ac933a3ae3 100644
--- a/src/declarative/qml/qdeclarativecontext_p.h
+++ b/src/declarative/qml/qdeclarativecontext_p.h
@@ -140,7 +140,8 @@ public:
quint32 isInternal:1;
quint32 ownedByParent:1; // unrelated to isInternal; parent context deletes children if true.
quint32 isJSContext:1;
- quint32 dummy:29;
+ quint32 isPragmaLibraryContext:1;
+ quint32 dummy:28;
QDeclarativeContext *publicContext;
// Property name cache
diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp
index 4afdaabaf9..b6c00b9387 100644
--- a/src/declarative/qml/qdeclarativeengine.cpp
+++ b/src/declarative/qml/qdeclarativeengine.cpp
@@ -441,6 +441,7 @@ void QDeclarativeEnginePrivate::init()
qRegisterMetaType<QScriptValue>("QScriptValue");
qRegisterMetaType<QDeclarativeComponent::Status>("QDeclarativeComponent::Status");
qRegisterMetaType<QList<QObject*> >("QList<QObject*>");
+ qRegisterMetaType<QList<int> >("QList<int>");
QDeclarativeData::init();
diff --git a/src/declarative/qml/qdeclarativevme.cpp b/src/declarative/qml/qdeclarativevme.cpp
index 9082ef06c1..4d5fa3607c 100644
--- a/src/declarative/qml/qdeclarativevme.cpp
+++ b/src/declarative/qml/qdeclarativevme.cpp
@@ -974,25 +974,34 @@ v8::Persistent<v8::Object> QDeclarativeVME::run(QDeclarativeContextData *parentC
bool shared = script->pragmas & QDeclarativeParser::Object::ScriptBlock::Shared;
+ QDeclarativeContextData *effectiveCtxt = parentCtxt;
+ if (shared)
+ effectiveCtxt = 0;
+
// Create the script context if required
QDeclarativeContextData *ctxt = new QDeclarativeContextData;
ctxt->isInternal = true;
ctxt->isJSContext = true;
+ if (shared)
+ ctxt->isPragmaLibraryContext = true;
+ else
+ ctxt->isPragmaLibraryContext = parentCtxt->isPragmaLibraryContext;
ctxt->url = script->url;
// For backward compatibility, if there are no imports, we need to use the
// imports from the parent context. See QTBUG-17518.
if (!script->importCache->isEmpty()) {
ctxt->imports = script->importCache;
- } else {
- ctxt->imports = parentCtxt->imports;
+ } else if (effectiveCtxt) {
+ ctxt->imports = effectiveCtxt->imports;
}
if (ctxt->imports) {
ctxt->imports->addref();
}
- ctxt->setParent(parentCtxt, true);
+ if (effectiveCtxt)
+ ctxt->setParent(effectiveCtxt, true);
for (int ii = 0; ii < script->scripts.count(); ++ii) {
ctxt->importedScripts << run(ctxt, script->scripts.at(ii)->scriptData());
diff --git a/src/declarative/qml/v8/qv8contextwrapper.cpp b/src/declarative/qml/v8/qv8contextwrapper.cpp
index 87ea3795ac..937be3fc3f 100644
--- a/src/declarative/qml/v8/qv8contextwrapper.cpp
+++ b/src/declarative/qml/v8/qv8contextwrapper.cpp
@@ -63,9 +63,8 @@ public:
QDeclarativeGuard<QObject> scopeObject;
quint32 hasSubContexts:1;
- quint32 ownsContext:1;
quint32 readOnly:1;
- quint32 dummy:29;
+ quint32 dummy:30;
QObject *secondaryScope;
@@ -88,14 +87,14 @@ private:
};
QV8ContextResource::QV8ContextResource(QV8Engine *engine, QDeclarativeContextData *context, QObject *scopeObject)
-: QV8ObjectResource(engine), scopeObject(scopeObject), hasSubContexts(false), ownsContext(false),
- readOnly(true), secondaryScope(0), context(context)
+: QV8ObjectResource(engine), scopeObject(scopeObject), hasSubContexts(false), readOnly(true),
+ secondaryScope(0), context(context)
{
}
QV8ContextResource::~QV8ContextResource()
{
- if (ownsContext && context)
+ if (context && context->isJSContext)
context->destroy();
}
@@ -168,7 +167,6 @@ v8::Local<v8::Object> QV8ContextWrapper::urlScope(const QUrl &url)
// XXX NewInstance() should be optimized
v8::Local<v8::Object> rv = m_urlConstructor->NewInstance();
QV8ContextResource *r = new QV8ContextResource(m_engine, context, 0);
- r->ownsContext = true;
rv->SetExternalResource(r);
return rv;
}
@@ -242,6 +240,9 @@ v8::Handle<v8::Value> QV8ContextWrapper::Getter(v8::Local<v8::String> property,
if (!context)
return v8::Undefined();
+ if (v8::Context::GetCallingQmlGlobal() != info.This())
+ return v8::Handle<v8::Value>();
+
// Search type (attached property/enum/imported scripts) names
// Secondary scope object
// while (context) {
@@ -252,6 +253,7 @@ v8::Handle<v8::Value> QV8ContextWrapper::Getter(v8::Local<v8::String> property,
// }
QV8Engine *engine = resource->engine;
+
QObject *scopeObject = resource->scopeObject;
QHashedV8String propertystring(property);
@@ -378,8 +380,11 @@ v8::Handle<v8::Value> QV8ContextWrapper::Setter(v8::Local<v8::String> property,
if (!context)
return v8::Undefined();
- // See QV8ContextWrapper::Getter for resolution order
+ if (v8::Context::GetCallingQmlGlobal() != info.This())
+ return v8::Handle<v8::Value>();
+ // See QV8ContextWrapper::Getter for resolution order
+
QV8Engine *engine = resource->engine;
QObject *scopeObject = resource->scopeObject;
diff --git a/src/declarative/qml/v8/qv8engine.cpp b/src/declarative/qml/v8/qv8engine.cpp
index 3ddac007d2..cb89d0f57f 100644
--- a/src/declarative/qml/v8/qv8engine.cpp
+++ b/src/declarative/qml/v8/qv8engine.cpp
@@ -1378,7 +1378,12 @@ v8::Handle<v8::Value> QV8Engine::createQmlObject(const v8::Arguments &args)
QDeclarativeEngine *engine = v8engine->engine();
QDeclarativeContextData *context = v8engine->callingContext();
- Q_ASSERT(context);
+ QDeclarativeContext *effectiveContext = 0;
+ if (context->isPragmaLibraryContext)
+ effectiveContext = engine->rootContext();
+ else
+ effectiveContext = context->asQDeclarativeContext();
+ Q_ASSERT(context && effectiveContext);
QString qml = v8engine->toString(args[0]->ToString());
if (qml.isEmpty())
@@ -1408,7 +1413,7 @@ v8::Handle<v8::Value> QV8Engine::createQmlObject(const v8::Arguments &args)
if (!component.isReady())
V8THROW_ERROR("Qt.createQmlObject(): Component is not ready");
- QObject *obj = component.beginCreate(context->asQDeclarativeContext());
+ QObject *obj = component.beginCreate(effectiveContext);
if(obj)
QDeclarativeData::get(obj, true)->setImplicitDestructible();
component.completeCreate();
@@ -1462,6 +1467,9 @@ v8::Handle<v8::Value> QV8Engine::createComponent(const v8::Arguments &args)
QDeclarativeEngine *engine = v8engine->engine();
QDeclarativeContextData *context = v8engine->callingContext();
+ QDeclarativeContextData *effectiveContext = context;
+ if (context->isPragmaLibraryContext)
+ effectiveContext = 0;
Q_ASSERT(context);
QString arg = v8engine->toString(args[0]->ToString());
@@ -1470,7 +1478,7 @@ v8::Handle<v8::Value> QV8Engine::createComponent(const v8::Arguments &args)
QUrl url = context->resolvedUrl(QUrl(arg));
QDeclarativeComponent *c = new QDeclarativeComponent(engine, url, engine);
- QDeclarativeComponentPrivate::get(c)->creationContext = context;
+ QDeclarativeComponentPrivate::get(c)->creationContext = effectiveContext;
QDeclarativeData::get(c, true)->setImplicitDestructible();
return v8engine->newQObject(c);
}
diff --git a/src/declarative/qml/v8/qv8include.cpp b/src/declarative/qml/v8/qv8include.cpp
index f8ef8a6af4..e2161a9001 100644
--- a/src/declarative/qml/v8/qv8include.cpp
+++ b/src/declarative/qml/v8/qv8include.cpp
@@ -136,6 +136,7 @@ void QV8Include::finished()
importContext->isInternal = true;
importContext->isJSContext = true;
importContext->url = m_url;
+ importContext->isPragmaLibraryContext = m_context->isPragmaLibraryContext;
importContext->setParent(m_context, true);
v8::Context::Scope ctxtscope(m_engine->context());
diff --git a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp
index 81e54c0c5b..1ed22532e6 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp
+++ b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp
@@ -2571,6 +2571,8 @@ void tst_qdeclarativeecmascript::signalWithUnknownTypes()
void tst_qdeclarativeecmascript::moduleApi()
{
+ QSKIP("Module API not supported with V8", SkipAll);
+
QDeclarativeComponent component(&engine, TEST_FILE("moduleApi.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
@@ -2639,7 +2641,7 @@ void tst_qdeclarativeecmascript::importScripts()
// then, ensure that unintended behaviour does not work.
QDeclarativeComponent failOneComponent(&engine, TEST_FILE("jsimportfail/failOne.qml"));
- QString expectedWarning = QLatin1String("file://") + TEST_FILE("jsimportfail/failOne.qml").toLocalFile() + QLatin1String(":6: TypeError: Result of expression 'TestScriptImport.ImportOneJs' [undefined] is not an object.");
+ QString expectedWarning = QLatin1String("file://") + TEST_FILE("jsimportfail/failOne.qml").toLocalFile() + QLatin1String(":6: TypeError: Cannot call method 'greetingString' of undefined");
QTest::ignoreMessage(QtWarningMsg, expectedWarning.toAscii().constData());
object = failOneComponent.create();
QVERIFY(object != 0);
@@ -2653,7 +2655,7 @@ void tst_qdeclarativeecmascript::importScripts()
QVERIFY(object->property("importScriptFunctionValue").toString().isEmpty());
delete object;
QDeclarativeComponent failThreeComponent(&engine, TEST_FILE("jsimportfail/failThree.qml"));
- expectedWarning = QLatin1String("file://") + TEST_FILE("jsimportfail/failThree.qml").toLocalFile() + QLatin1String(":7: TypeError: Result of expression 'testQtObject.TestModuleImport.JsQtTest' [undefined] is not an object.");
+ expectedWarning = QLatin1String("file://") + TEST_FILE("jsimportfail/failThree.qml").toLocalFile() + QLatin1String(":7: TypeError: Cannot read property 'JsQtTest' of undefined");
QTest::ignoreMessage(QtWarningMsg, expectedWarning.toAscii().constData());
object = failThreeComponent.create();
QVERIFY(object != 0);
diff --git a/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp b/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp
index 8044b8097a..b5aaa007e9 100644
--- a/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp
+++ b/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp
@@ -328,7 +328,6 @@ void tst_qdeclarativeimage::mirror()
p_e.drawPixmap(QRect(0, 0, width, height), srcPixmap, QRect(0, 0, srcPixmap.width(), srcPixmap.height()));
break;
case QDeclarativeImage::PreserveAspectFit:
- QEXPECT_FAIL("", "QTBUG-19538", Continue);
p_e.drawPixmap(QRect(25, 0, width / (width/height), height), srcPixmap, QRect(0, 0, srcPixmap.width(), srcPixmap.height()));
break;
case QDeclarativeImage::PreserveAspectCrop:
diff --git a/tests/auto/declarative/qdeclarativeinstruction/tst_qdeclarativeinstruction.cpp b/tests/auto/declarative/qdeclarativeinstruction/tst_qdeclarativeinstruction.cpp
index fda16409b7..3712db4852 100644
--- a/tests/auto/declarative/qdeclarativeinstruction/tst_qdeclarativeinstruction.cpp
+++ b/tests/auto/declarative/qdeclarativeinstruction/tst_qdeclarativeinstruction.cpp
@@ -332,6 +332,7 @@ void tst_qdeclarativeinstruction::dump()
i.storeScriptString.propertyIndex = 24;
i.storeScriptString.value = 3;
i.storeScriptString.scope = 1;
+ i.storeScriptString.bindingId = 4;
data->addInstruction(i);
}
@@ -535,7 +536,7 @@ void tst_qdeclarativeinstruction::dump()
<< "25\t\tSTORE_VARIANT_OBJECT\t22"
<< "26\t\tSTORE_INTERFACE\t\t23"
<< "27\t\tSTORE_SIGNAL\t\t2\t3\t\t\"console.log(1921)\""
- << "28\t\tSTORE_SCRIPT_STRING\t24\t3\t1\t0"
+ << "28\t\tSTORE_SCRIPT_STRING\t24\t3\t1\t4"
<< "29\t\tASSIGN_SIGNAL_OBJECT\t0\t\t\t\"mySignal\""
<< "30\t\tASSIGN_CUSTOMTYPE\t25\t6\t9"
<< "31\t\tSTORE_BINDING\t26\t3\t2"