From: Friedemann Kleint Date: Tue, 18 Oct 2011 09:00:02 +0000 (+0200) Subject: Declarative: Fix MSVC and g++ warnings X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=5ddcd47dbdab9710a547244d29fe038bde3d8c98;p=konrad%2Fqtdeclarative.git Declarative: Fix MSVC and g++ warnings Potentially severe: - Fix int/bool mismatches - Use of uninitialized variable - Do connectionMask shift operations in 64bit - Enum type mismatch for QLineControl::EchoMode Various: - class/struct mismatches - UnhandledEnumeration values - Unused variables - Constructor initialization order Change-Id: Ieb52f8990445fe95f94070175a0f9beb66863240 Reviewed-by: Martin Jones --- diff --git a/src/declarative/items/context2d/qsgcontext2dcommandbuffer.cpp b/src/declarative/items/context2d/qsgcontext2dcommandbuffer.cpp index 9dff4e8..29ed5fb 100644 --- a/src/declarative/items/context2d/qsgcontext2dcommandbuffer.cpp +++ b/src/declarative/items/context2d/qsgcontext2dcommandbuffer.cpp @@ -340,7 +340,6 @@ QSGContext2D::State QSGContext2DCommandBuffer::replay(QPainter* p, QSGContext2D: break; case QSGContext2D::Fill: { - bool hasPattern = p->brush().style() == Qt::TexturePattern; QPainterPath path = takePath(); path.closeSubpath(); if (HAS_SHADOW(state.shadowOffsetX, state.shadowOffsetY, state.shadowBlur, state.shadowColor)) diff --git a/src/declarative/items/context2d/qsgcontext2dtexture.cpp b/src/declarative/items/context2d/qsgcontext2dtexture.cpp index a57a5e5..721f847 100644 --- a/src/declarative/items/context2d/qsgcontext2dtexture.cpp +++ b/src/declarative/items/context2d/qsgcontext2dtexture.cpp @@ -182,8 +182,8 @@ void QSGContext2DTexture::canvasChanged(const QSize& canvasSize, const QSize& ti if (ts.height() > canvasSize.height()) ts.setHeight(canvasSize.height()); - bool canvasChanged = setCanvasSize(canvasSize); - bool tileChanged = setTileSize(ts); + setCanvasSize(canvasSize); + setTileSize(ts); if (canvasSize == canvasWindow.size()) { m_tiledCanvas = false; diff --git a/src/declarative/items/qsgspriteengine.cpp b/src/declarative/items/qsgspriteengine.cpp index 2ef36df..a376a06 100644 --- a/src/declarative/items/qsgspriteengine.cpp +++ b/src/declarative/items/qsgspriteengine.cpp @@ -226,7 +226,6 @@ QImage QSGSpriteEngine::assembledImage() if (!state->m_frameWidth) state->m_frameWidth = img.width() / state->frames(); - int imgHeight = state->frameHeight(); if (!state->m_frameHeight) state->m_frameHeight = img.height(); @@ -446,7 +445,7 @@ int QSGStochasticEngine::goalSeek(int curIdx, int spriteIdx, int dist) return *(options.begin()); int option = -1; qreal r =(qreal) qrand() / (qreal) RAND_MAX; - qreal total; + qreal total = 0; for (QSet::const_iterator iter=options.constBegin(); iter!=options.constEnd(); iter++) total += curState->m_to.value(m_states[(*iter)]->name()).toReal(); diff --git a/src/declarative/items/qsgspriteengine_p.h b/src/declarative/items/qsgspriteengine_p.h index 30a041a..8140b38 100644 --- a/src/declarative/items/qsgspriteengine_p.h +++ b/src/declarative/items/qsgspriteengine_p.h @@ -277,7 +277,7 @@ public: int spriteStart(int sprite=0); int spriteFrames(int sprite=0); int spriteDuration(int sprite=0); - int spriteX(int sprite=0) { return 0; }//Currently all rows are 0 aligned, if we get more space efficient we might change this + int spriteX(int /* sprite */ = 0) { return 0; }//Currently all rows are 0 aligned, if we get more space efficient we might change this int spriteY(int sprite=0); int spriteWidth(int sprite=0); int spriteHeight(int sprite=0); diff --git a/src/declarative/items/qsgtextinput.cpp b/src/declarative/items/qsgtextinput.cpp index 1c6bccb..6d0fa47 100644 --- a/src/declarative/items/qsgtextinput.cpp +++ b/src/declarative/items/qsgtextinput.cpp @@ -1359,10 +1359,12 @@ QVariant QSGTextInput::inputMethodQuery(Qt::InputMethodQuery property) const case Qt::ImCursorPosition: return QVariant(d->control->cursor()); case Qt::ImSurroundingText: - if (d->control->echoMode() == QLineControl::PasswordEchoOnEdit && !d->control->passwordEchoEditing()) + if (d->control->echoMode() == QLineControl::PasswordEchoOnEdit + && !d->control->passwordEchoEditing()) { return QVariant(displayText()); - else + } else { return QVariant(text()); + } case Qt::ImCurrentSelection: return QVariant(selectedText()); case Qt::ImMaximumTextLength: diff --git a/src/declarative/particles/qsgparticlesystem.cpp b/src/declarative/particles/qsgparticlesystem.cpp index 1d44988..1b01081 100644 --- a/src/declarative/particles/qsgparticlesystem.cpp +++ b/src/declarative/particles/qsgparticlesystem.cpp @@ -388,11 +388,11 @@ QSGParticleData::QSGParticleData(QSGParticleSystem* sys) , system(sys) , index(0) , systemIndex(-1) - , v8Datum(0) , colorOwner(0) , rotationOwner(0) , deformationOwner(0) , animationOwner(0) + , v8Datum(0) { x = 0; y = 0; @@ -617,8 +617,13 @@ void QSGParticleData::extendLife(float time) } QSGParticleSystem::QSGParticleSystem(QSGItem *parent) : - QSGItem(parent), particleCount(0), m_running(true), m_paused(false) - , m_nextIndex(0), m_componentComplete(false), stateEngine(0) + QSGItem(parent), + stateEngine(0), + m_running(true), + particleCount(0), + m_nextIndex(0), + m_componentComplete(false), + m_paused(false) { connect(&m_painterMapper, SIGNAL(mapped(QObject*)), this, SLOT(loadPainter(QObject*))); diff --git a/src/declarative/particles/qsgspritegoal.cpp b/src/declarative/particles/qsgspritegoal.cpp index 12d985f..260929f 100644 --- a/src/declarative/particles/qsgspritegoal.cpp +++ b/src/declarative/particles/qsgspritegoal.cpp @@ -80,7 +80,12 @@ QT_BEGIN_NAMESPACE */ QSGSpriteGoalAffector::QSGSpriteGoalAffector(QSGItem *parent) : - QSGParticleAffector(parent), m_goalIdx(-1), m_jump(false), m_systemStates(false), m_lastEngine(0), m_notUsingEngine(false) + QSGParticleAffector(parent), + m_goalIdx(-1), + m_lastEngine(0), + m_jump(false), + m_systemStates(false), + m_notUsingEngine(false) { } diff --git a/src/declarative/qml/qdeclarativedata_p.h b/src/declarative/qml/qdeclarativedata_p.h index 3229c5e..1bebee5 100644 --- a/src/declarative/qml/qdeclarativedata_p.h +++ b/src/declarative/qml/qdeclarativedata_p.h @@ -187,7 +187,7 @@ QDeclarativeNotifierEndpoint *QDeclarativeData::notify(int index) { Q_ASSERT(index <= 0xFFFF); - if (!notifyList || !(notifyList->connectionMask & (1 << (index % 64)))) { + if (!notifyList || !(notifyList->connectionMask & (1 << (quint64(index) % 64)))) { return 0; } else if (index < notifyList->notifiesSize) { return notifyList->notifies[index]; diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp index 33fd8b3..3f12431 100644 --- a/src/declarative/qml/qdeclarativeengine.cpp +++ b/src/declarative/qml/qdeclarativeengine.cpp @@ -1111,7 +1111,7 @@ void QDeclarativeData::addNotify(int index, QDeclarativeNotifierEndpoint *endpoi Q_ASSERT(!endpoint->isConnected()); index = qMin(index, 0xFFFF - 1); - notifyList->connectionMask |= (1 << (index % 64)); + notifyList->connectionMask |= (1 << (quint64(index) % 64)); if (index < notifyList->notifiesSize) { diff --git a/src/declarative/qml/qdeclarativeextensioninterface.h b/src/declarative/qml/qdeclarativeextensioninterface.h index 3d2b3c6..5b621e4 100644 --- a/src/declarative/qml/qdeclarativeextensioninterface.h +++ b/src/declarative/qml/qdeclarativeextensioninterface.h @@ -52,14 +52,16 @@ QT_MODULE(Declarative) class QDeclarativeEngine; -struct Q_DECLARATIVE_EXPORT QDeclarativeTypesExtensionInterface +class Q_DECLARATIVE_EXPORT QDeclarativeTypesExtensionInterface { +public: virtual ~QDeclarativeTypesExtensionInterface() {} virtual void registerTypes(const char *uri) = 0; }; -struct Q_DECLARATIVE_EXPORT QDeclarativeExtensionInterface : public QDeclarativeTypesExtensionInterface +class Q_DECLARATIVE_EXPORT QDeclarativeExtensionInterface : public QDeclarativeTypesExtensionInterface { +public: virtual ~QDeclarativeExtensionInterface() {} virtual void initializeEngine(QDeclarativeEngine *engine, const char *uri) = 0; }; diff --git a/src/declarative/qml/qdeclarativepropertycache.cpp b/src/declarative/qml/qdeclarativepropertycache.cpp index cf2022c..134c588 100644 --- a/src/declarative/qml/qdeclarativepropertycache.cpp +++ b/src/declarative/qml/qdeclarativepropertycache.cpp @@ -338,8 +338,12 @@ void QDeclarativePropertyCache::append(QDeclarativeEngine *engine, const QMetaOb // Extract method name const char *signature = m.signature(); const char *cptr = signature; - bool utf8 = false; - while (*cptr != '(') { Q_ASSERT(*cptr != 0); utf8 |= *cptr & 0x80; ++cptr; } + char utf8 = 0; + while (*cptr != '(') { + Q_ASSERT(*cptr != 0); + utf8 |= *cptr & 0x80; + ++cptr; + } Data *data = &methodIndexCache[ii - methodIndexCacheStart]; Data *sigdata = 0; @@ -417,9 +421,12 @@ void QDeclarativePropertyCache::append(QDeclarativeEngine *engine, const QMetaOb continue; const char *str = p.name(); - bool utf8 = false; + char utf8 = 0; const char *cptr = str; - while (*cptr != 0) { utf8 |= *cptr & 0x80; ++cptr; } + while (*cptr != 0) { + utf8 |= *cptr & 0x80; + ++cptr; + } Data *data = &propertyIndexCache[ii - propertyIndexCacheStart]; diff --git a/src/declarative/qml/v4/qv4bindings_p.h b/src/declarative/qml/v4/qv4bindings_p.h index 8d68863..603d05d 100644 --- a/src/declarative/qml/v4/qv4bindings_p.h +++ b/src/declarative/qml/v4/qv4bindings_p.h @@ -101,8 +101,9 @@ private: QV4Bindings *parent; }; - struct Subscription : public QDeclarativeNotifierEndpoint + class Subscription : public QDeclarativeNotifierEndpoint { + public: Subscription() : bindings(0), method(-1) { callback = &subscriptionCallback; } static void subscriptionCallback(QDeclarativeNotifierEndpoint *e); QV4Bindings *bindings; diff --git a/src/declarative/qml/v8/qv8engine.cpp b/src/declarative/qml/v8/qv8engine.cpp index e135ec9..7879b7c 100644 --- a/src/declarative/qml/v8/qv8engine.cpp +++ b/src/declarative/qml/v8/qv8engine.cpp @@ -203,6 +203,11 @@ QVariant QV8Engine::toVariant(v8::Handle value, int typeHint) QV8ObjectResource *r = (QV8ObjectResource *)value->ToObject()->GetExternalResource(); if (r) { switch (r->resourceType()) { + case QV8ObjectResource::Context2DStyleType: + case QV8ObjectResource::Context2DPixelArrayType: + case QV8ObjectResource::SignalHandlerType: + case QV8ObjectResource::IncubatorType: + case QV8ObjectResource::VisualDataItemType: case QV8ObjectResource::ContextType: case QV8ObjectResource::XMLHttpRequestType: case QV8ObjectResource::DOMNodeType: diff --git a/src/declarative/qml/v8/qv8variantwrapper.cpp b/src/declarative/qml/v8/qv8variantwrapper.cpp index fbf0832..671e4d3 100644 --- a/src/declarative/qml/v8/qv8variantwrapper.cpp +++ b/src/declarative/qml/v8/qv8variantwrapper.cpp @@ -167,14 +167,14 @@ QVariant &QV8VariantWrapper::variantValue(v8::Handle value) } v8::Handle QV8VariantWrapper::Getter(v8::Local /* property */, - const v8::AccessorInfo &info) + const v8::AccessorInfo & /* info */) { return v8::Handle(); } v8::Handle QV8VariantWrapper::Setter(v8::Local /* property */, v8::Local value, - const v8::AccessorInfo &info) + const v8::AccessorInfo & /* info */) { return value; } diff --git a/src/declarative/scenegraph/coreapi/qsgnodeupdater.cpp b/src/declarative/scenegraph/coreapi/qsgnodeupdater.cpp index 88d7e5a..7bf03fd 100644 --- a/src/declarative/scenegraph/coreapi/qsgnodeupdater.cpp +++ b/src/declarative/scenegraph/coreapi/qsgnodeupdater.cpp @@ -192,6 +192,8 @@ void QSGNodeUpdater::leaveGeometryNode(QSGGeometryNode *g) { #ifdef QSG_UPDATER_DEBUG qDebug() << "leave geometry" << g; +#else + Q_UNUSED(g) #endif } diff --git a/src/declarative/scenegraph/util/qsgvertexcolormaterial.cpp b/src/declarative/scenegraph/util/qsgvertexcolormaterial.cpp index 5f62703..78cef55 100644 --- a/src/declarative/scenegraph/util/qsgvertexcolormaterial.cpp +++ b/src/declarative/scenegraph/util/qsgvertexcolormaterial.cpp @@ -145,7 +145,7 @@ QSGVertexColorMaterial::QSGVertexColorMaterial() \internal */ -int QSGVertexColorMaterial::compare(const QSGMaterial *other) const +int QSGVertexColorMaterial::compare(const QSGMaterial * /* other */) const { return 0; } diff --git a/src/qtquick1/graphicsitems/qdeclarativetextinput.cpp b/src/qtquick1/graphicsitems/qdeclarativetextinput.cpp index 3a36e6b..009c72a 100644 --- a/src/qtquick1/graphicsitems/qdeclarativetextinput.cpp +++ b/src/qtquick1/graphicsitems/qdeclarativetextinput.cpp @@ -1392,7 +1392,8 @@ QVariant QDeclarative1TextInput::inputMethodQuery(Qt::InputMethodQuery property) case Qt::ImCursorPosition: return QVariant(d->control->cursor()); case Qt::ImSurroundingText: - if (d->control->echoMode() == PasswordEchoOnEdit && !d->control->passwordEchoEditing()) + if (d->control->echoMode() == QLineControl::PasswordEchoOnEdit + && !d->control->passwordEchoEditing()) return QVariant(displayText()); else return QVariant(text());