Merge master into api_changes
authorKent Hansen <kent.hansen@nokia.com>
Mon, 19 Mar 2012 11:29:32 +0000 (12:29 +0100)
committerKent Hansen <kent.hansen@nokia.com>
Mon, 19 Mar 2012 11:37:03 +0000 (12:37 +0100)
Conflicts:
src/qml/debugger/qqmlenginedebugservice.cpp
src/qml/qml/v8/qv8qobjectwrapper.cpp
src/quick/util/qquickimageprovider.cpp
tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp

Change-Id: Ie78ba2fabd32f4812bcae9dbdd66ed289dc11dcb

21 files changed:
1  2 
doc/src/qml/basictypes.qdoc
doc/src/qml/javascriptblocks.qdoc
doc/src/qml/propertybinding.qdoc
src/qml/debugger/qqmlenginedebugservice.cpp
src/qml/qml/qml.pri
src/qml/qml/qqmlengine.cpp
src/qml/qml/qqmlproperty.cpp
src/qml/qml/qqmlvme.cpp
src/qml/qml/qqmlvmemetaobject.cpp
src/qml/qml/v8/qqmlbuiltinfunctions.cpp
src/qml/qml/v8/qv8qobjectwrapper.cpp
src/qml/qml/v8/qv8valuetypewrapper.cpp
src/quick/items/qquickcanvas.cpp
src/quick/items/qquickitem.cpp
src/quick/items/qquickshadereffect.cpp
src/quick/util/qquickimageprovider.cpp
src/quick/util/qquickpixmapcache.cpp
tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp
tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp
tests/auto/quick/quick.pro

      }
      \endqml
  
 -    Attempting to assign a JavaScript function to a var property will result in
 -    a binding assignment as per other property types.  You can assign a JavaScript
 -    array containing a single function element instead.
 -
      It is important to note that changes in regular properties of JavaScript
-     objects assigned to a var property will \bold{not} trigger updates of bindings
+     objects assigned to a var property will \b{not} trigger updates of bindings
      that access them.  The example below will display "The car has 4 wheels" as
      the change to the wheels property will not cause the reevaluation of the
      binding assigned to the "text" property:
Simple merge
Simple merge
@@@ -247,8 -247,10 +247,8 @@@ void QQmlEngineDebugService::buildObjec
                  prop.value = expr->expression();
                  QObject *scope = expr->scopeObject();
                  if (scope) {
-                     QString methodName = QLatin1String(scope->metaObject()->method(signal->index()).name().constData());
 -                    QString sig = QString::fromLatin1(scope->metaObject()->method(signal->index()).signature());
 -                    int lparen = sig.indexOf(QLatin1Char('('));
 -                    if (lparen >= 0) {
 -                        QString methodName = sig.mid(0, lparen);
++                    QString methodName = QString::fromLatin1(scope->metaObject()->method(signal->index()).name());
 +                    if (!methodName.isEmpty()) {
                          prop.name = QLatin1String("on") + methodName[0].toUpper()
                                  + methodName.mid(1);
                      }
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
@@@ -579,55 -579,23 +579,53 @@@ static inline void StoreProperty(QV8Eng
                                   v8::Handle<v8::Value> value)
  {
      QQmlBinding *newBinding = 0;
 -
      if (value->IsFunction()) {
 -        QQmlContextData *context = engine->callingContext();
 -        v8::Handle<v8::Function> function = v8::Handle<v8::Function>::Cast(value);
 -
 -        v8::Local<v8::StackTrace> trace = 
 -            v8::StackTrace::CurrentStackTrace(1, (v8::StackTrace::StackTraceOptions)(v8::StackTrace::kLineNumber | 
 -                                                                                     v8::StackTrace::kScriptName));
 -        v8::Local<v8::StackFrame> frame = trace->GetFrame(0);
 -        int lineNumber = frame->GetLineNumber();
 -        int columnNumber = frame->GetColumn();
 -        QString url = engine->toString(frame->GetScriptName());
 -
 -        newBinding = new QQmlBinding(&function, object, context, url, lineNumber, columnNumber);
 -        newBinding->setTarget(object, *property, context);
 -        newBinding->setEvaluateFlags(newBinding->evaluateFlags() |
 -                                     QQmlBinding::RequiresThisObject);
 +        if (value->ToObject()->GetHiddenValue(engine->bindingFlagKey()).IsEmpty()) {
 +            if (!property->isVMEProperty()) {
 +                // XXX TODO: uncomment the following lines
 +                // assigning a JS function to a non-var-property is not allowed.
 +                //QString error = QLatin1String("Cannot assign JavaScript function to ") +
 +                //                QLatin1String(QMetaType::typeName(property->propType));
 +                //v8::ThrowException(v8::Exception::Error(engine->toString(error)));
 +                //return;
 +                // XXX TODO: remove the following transition behaviour
 +                // Temporarily allow assignment of functions to non-var properties
 +                // to mean binding assignment (as per old behaviour).
 +                QQmlContextData *context = engine->callingContext();
 +                v8::Handle<v8::Function> function = v8::Handle<v8::Function>::Cast(value);
 +
 +                v8::Local<v8::StackTrace> trace =
 +                    v8::StackTrace::CurrentStackTrace(1, (v8::StackTrace::StackTraceOptions)(v8::StackTrace::kLineNumber |
 +                                                                                             v8::StackTrace::kScriptName));
 +                v8::Local<v8::StackFrame> frame = trace->GetFrame(0);
 +                int lineNumber = frame->GetLineNumber();
-                 int columNumber = frame->GetColumn();
++                int columnNumber = frame->GetColumn();
 +                QString url = engine->toString(frame->GetScriptName());
 +
-                 newBinding = new QQmlBinding(&function, object, context);
-                 newBinding->setSourceLocation(url, lineNumber, columNumber);
++                newBinding = new QQmlBinding(&function, object, context, url, lineNumber, columnNumber);
 +                newBinding->setTarget(object, *property, context);
 +                newBinding->setEvaluateFlags(newBinding->evaluateFlags() |
 +                                             QQmlBinding::RequiresThisObject);
 +                qWarning("WARNING: function assignment is DEPRECATED and will be removed!  Wrap RHS in Qt.binding(): %s:%d", qPrintable(engine->toString(frame->GetScriptName())), frame->GetLineNumber());
 +            }
 +        } else {
 +            // binding assignment.
 +            QQmlContextData *context = engine->callingContext();
 +            v8::Handle<v8::Function> function = v8::Handle<v8::Function>::Cast(value);
 +
 +            v8::Local<v8::StackTrace> trace =
 +                v8::StackTrace::CurrentStackTrace(1, (v8::StackTrace::StackTraceOptions)(v8::StackTrace::kLineNumber |
 +                                                                                         v8::StackTrace::kScriptName));
 +            v8::Local<v8::StackFrame> frame = trace->GetFrame(0);
 +            int lineNumber = frame->GetLineNumber();
-             int columNumber = frame->GetColumn();
++            int columnNumber = frame->GetColumn();
 +            QString url = engine->toString(frame->GetScriptName());
 +
-             newBinding = new QQmlBinding(&function, object, context);
-             newBinding->setSourceLocation(url, lineNumber, columNumber);
++            newBinding = new QQmlBinding(&function, object, context, url, lineNumber, columnNumber);
 +            newBinding->setTarget(object, *property, context);
 +            newBinding->setEvaluateFlags(newBinding->evaluateFlags() |
 +                                         QQmlBinding::RequiresThisObject);
 +        }
      }
  
      QQmlAbstractBinding *oldBinding = 
Simple merge
Simple merge
Simple merge
@@@ -5028,13 -5054,9 +5060,13 @@@ void tst_qqmlecmascript::functionAssign
      QQmlComponent component(&engine, testFileUrl("functionAssignment.1.qml"));
  
      QString url = component.url().toString();
-     QString w1 = url + ":4: Unable to assign a function to a property of any type other than var.";
-     QString w2 = url + ":5: Invalid use of Qt.binding() in a binding declaration.";
-     QString w3 = url + ":6: Invalid use of Qt.binding() in a binding declaration.";
 -    QString warning = url + ":4:25: Unable to assign a function to a property.";
 -    QTest::ignoreMessage(QtWarningMsg, warning.toLatin1().constData());
 -    
++    QString w1 = url + ":4:25: Unable to assign a function to a property of any type other than var.";
++    QString w2 = url + ":5:25: Invalid use of Qt.binding() in a binding declaration.";
++    QString w3 = url + ":6:21: Invalid use of Qt.binding() in a binding declaration.";
 +    QTest::ignoreMessage(QtWarningMsg, w1.toLatin1().constData());
 +    QTest::ignoreMessage(QtWarningMsg, w2.toLatin1().constData());
 +    QTest::ignoreMessage(QtWarningMsg, w3.toLatin1().constData());
-     
++
      MyQmlObject *o = qobject_cast<MyQmlObject *>(component.create());
      QVERIFY(o != 0);
  
@@@ -883,25 -880,8 +883,25 @@@ void tst_qqmlvaluetypes::bindingAssignm
      object->setProperty("value", QVariant(92));
  
      QCOMPARE(object->rect().x(), 92);
 +    QCOMPARE(object->rect().y(), 97);
  
      delete object;
-     QString warning1 = testFileUrl("bindingAssignment.2.qml").toString() + QLatin1String(":6: Invalid use of Qt.binding() in a binding declaration.");
 +    }
 +
 +    // function assignment should fail without crashing
 +    {
++    QString warning1 = testFileUrl("bindingAssignment.2.qml").toString() + QLatin1String(":6:13: Invalid use of Qt.binding() in a binding declaration.");
 +    QString warning2 = testFileUrl("bindingAssignment.2.qml").toString() + QLatin1String(":10: Error: Cannot assign JavaScript function to value-type property");
 +    QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
 +    QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2));
 +    QQmlComponent component(&engine, testFileUrl("bindingAssignment.2.qml"));
 +    MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
 +    QVERIFY(object != 0);
 +    QCOMPARE(object->rect().x(), 5);
 +    object->setProperty("value", QVariant(92));
 +    QCOMPARE(object->rect().x(), 5);
 +    delete object;
 +    }
  }
  
  // Test bindings can read from value types
Simple merge