From 800ad68e4f000e65b0a83ef1da2a29d595964156 Mon Sep 17 00:00:00 2001 From: Martin Petersson Date: Tue, 26 Apr 2011 12:03:17 +0200 Subject: Fix compile warning on Windows Reviewed-by: Prasanth Ullattil --- src/corelib/io/qfilesystemengine_win.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/corelib/io/qfilesystemengine_win.cpp b/src/corelib/io/qfilesystemengine_win.cpp index 82c6eba..1dbc40f 100644 --- a/src/corelib/io/qfilesystemengine_win.cpp +++ b/src/corelib/io/qfilesystemengine_win.cpp @@ -583,6 +583,7 @@ QString QFileSystemEngine::owner(const QFileSystemEntry &entry, QAbstractFileEng } } #else + Q_UNUSED(entry); Q_UNUSED(own); #endif return name; -- cgit v0.12 From 2506b86828ca8140c2f22d85a4378df40899b132 Mon Sep 17 00:00:00 2001 From: Martin Petersson Date: Wed, 27 Apr 2011 12:36:53 +0200 Subject: QNetworkConfigurationManager: Fix network polling. startPolling() is called by each engine, so before it would start multiple singleshot timers. So I moved the timer to the class and check if it has already been started before it is activated again. So that we just use one timer. Task-number: QTBUG-17219 Reviewed-by: Iiro Kause Reviewed-by: Kranthi Kuntala --- src/network/bearer/qnetworkconfigmanager_p.cpp | 14 ++++++++++++-- src/network/bearer/qnetworkconfigmanager_p.h | 2 ++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/network/bearer/qnetworkconfigmanager_p.cpp b/src/network/bearer/qnetworkconfigmanager_p.cpp index c108ad3..e9b6703 100644 --- a/src/network/bearer/qnetworkconfigmanager_p.cpp +++ b/src/network/bearer/qnetworkconfigmanager_p.cpp @@ -60,7 +60,7 @@ Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader, #endif QNetworkConfigurationManagerPrivate::QNetworkConfigurationManagerPrivate() - : QObject(), mutex(QMutex::Recursive), forcedPolling(0), firstUpdate(true) + : QObject(), pollTimer(0), mutex(QMutex::Recursive), forcedPolling(0), firstUpdate(true) { qRegisterMetaType("QNetworkConfiguration"); qRegisterMetaType("QNetworkConfigurationPrivatePointer"); @@ -442,9 +442,19 @@ void QNetworkConfigurationManagerPrivate::startPolling() { QMutexLocker locker(&mutex); + if(!pollTimer) { + pollTimer = new QTimer(this); + pollTimer->setInterval(10000); + pollTimer->setSingleShot(true); + connect(pollTimer, SIGNAL(timeout()), this, SLOT(pollEngines())); + } + + if(pollTimer->isActive()) + return; + foreach (QBearerEngine *engine, sessionEngines) { if (engine->requiresPolling() && (forcedPolling || engine->configurationsInUse())) { - QTimer::singleShot(10000, this, SLOT(pollEngines())); + pollTimer->start(); break; } } diff --git a/src/network/bearer/qnetworkconfigmanager_p.h b/src/network/bearer/qnetworkconfigmanager_p.h index 81f38c5..abc4b9b 100644 --- a/src/network/bearer/qnetworkconfigmanager_p.h +++ b/src/network/bearer/qnetworkconfigmanager_p.h @@ -64,6 +64,7 @@ QT_BEGIN_NAMESPACE class QBearerEngine; +class QTimer; class Q_NETWORK_EXPORT QNetworkConfigurationManagerPrivate : public QObject { @@ -107,6 +108,7 @@ private Q_SLOTS: private: void startPolling(); + QTimer *pollTimer; private: mutable QMutex mutex; -- cgit v0.12 From 8f95a19d330480bd86650c3d2e4e147d3bca5789 Mon Sep 17 00:00:00 2001 From: Jens Georg Date: Wed, 13 Apr 2011 10:14:43 +0200 Subject: Fix QDateTime::toString for Qt::ISODate Fixes QTBUG-18290 and the "missing Z" from QTBUG-9698 Merge-request: 1149 Reviewed-by: Zeno Albisser --- src/corelib/tools/qdatetime.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/corelib/tools/qdatetime.cpp b/src/corelib/tools/qdatetime.cpp index a3a8884..ff868c0 100644 --- a/src/corelib/tools/qdatetime.cpp +++ b/src/corelib/tools/qdatetime.cpp @@ -2497,6 +2497,21 @@ QString QDateTime::toString(Qt::DateFormat f) const return QString(); // failed to convert buf += QLatin1Char('T'); buf += d->time.toString(Qt::ISODate); + switch (d->spec) { + case QDateTimePrivate::UTC: + buf += QLatin1Char('Z'); + break; + case QDateTimePrivate::OffsetFromUTC: { + int sign = d->utcOffset >= 0 ? 1: -1; + buf += QString::fromLatin1("%1%2:%3"). + arg(sign == 1 ? QLatin1Char('+') : QLatin1Char('-')). + arg(d->utcOffset * sign / SECS_PER_HOUR, 2, 10, QLatin1Char('0')). + arg((d->utcOffset / 60) % 60, 2, 10, QLatin1Char('0')); + break; + } + default: + break; + } } #ifndef QT_NO_TEXTDATE else if (f == Qt::TextDate) { -- cgit v0.12 From 3d4149afe62b4fc5d519a2a155b8f8c32e7e95c4 Mon Sep 17 00:00:00 2001 From: Jens Georg Date: Wed, 13 Apr 2011 10:14:44 +0200 Subject: Update documentation of QDateTime::toString Merge-request: 1149 Reviewed-by: Zeno Albisser --- src/corelib/tools/qdatetime.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/corelib/tools/qdatetime.cpp b/src/corelib/tools/qdatetime.cpp index ff868c0..d9a054a 100644 --- a/src/corelib/tools/qdatetime.cpp +++ b/src/corelib/tools/qdatetime.cpp @@ -2460,7 +2460,11 @@ void QDateTime::setTime_t(uint secsSince1Jan1970UTC) If the \a format is Qt::ISODate, the string format corresponds to the ISO 8601 extended specification for representations of - dates and times, taking the form YYYY-MM-DDTHH:MM:SS. + dates and times, taking the form YYYY-MM-DDTHH:MM:SS[Z|[+|-]HH:MM], + depending on the timeSpec() of the QDateTime. If the timeSpec() + is Qt::UTC, Z will be appended to the string; if the timeSpec() is + Qt::OffsetFromUTC the offset in hours and minutes from UTC will + be appended to the string. If the \a format is Qt::SystemLocaleShortDate or Qt::SystemLocaleLongDate, the string format depends on the locale -- cgit v0.12 From d9e0c2ea4d64b8fdfb31b28e71373735be38101b Mon Sep 17 00:00:00 2001 From: Jens Georg Date: Wed, 13 Apr 2011 10:14:46 +0200 Subject: Add test for ISODate change in QDateTime::toString Merge-request: 1149 Reviewed-by: Zeno Albisser --- tests/auto/qdatetime/tst_qdatetime.cpp | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/tests/auto/qdatetime/tst_qdatetime.cpp b/tests/auto/qdatetime/tst_qdatetime.cpp index f8836a6..d612911 100644 --- a/tests/auto/qdatetime/tst_qdatetime.cpp +++ b/tests/auto/qdatetime/tst_qdatetime.cpp @@ -85,6 +85,8 @@ private slots: void setTime_t(); void setMSecsSinceEpoch_data(); void setMSecsSinceEpoch(); + void toString_isoDate_data(); + void toString_isoDate(); void toString_enumformat(); void toString_strformat_data(); void toString_strformat(); @@ -506,6 +508,36 @@ void tst_QDateTime::setMSecsSinceEpoch() QCOMPARE(dt, reference.addMSecs(msecs)); } +void tst_QDateTime::toString_isoDate_data() +{ + QTest::addColumn("dt"); + QTest::addColumn("formatted"); + + QTest::newRow("localtime") + << QDateTime(QDate(1978, 11, 9), QTime(13, 28, 34)) + << QString("1978-11-09T13:28:34"); + QTest::newRow("UTC") + << QDateTime(QDate(1978, 11, 9), QTime(13, 28, 34), Qt::UTC) + << QString("1978-11-09T13:28:34Z"); + QDateTime dt(QDate(1978, 11, 9), QTime(13, 28, 34)); + dt.setUtcOffset(19800); + QTest::newRow("positive OffsetFromUTC") + << dt + << QString("1978-11-09T13:28:34+05:30"); + dt.setUtcOffset(-7200); + QTest::newRow("negative OffsetFromUTC") + << dt + << QString("1978-11-09T13:28:34-02:00"); +} + +void tst_QDateTime::toString_isoDate() +{ + QFETCH(QDateTime, dt); + QFETCH(QString, formatted); + + QCOMPARE(dt.toString(Qt::ISODate), formatted); +} + void tst_QDateTime::toString_enumformat() { QDateTime dt1(QDate(1995, 5, 20), QTime(12, 34, 56)); -- cgit v0.12 From ddd253e14318af45e5c56df736028b88257068c4 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Wed, 27 Apr 2011 17:02:35 +0200 Subject: Fixes warnings about unused variables Reviewed-by: Samuel --- src/gui/painting/qdrawhelper_sse2.cpp | 4 ---- src/gui/painting/qpaintbuffer.cpp | 10 ---------- src/gui/painting/qpaintengine_x11.cpp | 3 --- src/gui/painting/qpainterpath.cpp | 1 + src/gui/painting/qstroker.cpp | 1 + 5 files changed, 2 insertions(+), 17 deletions(-) diff --git a/src/gui/painting/qdrawhelper_sse2.cpp b/src/gui/painting/qdrawhelper_sse2.cpp index aad6bc9..efc6a61 100644 --- a/src/gui/painting/qdrawhelper_sse2.cpp +++ b/src/gui/painting/qdrawhelper_sse2.cpp @@ -112,8 +112,6 @@ void qt_blend_rgb32_on_rgb32_sse2(uchar *destPixels, int dbpl, // First, align dest to 16 bytes: ALIGNMENT_PROLOGUE_16BYTES(dst, x, w) { - quint32 s = src[x]; - s = BYTE_MUL(s, const_alpha); dst[x] = INTERPOLATE_PIXEL_255(src[x], const_alpha, dst[x], one_minus_const_alpha); } @@ -127,8 +125,6 @@ void qt_blend_rgb32_on_rgb32_sse2(uchar *destPixels, int dbpl, } } for (; x(ti); - qreal justificationWidth = 0; - if (si.justified) - justificationWidth = si.width.toReal(); - debug << "Cmd_DrawTextItem:" << pos << " " << text; break; } case QPaintBufferPrivate::Cmd_SystemStateChanged: { diff --git a/src/gui/painting/qpaintengine_x11.cpp b/src/gui/painting/qpaintengine_x11.cpp index 94828fb..6ba9a99 100644 --- a/src/gui/painting/qpaintengine_x11.cpp +++ b/src/gui/painting/qpaintengine_x11.cpp @@ -1611,8 +1611,6 @@ void QX11PaintEnginePrivate::fillPolygon_dev(const QPointF *polygonPoints, int p && (fill.style() != Qt::NoBrush) && ((has_fill_texture && fill.texture().hasAlpha()) || antialias || !solid_fill || has_alpha_pen != has_alpha_brush)) { - QRect br = tessellator->tessellate((QPointF *)clippedPoints, clippedCount, - mode == QPaintEngine::WindingMode); if (tessellator->size > 0) { XRenderPictureAttributes attrs; attrs.poly_edge = antialias ? PolyEdgeSmooth : PolyEdgeSharp; @@ -1771,7 +1769,6 @@ void QX11PaintEngine::drawPath(const QPainterPath &path) Q_D(QX11PaintEngine); if (path.isEmpty()) return; - QTransform old_matrix = d->matrix; if (d->has_brush) d->fillPath(path, QX11PaintEnginePrivate::BrushGC, true); diff --git a/src/gui/painting/qpainterpath.cpp b/src/gui/painting/qpainterpath.cpp index 27aed32..9fbac13 100644 --- a/src/gui/painting/qpainterpath.cpp +++ b/src/gui/painting/qpainterpath.cpp @@ -1126,6 +1126,7 @@ void QPainterPath::addText(const QPointF &point, const QFont &f, const QString & QTextEngine *eng = layout.engine(); layout.beginLayout(); QTextLine line = layout.createLine(); + Q_UNUSED(line); layout.endLayout(); const QScriptLine &sl = eng->lines[0]; if (!sl.length || !eng->layoutData) diff --git a/src/gui/painting/qstroker.cpp b/src/gui/painting/qstroker.cpp index fca46b4..dd723ed 100644 --- a/src/gui/painting/qstroker.cpp +++ b/src/gui/painting/qstroker.cpp @@ -552,6 +552,7 @@ void QStroker::joinPoints(qfixed focal_x, qfixed focal_y, const QLineF &nextLine // // line to the beginning of the arc segment, (should not be needed). // emitLineTo(qt_real_to_fixed(curve_start.x()), qt_real_to_fixed(curve_start.y())); + Q_UNUSED(curve_start); for (int i=0; i Date: Wed, 27 Apr 2011 18:29:27 +0200 Subject: Fixes warnings In QString, it would comlain that: assuming signed overflow does not occur when assuming that (X - c) > X is always false Changing to unsigned comparison fix the warning Others are about unused variables Reviewed-by: Thiago --- src/corelib/io/qfilesystemengine_unix.cpp | 1 + src/corelib/tools/qlocale.cpp | 2 -- src/corelib/tools/qstring.h | 4 ++-- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp index c9ebaa4..742b05e 100644 --- a/src/corelib/io/qfilesystemengine_unix.cpp +++ b/src/corelib/io/qfilesystemengine_unix.cpp @@ -356,6 +356,7 @@ bool QFileSystemEngine::fillMetaData(const QFileSystemEntry &entry, QFileSystemM const QByteArray &path = entry.nativeFilePath(); nativeFilePath = path.constData(); nativeFilePathLength = path.size(); + Q_UNUSED(nativeFilePathLength); } bool entryExists = true; // innocent until proven otherwise diff --git a/src/corelib/tools/qlocale.cpp b/src/corelib/tools/qlocale.cpp index 5c4085a..c8ed94b 100644 --- a/src/corelib/tools/qlocale.cpp +++ b/src/corelib/tools/qlocale.cpp @@ -2782,8 +2782,6 @@ bool QLocalePrivate::numberToCLocale(const QString &num, if (idx == l) return false; - const QChar _group = group(); - while (idx < l) { const QChar &in = uc[idx]; diff --git a/src/corelib/tools/qstring.h b/src/corelib/tools/qstring.h index 66cfa74..6418a8c 100644 --- a/src/corelib/tools/qstring.h +++ b/src/corelib/tools/qstring.h @@ -695,9 +695,9 @@ inline QString::QString(const QLatin1String &aLatin1) : d(fromLatin1_helper(aLat inline int QString::length() const { return d->size; } inline const QChar QString::at(int i) const -{ Q_ASSERT(i >= 0 && i < size()); return d->data[i]; } +{ Q_ASSERT(uint(i) < uint(size())); return d->data[i]; } inline const QChar QString::operator[](int i) const -{ Q_ASSERT(i >= 0 && i < size()); return d->data[i]; } +{ Q_ASSERT(uint(i) < uint(size())); return d->data[i]; } inline const QChar QString::operator[](uint i) const { Q_ASSERT(i < uint(size())); return d->data[i]; } inline bool QString::isEmpty() const -- cgit v0.12 From 61c6d66b7efd8de4a83b021e7c4ef2b1a803ece2 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Wed, 27 Apr 2011 18:33:54 +0200 Subject: Fixes warnings about unused variables Reviewed-by: Peter Hartmann --- src/network/access/qhttpnetworkconnection.cpp | 1 - src/network/kernel/qhostinfo.cpp | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/src/network/access/qhttpnetworkconnection.cpp b/src/network/access/qhttpnetworkconnection.cpp index 83156c6..07dd729 100644 --- a/src/network/access/qhttpnetworkconnection.cpp +++ b/src/network/access/qhttpnetworkconnection.cpp @@ -117,7 +117,6 @@ QHttpNetworkConnectionPrivate::~QHttpNetworkConnectionPrivate() void QHttpNetworkConnectionPrivate::init() { - Q_Q(QHttpNetworkConnection); for (int i = 0; i < channelCount; i++) { channels[i].setConnection(this->q_func()); channels[i].ssl = encrypt; diff --git a/src/network/kernel/qhostinfo.cpp b/src/network/kernel/qhostinfo.cpp index a16d4ca..8569817 100644 --- a/src/network/kernel/qhostinfo.cpp +++ b/src/network/kernel/qhostinfo.cpp @@ -290,6 +290,7 @@ QHostInfo QHostInfoPrivate::fromName(const QString &name, QSharedPointer networkSession) { + Q_UNUSED(networkSession); return QHostInfoAgent::fromName(hostName); } #endif -- cgit v0.12 From e8019cf8feb402303e6d253f5ca58bebfda42679 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Wed, 27 Apr 2011 18:35:42 +0200 Subject: Fixes warnings about unused variables Reviewed-by: jbache --- src/gui/styles/qcleanlooksstyle.cpp | 16 ---------------- src/gui/styles/qcommonstyle.cpp | 20 -------------------- src/gui/styles/qgtkpainter.cpp | 5 ----- src/gui/styles/qgtkstyle.cpp | 3 --- src/gui/styles/qplastiquestyle.cpp | 11 ----------- src/gui/styles/qwindowsstyle.cpp | 2 -- src/gui/widgets/qdockarealayout.cpp | 5 ----- src/gui/widgets/qdockwidget.cpp | 1 - src/gui/widgets/qplaintextedit.cpp | 1 + src/gui/widgets/qtextedit.cpp | 1 - src/gui/widgets/qworkspace.cpp | 1 - 11 files changed, 1 insertion(+), 65 deletions(-) diff --git a/src/gui/styles/qcleanlooksstyle.cpp b/src/gui/styles/qcleanlooksstyle.cpp index cc5fe10..786aab3 100644 --- a/src/gui/styles/qcleanlooksstyle.cpp +++ b/src/gui/styles/qcleanlooksstyle.cpp @@ -841,7 +841,6 @@ void QCleanlooksStyle::drawPrimitive(PrimitiveElement elem, case PE_PanelButtonTool: painter->save(); if ((option->state & State_Enabled || option->state & State_On) || !(option->state & State_AutoRaise)) { - QRect rect = option->rect; QPen oldPen = painter->pen(); if (widget && widget->inherits("QDockWidgetTitleButton")) { @@ -1241,7 +1240,6 @@ void QCleanlooksStyle::drawPrimitive(PrimitiveElement elem, if (const QStyleOptionTabWidgetFrame *twf = qstyleoption_cast(option)) { QColor borderColor = darkOutline.lighter(110); QColor alphaCornerColor = mergedColors(borderColor, option->palette.background().color()); - QColor innerShadow = mergedColors(borderColor, option->palette.base().color()); int borderThickness = proxy()->pixelMetric(PM_TabBarBaseOverlap, twf, widget); bool reverse = (twf->direction == Qt::RightToLeft); @@ -1879,7 +1877,6 @@ void QCleanlooksStyle::drawControl(ControlElement element, const QStyleOption *o } else { alphaCornerColor = mergedColors(option->palette.background().color(), borderColor); } - QColor alphaTextColor = mergedColors(option->palette.background().color(), option->palette.text().color()); if (menuItem->menuItemType == QStyleOptionMenuItem::Separator) { painter->fillRect(menuItem->rect, menuBackground); int w = 0; @@ -2220,7 +2217,6 @@ void QCleanlooksStyle::drawControl(ControlElement element, const QStyleOption *o && tabBarAlignment == Qt::AlignLeft); QColor light = tab->palette.light().color(); - QColor midlight = tab->palette.midlight().color(); QColor background = tab->palette.background().color(); int borderThinkness = proxy()->pixelMetric(PM_TabBarBaseOverlap, tab, widget); @@ -2444,14 +2440,6 @@ void QCleanlooksStyle::drawComplexControl(ComplexControl control, const QStyleOp QColor gradientStartColor = option->palette.button().color().lighter(108); QColor gradientStopColor = mergedColors(option->palette.button().color().darker(108), dark.lighter(150), 70); - QColor highlightedGradientStartColor = option->palette.button().color(); - QColor highlightedGradientStopColor = mergedColors(option->palette.button().color(), option->palette.highlight().color(), 85); - - QColor highlightedDarkInnerBorderColor = mergedColors(option->palette.button().color(), option->palette.highlight().color(), 35); - QColor highlightedLightInnerBorderColor = mergedColors(option->palette.button().color(), option->palette.highlight().color(), 58); - - QColor buttonShadowAlpha = option->palette.background().color().darker(105); - QPalette palette = option->palette; switch (control) { @@ -3437,7 +3425,6 @@ void QCleanlooksStyle::drawComplexControl(ComplexControl control, const QStyleOp if (const QStyleOptionSlider *slider = qstyleoption_cast(option)) { QRect groove = proxy()->subControlRect(CC_Slider, option, SC_SliderGroove, widget); QRect handle = proxy()->subControlRect(CC_Slider, option, SC_SliderHandle, widget); - QRect ticks = proxy()->subControlRect(CC_Slider, option, SC_SliderTickmarks, widget); bool horizontal = slider->orientation == Qt::Horizontal; bool ticksAbove = slider->tickPosition & QSlider::TicksAbove; @@ -3539,8 +3526,6 @@ void QCleanlooksStyle::drawComplexControl(ComplexControl control, const QStyleOp QRect pixmapRect(0, 0, handle.width(), handle.height()); QPainter handlePainter(&cache); - QColor highlightedGradientStartColor = option->palette.button().color(); - QColor highlightedGradientStopColor = option->palette.light().color(); QColor gradientStartColor = mergedColors(option->palette.button().color().lighter(155), dark.lighter(155), 50); QColor gradientStopColor = gradientStartColor.darker(108); @@ -3557,7 +3542,6 @@ void QCleanlooksStyle::drawComplexControl(ComplexControl control, const QStyleOp } // gradient fill - QRect innerBorder = gradRect; QRect r = pixmapRect.adjusted(1, 1, -1, -1); qt_cleanlooks_draw_gradient(&handlePainter, gradRect, diff --git a/src/gui/styles/qcommonstyle.cpp b/src/gui/styles/qcommonstyle.cpp index 8f99d6a..7944a0b 100644 --- a/src/gui/styles/qcommonstyle.cpp +++ b/src/gui/styles/qcommonstyle.cpp @@ -901,24 +901,6 @@ QSize QCommonStylePrivate::viewItemSize(const QStyleOptionViewItemV4 *option, in return QSize(0, 0); } -static QSizeF viewItemTextLayout(QTextLayout &textLayout, int lineWidth) -{ - qreal height = 0; - qreal widthUsed = 0; - textLayout.beginLayout(); - while (true) { - QTextLine line = textLayout.createLine(); - if (!line.isValid()) - break; - line.setLineWidth(lineWidth); - line.setPosition(QPointF(0, height)); - height += line.height(); - widthUsed = qMax(widthUsed, line.naturalTextWidth()); - } - textLayout.endLayout(); - return QSizeF(widthUsed, height); -} - void QCommonStylePrivate::viewItemDrawText(QPainter *p, const QStyleOptionViewItemV4 *option, const QRect &rect) const { Q_Q(const QCommonStyle); @@ -936,8 +918,6 @@ void QCommonStylePrivate::viewItemDrawText(QPainter *p, const QStyleOptionViewIt textLayout.setFont(option->font); textLayout.setText(option->text); - QSizeF textLayoutSize = viewItemTextLayout(textLayout, textRect.width()); - QString elidedText; qreal height = 0; qreal width = 0; diff --git a/src/gui/styles/qgtkpainter.cpp b/src/gui/styles/qgtkpainter.cpp index 68ade04..6258fe4 100644 --- a/src/gui/styles/qgtkpainter.cpp +++ b/src/gui/styles/qgtkpainter.cpp @@ -586,7 +586,6 @@ void QGtkPainter::paintShadow(GtkWidget *gtkWidget, const gchar* part, if (!rect.isValid()) return; - QRect r = rect; QPixmap cache; QString pixmapName = uniqueName(QLS(part), state, shadow, rect.size()) % pmKey; if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) { @@ -605,7 +604,6 @@ void QGtkPainter::paintFlatBox(GtkWidget *gtkWidget, const gchar* part, { if (!rect.isValid()) return; - QRect r = rect; QPixmap cache; QString pixmapName = uniqueName(QLS(part), state, shadow, rect.size()) % pmKey; if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) { @@ -632,7 +630,6 @@ void QGtkPainter::paintExtention(GtkWidget *gtkWidget, if (!rect.isValid()) return; - QRect r = rect; QPixmap cache; QString pixmapName = uniqueName(QLS(part), state, shadow, rect.size(), gtkWidget) % HexString(gap_pos); @@ -660,7 +657,6 @@ void QGtkPainter::paintOption(GtkWidget *gtkWidget, const QRect &radiorect, if (!rect.isValid()) return; - QRect r = rect; QPixmap cache; QString pixmapName = uniqueName(detail, state, shadow, rect.size()); GdkRectangle gtkCliprect = {0, 0, rect.width(), rect.height()}; @@ -692,7 +688,6 @@ void QGtkPainter::paintCheckbox(GtkWidget *gtkWidget, const QRect &checkrect, if (!rect.isValid()) return; - QRect r = rect; QPixmap cache; QString pixmapName = uniqueName(detail, state, shadow, rect.size()); GdkRectangle gtkCliprect = {0, 0, rect.width(), rect.height()}; diff --git a/src/gui/styles/qgtkstyle.cpp b/src/gui/styles/qgtkstyle.cpp index 277e302..d6dd527 100644 --- a/src/gui/styles/qgtkstyle.cpp +++ b/src/gui/styles/qgtkstyle.cpp @@ -782,7 +782,6 @@ void QGtkStyle::drawPrimitive(PrimitiveElement element, GtkStateType state = gtkPainter.gtkState(option); style = gtkTreeHeader->style; GtkArrowType type = GTK_ARROW_UP; - QRect r = header->rect; QImage arrow; // This sorting indicator inversion is intentional, and follows the GNOME HIG. // See http://library.gnome.org/devel/hig-book/stable/controls-lists.html.en#controls-lists-sortable @@ -1857,7 +1856,6 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom editArea.setRight(upRect.left()); } if (spinBox->frame) { - GtkShadowType shadow = GTK_SHADOW_OUT; GtkStateType state = gtkPainter.gtkState(option); if (!(option->state & State_Enabled)) @@ -1867,7 +1865,6 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom else if (state == GTK_STATE_PRELIGHT) state = GTK_STATE_NORMAL; - shadow = GTK_SHADOW_IN; style = gtkPainter.getStyle(gtkSpinButton); diff --git a/src/gui/styles/qplastiquestyle.cpp b/src/gui/styles/qplastiquestyle.cpp index 02ce60e..1d33212 100644 --- a/src/gui/styles/qplastiquestyle.cpp +++ b/src/gui/styles/qplastiquestyle.cpp @@ -2007,14 +2007,10 @@ void QPlastiqueStyle::drawControl(ControlElement element, const QStyleOption *op } else { alphaCornerColor = mergedColors(option->palette.background().color(), borderColor); } - QColor alphaTextColor = mergedColors(option->palette.background().color(), option->palette.text().color()); QColor gradientStartColor = option->palette.button().color().lighter(104); QColor gradientStopColor = option->palette.button().color().darker(105); - QColor shadowGradientStartColor = option->palette.button().color().darker(115); - QColor shadowGradientStopColor = option->palette.button().color().darker(120); - QColor highlightedGradientStartColor = option->palette.button().color().lighter(101); QColor highlightedGradientStopColor = mergedColors(option->palette.button().color(), option->palette.highlight().color(), 85); @@ -2025,8 +2021,6 @@ void QPlastiqueStyle::drawControl(ControlElement element, const QStyleOption *op QColor highlightedLightInnerBorderColor = mergedColors(option->palette.button().color(), option->palette.highlight().color(), 58); QColor alphaInnerColor = mergedColors(highlightedDarkInnerBorderColor, option->palette.base().color()); - QColor lightShadow = lightShadowGradientStartColor; - QColor shadow = shadowGradientStartColor; switch (element) { #ifndef QT_NO_TABBAR @@ -3786,10 +3780,6 @@ void QPlastiqueStyle::drawComplexControl(ComplexControl control, const QStyleOpt } QColor gradientStartColor = option->palette.button().color().lighter(104); QColor gradientStopColor = option->palette.button().color().darker(105); - QColor highlightedGradientStartColor = option->palette.button().color().lighter(101); - QColor highlightedGradientStopColor = mergedColors(option->palette.button().color(), option->palette.highlight().color(), 85); - QColor highlightedDarkInnerBorderColor = mergedColors(option->palette.button().color(), option->palette.highlight().color(), 35); - QColor highlightedLightInnerBorderColor = mergedColors(option->palette.button().color(), option->palette.highlight().color(), 58); switch (control) { #ifndef QT_NO_SLIDER @@ -3797,7 +3787,6 @@ void QPlastiqueStyle::drawComplexControl(ComplexControl control, const QStyleOpt if (const QStyleOptionSlider *slider = qstyleoption_cast(option)) { QRect grooveRegion = proxy()->subControlRect(CC_Slider, option, SC_SliderGroove, widget); QRect handle = proxy()->subControlRect(CC_Slider, option, SC_SliderHandle, widget); - QRect ticks = proxy()->subControlRect(CC_Slider, option, SC_SliderTickmarks, widget); bool horizontal = slider->orientation == Qt::Horizontal; bool ticksAbove = slider->tickPosition & QSlider::TicksAbove; bool ticksBelow = slider->tickPosition & QSlider::TicksBelow; diff --git a/src/gui/styles/qwindowsstyle.cpp b/src/gui/styles/qwindowsstyle.cpp index 44f3f92..f61fe67 100644 --- a/src/gui/styles/qwindowsstyle.cpp +++ b/src/gui/styles/qwindowsstyle.cpp @@ -2028,10 +2028,8 @@ void QWindowsStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPai && tabBarAlignment == Qt::AlignLeft); QColor light = tab->palette.light().color(); - QColor midlight = tab->palette.midlight().color(); QColor dark = tab->palette.dark().color(); QColor shadow = tab->palette.shadow().color(); - QColor background = tab->palette.background().color(); int borderThinkness = proxy()->pixelMetric(PM_TabBarBaseOverlap, tab, widget); if (selected) borderThinkness /= 2; diff --git a/src/gui/widgets/qdockarealayout.cpp b/src/gui/widgets/qdockarealayout.cpp index 223421d..28c0388 100644 --- a/src/gui/widgets/qdockarealayout.cpp +++ b/src/gui/widgets/qdockarealayout.cpp @@ -2100,7 +2100,6 @@ bool QDockAreaLayoutInfo::updateTabBar() const bool gap = false; int tab_idx = 0; - bool changed = false; for (int i = 0; i < item_list.count(); ++i) { const QDockAreaLayoutItem &item = item_list.at(i); if (item.skip()) @@ -2121,7 +2120,6 @@ bool QDockAreaLayoutInfo::updateTabBar() const tabBar->setTabToolTip(tab_idx, title); #endif tabBar->setTabData(tab_idx, id); - changed = true; } else if (qvariant_cast(tabBar->tabData(tab_idx)) != id) { if (tab_idx + 1 < tabBar->count() && qvariant_cast(tabBar->tabData(tab_idx + 1)) == id) @@ -2133,7 +2131,6 @@ bool QDockAreaLayoutInfo::updateTabBar() const #endif tabBar->setTabData(tab_idx, id); } - changed = true; } if (title != tabBar->tabText(tab_idx)) { @@ -2141,7 +2138,6 @@ bool QDockAreaLayoutInfo::updateTabBar() const #ifndef QT_NO_TOOLTIP tabBar->setTabToolTip(tab_idx, title); #endif - changed = true; } ++tab_idx; @@ -2149,7 +2145,6 @@ bool QDockAreaLayoutInfo::updateTabBar() const while (tab_idx < tabBar->count()) { tabBar->removeTab(tab_idx); - changed = true; } tabBar->blockSignals(blocked); diff --git a/src/gui/widgets/qdockwidget.cpp b/src/gui/widgets/qdockwidget.cpp index 9d1a737..16b60c8 100644 --- a/src/gui/widgets/qdockwidget.cpp +++ b/src/gui/widgets/qdockwidget.cpp @@ -161,7 +161,6 @@ void QDockWidgetTitleButton::paintEvent(QPaintEvent *) { QPainter p(this); - QRect r = rect(); QStyleOptionToolButton opt; opt.init(this); opt.state |= QStyle::State_AutoRaise; diff --git a/src/gui/widgets/qplaintextedit.cpp b/src/gui/widgets/qplaintextedit.cpp index 7435691..9871ed3 100644 --- a/src/gui/widgets/qplaintextedit.cpp +++ b/src/gui/widgets/qplaintextedit.cpp @@ -483,6 +483,7 @@ int QPlainTextEditPrivate::verticalOffset(int topBlock, int topLine) const QPlainTextDocumentLayout *documentLayout = qobject_cast(doc->documentLayout()); Q_ASSERT(documentLayout); QRectF r = documentLayout->blockBoundingRect(currentBlock); + Q_UNUSED(r); QTextLayout *layout = currentBlock.layout(); if (layout && topLine <= layout->lineCount()) { QTextLine line = layout->lineAt(topLine - 1); diff --git a/src/gui/widgets/qtextedit.cpp b/src/gui/widgets/qtextedit.cpp index ff924bf..8df436f 100644 --- a/src/gui/widgets/qtextedit.cpp +++ b/src/gui/widgets/qtextedit.cpp @@ -2614,7 +2614,6 @@ Qt::TextFormat QTextEdit::textFormat() const void QTextEdit::append(const QString &text) { Q_D(QTextEdit); - QTextBlock lastBlock = d->control->document()->lastBlock(); const bool atBottom = isReadOnly() ? d->verticalOffset() >= d->vbar->maximum() : d->control->textCursor().atEnd(); d->control->append(text); diff --git a/src/gui/widgets/qworkspace.cpp b/src/gui/widgets/qworkspace.cpp index bf50d07..13ef13b 100644 --- a/src/gui/widgets/qworkspace.cpp +++ b/src/gui/widgets/qworkspace.cpp @@ -1239,7 +1239,6 @@ QWidget * QWorkspace::addWindow(QWidget *w, Qt::WindowFlags flags) int x = w->x(); int y = w->y(); bool hasPos = w->testAttribute(Qt::WA_Moved); - QSize s = w->size().expandedTo(qSmartMinSize(w)); if (!hasSize && w->sizeHint().isValid()) w->adjustSize(); -- cgit v0.12 From 28061caa38d94de85db9aec743d1efba33c1e46f Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Wed, 27 Apr 2011 18:37:28 +0200 Subject: Fixes warnings about unused variables Reviewed-by: Samuel --- src/gui/graphicsview/qgraphicsanchorlayout_p.cpp | 4 ++-- src/gui/graphicsview/qgraphicswidget_p.cpp | 4 ---- src/gui/itemviews/qtableview.cpp | 1 - src/gui/kernel/qgesturemanager.cpp | 1 - src/gui/kernel/qwidget_x11.cpp | 4 +--- src/gui/text/qtextdocumentlayout.cpp | 1 + src/gui/text/qtextlayout.cpp | 2 -- src/gui/util/qflickgesture.cpp | 4 ++-- src/gui/util/qscroller.cpp | 3 --- 9 files changed, 6 insertions(+), 18 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp index 48cbec3..78918cc 100644 --- a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp +++ b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp @@ -451,8 +451,8 @@ static QPair getFactor(qreal valu static qreal interpolate(const QPair &factor, qreal min, qreal minPref, qreal pref, qreal maxPref, qreal max) { - qreal lower; - qreal upper; + qreal lower = 0; + qreal upper = 0; switch (factor.first) { case QGraphicsAnchorLayoutPrivate::MinimumToMinPreferred: diff --git a/src/gui/graphicsview/qgraphicswidget_p.cpp b/src/gui/graphicsview/qgraphicswidget_p.cpp index 4580055..63d7298 100644 --- a/src/gui/graphicsview/qgraphicswidget_p.cpp +++ b/src/gui/graphicsview/qgraphicswidget_p.cpp @@ -857,8 +857,6 @@ void QGraphicsWidgetPrivate::setWidth(qreal w) if (q->geometry().width() == w) return; - QRectF oldGeom = q->geometry(); - q->setGeometry(QRectF(q->x(), q->y(), w, height())); } @@ -882,8 +880,6 @@ void QGraphicsWidgetPrivate::setHeight(qreal h) if (q->geometry().height() == h) return; - QRectF oldGeom = q->geometry(); - q->setGeometry(QRectF(q->x(), q->y(), width(), h)); } diff --git a/src/gui/itemviews/qtableview.cpp b/src/gui/itemviews/qtableview.cpp index e494ee5..a5eed1d 100644 --- a/src/gui/itemviews/qtableview.cpp +++ b/src/gui/itemviews/qtableview.cpp @@ -1285,7 +1285,6 @@ void QTableView::paintEvent(QPaintEvent *event) const QPen gridPen = QPen(gridColor, 0, d->gridStyle); const QHeaderView *verticalHeader = d->verticalHeader; const QHeaderView *horizontalHeader = d->horizontalHeader; - const QStyle::State state = option.state; const bool alternate = d->alternatingColors; const bool rightToLeft = isRightToLeft(); diff --git a/src/gui/kernel/qgesturemanager.cpp b/src/gui/kernel/qgesturemanager.cpp index 5359fb3..7aa7dffd 100644 --- a/src/gui/kernel/qgesturemanager.cpp +++ b/src/gui/kernel/qgesturemanager.cpp @@ -566,7 +566,6 @@ void QGestureManager::getGestureTargets(const QSet &gestures, = w->d_func()->gestureContext.find(type); if (it != w->d_func()->gestureContext.end()) { // i.e. 'w' listens to gesture 'type' - Qt::GestureFlags flags = it.value(); if (!(it.value() & Qt::DontStartGestureOnChildren) && w != widget) { // conflicting gesture! (*conflicts)[widget].append(gestures[widget]); diff --git a/src/gui/kernel/qwidget_x11.cpp b/src/gui/kernel/qwidget_x11.cpp index 5ece7d6..241a13f 100644 --- a/src/gui/kernel/qwidget_x11.cpp +++ b/src/gui/kernel/qwidget_x11.cpp @@ -486,8 +486,6 @@ void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyO bool topLevel = (flags & Qt::Window); bool popup = (type == Qt::Popup); - bool dialog = (type == Qt::Dialog - || type == Qt::Sheet); bool desktop = (type == Qt::Desktop); bool tool = (type == Qt::Tool || type == Qt::SplashScreen || type == Qt::ToolTip || type == Qt::Drawer); @@ -553,7 +551,7 @@ void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyO int sh = DisplayHeight(dpy,scr); if (desktop) { // desktop widget - dialog = popup = false; // force these flags off + popup = false; // force these flags off data.crect.setRect(0, 0, sw, sh); } else if (topLevel && !q->testAttribute(Qt::WA_Resized)) { QDesktopWidget *desktopWidget = qApp->desktop(); diff --git a/src/gui/text/qtextdocumentlayout.cpp b/src/gui/text/qtextdocumentlayout.cpp index ce157be..69ea948 100644 --- a/src/gui/text/qtextdocumentlayout.cpp +++ b/src/gui/text/qtextdocumentlayout.cpp @@ -3081,6 +3081,7 @@ void QTextDocumentLayoutPrivate::ensureLayouted(QFixed y) const if (currentLazyLayoutPosition == -1) return; const QSizeF oldSize = q->dynamicDocumentSize(); + Q_UNUSED(oldSize); if (checkPoints.isEmpty()) layoutStep(); diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp index 93f71d3..df4ce97 100644 --- a/src/gui/text/qtextlayout.cpp +++ b/src/gui/text/qtextlayout.cpp @@ -1378,8 +1378,6 @@ void QTextLayout::drawCursor(QPainter *p, const QPointF &pos, int cursorPosition d->itemize(); QPointF position = pos + d->position; - QFixed pos_x = QFixed::fromReal(position.x()); - QFixed pos_y = QFixed::fromReal(position.y()); cursorPosition = qBound(0, cursorPosition, d->layoutData->string.length()); int line = 0; diff --git a/src/gui/util/qflickgesture.cpp b/src/gui/util/qflickgesture.cpp index fdd2a95..f87c84c 100644 --- a/src/gui/util/qflickgesture.cpp +++ b/src/gui/util/qflickgesture.cpp @@ -218,10 +218,10 @@ public: mouseTarget = 0; } else if (mouseTarget) { // we did send a press, so we need to fake a release now - Qt::MouseButtons mouseButtons = QApplication::mouseButtons(); // release all pressed mouse buttons - /*for (int i = 0; i < 32; ++i) { + /* Qt::MouseButtons mouseButtons = QApplication::mouseButtons(); + for (int i = 0; i < 32; ++i) { if (mouseButtons & (1 << i)) { Qt::MouseButton b = static_cast(1 << i); mouseButtons &= ~b; diff --git a/src/gui/util/qscroller.cpp b/src/gui/util/qscroller.cpp index db128c1..870d56f 100644 --- a/src/gui/util/qscroller.cpp +++ b/src/gui/util/qscroller.cpp @@ -1777,10 +1777,7 @@ void QScrollerPrivate::setState(QScroller::State newstate) */ void QScrollerPrivate::setContentPositionHelperDragging(const QPointF &deltaPos) { - Q_Q(QScroller); - QPointF ppm = q->pixelPerMeter(); const QScrollerPropertiesPrivate *sp = properties.d.data(); - QPointF v = q->velocity(); if (sp->overshootDragResistanceFactor) overshootPosition /= sp->overshootDragResistanceFactor; -- cgit v0.12 From 8d4cd52b6981a4e6deea7fdb77f56e40c4f3e6ba Mon Sep 17 00:00:00 2001 From: Martin Petersson Date: Thu, 28 Apr 2011 12:07:07 +0200 Subject: QAbstractSocket: Fix waitForReadyRead infinite loop. Make sure that waitForReadyRead times out if the read buffer is full. Task-number: QTBUG-16123 Reviewed-by: Peter Hartmann --- src/network/socket/qabstractsocket.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/network/socket/qabstractsocket.cpp b/src/network/socket/qabstractsocket.cpp index 7af71cc..cfb1413 100644 --- a/src/network/socket/qabstractsocket.cpp +++ b/src/network/socket/qabstractsocket.cpp @@ -1877,7 +1877,7 @@ bool QAbstractSocket::waitForReadyRead(int msecs) } Q_ASSERT(d->socketEngine); - forever { + do { bool readyToRead = false; bool readyToWrite = false; if (!d->socketEngine->waitForReadOrWrite(&readyToRead, &readyToWrite, true, !d->writeBuffer.isEmpty(), @@ -1904,7 +1904,7 @@ bool QAbstractSocket::waitForReadyRead(int msecs) if (state() != ConnectedState) return false; - } + } while (qt_timeout_value(msecs, stopWatch.elapsed()) > 0); return false; } -- cgit v0.12 From 2fe1f118a791383de68d33a76f72d260f8bda2eb Mon Sep 17 00:00:00 2001 From: Zeno Albisser Date: Thu, 28 Apr 2011 12:50:47 +0200 Subject: fix tst_qscriptengine after merging MR-1149 Reviewed-by: Olivier Goffart --- tests/auto/qscriptengine/tst_qscriptengine.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/auto/qscriptengine/tst_qscriptengine.cpp b/tests/auto/qscriptengine/tst_qscriptengine.cpp index bc4091d..7ba2be2 100644 --- a/tests/auto/qscriptengine/tst_qscriptengine.cpp +++ b/tests/auto/qscriptengine/tst_qscriptengine.cpp @@ -5815,6 +5815,7 @@ void tst_QScriptEngine::dateConversionJSQt() QString qtUTCDateStr = qtDate.toUTC().toString(Qt::ISODate); QString jsUTCDateStr = jsDate.property("toISOString").call(jsDate).toString(); jsUTCDateStr.chop(5); // get rid of milliseconds (".000Z") + jsUTCDateStr.append("Z"); // append the timezone specifier again if (qtUTCDateStr != jsUTCDateStr) QFAIL(qPrintable(jsDate.toString())); secs += 2*60*60; @@ -5829,6 +5830,7 @@ void tst_QScriptEngine::dateConversionQtJS() QScriptValue jsDate = eng.newDate(qtDate); QString jsUTCDateStr = jsDate.property("toISOString").call(jsDate).toString(); jsUTCDateStr.chop(5); // get rid of milliseconds (".000Z") + jsUTCDateStr.append("Z"); // append the timezone specifier again QString qtUTCDateStr = qtDate.toUTC().toString(Qt::ISODate); if (jsUTCDateStr != qtUTCDateStr) QFAIL(qPrintable(qtDate.toString())); -- cgit v0.12 From c85c1ea36cd9ebe6a9ff970d7ba0ce8d08d5b27b Mon Sep 17 00:00:00 2001 From: Peter Hartmann Date: Wed, 27 Apr 2011 11:48:53 +0200 Subject: QNetworkCookie: allow spaces in unquoted values We should follow http://tools.ietf.org/html/draft-ietf-httpstate-cookie-23 , which says parse the value until reaching the next ';' or the end of the line. Other cookie implementations allow spaces in unquoted values as well. Reviewed-by: Martin Petersson Task-number: QTBUG-18876 --- src/network/access/qnetworkcookie.cpp | 9 +++++---- tests/auto/qnetworkcookie/tst_qnetworkcookie.cpp | 8 ++++++++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/network/access/qnetworkcookie.cpp b/src/network/access/qnetworkcookie.cpp index 52eb345..eec8507 100644 --- a/src/network/access/qnetworkcookie.cpp +++ b/src/network/access/qnetworkcookie.cpp @@ -395,8 +395,8 @@ static QPair nextField(const QByteArray &text, int &posi // qdtext = > // quoted-pair = "\" CHAR - // If its NAME=VALUE, retain the value as is - // refer to ttp://bugreports.qt.nokia.com/browse/QTBUG-17746 + // If it is NAME=VALUE, retain the value as is + // refer to http://bugreports.qt.nokia.com/browse/QTBUG-17746 if (isNameValue) second += '"'; ++i; @@ -432,7 +432,9 @@ static QPair nextField(const QByteArray &text, int &posi position = i; for ( ; i < length; ++i) { register char c = text.at(i); - if (c == ',' || c == ';' || isLWS(c)) + // for name value pairs, we want to parse until reaching the next ';' + // and not break when reaching a space char + if (c == ',' || c == ';' || ((isNameValue && (c == '\n' || c == '\r')) || (!isNameValue && isLWS(c)))) break; } @@ -487,7 +489,6 @@ QByteArray QNetworkCookie::toRawForm(RawForm form) const result += '='; if ((d->value.contains(';') || d->value.contains(',') || - d->value.contains(' ') || d->value.contains('"')) && (!d->value.startsWith('"') && !d->value.endsWith('"'))) { diff --git a/tests/auto/qnetworkcookie/tst_qnetworkcookie.cpp b/tests/auto/qnetworkcookie/tst_qnetworkcookie.cpp index e0c477b..9a58482 100644 --- a/tests/auto/qnetworkcookie/tst_qnetworkcookie.cpp +++ b/tests/auto/qnetworkcookie/tst_qnetworkcookie.cpp @@ -182,6 +182,14 @@ void tst_QNetworkCookie::parseSingleCookie_data() cookie.setValue("\"\\\"a, b; c\\\"\""); QTest::newRow("with-value-with-special5") << "a = \"\\\"a, b; c\\\"\"" << cookie; + cookie.setValue("b c"); + QTest::newRow("with-value-with-whitespace") << "a = b c" << cookie; + + cookie.setValue("\"b\""); + QTest::newRow("quoted-value") << "a = \"b\"" << cookie; + cookie.setValue("\"b c\""); + QTest::newRow("quoted-value-with-whitespace") << "a = \"b c\"" << cookie; + cookie.setValue("b"); cookie.setSecure(true); QTest::newRow("secure") << "a=b;secure" << cookie; -- cgit v0.12 From 31ef8fa6abc2ea23c6f0a996b36494d88aafb0b5 Mon Sep 17 00:00:00 2001 From: mae Date: Fri, 29 Apr 2011 11:44:43 +0200 Subject: Reduce open and stat system calls for QSettings The patch moves the global static QSettings object from QLibrary to QCoreApplication and reduces a few stat and open calls. Without the patch, a large Trolltech.conf was pushed out of the unused settings cache during startup, meaning Trolltech.conf was parsed more than once. Reviewed-by: Liang Qi --- src/corelib/io/qsettings.cpp | 29 +++++------------------------ src/corelib/kernel/qcoreapplication.cpp | 12 ++++++++++++ src/corelib/kernel/qcoreapplication_p.h | 2 ++ src/corelib/plugin/qlibrary.cpp | 13 ++----------- src/gui/kernel/qcursor_x11.cpp | 3 +++ 5 files changed, 24 insertions(+), 35 deletions(-) diff --git a/src/corelib/io/qsettings.cpp b/src/corelib/io/qsettings.cpp index b084ca5..f43fb31 100644 --- a/src/corelib/io/qsettings.cpp +++ b/src/corelib/io/qsettings.cpp @@ -981,23 +981,6 @@ QStringList QSettingsPrivate::splitArgs(const QString &s, int idx) // ************************************************************************ // QConfFileSettingsPrivate -/* - If we don't have the permission to read the file, returns false. - If the file doesn't exist, returns true. -*/ -static bool checkAccess(const QString &name) -{ - QFileInfo fileInfo(name); - - if (fileInfo.exists()) { - QFile file(name); - // if the file exists but we can't open it, report an error - return file.open(QFile::ReadOnly); - } else { - return true; - } -} - void QConfFileSettingsPrivate::initFormat() { extension = (format == QSettings::NativeFormat) ? QLatin1String(".conf") : QLatin1String(".ini"); @@ -1026,18 +1009,13 @@ void QConfFileSettingsPrivate::initFormat() void QConfFileSettingsPrivate::initAccess() { - bool readAccess = false; if (confFiles[spec]) { - readAccess = checkAccess(confFiles[spec]->name); if (format > QSettings::IniFormat) { if (!readFunc) - readAccess = false; + setStatus(QSettings::AccessError); } } - if (!readAccess) - setStatus(QSettings::AccessError); - sync(); // loads the files the first time } @@ -1432,7 +1410,7 @@ void QConfFileSettingsPrivate::syncConfFile(int confFileNo) We can often optimize the read-only case, if the file on disk hasn't changed. */ - if (readOnly) { + if (readOnly && confFile->size > 0) { QFileInfo fileInfo(confFile->name); if (confFile->size == fileInfo.size() && confFile->timeStamp == fileInfo.lastModified()) return; @@ -1455,6 +1433,9 @@ void QConfFileSettingsPrivate::syncConfFile(int confFileNo) if (!file.isOpen()) file.open(QFile::ReadOnly); + if (!createFile && !file.isOpen()) + setStatus(QSettings::AccessError); + #ifdef Q_OS_WIN HANDLE readSemaphore = 0; HANDLE writeSemaphore = 0; diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index be86c58..df8bc59 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -270,6 +270,8 @@ bool QCoreApplicationPrivate::is_app_closing = false; Q_CORE_EXPORT bool qt_locale_initialized = false; +QSettings *QCoreApplicationPrivate::trolltechConf = 0; + Q_CORE_EXPORT uint qGlobalPostedEventsCount() { QThreadData *currentThreadData = QThreadData::current(); @@ -371,6 +373,9 @@ QCoreApplicationPrivate::~QCoreApplicationPrivate() threadData->postEventList.recursion = 0; threadData->quitNow = false; } + + delete trolltechConf; + trolltechConf = 0; } void QCoreApplicationPrivate::createEventDispatcher() @@ -688,6 +693,13 @@ void QCoreApplication::init() } #endif + + /* + Create an instance of Trolltech.conf. This ensures that the settings will not + be thrown out of QSetting's cache for unused settings. + */ + d->trolltechConf = new QSettings(QSettings::UserScope, QLatin1String("Trolltech")); + qt_startup_hook(); } diff --git a/src/corelib/kernel/qcoreapplication_p.h b/src/corelib/kernel/qcoreapplication_p.h index add2a35..0557f83 100644 --- a/src/corelib/kernel/qcoreapplication_p.h +++ b/src/corelib/kernel/qcoreapplication_p.h @@ -55,6 +55,7 @@ #include "QtCore/qcoreapplication.h" #include "QtCore/qtranslator.h" +#include "QtCore/qsettings.h" #include "private/qobject_p.h" #ifdef Q_OS_SYMBIAN @@ -139,6 +140,7 @@ public: #if defined(QT3_SUPPORT) static bool useQt3Support; #endif + static QSettings *trolltechConf; }; QT_END_NAMESPACE diff --git a/src/corelib/plugin/qlibrary.cpp b/src/corelib/plugin/qlibrary.cpp index 80e927b..6f3ee1c 100644 --- a/src/corelib/plugin/qlibrary.cpp +++ b/src/corelib/plugin/qlibrary.cpp @@ -52,6 +52,7 @@ #include #include #include +#include #ifdef Q_OS_MAC # include #endif @@ -408,12 +409,6 @@ static bool qt_unix_query(const QString &library, uint *version, bool *debug, QB typedef QMap LibraryMap; struct LibraryData { - LibraryData() : settings(0) { } - ~LibraryData() { - delete settings; - } - - QSettings *settings; LibraryMap libraryMap; QSet loadedLibs; }; @@ -711,11 +706,7 @@ bool QLibraryPrivate::isPlugin(QSettings *settings) QStringList reg; #ifndef QT_NO_SETTINGS if (!settings) { - settings = libraryData()->settings; - if (!settings) { - settings = new QSettings(QSettings::UserScope, QLatin1String("Trolltech")); - libraryData()->settings = settings; - } + settings = QCoreApplicationPrivate::trolltechConf; } reg = settings->value(regkey).toStringList(); #endif diff --git a/src/gui/kernel/qcursor_x11.cpp b/src/gui/kernel/qcursor_x11.cpp index d0ed98e..0bc7250 100644 --- a/src/gui/kernel/qcursor_x11.cpp +++ b/src/gui/kernel/qcursor_x11.cpp @@ -55,6 +55,9 @@ #endif // QT_NO_XCURSOR #ifndef QT_NO_XFIXES +#ifndef Status +#define Status int +#endif # include #endif // QT_NO_XFIXES -- cgit v0.12 From 988871dabf3c949ffc71d126131281a3ae641ebf Mon Sep 17 00:00:00 2001 From: mae Date: Mon, 2 May 2011 11:56:03 +0200 Subject: Fix regression with QSettings patch The plugin loader is used without QCoreApplication. This fixes 31ef8fa6abc2ea23c6f0a996b36494d88aafb0b5 --- src/corelib/kernel/qcoreapplication.cpp | 21 ++++++++++----------- src/corelib/kernel/qcoreapplication_p.h | 2 +- src/corelib/plugin/qlibrary.cpp | 2 +- 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index df8bc59..e569894 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -270,7 +270,16 @@ bool QCoreApplicationPrivate::is_app_closing = false; Q_CORE_EXPORT bool qt_locale_initialized = false; -QSettings *QCoreApplicationPrivate::trolltechConf = 0; +/* + Create an instance of Trolltech.conf. This ensures that the settings will not + be thrown out of QSetting's cache for unused settings. + */ +Q_GLOBAL_STATIC_WITH_ARGS(QSettings, trolltechConf, (QSettings::UserScope, QLatin1String("Trolltech"))) + +QSettings *QCoreApplicationPrivate::trolltechConf() +{ + return ::trolltechConf(); +} Q_CORE_EXPORT uint qGlobalPostedEventsCount() { @@ -373,9 +382,6 @@ QCoreApplicationPrivate::~QCoreApplicationPrivate() threadData->postEventList.recursion = 0; threadData->quitNow = false; } - - delete trolltechConf; - trolltechConf = 0; } void QCoreApplicationPrivate::createEventDispatcher() @@ -693,13 +699,6 @@ void QCoreApplication::init() } #endif - - /* - Create an instance of Trolltech.conf. This ensures that the settings will not - be thrown out of QSetting's cache for unused settings. - */ - d->trolltechConf = new QSettings(QSettings::UserScope, QLatin1String("Trolltech")); - qt_startup_hook(); } diff --git a/src/corelib/kernel/qcoreapplication_p.h b/src/corelib/kernel/qcoreapplication_p.h index 0557f83..eb46ae5 100644 --- a/src/corelib/kernel/qcoreapplication_p.h +++ b/src/corelib/kernel/qcoreapplication_p.h @@ -140,7 +140,7 @@ public: #if defined(QT3_SUPPORT) static bool useQt3Support; #endif - static QSettings *trolltechConf; + static QSettings *trolltechConf(); }; QT_END_NAMESPACE diff --git a/src/corelib/plugin/qlibrary.cpp b/src/corelib/plugin/qlibrary.cpp index 6f3ee1c..d9aac00 100644 --- a/src/corelib/plugin/qlibrary.cpp +++ b/src/corelib/plugin/qlibrary.cpp @@ -706,7 +706,7 @@ bool QLibraryPrivate::isPlugin(QSettings *settings) QStringList reg; #ifndef QT_NO_SETTINGS if (!settings) { - settings = QCoreApplicationPrivate::trolltechConf; + settings = QCoreApplicationPrivate::trolltechConf(); } reg = settings->value(regkey).toStringList(); #endif -- cgit v0.12 From c99be6bf73dce10fc706764b72a8dacc1c6589a0 Mon Sep 17 00:00:00 2001 From: mae Date: Mon, 2 May 2011 12:45:43 +0200 Subject: Fix namespace issue with the global static --- src/corelib/kernel/qcoreapplication.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index e569894..c0b1748 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -274,11 +274,11 @@ Q_CORE_EXPORT bool qt_locale_initialized = false; Create an instance of Trolltech.conf. This ensures that the settings will not be thrown out of QSetting's cache for unused settings. */ -Q_GLOBAL_STATIC_WITH_ARGS(QSettings, trolltechConf, (QSettings::UserScope, QLatin1String("Trolltech"))) +Q_GLOBAL_STATIC_WITH_ARGS(QSettings, staticTrolltechConf, (QSettings::UserScope, QLatin1String("Trolltech"))) QSettings *QCoreApplicationPrivate::trolltechConf() { - return ::trolltechConf(); + return staticTrolltechConf(); } Q_CORE_EXPORT uint qGlobalPostedEventsCount() -- cgit v0.12 From 0ba0c374fe055623381e3795daa6743c5c995bbc Mon Sep 17 00:00:00 2001 From: Liang Qi Date: Tue, 19 Apr 2011 07:47:33 +0200 Subject: Rewrite the interfaces of QtConcurrent. At least make RVCT 2.2 work. Task-number: QTBUG-5182 Task-number: QTBUG-9070 Reviewed-by: Olivier Goffart Reviewed-by: joao --- src/corelib/concurrent/qtconcurrentfilter.h | 554 ++---------------- .../concurrent/qtconcurrentfunctionwrappers.h | 137 +++++ src/corelib/concurrent/qtconcurrentmap.h | 636 +++------------------ 3 files changed, 270 insertions(+), 1057 deletions(-) diff --git a/src/corelib/concurrent/qtconcurrentfilter.h b/src/corelib/concurrent/qtconcurrentfilter.h index e392212..63dcc4b 100644 --- a/src/corelib/concurrent/qtconcurrentfilter.h +++ b/src/corelib/concurrent/qtconcurrentfilter.h @@ -115,19 +115,7 @@ ThreadEngineStarter filterInternal(Sequence &sequence, KeepFunctor keep, T template QFuture filter(Sequence &sequence, KeepFunctor keep) { - return filterInternal(sequence, keep, &Sequence::push_back); -} - -template -QFuture filter(Sequence &sequence, bool (keep)(T)) -{ - return filterInternal(sequence, FunctionWrapper1(keep), &Sequence::push_back); -} - -template -QFuture filter(Sequence &sequence, bool (C::*keep)() const) -{ - return filterInternal(sequence, ConstMemberFunctionWrapper(keep), &Sequence::push_back); + return filterInternal(sequence, QtPrivate::createFunctionWrapper(keep), &Sequence::push_back); } // filteredReduced() on sequences @@ -137,103 +125,20 @@ QFuture filteredReduced(const Sequence &sequence, ReduceFunctor reduce, ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce)) { - return startFilteredReduced(sequence, keep, reduce, options); - } - -template -QFuture filteredReduced(const Sequence &sequence, - bool (filter)(T), - ReduceFunctor reduce, - ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce)) -{ - return filteredReduced(sequence, - FunctionWrapper1(filter), - reduce, - options); + return startFilteredReduced(sequence, QtPrivate::createFunctionWrapper(keep), QtPrivate::createFunctionWrapper(reduce), options); } -template -QFuture filteredReduced(const Sequence &sequence, - bool (C::*filter)() const, +template +QFuture::ResultType> filteredReduced(const Sequence &sequence, + KeepFunctor keep, ReduceFunctor reduce, ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce)) { - return filteredReduced(sequence, - ConstMemberFunctionWrapper(filter), - reduce, - options); -} - -template -QFuture filteredReduced(const Sequence &sequence, - KeepFunctor keep, - T (reduce)(U &, V), - ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce)) -{ - return filteredReduced(sequence, - keep, - FunctionWrapper2(reduce), - options); -} - -template -QFuture filteredReduced(const Sequence &sequence, - KeepFunctor keep, - T (C::*reduce)(U), - ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce)) -{ - return filteredReduced(sequence, - keep, - MemberFunctionWrapper1(reduce), - options); -} - -template -QFuture filteredReduced(const Sequence &sequence, - bool (keep)(T), - U (reduce)(V &, W), - ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce)) -{ - return filteredReduced(sequence, - FunctionWrapper1(keep), - FunctionWrapper2(reduce), - options); -} - -template -QFuture filteredReduced(const Sequence &sequence, - bool (C::*keep)() const, - T (reduce)(U &, V), - ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce)) -{ - return filteredReduced(sequence, - ConstMemberFunctionWrapper(keep), - FunctionWrapper2(reduce), - options); -} - -template -QFuture filteredReduced(const Sequence &sequence, - bool (keep)(T), - U (C::*reduce)(V), - ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce)) -{ - return filteredReduced(sequence, - FunctionWrapper1(keep), - MemberFunctionWrapper1(reduce), - options); -} - -template -QFuture filteredReduced(const Sequence &sequence, - bool (C::*keep)() const, - T (D::*reduce)(U), - ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce)) -{ - return filteredReduced(sequence, - ConstMemberFunctionWrapper(keep), - MemberFunctionWrapper1(reduce), - options); + return startFilteredReduced::ResultType> + (sequence, + QtPrivate::createFunctionWrapper(keep), + QtPrivate::createFunctionWrapper(reduce), + options); } // filteredReduced() on iterators @@ -244,184 +149,42 @@ QFuture filteredReduced(Iterator begin, ReduceFunctor reduce, ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce)) { - return startFilteredReduced(begin, end, keep, reduce, options); -} - -template -QFuture filteredReduced(Iterator begin, - Iterator end, - bool (filter)(T), - ReduceFunctor reduce, - ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce)) -{ - return filteredReduced(begin, - end, - FunctionWrapper1(filter), - reduce, - options); + return startFilteredReduced(begin, end, QtPrivate::createFunctionWrapper(keep), QtPrivate::createFunctionWrapper(reduce), options); } -template -QFuture filteredReduced(Iterator begin, +template +QFuture::ResultType> filteredReduced(Iterator begin, Iterator end, - bool (C::*filter)() const, + KeepFunctor keep, ReduceFunctor reduce, ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce)) { - return filteredReduced(begin, - end, - ConstMemberFunctionWrapper(filter), - reduce, - options); -} - -template -QFuture filteredReduced(Iterator begin, - Iterator end, - KeepFunctor keep, - T (reduce)(U &, V), - ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce)) -{ - return filteredReduced(begin, - end, - keep, - FunctionWrapper2(reduce), - options); -} - -template -QFuture filteredReduced(Iterator begin, - Iterator end, - KeepFunctor keep, - T (C::*reduce)(U), - ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce)) -{ - return filteredReduced(begin, - end, - keep, - MemberFunctionWrapper1(reduce), - options); -} - -template -QFuture filteredReduced(Iterator begin, - Iterator end, - bool (keep)(T), - U (reduce)(V &, W), - ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce)) -{ - return filteredReduced(begin, - end, - FunctionWrapper1(keep), - FunctionWrapper2(reduce), - options); -} - -template -QFuture filteredReduced(Iterator begin, - Iterator end, - bool (C::*keep)() const, - T (reduce)(U &, V), - ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce)) -{ - return filteredReduced(begin, - end, - ConstMemberFunctionWrapper(keep), - FunctionWrapper2(reduce), - options); -} - -template -QFuture filteredReduced(Iterator begin, - Iterator end, - bool (keep)(T), - U (C::*reduce)(V), - ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce)) -{ - return filteredReduced(begin, - end, - FunctionWrapper1(keep), - MemberFunctionWrapper1(reduce), - options); + return startFilteredReduced::ResultType> + (begin, end, + QtPrivate::createFunctionWrapper(keep), + QtPrivate::createFunctionWrapper(reduce), + options); } -template -QFuture filteredReduced(Iterator begin, - Iterator end, - bool (C::*keep)() const, - T (D::*reduce)(U), - ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce)) -{ - return filteredReduced(begin, - end, - ConstMemberFunctionWrapper(keep), - MemberFunctionWrapper1(reduce), - options); -} - - // filtered() on sequences template QFuture filtered(const Sequence &sequence, KeepFunctor keep) { - return startFiltered(sequence, keep); -} - -template -QFuture filtered(const Sequence &sequence, bool (keep)(T)) -{ - return startFiltered(sequence, FunctionWrapper1(keep)); -} - -template -QFuture filtered(const Sequence &sequence, bool (C::*keep)() const) -{ - return startFiltered(sequence, ConstMemberFunctionWrapper(keep)); + return startFiltered(sequence, QtPrivate::createFunctionWrapper(keep)); } // filtered() on iterators template QFuture::value_type> filtered(Iterator begin, Iterator end, KeepFunctor keep) { - return startFiltered(begin, end, keep); + return startFiltered(begin, end, QtPrivate::createFunctionWrapper(keep)); } -template -QFuture::value_type> filtered(Iterator begin, Iterator end, bool (keep)(T)) -{ - return startFiltered(begin, end, FunctionWrapper1(keep)); -} - -template -QFuture::value_type> filtered(Iterator begin, - Iterator end, - bool (C::*keep)() const) -{ - return startFiltered(begin, end, ConstMemberFunctionWrapper(keep)); -} - - // blocking filter() on sequences template void blockingFilter(Sequence &sequence, KeepFunctor keep) { - filterInternal(sequence, keep, &Sequence::push_back).startBlocking(); -} - -template -void blockingFilter(Sequence &sequence, bool (keep)(T)) -{ - filterInternal(sequence, FunctionWrapper1(keep), &Sequence::push_back) - .startBlocking(); -} - -template -void blockingFilter(Sequence &sequence, bool (C::*keep)() const) -{ - filterInternal(sequence, - ConstMemberFunctionWrapper(keep), - &Sequence::push_back) - .startBlocking(); + filterInternal(sequence, QtPrivate::createFunctionWrapper(keep), &Sequence::push_back).startBlocking(); } // blocking filteredReduced() on sequences @@ -431,111 +194,20 @@ ResultType blockingFilteredReduced(const Sequence &sequence, ReduceFunctor reduce, ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce)) { - return startFilteredReduced(sequence, keep, reduce, options) + return startFilteredReduced(sequence, QtPrivate::createFunctionWrapper(keep), QtPrivate::createFunctionWrapper(reduce), options) .startBlocking(); } -template -ResultType blockingFilteredReduced(const Sequence &sequence, - bool (filter)(T), - ReduceFunctor reduce, - ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce)) -{ - return blockingFilteredReduced - (sequence, - FunctionWrapper1(filter), - reduce, - options); -} - -template -ResultType blockingFilteredReduced(const Sequence &sequence, - bool (C::*filter)() const, +template +typename QtPrivate::ReduceResultType::ResultType blockingFilteredReduced(const Sequence &sequence, + KeepFunctor keep, ReduceFunctor reduce, ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce)) { - return blockingFilteredReduced - (sequence, - ConstMemberFunctionWrapper(filter), - reduce, - options); -} - -template -U blockingFilteredReduced(const Sequence &sequence, - KeepFunctor keep, - T (reduce)(U &, V), - ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce)) -{ - return blockingFilteredReduced - (sequence, - keep, - FunctionWrapper2(reduce), - options); -} - -template -C blockingFilteredReduced(const Sequence &sequence, - KeepFunctor keep, - T (C::*reduce)(U), - ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce)) -{ - return blockingFilteredReduced + return blockingFilteredReduced::ResultType> (sequence, - keep, - MemberFunctionWrapper1(reduce), - options); -} - -template -V blockingFilteredReduced(const Sequence &sequence, - bool (keep)(T), - U (reduce)(V &, W), - ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce)) -{ - return blockingFilteredReduced - (sequence, - FunctionWrapper1(keep), - FunctionWrapper2(reduce), - options); -} - -template -U blockingFilteredReduced(const Sequence &sequence, - bool (C::*keep)() const, - T (reduce)(U &, V), - ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce)) -{ - return blockingFilteredReduced - (sequence, - ConstMemberFunctionWrapper(keep), - FunctionWrapper2(reduce), - options); -} - -template -C blockingFilteredReduced(const Sequence &sequence, - bool (keep)(T), - U (C::*reduce)(V), - ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce)) -{ - return blockingFilteredReduced - (sequence, - FunctionWrapper1(keep), - MemberFunctionWrapper1(reduce), - options); -} - -template -D blockingFilteredReduced(const Sequence &sequence, - bool (C::*keep)() const, - T (D::*reduce)(U), - ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce)) -{ - return blockingFilteredReduced - (sequence, - ConstMemberFunctionWrapper(keep), - MemberFunctionWrapper1(reduce), + QtPrivate::createFunctionWrapper(keep), + QtPrivate::createFunctionWrapper(reduce), options); } @@ -547,150 +219,34 @@ ResultType blockingFilteredReduced(Iterator begin, ReduceFunctor reduce, ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce)) { - return startFilteredReduced(begin, end, keep, reduce, options) + return startFilteredReduced + (begin, end, + QtPrivate::createFunctionWrapper(keep), + QtPrivate::createFunctionWrapper(reduce), + options) .startBlocking(); } -template -ResultType blockingFilteredReduced(Iterator begin, - Iterator end, - bool (filter)(T), - ReduceFunctor reduce, - ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce)) -{ - return blockingFilteredReduced - (begin, - end, - FunctionWrapper1(filter), - reduce, - options); -} - -template -ResultType blockingFilteredReduced(Iterator begin, +template +typename QtPrivate::ReduceResultType::ResultType blockingFilteredReduced(Iterator begin, Iterator end, - bool (C::*filter)() const, + KeepFunctor keep, ReduceFunctor reduce, ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce)) { - return blockingFilteredReduced - (begin, - end, - ConstMemberFunctionWrapper(filter), - reduce, - options); -} - -template -U blockingFilteredReduced(Iterator begin, - Iterator end, - KeepFunctor keep, - T (reduce)(U &, V), - ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce)) -{ - return blockingFilteredReduced - (begin, - end, - keep, - FunctionWrapper2(reduce), - options); -} - -template -C blockingFilteredReduced(Iterator begin, - Iterator end, - KeepFunctor keep, - T (C::*reduce)(U), - ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce)) -{ - return blockingFilteredReduced - (begin, - end, - keep, - MemberFunctionWrapper1(reduce), - options); -} - -template -V blockingFilteredReduced(Iterator begin, - Iterator end, - bool (keep)(T), - U (reduce)(V &, W), - ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce)) -{ - return blockingFilteredReduced - (begin, - end, - FunctionWrapper1(keep), - FunctionWrapper2(reduce), - options); -} - -template -U blockingFilteredReduced(Iterator begin, - Iterator end, - bool (C::*keep)() const, - T (reduce)(U &, V), - ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce)) -{ - return blockingFilteredReduced - (begin, - end, - ConstMemberFunctionWrapper(keep), - FunctionWrapper2(reduce), - options); -} - -template -C blockingFilteredReduced(Iterator begin, - Iterator end, - bool (keep)(T), - U (C::*reduce)(V), - ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce)) -{ - return blockingFilteredReduced - (begin, - end, - FunctionWrapper1(keep), - MemberFunctionWrapper1(reduce), - options); -} - -template -D blockingFilteredReduced(Iterator begin, - Iterator end, - bool (C::*keep)() const, - T (D::*reduce)(U), - ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce)) -{ - return blockingFilteredReduced - (begin, - end, - ConstMemberFunctionWrapper(keep), - MemberFunctionWrapper1(reduce), - options); + return startFilteredReduced::ResultType> + (begin, end, + QtPrivate::createFunctionWrapper(keep), + QtPrivate::createFunctionWrapper(reduce), + options) + .startBlocking(); } // blocking filtered() on sequences template Sequence blockingFiltered(const Sequence &sequence, KeepFunctor keep) { - return blockingFilteredReduced(sequence, keep, &Sequence::push_back, OrderedReduce); -} - -template -Sequence blockingFiltered(const Sequence &sequence, bool (keep)(T)) -{ - return blockingFilteredReduced(sequence, keep, &Sequence::push_back, OrderedReduce); -} - -template -Sequence blockingFiltered(const Sequence &sequence, bool (C::*filter)() const) -{ - return blockingFilteredReduced(sequence, - filter, - &Sequence::push_back, - OrderedReduce); + return blockingFilteredReduced(sequence, QtPrivate::createFunctionWrapper(keep), &Sequence::push_back, OrderedReduce); } // blocking filtered() on iterators @@ -699,27 +255,7 @@ OutputSequence blockingFiltered(Iterator begin, Iterator end, KeepFunctor keep) { return blockingFilteredReduced(begin, end, - keep, - &OutputSequence::push_back, - OrderedReduce); -} - -template -OutputSequence blockingFiltered(Iterator begin, Iterator end, bool (keep)(T)) -{ - return blockingFilteredReduced(begin, - end, - keep, - &OutputSequence::push_back, - OrderedReduce); -} - -template -OutputSequence blockingFiltered(Iterator begin, Iterator end, bool (C::*filter)() const) -{ - return blockingFilteredReduced(begin, - end, - filter, + QtPrivate::createFunctionWrapper(keep), &OutputSequence::push_back, OrderedReduce); } diff --git a/src/corelib/concurrent/qtconcurrentfunctionwrappers.h b/src/corelib/concurrent/qtconcurrentfunctionwrappers.h index f31f7d2..1c19164 100644 --- a/src/corelib/concurrent/qtconcurrentfunctionwrappers.h +++ b/src/corelib/concurrent/qtconcurrentfunctionwrappers.h @@ -163,6 +163,143 @@ private: } // namespace QtConcurrent. +namespace QtPrivate { + +template +const T& createFunctionWrapper(const T& t) +{ + return t; +} + +template +QtConcurrent::FunctionWrapper1 createFunctionWrapper(T (*func)(U)) +{ + return QtConcurrent::FunctionWrapper1(func); +} + +template +QtConcurrent::MemberFunctionWrapper createFunctionWrapper(T (C::*func)()) +{ + return QtConcurrent::MemberFunctionWrapper(func); +} + +template +QtConcurrent::MemberFunctionWrapper1 createFunctionWrapper(T (C::*func)(U)) +{ + return QtConcurrent::MemberFunctionWrapper1(func); +} + +template +QtConcurrent::ConstMemberFunctionWrapper createFunctionWrapper(T (C::*func)() const) +{ + return QtConcurrent::ConstMemberFunctionWrapper(func); +} + +template +struct ReduceResultType; + +template +struct ReduceResultType +{ + typedef U ResultType; +}; + +template +struct ReduceResultType +{ + typedef C ResultType; +}; + +template +struct MapResultType +{ + typedef typename MapFunctor::result_type ResultType; +}; + +template +struct MapResultType +{ + typedef U ResultType; +}; + +template +struct MapResultType +{ + typedef T ResultType; +}; + +#ifndef QT_NO_TEMPLATE_TEMPLATE_PARAMETERS + +template