diff options
author | Erik Verbruggen <erik.verbruggen@digia.com> | 2013-11-01 12:38:32 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-11-04 02:16:04 +0100 |
commit | a79e400150e9d550cc4ddc0c0497778d8b78fe5d (patch) | |
tree | 5a66670d4c31aaf0d356042b6fe607728e237b5b /src/qml/qml | |
parent | b5991ce2a61219bda5a7fa6e33f323158d1eb78b (diff) |
Fix various compiler warnings in order to remove warn_off in the near future
Change-Id: Ic0492fbe31a1e134674bc6c20381f735dd6d5b7a
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/qml/qml')
-rw-r--r-- | src/qml/qml/ftw/qhashedstring.cpp | 131 | ||||
-rw-r--r-- | src/qml/qml/qqmlabstractbinding.cpp | 3 | ||||
-rw-r--r-- | src/qml/qml/qqmlcomponent.cpp | 4 | ||||
-rw-r--r-- | src/qml/qml/qqmlengine.cpp | 1 | ||||
-rw-r--r-- | src/qml/qml/qqmlimport.cpp | 8 | ||||
-rw-r--r-- | src/qml/qml/qqmljavascriptexpression.cpp | 5 | ||||
-rw-r--r-- | src/qml/qml/qqmllistwrapper.cpp | 2 | ||||
-rw-r--r-- | src/qml/qml/qqmlobjectcreator.cpp | 14 | ||||
-rw-r--r-- | src/qml/qml/qqmlpropertycache.cpp | 2 | ||||
-rw-r--r-- | src/qml/qml/qqmltypeloader.cpp | 2 | ||||
-rw-r--r-- | src/qml/qml/qqmltypenamecache.cpp | 2 | ||||
-rw-r--r-- | src/qml/qml/qqmlvme.cpp | 2 | ||||
-rw-r--r-- | src/qml/qml/qqmlxmlhttprequest.cpp | 4 | ||||
-rw-r--r-- | src/qml/qml/v8/qqmlbuiltinfunctions.cpp | 18 | ||||
-rw-r--r-- | src/qml/qml/v8/qv8engine.cpp | 2 |
15 files changed, 33 insertions, 167 deletions
diff --git a/src/qml/qml/ftw/qhashedstring.cpp b/src/qml/qml/ftw/qhashedstring.cpp index 40caaf379f..321e6ccb41 100644 --- a/src/qml/qml/ftw/qhashedstring.cpp +++ b/src/qml/qml/ftw/qhashedstring.cpp @@ -209,137 +209,6 @@ static inline bool isUnicodeNonCharacter(uint ucs4) || (ucs4 - 0xfdd0U) < 16; } -static int utf8LengthFromUtf16(const QChar *uc, int len) -{ - int length = 0; - - int surrogate_high = -1; - - const QChar *ch = uc; - int invalid = 0; - - const QChar *end = ch + len; - while (ch < end) { - uint u = ch->unicode(); - if (surrogate_high >= 0) { - if (u >= 0xdc00 && u < 0xe000) { - u = (surrogate_high - 0xd800)*0x400 + (u - 0xdc00) + 0x10000; - surrogate_high = -1; - } else { - // high surrogate without low - ++ch; - ++invalid; - surrogate_high = -1; - continue; - } - } else if (u >= 0xdc00 && u < 0xe000) { - // low surrogate without high - ++ch; - ++invalid; - continue; - } else if (u >= 0xd800 && u < 0xdc00) { - surrogate_high = u; - ++ch; - continue; - } - - if (u < 0x80) { - ++length; - } else { - if (u < 0x0800) { - ++length; - } else { - // is it one of the Unicode non-characters? - if (isUnicodeNonCharacter(u)) { - ++length; - ++ch; - ++invalid; - continue; - } - - if (u > 0xffff) { - ++length; - ++length; - } else { - ++length; - } - ++length; - } - ++length; - } - ++ch; - } - - return length; -} - -// Writes the utf8 version of uc to output. uc is of length len. -// There must be at least utf8LengthFromUtf16(uc, len) bytes in output. -// A null terminator is not written. -static void utf8FromUtf16(char *output, const QChar *uc, int len) -{ - uchar replacement = '?'; - int surrogate_high = -1; - - uchar* cursor = (uchar*)output; - const QChar *ch = uc; - int invalid = 0; - - const QChar *end = ch + len; - while (ch < end) { - uint u = ch->unicode(); - if (surrogate_high >= 0) { - if (u >= 0xdc00 && u < 0xe000) { - u = (surrogate_high - 0xd800)*0x400 + (u - 0xdc00) + 0x10000; - surrogate_high = -1; - } else { - // high surrogate without low - *cursor = replacement; - ++ch; - ++invalid; - surrogate_high = -1; - continue; - } - } else if (u >= 0xdc00 && u < 0xe000) { - // low surrogate without high - *cursor = replacement; - ++ch; - ++invalid; - continue; - } else if (u >= 0xd800 && u < 0xdc00) { - surrogate_high = u; - ++ch; - continue; - } - - if (u < 0x80) { - *cursor++ = (uchar)u; - } else { - if (u < 0x0800) { - *cursor++ = 0xc0 | ((uchar) (u >> 6)); - } else { - // is it one of the Unicode non-characters? - if (isUnicodeNonCharacter(u)) { - *cursor++ = replacement; - ++ch; - ++invalid; - continue; - } - - if (u > 0xffff) { - *cursor++ = 0xf0 | ((uchar) (u >> 18)); - *cursor++ = 0x80 | (((uchar) (u >> 12)) & 0x3f); - } else { - *cursor++ = 0xe0 | (((uchar) (u >> 12)) & 0x3f); - } - *cursor++ = 0x80 | (((uchar) (u >> 6)) & 0x3f); - } - *cursor++ = 0x80 | ((uchar) (u&0x3f)); - } - ++ch; - } -} - QHashedStringRef QHashedStringRef::mid(int offset, int length) const { Q_ASSERT(offset < m_length); diff --git a/src/qml/qml/qqmlabstractbinding.cpp b/src/qml/qml/qqmlabstractbinding.cpp index c01981b3d2..32762a46bf 100644 --- a/src/qml/qml/qqmlabstractbinding.cpp +++ b/src/qml/qml/qqmlabstractbinding.cpp @@ -56,9 +56,8 @@ QQmlAbstractBinding::VTable *QQmlAbstractBinding::vTables[] = { }; QQmlAbstractBinding::QQmlAbstractBinding(BindingType bt) -: m_nextBindingPtr(bt) + : m_nextBindingPtr(bt) { - Q_ASSERT(bt <= 0x03); } QQmlAbstractBinding::~QQmlAbstractBinding() diff --git a/src/qml/qml/qqmlcomponent.cpp b/src/qml/qml/qqmlcomponent.cpp index 883237130b..bc804c4f2d 100644 --- a/src/qml/qml/qqmlcomponent.cpp +++ b/src/qml/qml/qqmlcomponent.cpp @@ -1265,7 +1265,6 @@ void QQmlComponent::createObject(QQmlV4Function *args) Q_ASSERT(object->isObject()); if (!valuemap->isUndefined()) { - QQmlComponentExtension *e = componentExtension(args->engine()); QV4::ScopedObject qmlglobal(scope, args->qmlGlobal()); QV4::ScopedValue f(scope, QV4::Script::evaluate(v4, QString::fromLatin1(INITIALPROPERTIES_SOURCE), qmlglobal)); Q_ASSERT(f->asFunctionObject()); @@ -1420,7 +1419,6 @@ void QQmlComponentPrivate::initializeObjectWithInitialProperties(const QV4::Valu Q_ASSERT(object->asObject()); if (!valuemap->isUndefined()) { - QQmlComponentExtension *e = componentExtension(v8engine); QV4::ScopedObject qmlGlobalObj(scope, qmlGlobal); QV4::Scoped<QV4::FunctionObject> f(scope, QV4::Script::evaluate(QV8Engine::getV4(v8engine), QString::fromLatin1(INITIALPROPERTIES_SOURCE), qmlGlobalObj)); @@ -1521,8 +1519,6 @@ void QmlIncubatorObject::setInitialState(QObject *o) QQmlComponent_setQmlParent(o, parent); if (!valuemap.isUndefined()) { - QQmlComponentExtension *e = componentExtension(v8); - QV4::ExecutionEngine *v4 = QV8Engine::getV4(v8); QV4::Scope scope(v4); diff --git a/src/qml/qml/qqmlengine.cpp b/src/qml/qml/qqmlengine.cpp index 64cde85913..f7b36b51bb 100644 --- a/src/qml/qml/qqmlengine.cpp +++ b/src/qml/qml/qqmlengine.cpp @@ -1761,7 +1761,6 @@ void QQmlEnginePrivate::warning(const QList<QQmlError> &errors) void QQmlEnginePrivate::warning(QQmlDelayedError *error) { - Q_Q(QQmlEngine); warning(error->error()); } diff --git a/src/qml/qml/qqmlimport.cpp b/src/qml/qml/qqmlimport.cpp index 63151b18bf..f33fd97c16 100644 --- a/src/qml/qml/qqmlimport.cpp +++ b/src/qml/qml/qqmlimport.cpp @@ -839,11 +839,12 @@ bool QQmlImportsPrivate::populatePluginPairVector(QVector<StaticPluginPair> &res foreach (const QStaticPlugin &plugin, plugins) { // Since a module can list more than one plugin, we keep iterating even after we found a match. if (QQmlExtensionPlugin *instance = qobject_cast<QQmlExtensionPlugin *>(plugin.instance())) { - const QJsonArray metaTagsUriList = plugin.metaData().value("uri").toArray(); + const QJsonArray metaTagsUriList = plugin.metaData().value(QStringLiteral("uri")).toArray(); if (metaTagsUriList.isEmpty()) { if (errors) { QQmlError error; - error.setDescription(QQmlImportDatabase::tr("static plugin for module \"%1\" with name \"%2\" has no metadata URI").arg(uri).arg(instance->metaObject()->className())); + error.setDescription(QQmlImportDatabase::tr("static plugin for module \"%1\" with name \"%2\" has no metadata URI") + .arg(uri).arg(QString::fromUtf8(instance->metaObject()->className()))); error.setUrl(QUrl::fromLocalFile(qmldirPath)); errors->prepend(error); } @@ -945,7 +946,8 @@ bool QQmlImportsPrivate::importExtension(const QString &qmldirFilePath, if (errors) { QQmlError poppedError = errors->takeFirst(); QQmlError error; - error.setDescription(QQmlImportDatabase::tr("static plugin for module \"%1\" with name \"%2\" cannot be loaded: %3").arg(uri).arg(instance->metaObject()->className()).arg(poppedError.description())); + error.setDescription(QQmlImportDatabase::tr("static plugin for module \"%1\" with name \"%2\" cannot be loaded: %3") + .arg(uri).arg(QString::fromUtf8(instance->metaObject()->className())).arg(poppedError.description())); error.setUrl(QUrl::fromLocalFile(qmldirFilePath)); errors->prepend(error); } diff --git a/src/qml/qml/qqmljavascriptexpression.cpp b/src/qml/qml/qqmljavascriptexpression.cpp index 79b7aa2e7a..53b7504196 100644 --- a/src/qml/qml/qqmljavascriptexpression.cpp +++ b/src/qml/qml/qqmljavascriptexpression.cpp @@ -148,9 +148,6 @@ QV4::ReturnedValue QQmlJavaScriptExpression::evaluate(QQmlContextData *context, if (notifyOnValueChanged()) capture.guards.copyAndClearPrepend(activeGuards); - QQmlContextData *lastSharedContext = 0; - QObject *lastSharedScope = 0; - // All code that follows must check with watcher before it accesses data members // incase we have been deleted. DeleteWatcher watcher(this); @@ -275,6 +272,8 @@ void QQmlJavaScriptExpression::clearError() QQmlError QQmlJavaScriptExpression::error(QQmlEngine *engine) const { + Q_UNUSED(engine); + if (m_vtable.hasValue()) return m_vtable.constValue()->error(); else diff --git a/src/qml/qml/qqmllistwrapper.cpp b/src/qml/qml/qqmllistwrapper.cpp index 12ebc102ee..73dc3192aa 100644 --- a/src/qml/qml/qqmllistwrapper.cpp +++ b/src/qml/qml/qqmllistwrapper.cpp @@ -122,6 +122,8 @@ ReturnedValue QmlListWrapper::get(Managed *m, const StringRef name, bool *hasPro ReturnedValue QmlListWrapper::getIndexed(Managed *m, uint index, bool *hasProperty) { + Q_UNUSED(hasProperty); + QV4::ExecutionEngine *e = m->engine(); QmlListWrapper *w = m->as<QmlListWrapper>(); if (!w) diff --git a/src/qml/qml/qqmlobjectcreator.cpp b/src/qml/qml/qqmlobjectcreator.cpp index 8cce2db340..59d7da342d 100644 --- a/src/qml/qml/qqmlobjectcreator.cpp +++ b/src/qml/qml/qqmlobjectcreator.cpp @@ -1266,7 +1266,7 @@ QObject *QmlObjectCreator::createInstance(int index, QObject *parent) } QQmlData *ddata = QQmlData::get(instance, /*create*/true); - if (index == qmlUnit->indexOfRootObject) { + if (static_cast<quint32>(index) == qmlUnit->indexOfRootObject) { if (ddata->context) { Q_ASSERT(ddata->context != context); Q_ASSERT(ddata->outerContext); @@ -1433,7 +1433,7 @@ bool QQmlComponentAndAliasResolver::resolve() // when someProperty _is_ a QQmlComponent. In that case the Item {} // should be implicitly surrounded by Component {} - for (int i = 0; i < qmlUnit->nObjects; ++i) { + for (quint32 i = 0; i < qmlUnit->nObjects; ++i) { const QV4::CompiledData::Object *obj = qmlUnit->objectAt(i); if (stringAt(obj->inheritedTypeNameIndex).isEmpty()) continue; @@ -1517,14 +1517,14 @@ bool QQmlComponentAndAliasResolver::collectIdsAndAliases(int objectIndex) } const QV4::CompiledData::Property *property = obj->propertyTable(); - for (int i = 0; i < obj->nProperties; ++i, ++property) + for (quint32 i = 0; i < obj->nProperties; ++i, ++property) if (property->type == QV4::CompiledData::Property::Alias) { _objectsWithAliases.append(objectIndex); break; } const QV4::CompiledData::Binding *binding = obj->bindingTable(); - for (int i = 0; i < obj->nBindings; ++i, ++binding) { + for (quint32 i = 0; i < obj->nBindings; ++i, ++binding) { if (binding->type != QV4::CompiledData::Binding::Type_Object && binding->type != QV4::CompiledData::Binding::Type_AttachedProperty && binding->type != QV4::CompiledData::Binding::Type_GroupProperty) @@ -1700,7 +1700,7 @@ QQmlPropertyValidator::QQmlPropertyValidator(const QUrl &url, const QV4::Compile bool QQmlPropertyValidator::validate() { - for (int i = 0; i < qmlUnit->nObjects; ++i) { + for (quint32 i = 0; i < qmlUnit->nObjects; ++i) { const QV4::CompiledData::Object *obj = qmlUnit->objectAt(i); if (stringAt(obj->inheritedTypeNameIndex).isEmpty()) continue; @@ -1724,7 +1724,7 @@ bool QQmlPropertyValidator::validateObject(const QV4::CompiledData::Object *obj, QQmlPropertyData *defaultProperty = propertyCache->defaultProperty(); const QV4::CompiledData::Binding *binding = obj->bindingTable(); - for (int i = 0; i < obj->nBindings; ++i, ++binding) { + for (quint32 i = 0; i < obj->nBindings; ++i, ++binding) { if (binding->type == QV4::CompiledData::Binding::Type_AttachedProperty || binding->type == QV4::CompiledData::Binding::Type_GroupProperty) continue; @@ -1760,4 +1760,6 @@ bool QQmlPropertyValidator::validateObject(const QV4::CompiledData::Object *obj, } } } + + return true; } diff --git a/src/qml/qml/qqmlpropertycache.cpp b/src/qml/qml/qqmlpropertycache.cpp index 2cb944d824..6c40557886 100644 --- a/src/qml/qml/qqmlpropertycache.cpp +++ b/src/qml/qml/qqmlpropertycache.cpp @@ -1154,7 +1154,7 @@ QString QQmlPropertyCache::signalParameterStringForJS(QQmlEngine *engine, const if (errorString) *errorString = QCoreApplication::translate("QQmlRewrite", "Signal uses unnamed parameter followed by named parameter."); return QString(); - } else if (illegalNames.contains(param)) { + } else if (illegalNames.contains(QString::fromUtf8(param))) { if (errorString) *errorString = QCoreApplication::translate("QQmlRewrite", "Signal parameter \"%1\" hides global variable.").arg(QString::fromUtf8(param)); return QString(); diff --git a/src/qml/qml/qqmltypeloader.cpp b/src/qml/qml/qqmltypeloader.cpp index 4abc33a49e..4b398fb6b8 100644 --- a/src/qml/qml/qqmltypeloader.cpp +++ b/src/qml/qml/qqmltypeloader.cpp @@ -2691,8 +2691,8 @@ QQmlScriptData::QQmlScriptData() : importCache(0) , pragmas(QQmlScript::Object::ScriptBlock::None) , m_loaded(false) - , m_program(0) , m_precompiledScript(0) + , m_program(0) { } diff --git a/src/qml/qml/qqmltypenamecache.cpp b/src/qml/qml/qqmltypenamecache.cpp index 87764c49ae..a880bbdd58 100644 --- a/src/qml/qml/qqmltypenamecache.cpp +++ b/src/qml/qml/qqmltypenamecache.cpp @@ -106,7 +106,7 @@ QQmlTypeNameCache::Result QQmlTypeNameCache::query(const QHashedStringRef &name, const Import *i = static_cast<const Import *>(importNamespace); Q_ASSERT(i->scriptIndex == -1); - Result result = result = typeSearch(i->modules, name); + Result result = typeSearch(i->modules, name); if (!result.isValid()) result = query(i->compositeSingletons, name); diff --git a/src/qml/qml/qqmlvme.cpp b/src/qml/qml/qqmlvme.cpp index b425b84a53..7c27d77b2e 100644 --- a/src/qml/qml/qqmlvme.cpp +++ b/src/qml/qml/qqmlvme.cpp @@ -638,7 +638,7 @@ QObject *QQmlVME::run(QList<QQmlError> *errors, QML_BEGIN_INSTR(CreateSimpleObject) QObject *o = (QObject *)operator new(instr.typeSize + sizeof(QQmlData)); - ::memset(o, 0, instr.typeSize + sizeof(QQmlData)); + ::memset(static_cast<void *>(o), 0, instr.typeSize + sizeof(QQmlData)); instr.create(o); QQmlData *ddata = (QQmlData *)(((const char *)o) + instr.typeSize); diff --git a/src/qml/qml/qqmlxmlhttprequest.cpp b/src/qml/qml/qqmlxmlhttprequest.cpp index 541c188d13..ab4c94704c 100644 --- a/src/qml/qml/qqmlxmlhttprequest.cpp +++ b/src/qml/qml/qqmlxmlhttprequest.cpp @@ -189,8 +189,8 @@ class NamedNodeMap : public Object public: NamedNodeMap(ExecutionEngine *engine, NodeImpl *data, const QList<NodeImpl *> &list) : Object(engine) - , d(data) , list(list) + , d(data) { vtbl = &static_vtbl; @@ -608,7 +608,6 @@ ReturnedValue Node::create(QV8Engine *engine, NodeImpl *data) ExecutionEngine *v4 = QV8Engine::getV4(engine); Scope scope(v4); - QQmlXMLHttpRequestData *d = xhrdata(engine); Scoped<Node> instance(scope, new (v4->memoryManager) Node(v4, data)); ScopedObject p(scope); @@ -992,7 +991,6 @@ ReturnedValue NodeList::get(Managed *m, const StringRef name, bool *hasProperty) ReturnedValue NodeList::create(QV8Engine *engine, NodeImpl *data) { - QQmlXMLHttpRequestData *d = xhrdata(engine); ExecutionEngine *v4 = QV8Engine::getV4(engine); Scope scope(v4); Scoped<NodeList> instance(scope, new (v4->memoryManager) NodeList(v4, data)); diff --git a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp index 047faabd1a..c02096614b 100644 --- a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp +++ b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp @@ -102,11 +102,11 @@ QV4::QtObject::QtObject(ExecutionEngine *v4, QQmlEngine *qmlEngine) for (int ii = 0; ii < qtMetaObject->enumeratorCount(); ++ii) { QMetaEnum enumerator = qtMetaObject->enumerator(ii); for (int jj = 0; jj < enumerator.keyCount(); ++jj) { - put((str = v4->newString(enumerator.key(jj))), (v = QV4::Primitive::fromInt32(enumerator.value(jj)))); + put((str = v4->newString(QString::fromUtf8(enumerator.key(jj)))), (v = QV4::Primitive::fromInt32(enumerator.value(jj)))); } } - put((str = v4->newString("Asynchronous")), (v = QV4::Primitive::fromInt32(0))); - put((str = v4->newString("Synchronous")), (v = QV4::Primitive::fromInt32(1))); + put((str = v4->newString(QStringLiteral("Asynchronous"))), (v = QV4::Primitive::fromInt32(0))); + put((str = v4->newString(QStringLiteral("Synchronous"))), (v = QV4::Primitive::fromInt32(1))); defineDefaultProperty(QStringLiteral("include"), QV4Include::method_include); defineDefaultProperty(QStringLiteral("isQtObject"), method_isQtObject); @@ -962,16 +962,16 @@ ReturnedValue QtObject::method_createQmlObject(SimpleCallContext *ctx) const QQmlError &error = errors.at(ii); errorstr += QLatin1String("\n ") + error.toString(); qmlerror = v4->newObject(); - qmlerror->put((s = v4->newString("lineNumber")), (v = QV4::Primitive::fromInt32(error.line()))); - qmlerror->put((s = v4->newString("columnNumber")), (v = QV4::Primitive::fromInt32(error.column()))); - qmlerror->put((s = v4->newString("fileName")), (v = v4->newString(error.url().toString()))); - qmlerror->put((s = v4->newString("message")), (v = v4->newString(error.description()))); + qmlerror->put((s = v4->newString(QStringLiteral("lineNumber"))), (v = QV4::Primitive::fromInt32(error.line()))); + qmlerror->put((s = v4->newString(QStringLiteral("columnNumber"))), (v = QV4::Primitive::fromInt32(error.column()))); + qmlerror->put((s = v4->newString(QStringLiteral("fileName"))), (v = v4->newString(error.url().toString()))); + qmlerror->put((s = v4->newString(QStringLiteral("message"))), (v = v4->newString(error.description()))); qmlerrors->putIndexed(ii, qmlerror); } v = v4->newString(errorstr); Scoped<Object> errorObject(scope, v4->newErrorObject(v)); - errorObject->put((s = v4->newString("qmlErrors")), qmlerrors); + errorObject->put((s = v4->newString(QStringLiteral("qmlErrors"))), qmlerrors); return errorObject.asReturnedValue(); } }; @@ -1358,7 +1358,7 @@ static QString jsStack(QV4::ExecutionEngine *engine) { QString::number(frame.line)); if (i) - stack += QChar('\n'); + stack += QLatin1Char('\n'); stack += stackFrame; } return stack; diff --git a/src/qml/qml/v8/qv8engine.cpp b/src/qml/qml/v8/qv8engine.cpp index 4e8738b826..14fd74701f 100644 --- a/src/qml/qml/v8/qv8engine.cpp +++ b/src/qml/qml/v8/qv8engine.cpp @@ -141,7 +141,7 @@ QVariant QV8Engine::toVariant(const QV4::ValueRef value, int typeHint) return QVariant::fromValue(QV4::JsonObject::toJsonObject(object)); } else if (QV4::QObjectWrapper *wrapper = object->as<QV4::QObjectWrapper>()) { return qVariantFromValue<QObject *>(wrapper->object()); - } else if (QV4::QmlContextWrapper *wrapper = object->as<QV4::QmlContextWrapper>()) { + } else if (object->as<QV4::QmlContextWrapper>()) { return QVariant(); } else if (QV4::QmlTypeWrapper *w = object->as<QV4::QmlTypeWrapper>()) { return w->toVariant(); |