qtbase tests: Fix some warnings

- Fix warnings about QAtomicPointer/Int usage
- Fix some gcc 4.6 warnings about assigned/unused variables

Change-Id: Ib4dbf9110f0dad93ad48e97278310f05fad3a82a
Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
This commit is contained in:
Friedemann Kleint 2011-11-17 15:52:53 +01:00 committed by Qt by Nokia
parent ed5583048e
commit e8b4c49efd
28 changed files with 62 additions and 92 deletions

View File

@ -301,14 +301,14 @@ void tst_QAnimationGroup::setParentAutoAdd()
void tst_QAnimationGroup::beginNestedGroup()
{
QAnimationGroup *subGroup;
QAnimationGroup *parent = new QParallelAnimationGroup();
for (int i = 0; i < 10; ++i) {
if (i & 1)
subGroup = new QParallelAnimationGroup(parent);
else
subGroup = new QSequentialAnimationGroup(parent);
if (i & 1) {
new QParallelAnimationGroup(parent);
} else {
new QSequentialAnimationGroup(parent);
}
QCOMPARE(parent->animationCount(), 1);
QAnimationGroup *child = static_cast<QAnimationGroup *>(parent->animationAt(0));

View File

@ -95,7 +95,6 @@ void tst_QFuture::resultStore()
{
ResultStore<int> store;
ResultIteratorBase it = store.begin();
QVERIFY(store.begin() == store.end());
QVERIFY(store.resultAt(0) == store.end());
QVERIFY(store.resultAt(1) == store.end());

View File

@ -233,7 +233,8 @@ public:
bool shouldThrottleThread()
{
return (iterations > 100 && iterations < 200);
const int load = iterations.load();
return (load > 100 && load < 200);
}
bool throttling;
};

View File

@ -1285,6 +1285,7 @@ void tst_QtConcurrentMap::mappedReduced()
// test Q_DECLARE_OPERATORS_FOR_FLAGS
QtConcurrent::ReduceOptions opt = (QtConcurrent::UnorderedReduce | QtConcurrent::SequentialReduce);
QVERIFY(opt);
// functor-functor
{

View File

@ -88,7 +88,6 @@ void tst_QtConcurrentResultStore::iterators()
{
{
ResultStore<int> store;
ResultIteratorBase it = store.begin();
QVERIFY(store.begin() == store.end());
QVERIFY(store.resultAt(0) == store.end());
QVERIFY(store.resultAt(1) == store.end());

View File

@ -1023,12 +1023,12 @@ void tst_QMetaObjectBuilder::removeNotifySignal()
{
QMetaObjectBuilder builder;
QMetaMethodBuilder method1 = builder.addSignal("foo(const QString&, int)");
QMetaMethodBuilder method2 = builder.addSignal("bar(QString)");
builder.addSignal("foo(const QString&, int)");
QMetaMethodBuilder method = builder.addSignal("bar(QString)");
// Setup property
QMetaPropertyBuilder prop = builder.addProperty("prop", "const QString &");
prop.setNotifySignal(method2);
prop.setNotifySignal(method);
QVERIFY(prop.hasNotifySignal());
QCOMPARE(prop.notifySignal().index(), 1);

View File

@ -129,10 +129,8 @@ void tst_QSocketNotifier::unexpectedDisconnection()
NATIVESOCKETENGINE readEnd1;
readEnd1.initialize(QAbstractSocket::TcpSocket);
bool b = readEnd1.connectToHost(server.serverAddress(), server.serverPort());
readEnd1.connectToHost(server.serverAddress(), server.serverPort());
QVERIFY(readEnd1.waitForWrite());
// while (!b && readEnd1.state() != QAbstractSocket::ConnectedState)
// b = readEnd1.connectToHost(server.serverAddress(), server.serverPort());
QVERIFY(readEnd1.state() == QAbstractSocket::ConnectedState);
QVERIFY(server.waitForNewConnection());
QTcpSocket *writeEnd1 = server.nextPendingConnection();
@ -140,10 +138,8 @@ void tst_QSocketNotifier::unexpectedDisconnection()
NATIVESOCKETENGINE readEnd2;
readEnd2.initialize(QAbstractSocket::TcpSocket);
b = readEnd2.connectToHost(server.serverAddress(), server.serverPort());
readEnd2.connectToHost(server.serverAddress(), server.serverPort());
QVERIFY(readEnd2.waitForWrite());
// while (!b)
// b = readEnd2.connectToHost(server.serverAddress(), server.serverPort());
QVERIFY(readEnd2.state() == QAbstractSocket::ConnectedState);
QVERIFY(server.waitForNewConnection());
QTcpSocket *writeEnd2 = server.nextPendingConnection();

View File

@ -430,7 +430,6 @@ public:
m_timer.stop();
QTime now = QTime::currentTime();
int elapsed = m_startedTime.elapsed();
if (elapsed < m_interval / 2) {

View File

@ -576,28 +576,28 @@ public:
quint64 i = 0;
while (t.elapsed() < one_minute) {
i++;
uint nb = (i * 9 + lockCount * 13) % threadCount;
uint nb = (i * 9 + lockCount.load() * 13) % threadCount;
QMutexLocker locker(&mutex[nb]);
if (sentinel[nb]) errorCount.ref();
if (sentinel[nb].load()) errorCount.ref();
if (sentinel[nb].fetchAndAddRelaxed(5)) errorCount.ref();
if (!sentinel[nb].testAndSetRelaxed(5, 0)) errorCount.ref();
if (sentinel[nb]) errorCount.ref();
if (sentinel[nb].load()) errorCount.ref();
lockCount.ref();
nb = (nb * 17 + i * 5 + lockCount * 3) % threadCount;
nb = (nb * 17 + i * 5 + lockCount.load() * 3) % threadCount;
if (mutex[nb].tryLock()) {
if (sentinel[nb]) errorCount.ref();
if (sentinel[nb].load()) errorCount.ref();
if (sentinel[nb].fetchAndAddRelaxed(16)) errorCount.ref();
if (!sentinel[nb].testAndSetRelaxed(16, 0)) errorCount.ref();
if (sentinel[nb]) errorCount.ref();
if (sentinel[nb].load()) errorCount.ref();
lockCount.ref();
mutex[nb].unlock();
}
nb = (nb * 15 + i * 47 + lockCount * 31) % threadCount;
nb = (nb * 15 + i * 47 + lockCount.load() * 31) % threadCount;
if (mutex[nb].tryLock(2)) {
if (sentinel[nb]) errorCount.ref();
if (sentinel[nb].load()) errorCount.ref();
if (sentinel[nb].fetchAndAddRelaxed(53)) errorCount.ref();
if (!sentinel[nb].testAndSetRelaxed(53, 0)) errorCount.ref();
if (sentinel[nb]) errorCount.ref();
if (sentinel[nb].load()) errorCount.ref();
lockCount.ref();
mutex[nb].unlock();
}

View File

@ -4541,17 +4541,16 @@ void tst_QString::nanAndInf()
QVERIFY(ok);
QVERIFY(d == -INFINITY);
long l;
l = QString("INF").toLong(&ok);
QString("INF").toLong(&ok);
QVERIFY(!ok);
l = QString("INF").toLong(&ok, 36);
QString("INF").toLong(&ok, 36);
QVERIFY(ok);
l = QString("INF0").toLong(&ok, 36);
QString("INF0").toLong(&ok, 36);
QVERIFY(ok);
l = QString("0INF0").toLong(&ok, 36);
QString("0INF0").toLong(&ok, 36);
QVERIFY(ok);
}

View File

@ -1107,7 +1107,7 @@ class VirtualObject: public QDBusVirtualObject
public:
VirtualObject() :success(true) {}
QString introspect(const QString &path) const
QString introspect(const QString & /* path */) const
{
return QString();
}

View File

@ -211,8 +211,8 @@ tst_QDBusThreading::tst_QDBusThreading()
void tst_QDBusThreading::joinThreads()
{
threadJoin.acquire(threadJoinCount);
threadJoinCount = 0;
threadJoin.acquire(threadJoinCount.load());
threadJoinCount.store(0);
}
bool tst_QDBusThreading::waitForSignal(QObject *obj, const char *signal, int delay)

View File

@ -718,7 +718,7 @@ void tst_QImageReader::sizeBeforeFormat()
{
QImageReader reader(prefix + fileName);
QSize size = reader.size();
reader.size();
formatB = reader.format();
}

View File

@ -891,8 +891,8 @@ void tst_QShortcut::ambiguousItems()
pb1.show(); // Must be show for QShortcutMap::correctSubWindow to trigger
pb2.show();
QShortcut *cut1 = setupShortcut(&pb1, "shortcut1-pb1", TriggerSlot1, "M");
QShortcut *cut2 = setupShortcut(&pb1, "shortcut2-pb2", TriggerSlot2, "M");
setupShortcut(&pb1, "shortcut1-pb1", TriggerSlot1, "M");
setupShortcut(&pb1, "shortcut2-pb2", TriggerSlot2, "M");
currentResult = NoResult;
sendKeyEvents( Qt::Key_M, 'm' );
@ -910,7 +910,6 @@ void tst_QShortcut::ambiguousItems()
QCOMPARE( ambigResult, Slot1Triggered );
clearAllShortcuts();
cut1 = 0; cut2 = 0;
}
@ -933,8 +932,8 @@ void tst_QShortcut::unicodeCompare()
QKeySequence ks1("Ctrl+M"); // Unicode
QKeySequence ks2(Qt::CTRL+Qt::Key_M); // non-Unicode
QShortcut *cut1 = setupShortcut(&pb1, "shortcut1-pb1", TriggerSlot1, ks1);
QShortcut *cut2 = setupShortcut(&pb1, "shortcut2-pb2", TriggerSlot2, ks2);
setupShortcut(&pb1, "shortcut1-pb1", TriggerSlot1, ks1);
setupShortcut(&pb1, "shortcut2-pb2", TriggerSlot2, ks2);
currentResult = NoResult;
sendKeyEvents( Qt::CTRL+Qt::Key_M, 0 );
@ -945,7 +944,6 @@ void tst_QShortcut::unicodeCompare()
QVERIFY( !(ks1 != ks2) );
clearAllShortcuts();
cut1 = 0; cut2 = 0;
}
// ------------------------------------------------------------------

View File

@ -3274,7 +3274,6 @@ void tst_QTextDocumentFragment::html_hrMargins()
cursor.movePosition(QTextCursor::NextBlock);
block = cursor.block();
QTextBlock hr = block;
QVERIFY(qMax(first.blockFormat().bottomMargin(), block.blockFormat().topMargin()) > 0);
cursor.movePosition(QTextCursor::NextBlock);

View File

@ -1188,7 +1188,7 @@ void tst_QTextLayout::capitalization_allUpperCase()
font.setCapitalization(QFont::AllUppercase);
QTextLayout layout("Test", font);
layout.beginLayout();
QTextLine line = layout.createLine();
layout.createLine();
layout.endLayout();
QTextEngine *engine = layout.engine();
@ -1203,7 +1203,7 @@ void tst_QTextLayout::capitalization_allLowerCase()
font.setCapitalization(QFont::AllLowercase);
QTextLayout layout("Test", font);
layout.beginLayout();
QTextLine line = layout.createLine();
layout.createLine();
layout.endLayout();
QTextEngine *engine = layout.engine();
@ -1218,7 +1218,7 @@ void tst_QTextLayout::capitalization_smallCaps()
font.setCapitalization(QFont::SmallCaps);
QTextLayout layout("Test", font);
layout.beginLayout();
QTextLine line = layout.createLine();
layout.createLine();
layout.endLayout();
QTextEngine *engine = layout.engine();
@ -1234,7 +1234,7 @@ void tst_QTextLayout::capitalization_capitalize()
font.setCapitalization(QFont::Capitalize);
QTextLayout layout("hello\tworld", font);
layout.beginLayout();
QTextLine line = layout.createLine();
layout.createLine();
layout.endLayout();
QTextEngine *engine = layout.engine();

View File

@ -2283,11 +2283,10 @@ int CacheFoo::counter = 0;
void tst_Collections::cache()
{
{
CacheFoo* cf;
QCache<int, CacheFoo> cache(120);
int i;
for (i = 0; i < 30; i++) {
cf = cache.object(10);
cache.object(10);
cache.insert(i, new CacheFoo(i), i);
}
@ -3009,6 +3008,7 @@ void instantiateContainer()
constIt = constContainer.end();
container.constEnd();
Q_UNUSED(constIt)
#endif
container.clear();
container.contains(value);
@ -3032,6 +3032,7 @@ void instantiateMutableIterationContainer()
typename ContainerType::iterator it;
it = container.begin();
it = container.end();
Q_UNUSED(it)
#endif
// QSet lacks count(T).

View File

@ -82,7 +82,7 @@ bool v8test_externalteardown()
Persistent<Context> context = Context::New();
Context::Scope context_scope(context);
Local<String> str = String::NewExternal(new MyStringResource);
String::NewExternal(new MyStringResource);
Local<FunctionTemplate> ft = FunctionTemplate::New();
ft->InstanceTemplate()->SetHasExternalResource(true);

View File

@ -517,11 +517,9 @@ void tst_QFiledialog::completer()
if (!fullPath.endsWith(QLatin1Char('/')))
fullPath.append(QLatin1Char('/'));
fullPath.append(input);
bool inputStartsWithRootPath = false;
if (input.startsWith(QDir::rootPath())) {
fullPath = input;
input.clear();
inputStartsWithRootPath = true;
}
QFileInfo fi(fullPath);

View File

@ -522,6 +522,7 @@ void tst_QMessageBox::testSymbols()
button = QMessageBox::Default;
button = QMessageBox::Escape;
button = QMessageBox::FlagMask;
QVERIFY(button);
const QString text = QStringLiteral("Foo");
mb1.setText(text);

View File

@ -578,7 +578,6 @@ void tst_QGraphicsProxyWidget::eventFilter()
break;
}
case QEvent::Resize: {
QSize oldSize = widget->size();
QSize newSize = QSize(100, 100);
if (fromObject) {
widget->resize(newSize);
@ -590,7 +589,6 @@ void tst_QGraphicsProxyWidget::eventFilter()
break;
}
case QEvent::Move: {
QPoint oldPoint = widget->pos();
QPoint newPoint = QPoint(100, 100);
if (fromObject) {
widget->move(newPoint);
@ -2651,26 +2649,25 @@ void tst_QGraphicsProxyWidget::childPos_data()
QTest::addColumn<bool>("moveCombo");
QTest::addColumn<QPoint>("comboPos");
QTest::addColumn<QPointF>("proxyPos");
QTest::addColumn<QPointF>("menuPos");
QTest::newRow("0") << true << QPoint() << QPointF() << QPointF();
QTest::newRow("1") << true << QPoint(10, 0) << QPointF(10, 0) << QPointF();
QTest::newRow("2") << true << QPoint(100, 0) << QPointF(100, 0) << QPointF();
QTest::newRow("3") << true << QPoint(1000, 0) << QPointF(1000, 0) << QPointF();
QTest::newRow("4") << true << QPoint(10000, 0) << QPointF(10000, 0) << QPointF();
QTest::newRow("5") << true << QPoint(-10000, 0) << QPointF(-10000, 0) << QPointF();
QTest::newRow("6") << true << QPoint(-1000, 0) << QPointF(-1000, 0) << QPointF();
QTest::newRow("7") << true << QPoint(-100, 0) << QPointF(-100, 0) << QPointF();
QTest::newRow("8") << true << QPoint(-10, 0) << QPointF(-10, 0) << QPointF();
QTest::newRow("0-") << false << QPoint() << QPointF() << QPointF();
QTest::newRow("1-") << false << QPoint(10, 0) << QPointF(10, 0) << QPointF();
QTest::newRow("2-") << false << QPoint(100, 0) << QPointF(100, 0) << QPointF();
QTest::newRow("3-") << false << QPoint(1000, 0) << QPointF(1000, 0) << QPointF();
QTest::newRow("4-") << false << QPoint(10000, 0) << QPointF(10000, 0) << QPointF();
QTest::newRow("5-") << false << QPoint(-10000, 0) << QPointF(-10000, 0) << QPointF();
QTest::newRow("6-") << false << QPoint(-1000, 0) << QPointF(-1000, 0) << QPointF();
QTest::newRow("7-") << false << QPoint(-100, 0) << QPointF(-100, 0) << QPointF();
QTest::newRow("8-") << false << QPoint(-10, 0) << QPointF(-10, 0) << QPointF();
QTest::newRow("0") << true << QPoint() << QPointF();
QTest::newRow("1") << true << QPoint(10, 0) << QPointF(10, 0);
QTest::newRow("2") << true << QPoint(100, 0) << QPointF(100, 0);
QTest::newRow("3") << true << QPoint(1000, 0) << QPointF(1000, 0);
QTest::newRow("4") << true << QPoint(10000, 0) << QPointF(10000, 0);
QTest::newRow("5") << true << QPoint(-10000, 0) << QPointF(-10000, 0);
QTest::newRow("6") << true << QPoint(-1000, 0) << QPointF(-1000, 0);
QTest::newRow("7") << true << QPoint(-100, 0) << QPointF(-100, 0);
QTest::newRow("8") << true << QPoint(-10, 0) << QPointF(-10, 0);
QTest::newRow("0-") << false << QPoint() << QPointF();
QTest::newRow("1-") << false << QPoint(10, 0) << QPointF(10, 0);
QTest::newRow("2-") << false << QPoint(100, 0) << QPointF(100, 0);
QTest::newRow("3-") << false << QPoint(1000, 0) << QPointF(1000, 0);
QTest::newRow("4-") << false << QPoint(10000, 0) << QPointF(10000, 0);
QTest::newRow("5-") << false << QPoint(-10000, 0) << QPointF(-10000, 0);
QTest::newRow("6-") << false << QPoint(-1000, 0) << QPointF(-1000, 0);
QTest::newRow("7-") << false << QPoint(-100, 0) << QPointF(-100, 0);
QTest::newRow("8-") << false << QPoint(-10, 0) << QPointF(-10, 0);
}
void tst_QGraphicsProxyWidget::childPos()
@ -2681,7 +2678,6 @@ void tst_QGraphicsProxyWidget::childPos()
QFETCH(bool, moveCombo);
QFETCH(QPoint, comboPos);
QFETCH(QPointF, proxyPos);
QFETCH(QPointF, menuPos);
QGraphicsScene scene;

View File

@ -1369,7 +1369,6 @@ void tst_QGraphicsView::itemsInRect()
view.setSceneRect(-10000, -10000, 20000, 20000);
view.show();
QPoint centerPoint = view.viewport()->rect().center();
QRect leftRect = view.mapFromScene(-30, -10, 20, 20).boundingRect();
QRect rightRect = view.mapFromScene(30, -10, 20, 20).boundingRect();
@ -1490,7 +1489,6 @@ void tst_QGraphicsView::itemsInPoly()
view.setSceneRect(-10000, -10000, 20000, 20000);
view.show();
QPoint centerPoint = view.viewport()->rect().center();
QPolygon leftPoly = view.mapFromScene(QRectF(-30, -10, 20, 20));
QPolygon rightPoly = view.mapFromScene(QRectF(30, -10, 20, 20));
@ -1534,7 +1532,6 @@ void tst_QGraphicsView::itemsInPath()
view.setSceneRect(-10000, -10000, 20000, 20000);
view.show();
QPoint centerPoint = view.viewport()->rect().center();
QPainterPath leftPath;
leftPath.addEllipse(QRect(view.mapFromScene(-30, -10), QSize(20, 20)));
@ -1794,7 +1791,6 @@ void tst_QGraphicsView::mapToScenePath()
view.translate(10, 10);
view.setFixedSize(300, 300);
view.show();
QPoint center = view.viewport()->rect().center();
QRect rect(QPoint(10, 0), QSize(10, 10));
QPainterPath path;

View File

@ -169,7 +169,7 @@ void tst_QStringListModel::rowsAboutToBeRemoved_rowsRemoved_data()
QStringList strings3; strings3 << "One" << "Two" << "Three" << "Four" << "Five";
QStringList aboutto3; aboutto3 << "One" << "Two" << "Three" << "Four" << "Five";
QStringList res3; res3 ;
QStringList res3;
QTest::newRow( "data3" ) << strings3 << 0 << 5 << aboutto3 << res3;
/* Not sure if this is a valid test */

View File

@ -3280,8 +3280,6 @@ void tst_QTreeWidget::taskQTBUG2844_visualItemRect()
tree.setColumnCount(3);
QTreeWidgetItem item(&tree);
QRect itemRect = tree.visualItemRect(&item);
QRect rectCol0 = tree.visualRect(tree.indexFromItem(&item, 0));
QRect rectCol1 = tree.visualRect(tree.indexFromItem(&item, 1));
QRect rectCol2 = tree.visualRect(tree.indexFromItem(&item, 2));

View File

@ -5015,8 +5015,6 @@ void tst_QWidget::moveChild()
parent.setGeometry(60, 60, 150, 150);
#endif
child.setGeometry(25, 25, 50, 50);
QPoint childOffset = child.mapToGlobal(QPoint());
parent.show();
QTest::qWaitForWindowShown(&parent);
QTest::qWait(30);
@ -6970,9 +6968,6 @@ void tst_QWidget::render_worldTransform()
painter.translate(105, 5);
painter.rotate(90);
const QTransform worldTransform = painter.worldTransform();
const QTransform deviceTransform = painter.deviceTransform();
// Render widgets onto image.
widget.render(&painter);
#ifdef RENDER_DEBUG
@ -7100,7 +7095,6 @@ void tst_QWidget::repaintWhenChildDeleted()
w.r = QRegion();
{
const QPoint tlwOffset = w.geometry().topLeft();
ColorWidget child(&w, Qt::blue);
child.setGeometry(10, 10, 10, 10);
child.show();

View File

@ -180,7 +180,6 @@ void tst_QCalendarWidget::buttonClickCheck()
object.setGeometry(0,0,size.width(), size.height());
object.show();
QRect rect = object.geometry();
QDate selectedDate(2005, 1, 1);
//click on the month buttons
int month = object.monthShown();

View File

@ -294,7 +294,6 @@ void tst_QMainWindow::iconSize()
// the default is determined by the style
const int metric = mw.style()->pixelMetric(QStyle::PM_ToolBarIconSize);
const QSize defaultIconSize = QSize(metric, metric);
const QSize smallIconSize = QSize(metric / 2, metric / 2);
const QSize largeIconSize = QSize(metric * 2, metric * 2);

View File

@ -2026,9 +2026,6 @@ void tst_QTextEdit::fullWidthSelection2()
widget.setExtraSelections(selections);
compareWidgetAndImage(widget, "fullWidthSelection/nowrap_long.png");
QTextLine line = widget.document()->begin().layout()->lineAt(0);
// qDebug() << line.width();
}
void tst_QTextEdit::compareWidgetAndImage(QTextEdit &widget, const QString &imageFileName)