diff options
author | Qt Continuous Integration System <qt-info@nokia.com> | 2010-08-24 09:12:41 (GMT) |
---|---|---|
committer | Qt Continuous Integration System <qt-info@nokia.com> | 2010-08-24 09:12:41 (GMT) |
commit | 31aab590f1c14ef1aaa2742cd2a369465c48aa2f (patch) | |
tree | 2992dd868b3ae491961da535c48cb85b4507f29e | |
parent | 0067b1fd6ce3abb2600de9567039fd9710b176d2 (diff) | |
parent | 6536f950bb4eb21f769086a9e95bb76e81a39e3c (diff) | |
download | Qt-31aab590f1c14ef1aaa2742cd2a369465c48aa2f.zip Qt-31aab590f1c14ef1aaa2742cd2a369465c48aa2f.tar.gz Qt-31aab590f1c14ef1aaa2742cd2a369465c48aa2f.tar.bz2 |
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into 4.7-integration
* '4.7' of scm.dev.nokia.troll.no:qt/qt-qml:
Fix few declarative code issues discovered by static code analysis
Use SpringAnimation in relevant examples again.
Fix crach in synchronization of ListModel in WorkerThread.
Enable mouse text selection in searchbox example
Make QML tests compile on OpenSolaris
Document QML_DECLARE_TYPEINFO
20 files changed, 66 insertions, 39 deletions
diff --git a/doc/src/declarative/qtdeclarative.qdoc b/doc/src/declarative/qtdeclarative.qdoc index b4f4c83..f163a66 100644 --- a/doc/src/declarative/qtdeclarative.qdoc +++ b/doc/src/declarative/qtdeclarative.qdoc @@ -59,6 +59,16 @@ Equivalent to Q_DECLARE_METATYPE(TYPE) and Q_DECLARE_METATYPE(QDeclarativeListProperty<TYPE>) */ +/*! + \macro QML_DECLARE_TYPEINFO(Type,Flags) + \relates QDeclarativeEngine + + Declares additional properties of a type. + + Current the only supported type info is \c QML_HAS_ATTACHED_PROPERTIES which + declares that the \c Type supports \l {Attached Properties}. +*/ + /*! \fn int qmlRegisterType(const char *uri, int versionMajor, int versionMinor, const char *qmlName) diff --git a/examples/declarative/toys/clocks/content/Clock.qml b/examples/declarative/toys/clocks/content/Clock.qml index eaa14c6..765e8b8 100644 --- a/examples/declarative/toys/clocks/content/Clock.qml +++ b/examples/declarative/toys/clocks/content/Clock.qml @@ -77,7 +77,7 @@ Item { origin.x: 7.5; origin.y: 73; angle: (clock.hours * 30) + (clock.minutes * 0.5) Behavior on angle { - RotationAnimation{ direction: RotationAnimation.Clockwise } + SpringAnimation { spring: 2; damping: 0.2; modulus: 360 } } } } @@ -91,7 +91,7 @@ Item { origin.x: 6.5; origin.y: 83; angle: clock.minutes * 6 Behavior on angle { - RotationAnimation{ direction: RotationAnimation.Clockwise } + SpringAnimation { spring: 2; damping: 0.2; modulus: 360 } } } } @@ -105,7 +105,7 @@ Item { origin.x: 2.5; origin.y: 80; angle: clock.seconds * 6 Behavior on angle { - RotationAnimation{ direction: RotationAnimation.Clockwise } + SpringAnimation { spring: 2; damping: 0.2; modulus: 360 } } } } diff --git a/examples/declarative/toys/tvtennis/tvtennis.qml b/examples/declarative/toys/tvtennis/tvtennis.qml index 2e144ed..4080c87 100644 --- a/examples/declarative/toys/tvtennis/tvtennis.qml +++ b/examples/declarative/toys/tvtennis/tvtennis.qml @@ -87,14 +87,14 @@ Rectangle { color: "Lime" x: 2; width: 20; height: 90 y: ball.direction == 'left' ? ball.y - 45 : page.height/2 -45; - Behavior on y { SpringAnimation{ spring: 1; damping: .1; } } + Behavior on y { SpringAnimation{ velocity: 300 } } } Rectangle { id: rightBat color: "Lime" x: page.width - 22; width: 20; height: 90 y: ball.direction == 'right' ? ball.y - 45 : page.height/2 -45; - Behavior on y { SpringAnimation{ spring: 1; damping: .1; } } + Behavior on y { SpringAnimation{ velocity: 300 } } } // The rest, to make it look realistic, if neither ever scores... diff --git a/examples/declarative/ui-components/searchbox/SearchBox.qml b/examples/declarative/ui-components/searchbox/SearchBox.qml index 6d87837..8ef21b3 100644 --- a/examples/declarative/ui-components/searchbox/SearchBox.qml +++ b/examples/declarative/ui-components/searchbox/SearchBox.qml @@ -75,6 +75,7 @@ FocusScope { id: textInput anchors { left: parent.left; leftMargin: 8; right: clear.left; rightMargin: 8; verticalCenter: parent.verticalCenter } focus: true + selectByMouse: true } Image { diff --git a/src/declarative/graphicsitems/qdeclarativelistview.cpp b/src/declarative/graphicsitems/qdeclarativelistview.cpp index ec1b6cf..2e2e08c 100644 --- a/src/declarative/graphicsitems/qdeclarativelistview.cpp +++ b/src/declarative/graphicsitems/qdeclarativelistview.cpp @@ -983,7 +983,7 @@ void QDeclarativeListViewPrivate::updateSections() void QDeclarativeListViewPrivate::updateCurrentSection() { if (!sectionCriteria || visibleItems.isEmpty()) { - currentSection = QString(); + currentSection.clear(); return; } int index = 0; diff --git a/src/declarative/graphicsitems/qdeclarativetext.cpp b/src/declarative/graphicsitems/qdeclarativetext.cpp index fcd112e..b96b43c 100644 --- a/src/declarative/graphicsitems/qdeclarativetext.cpp +++ b/src/declarative/graphicsitems/qdeclarativetext.cpp @@ -1218,7 +1218,7 @@ void QDeclarativeText::mousePressEvent(QGraphicsSceneMouseEvent *event) if (!d->richText || !d->doc || d->doc->documentLayout()->anchorAt(event->pos()).isEmpty()) { event->setAccepted(false); - d->activeLink = QString(); + d->activeLink.clear(); } else { d->activeLink = d->doc->documentLayout()->anchorAt(event->pos()); } diff --git a/src/declarative/qml/parser/qdeclarativejslexer.cpp b/src/declarative/qml/parser/qdeclarativejslexer.cpp index 65a6af2..cd08658 100644 --- a/src/declarative/qml/parser/qdeclarativejslexer.cpp +++ b/src/declarative/qml/parser/qdeclarativejslexer.cpp @@ -120,7 +120,7 @@ Lexer::~Lexer() void Lexer::setCode(const QString &c, int lineno) { - errmsg = QString(); + errmsg.clear(); yylineno = lineno; yycolumn = 1; restrKeyword = false; diff --git a/src/declarative/qml/qdeclarativecompositetypemanager.cpp b/src/declarative/qml/qdeclarativecompositetypemanager.cpp index 26b2a9b..2e77534 100644 --- a/src/declarative/qml/qdeclarativecompositetypemanager.cpp +++ b/src/declarative/qml/qdeclarativecompositetypemanager.cpp @@ -544,7 +544,7 @@ int QDeclarativeCompositeTypeManager::resolveTypes(QDeclarativeCompositeTypeData } - foreach (QDeclarativeScriptParser::Import imp, unit->data.imports()) { + foreach (const QDeclarativeScriptParser::Import &imp, unit->data.imports()) { QDeclarativeDirComponents qmldircomponentsnetwork; if (imp.type == QDeclarativeScriptParser::Import::Script) continue; diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp index cedf9d5..4e45636 100644 --- a/src/declarative/qml/qdeclarativeengine.cpp +++ b/src/declarative/qml/qdeclarativeengine.cpp @@ -2079,7 +2079,7 @@ void QDeclarativeEnginePrivate::registerCompositeType(QDeclarativeCompiledData * QByteArray name = data->root->className(); QByteArray ptr = name + '*'; - QByteArray lst = "QDeclarativeListProperty<" + name + ">"; + QByteArray lst = "QDeclarativeListProperty<" + name + '>'; int ptr_type = QMetaType::registerType(ptr.constData(), voidptr_destructor, voidptr_constructor); diff --git a/src/declarative/qml/qdeclarativeimport.cpp b/src/declarative/qml/qdeclarativeimport.cpp index 8d81b34..5c21ebc 100644 --- a/src/declarative/qml/qdeclarativeimport.cpp +++ b/src/declarative/qml/qdeclarativeimport.cpp @@ -338,7 +338,7 @@ QString QDeclarativeImportsPrivate::resolvedUri(const QString &dir_arg, QDeclara qSort(paths.begin(), paths.end(), greaterThan); // Ensure subdirs preceed their parents. QString stableRelativePath = dir; - foreach( QString path, paths) { + foreach(const QString &path, paths) { if (dir.startsWith(path)) { stableRelativePath = dir.mid(path.length()+1); break; diff --git a/src/declarative/qml/qdeclarativescriptparser.cpp b/src/declarative/qml/qdeclarativescriptparser.cpp index 0657f49..0b3b35f 100644 --- a/src/declarative/qml/qdeclarativescriptparser.cpp +++ b/src/declarative/qml/qdeclarativescriptparser.cpp @@ -543,7 +543,7 @@ bool ProcessAST::visit(AST::UiPublicMember *node) QString typemodifier; if(node->typeModifier) typemodifier = node->typeModifier->asString(); - if (typemodifier == QString()) { + if (typemodifier.isEmpty()) { type = Object::DynamicProperty::Custom; } else if(typemodifier == QLatin1String("list")) { type = Object::DynamicProperty::CustomList; diff --git a/src/declarative/qml/qmetaobjectbuilder.cpp b/src/declarative/qml/qmetaobjectbuilder.cpp index 6e4d7b8..0954248 100644 --- a/src/declarative/qml/qmetaobjectbuilder.cpp +++ b/src/declarative/qml/qmetaobjectbuilder.cpp @@ -1142,7 +1142,7 @@ static QByteArray buildParameterNames if (!parameterNames.isEmpty()) { QByteArray names; bool first = true; - foreach (QByteArray name, parameterNames) { + foreach (const QByteArray &name, parameterNames) { if (first) first = false; else diff --git a/src/declarative/util/qdeclarativelistmodel.cpp b/src/declarative/util/qdeclarativelistmodel.cpp index 1f66f0f..0162beb 100644 --- a/src/declarative/util/qdeclarativelistmodel.cpp +++ b/src/declarative/util/qdeclarativelistmodel.cpp @@ -570,7 +570,7 @@ bool QDeclarativeListModelParser::compileProperty(const QDeclarativeCustomParser QList<QDeclarativeCustomParserProperty> props = node.properties(); for(int jj = 0; jj < props.count(); ++jj) { const QDeclarativeCustomParserProperty &nodeProp = props.at(jj); - if (nodeProp.name() == "") { + if (nodeProp.name().isEmpty()) { error(nodeProp, QDeclarativeListModel::tr("ListElement: cannot contain nested elements")); return false; } @@ -658,7 +658,7 @@ QByteArray QDeclarativeListModelParser::compile(const QList<QDeclarativeCustomPa for(int ii = 0; ii < customProps.count(); ++ii) { const QDeclarativeCustomParserProperty &prop = customProps.at(ii); - if(prop.name() != "") { // isn't default property + if(!prop.name().isEmpty()) { // isn't default property error(prop, QDeclarativeListModel::tr("ListModel: undefined property '%1'").arg(QString::fromUtf8(prop.name()))); return QByteArray(); } diff --git a/src/declarative/util/qdeclarativelistmodelworkeragent.cpp b/src/declarative/util/qdeclarativelistmodelworkeragent.cpp index 534c923..498de6d 100644 --- a/src/declarative/util/qdeclarativelistmodelworkeragent.cpp +++ b/src/declarative/util/qdeclarativelistmodelworkeragent.cpp @@ -187,12 +187,17 @@ void QDeclarativeListModelWorkerAgent::sync() s->data = data; s->list = m_copy; data.changes.clear(); + + mutex.lock(); QCoreApplication::postEvent(this, s); + syncDone.wait(&mutex); + mutex.unlock(); } bool QDeclarativeListModelWorkerAgent::event(QEvent *e) { if (e->type() == QEvent::User) { + QMutexLocker locker(&mutex); Sync *s = static_cast<Sync *>(e); const QList<Change> &changes = s->data.changes; @@ -202,13 +207,18 @@ bool QDeclarativeListModelWorkerAgent::event(QEvent *e) FlatListModel *orig = m_orig->m_flat; FlatListModel *copy = s->list->m_flat; - if (!orig || !copy) + if (!orig || !copy) { + syncDone.wakeAll(); return QObject::event(e); - + } + orig->m_roles = copy->m_roles; orig->m_strings = copy->m_strings; orig->m_values = copy->m_values; + syncDone.wakeAll(); + locker.unlock(); + for (int ii = 0; ii < changes.count(); ++ii) { const Change &change = changes.at(ii); switch (change.type) { @@ -229,6 +239,8 @@ bool QDeclarativeListModelWorkerAgent::event(QEvent *e) if (cc) emit m_orig->countChanged(); + } else { + syncDone.wakeAll(); } } diff --git a/src/declarative/util/qdeclarativelistmodelworkeragent_p.h b/src/declarative/util/qdeclarativelistmodelworkeragent_p.h index 1622144..01da374 100644 --- a/src/declarative/util/qdeclarativelistmodelworkeragent_p.h +++ b/src/declarative/util/qdeclarativelistmodelworkeragent_p.h @@ -57,6 +57,8 @@ #include <QtScript/qscriptvalue.h> #include <QtGui/qevent.h> +#include <QMutex> +#include <QWaitCondition> QT_BEGIN_HEADER @@ -142,6 +144,8 @@ private: QAtomicInt m_ref; QDeclarativeListModel *m_orig; QDeclarativeListModel *m_copy; + QMutex mutex; + QWaitCondition syncDone; }; QT_END_NAMESPACE diff --git a/src/declarative/util/qdeclarativestategroup.cpp b/src/declarative/util/qdeclarativestategroup.cpp index fc90baa..6d9563e 100644 --- a/src/declarative/util/qdeclarativestategroup.cpp +++ b/src/declarative/util/qdeclarativestategroup.cpp @@ -272,7 +272,7 @@ void QDeclarativeStateGroup::componentComplete() return; } else if (!d->currentState.isEmpty()) { QString cs = d->currentState; - d->currentState = QString(); + d->currentState.clear(); d->setCurrentStateInternal(cs, true); } } @@ -314,7 +314,7 @@ bool QDeclarativeStateGroupPrivate::updateAutoState() } } if (revert) { - bool rv = currentState != QString(); + bool rv = !currentState.isEmpty(); q->setState(QString()); return rv; } else { diff --git a/tests/auto/declarative/qdeclarativeecmascript/testtypes.h b/tests/auto/declarative/qdeclarativeecmascript/testtypes.h index 19bfd37..37d6dbd 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/testtypes.h +++ b/tests/auto/declarative/qdeclarativeecmascript/testtypes.h @@ -604,62 +604,62 @@ class NumberAssignment : public QObject { Q_OBJECT public: - Q_PROPERTY(qreal test1 READ test1 WRITE setTest1); + Q_PROPERTY(qreal test1 READ test1 WRITE setTest1) qreal _test1; qreal test1() const { return _test1; } void setTest1(qreal v) { _test1 = v; } - Q_PROPERTY(qreal test2 READ test2 WRITE setTest2); + Q_PROPERTY(qreal test2 READ test2 WRITE setTest2) qreal _test2; qreal test2() const { return _test2; } void setTest2(qreal v) { _test2 = v; } - Q_PROPERTY(qreal test3 READ test3 WRITE setTest3); + Q_PROPERTY(qreal test3 READ test3 WRITE setTest3) qreal _test3; qreal test3() const { return _test3; } void setTest3(qreal v) { _test3 = v; } - Q_PROPERTY(qreal test4 READ test4 WRITE setTest4); + Q_PROPERTY(qreal test4 READ test4 WRITE setTest4) qreal _test4; qreal test4() const { return _test4; } void setTest4(qreal v) { _test4 = v; } - Q_PROPERTY(int test5 READ test5 WRITE setTest5); + Q_PROPERTY(int test5 READ test5 WRITE setTest5) int _test5; int test5() const { return _test5; } void setTest5(int v) { _test5 = v; } - Q_PROPERTY(int test6 READ test6 WRITE setTest6); + Q_PROPERTY(int test6 READ test6 WRITE setTest6) int _test6; int test6() const { return _test6; } void setTest6(int v) { _test6 = v; } - Q_PROPERTY(int test7 READ test7 WRITE setTest7); + Q_PROPERTY(int test7 READ test7 WRITE setTest7) int _test7; int test7() const { return _test7; } void setTest7(int v) { _test7 = v; } - Q_PROPERTY(int test8 READ test8 WRITE setTest8); + Q_PROPERTY(int test8 READ test8 WRITE setTest8) int _test8; int test8() const { return _test8; } void setTest8(int v) { _test8 = v; } - Q_PROPERTY(unsigned int test9 READ test9 WRITE setTest9); + Q_PROPERTY(unsigned int test9 READ test9 WRITE setTest9) unsigned int _test9; unsigned int test9() const { return _test9; } void setTest9(unsigned int v) { _test9 = v; } - Q_PROPERTY(unsigned int test10 READ test10 WRITE setTest10); + Q_PROPERTY(unsigned int test10 READ test10 WRITE setTest10) unsigned int _test10; unsigned int test10() const { return _test10; } void setTest10(unsigned int v) { _test10 = v; } - Q_PROPERTY(unsigned int test11 READ test11 WRITE setTest11); + Q_PROPERTY(unsigned int test11 READ test11 WRITE setTest11) unsigned int _test11; unsigned int test11() const { return _test11; } void setTest11(unsigned int v) { _test11 = v; } - Q_PROPERTY(unsigned int test12 READ test12 WRITE setTest12); + Q_PROPERTY(unsigned int test12 READ test12 WRITE setTest12) unsigned int _test12; unsigned int test12() const { return _test12; } void setTest12(unsigned int v) { _test12 = v; } diff --git a/tests/auto/declarative/qdeclarativemetatype/tst_qdeclarativemetatype.cpp b/tests/auto/declarative/qdeclarativemetatype/tst_qdeclarativemetatype.cpp index b06ad7c..862b7d2 100644 --- a/tests/auto/declarative/qdeclarativemetatype/tst_qdeclarativemetatype.cpp +++ b/tests/auto/declarative/qdeclarativemetatype/tst_qdeclarativemetatype.cpp @@ -313,7 +313,7 @@ void tst_qdeclarativemetatype::qmlParserStatusCast() QVERIFY(reinterpret_cast<char *>((QObject *)&t) != reinterpret_cast<char *>((QDeclarativeParserStatus *)&t)); QDeclarativeParserStatus *status = reinterpret_cast<QDeclarativeParserStatus *>(reinterpret_cast<char *>((QObject *)&t) + cast); - QCOMPARE(status, &t); + QCOMPARE(status, (QDeclarativeParserStatus*)&t); } void tst_qdeclarativemetatype::qmlPropertyValueSourceCast() @@ -333,7 +333,7 @@ void tst_qdeclarativemetatype::qmlPropertyValueSourceCast() QVERIFY(reinterpret_cast<char *>((QObject *)&t) != reinterpret_cast<char *>((QDeclarativePropertyValueSource *)&t)); QDeclarativePropertyValueSource *source = reinterpret_cast<QDeclarativePropertyValueSource *>(reinterpret_cast<char *>((QObject *)&t) + cast); - QCOMPARE(source, &t); + QCOMPARE(source, (QDeclarativePropertyValueSource*)&t); } void tst_qdeclarativemetatype::qmlPropertyValueInterceptorCast() @@ -353,7 +353,7 @@ void tst_qdeclarativemetatype::qmlPropertyValueInterceptorCast() QVERIFY(reinterpret_cast<char *>((QObject *)&t) != reinterpret_cast<char *>((QDeclarativePropertyValueInterceptor *)&t)); QDeclarativePropertyValueInterceptor *interceptor = reinterpret_cast<QDeclarativePropertyValueInterceptor *>(reinterpret_cast<char *>((QObject *)&t) + cast); - QCOMPARE(interceptor, &t); + QCOMPARE(interceptor, (QDeclarativePropertyValueInterceptor*)&t); } void tst_qdeclarativemetatype::isList() diff --git a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp index 57a5e29..56a3121 100644 --- a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp +++ b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp @@ -1096,7 +1096,7 @@ void tst_qdeclarativetextedit::openInputPanelOnFocus() QApplication::processEvents(); QCOMPARE(ic.openInputPanelReceived, true); ic.openInputPanelReceived = false; - QCOMPARE(view.inputContext(), &ic); + QCOMPARE(view.inputContext(), (QInputContext*)&ic); QVERIFY(view.testAttribute(Qt::WA_InputMethodEnabled)); // input method should be disabled if focus diff --git a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp index 98a6012..7450d35 100644 --- a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp +++ b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp @@ -194,7 +194,7 @@ void tst_qdeclarativetextinput::width() QDeclarativeTextInput *textinputObject = qobject_cast<QDeclarativeTextInput*>(textinputComponent.create()); QVERIFY(textinputObject != 0); - int delta = abs(int(textinputObject->width()) - metricWidth); + int delta = abs(int(int(textinputObject->width()) - metricWidth)); QVERIFY(delta <= 3.0); // As best as we can hope for cross-platform. delete textinputObject; @@ -451,7 +451,7 @@ void tst_qdeclarativetextinput::positionAt() QFontMetrics fm(textinputObject->font()); int pos = textinputObject->positionAt(textinputObject->width()/2); - int diff = abs(fm.width(textinputObject->text()) - (fm.width(textinputObject->text().left(pos))+textinputObject->width()/2)); + int diff = abs(int(fm.width(textinputObject->text()) - (fm.width(textinputObject->text().left(pos))+textinputObject->width()/2))); // some tollerance for different fonts. #ifdef Q_OS_LINUX @@ -463,7 +463,7 @@ void tst_qdeclarativetextinput::positionAt() // Check without autoscroll... textinputObject->setAutoScroll(false); pos = textinputObject->positionAt(textinputObject->width()/2); - diff = abs(fm.width(textinputObject->text().left(pos))-textinputObject->width()/2); + diff = abs(int(fm.width(textinputObject->text().left(pos))-textinputObject->width()/2)); // some tollerance for different fonts. #ifdef Q_OS_LINUX @@ -1038,7 +1038,7 @@ void tst_qdeclarativetextinput::openInputPanelOnFocus() QApplication::processEvents(); QCOMPARE(ic.openInputPanelReceived, true); ic.openInputPanelReceived = false; - QCOMPARE(view.inputContext(), &ic); + QCOMPARE(view.inputContext(), (QInputContext*)&ic); QVERIFY(view.testAttribute(Qt::WA_InputMethodEnabled)); // input method should be disabled if focus |