Declarative: Fix MSVC and g++ warnings
authorFriedemann Kleint <Friedemann.Kleint@nokia.com>
Tue, 18 Oct 2011 09:00:02 +0000 (11:00 +0200)
committerQt by Nokia <qt-info@nokia.com>
Wed, 19 Oct 2011 08:31:31 +0000 (10:31 +0200)
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 <martin.jones@nokia.com>
17 files changed:
src/declarative/items/context2d/qsgcontext2dcommandbuffer.cpp
src/declarative/items/context2d/qsgcontext2dtexture.cpp
src/declarative/items/qsgspriteengine.cpp
src/declarative/items/qsgspriteengine_p.h
src/declarative/items/qsgtextinput.cpp
src/declarative/particles/qsgparticlesystem.cpp
src/declarative/particles/qsgspritegoal.cpp
src/declarative/qml/qdeclarativedata_p.h
src/declarative/qml/qdeclarativeengine.cpp
src/declarative/qml/qdeclarativeextensioninterface.h
src/declarative/qml/qdeclarativepropertycache.cpp
src/declarative/qml/v4/qv4bindings_p.h
src/declarative/qml/v8/qv8engine.cpp
src/declarative/qml/v8/qv8variantwrapper.cpp
src/declarative/scenegraph/coreapi/qsgnodeupdater.cpp
src/declarative/scenegraph/util/qsgvertexcolormaterial.cpp
src/qtquick1/graphicsitems/qdeclarativetextinput.cpp

index 9dff4e8..29ed5fb 100644 (file)
@@ -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))
index a57a5e5..721f847 100644 (file)
@@ -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;
index 2ef36df..a376a06 100644 (file)
@@ -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<int>::const_iterator iter=options.constBegin();
                 iter!=options.constEnd(); iter++)
                 total += curState->m_to.value(m_states[(*iter)]->name()).toReal();
index 30a041a..8140b38 100644 (file)
@@ -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);
index 1c6bccb..6d0fa47 100644 (file)
@@ -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:
index 1d44988..1b01081 100644 (file)
@@ -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*)));
index 12d985f..260929f 100644 (file)
@@ -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)
 {
 }
 
index 3229c5e..1bebee5 100644 (file)
@@ -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];
index 33fd8b3..3f12431 100644 (file)
@@ -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) {
 
index 3d2b3c6..5b621e4 100644 (file)
@@ -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;
 };
index cf2022c..134c588 100644 (file)
@@ -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];
 
index 8d68863..603d05d 100644 (file)
@@ -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;
index e135ec9..7879b7c 100644 (file)
@@ -203,6 +203,11 @@ QVariant QV8Engine::toVariant(v8::Handle<v8::Value> 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:
index fbf0832..671e4d3 100644 (file)
@@ -167,14 +167,14 @@ QVariant &QV8VariantWrapper::variantValue(v8::Handle<v8::Value> value)
 }
 
 v8::Handle<v8::Value> QV8VariantWrapper::Getter(v8::Local<v8::String> /* property */,
-                                                const v8::AccessorInfo &info)
+                                                const v8::AccessorInfo & /* info */)
 {
     return v8::Handle<v8::Value>();
 }
 
 v8::Handle<v8::Value> QV8VariantWrapper::Setter(v8::Local<v8::String> /* property */,
                                                 v8::Local<v8::Value> value,
-                                                const v8::AccessorInfo &info)
+                                                const v8::AccessorInfo & /* info */)
 {
     return value;
 }
index 88d7e5a..7bf03fd 100644 (file)
@@ -192,6 +192,8 @@ void QSGNodeUpdater::leaveGeometryNode(QSGGeometryNode *g)
 {
 #ifdef QSG_UPDATER_DEBUG
     qDebug() << "leave geometry" << g;
+#else
+    Q_UNUSED(g)
 #endif
 }
 
index 5f62703..78cef55 100644 (file)
@@ -145,7 +145,7 @@ QSGVertexColorMaterial::QSGVertexColorMaterial()
     \internal
  */
 
-int QSGVertexColorMaterial::compare(const QSGMaterial *other) const
+int QSGVertexColorMaterial::compare(const QSGMaterial * /* other */) const
 {
     return 0;
 }
index 3a36e6b..009c72a 100644 (file)
@@ -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());