diff options
Diffstat (limited to 'src')
47 files changed, 368 insertions, 222 deletions
diff --git a/src/corelib/io/qbuffer.cpp b/src/corelib/io/qbuffer.cpp index 38e406b1a4..35e7b6809c 100644 --- a/src/corelib/io/qbuffer.cpp +++ b/src/corelib/io/qbuffer.cpp @@ -333,23 +333,18 @@ bool QBuffer::open(OpenMode flags) { Q_D(QBuffer); - if ((flags & Append) == Append) + if ((flags & (Append | Truncate)) != 0) flags |= WriteOnly; - setOpenMode(flags); - if (!(isReadable() || isWritable())) { - qWarning("QFile::open: File access not specified"); + if ((flags & (ReadOnly | WriteOnly)) == 0) { + qWarning("QBuffer::open: Buffer access not specified"); return false; } - if ((flags & QIODevice::Truncate) == QIODevice::Truncate) { + if ((flags & Truncate) == Truncate) d->buf->resize(0); - } - if ((flags & QIODevice::Append) == QIODevice::Append) // append to end of buffer - seek(d->buf->size()); - else - seek(0); + d->ioIndex = (flags & Append) == Append ? d->buf->size() : 0; - return true; + return QIODevice::open(flags); } /*! diff --git a/src/corelib/io/qprocess.cpp b/src/corelib/io/qprocess.cpp index a14c4fdc7d..ddbbbd5286 100644 --- a/src/corelib/io/qprocess.cpp +++ b/src/corelib/io/qprocess.cpp @@ -1673,13 +1673,10 @@ QProcessEnvironment QProcess::processEnvironment() const bool QProcess::waitForStarted(int msecs) { Q_D(QProcess); - if (d->processState == QProcess::Starting) { - if (!d->waitForStarted(msecs)) - return false; - setProcessState(QProcess::Running); - emit started(); - } - return d->processState == QProcess::Running; + if (d->processState == QProcess::Running) + return true; + + return d->waitForStarted(msecs); } /*! \reimp diff --git a/src/corelib/tools/qpoint.h b/src/corelib/tools/qpoint.h index c0cf2192c1..b394ece1a6 100644 --- a/src/corelib/tools/qpoint.h +++ b/src/corelib/tools/qpoint.h @@ -92,14 +92,8 @@ public: private: friend class QTransform; - // ### Qt 5; remove the ifdef and just have the same order on all platforms. -#if defined(Q_OS_MAC) - int yp; - int xp; -#else int xp; int yp; -#endif }; Q_DECLARE_TYPEINFO(QPoint, Q_MOVABLE_TYPE); diff --git a/src/dbus/qdbus_symbols_p.h b/src/dbus/qdbus_symbols_p.h index 8b46e6ac89..a59c08a8ab 100644 --- a/src/dbus/qdbus_symbols_p.h +++ b/src/dbus/qdbus_symbols_p.h @@ -301,6 +301,8 @@ DEFINEFUNC(void , dbus_get_version , (int *major_version_p, int *minor_version_p, int *micro_version_p), (major_version_p, minor_version_p, micro_version_p), ) +DEFINEFUNC(char* , dbus_get_local_machine_id , (void), (), return) + /* dbus-pending-call.h */ DEFINEFUNC(dbus_bool_t , dbus_pending_call_set_notify, (DBusPendingCall *pending, diff --git a/src/dbus/qdbusconnection.cpp b/src/dbus/qdbusconnection.cpp index 58c1caa5dc..0b4133c8dd 100644 --- a/src/dbus/qdbusconnection.cpp +++ b/src/dbus/qdbusconnection.cpp @@ -1124,6 +1124,27 @@ void QDBusConnectionPrivate::setBusService(const QDBusConnection &connection) } /*! + \since 4.8 + Returns the local machine ID as known to the D-Bus system. Each + node or host that runs D-Bus has a unique identifier that can be + used to distinguish it from other hosts if they are sharing + resources like the filesystem. + + Note that the local machine ID is not guaranteed to be persistent + across boots of the system, so this identifier should not be + stored in persistent storage (like the filesystem). It is + guaranteed to remain constant only during the lifetime of this + boot session. +*/ +QByteArray QDBusConnection::localMachineId() +{ + char *dbus_machine_id = q_dbus_get_local_machine_id(); + QByteArray result = dbus_machine_id; + q_dbus_free(dbus_machine_id); + return result; +} + +/*! \namespace QDBus \inmodule QtDBus diff --git a/src/dbus/qdbusconnection.h b/src/dbus/qdbusconnection.h index 19418d61a6..4bdd055f52 100644 --- a/src/dbus/qdbusconnection.h +++ b/src/dbus/qdbusconnection.h @@ -176,6 +176,8 @@ public: static void disconnectFromBus(const QString &name); static void disconnectFromPeer(const QString &name); + static QByteArray localMachineId(); + static QDBusConnection sessionBus(); static QDBusConnection systemBus(); diff --git a/src/gui/painting/qcosmeticstroker.cpp b/src/gui/painting/qcosmeticstroker.cpp index 3ee262fcf1..d694b4b9a8 100644 --- a/src/gui/painting/qcosmeticstroker.cpp +++ b/src/gui/painting/qcosmeticstroker.cpp @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + #include "qcosmeticstroker_p.h" #include "private/qpainterpath_p.h" #include <qdebug.h> @@ -99,6 +140,10 @@ static void drawLineAA(QCosmeticStroker *stroker, qreal x1, qreal y1, qreal x2, inline void drawPixel(QCosmeticStroker *stroker, int x, int y, int coverage) { + const QRect &cl = stroker->clip; + if (x < cl.x() || x > cl.right() || y < cl.y() || y > cl.bottom()) + return; + int lastx = stroker->spans[stroker->current_span-1].x + stroker->spans[stroker->current_span-1].len ; int lasty = stroker->spans[stroker->current_span-1].y; diff --git a/src/gui/painting/qcosmeticstroker_p.h b/src/gui/painting/qcosmeticstroker_p.h index 1355a5ad13..0aa71fc9cd 100644 --- a/src/gui/painting/qcosmeticstroker_p.h +++ b/src/gui/painting/qcosmeticstroker_p.h @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + #ifndef QCOSMETICSTROKER_P_H #define QCOSMETICSTROKER_P_H diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp index 62004c965b..e9a3b7a16c 100644 --- a/src/gui/painting/qpaintengine_raster.cpp +++ b/src/gui/painting/qpaintengine_raster.cpp @@ -2002,15 +2002,8 @@ void QRasterPaintEngine::drawPolygon(const QPoint *points, int pointCount, Polyg if (s->penData.blend) { int count = pointCount * 2; QVarLengthArray<qreal> fpoints(count); - #ifdef Q_WS_MAC - for (int i=0; i<count; i+=2) { - fpoints[i] = ((int *) points)[i+1]; - fpoints[i+1] = ((int *) points)[i]; - } - #else for (int i=0; i<count; ++i) fpoints[i] = ((int *) points)[i]; - #endif QVectorPath vp((qreal *) fpoints.data(), pointCount, 0, QVectorPath::polygonFlags(mode)); if (s->flags.fast_pen) { diff --git a/src/gui/painting/qpaintengineex.cpp b/src/gui/painting/qpaintengineex.cpp index 8510416fcb..9427dd5105 100644 --- a/src/gui/painting/qpaintengineex.cpp +++ b/src/gui/painting/qpaintengineex.cpp @@ -789,15 +789,8 @@ void QPaintEngineEx::drawLines(const QLine *lines, int lineCount) qreal pts[64]; int count2 = count<<1; -#ifdef Q_WS_MAC - for (int i=0; i<count2; i+=2) { - pts[i] = ((int *) lines)[i+1]; - pts[i+1] = ((int *) lines)[i]; - } -#else for (int i=0; i<count2; ++i) pts[i] = ((int *) lines)[i]; -#endif QVectorPath path(pts, count, qpaintengineex_line_types_16, QVectorPath::LinesHint); stroke(path, state()->pen); @@ -1084,7 +1077,7 @@ void QPaintEngineEx::drawStaticTextItem(QStaticTextItem *staticTextItem) changedHints = true; } - fill(qtVectorPathForPath(path), staticTextItem->color); + fill(qtVectorPathForPath(path), s->pen.color()); if (changedHints) { s->renderHints = oldHints; diff --git a/src/gui/text/qfont.cpp b/src/gui/text/qfont.cpp index 8b78b52c08..846d5a3814 100644 --- a/src/gui/text/qfont.cpp +++ b/src/gui/text/qfont.cpp @@ -140,6 +140,7 @@ bool QFontDef::exactMatch(const QFontDef &other) const && weight == other.weight && style == other.style && this_family == other_family + && styleName == other.styleName && (this_foundry.isEmpty() || other_foundry.isEmpty() || this_foundry == other_foundry) diff --git a/src/gui/text/qfont_p.h b/src/gui/text/qfont_p.h index 8eeae6ffc1..4ae31c38d6 100644 --- a/src/gui/text/qfont_p.h +++ b/src/gui/text/qfont_p.h @@ -113,6 +113,7 @@ struct QFontDef && styleStrategy == other.styleStrategy && ignorePitch == other.ignorePitch && fixedPitch == other.fixedPitch && family == other.family + && styleName == other.styleName && hintingPreference == other.hintingPreference #ifdef Q_WS_X11 && addStyle == other.addStyle @@ -128,6 +129,8 @@ struct QFontDef if (styleHint != other.styleHint) return styleHint < other.styleHint; if (styleStrategy != other.styleStrategy) return styleStrategy < other.styleStrategy; if (family != other.family) return family < other.family; + if (!styleName.isEmpty() && !other.styleName.isEmpty() && styleName != other.styleName) + return styleName < other.styleName; if (hintingPreference != other.hintingPreference) return hintingPreference < other.hintingPreference; #ifdef Q_WS_X11 diff --git a/src/gui/text/qfontdatabase.cpp b/src/gui/text/qfontdatabase.cpp index ad8c6c9ab5..5369ac52f3 100644 --- a/src/gui/text/qfontdatabase.cpp +++ b/src/gui/text/qfontdatabase.cpp @@ -1123,13 +1123,13 @@ QT_BEGIN_INCLUDE_NAMESPACE #elif defined(Q_OS_SYMBIAN) # include "qfontdatabase_s60.cpp" #endif +QT_END_INCLUDE_NAMESPACE #if !defined(Q_WS_X11) QString QFontDatabase::resolveFontFamilyAlias(const QString &family) { return family; } #endif -QT_END_INCLUDE_NAMESPACE static QtFontStyle *bestStyle(QtFontFoundry *foundry, const QtFontStyle::Key &styleKey) { diff --git a/src/gui/text/qharfbuzz_copy_p.h b/src/gui/text/qharfbuzz_copy_p.h index 74b824ab35..835d8fb1a6 100644 --- a/src/gui/text/qharfbuzz_copy_p.h +++ b/src/gui/text/qharfbuzz_copy_p.h @@ -43,7 +43,7 @@ extern "C" { #ifdef __xlC__ typedef unsigned hb_bitfield; #else -typedef quint8 hb_bitfield; +typedef QT_PREPEND_NAMESPACE(quint8) hb_bitfield; #endif typedef enum { @@ -66,12 +66,12 @@ typedef enum { HB_Err_Out_Of_Memory = 0xDEAD } HB_Error; -typedef quint32 HB_Glyph; +typedef QT_PREPEND_NAMESPACE(quint32) HB_Glyph; typedef void * HB_Font; typedef void * HB_Face; typedef void * HB_FontRec; -typedef quint32 hb_uint32; -typedef qint32 HB_Fixed; +typedef QT_PREPEND_NAMESPACE(quint32) hb_uint32; +typedef QT_PREPEND_NAMESPACE(qint32) HB_Fixed; typedef struct { HB_Fixed x; diff --git a/src/gui/text/qtextdocument.cpp b/src/gui/text/qtextdocument.cpp index 3ca72bf14e..a488c13156 100644 --- a/src/gui/text/qtextdocument.cpp +++ b/src/gui/text/qtextdocument.cpp @@ -2710,6 +2710,8 @@ void QTextHtmlExporter::emitBlock(const QTextBlock &block) emitBlockAttributes(block); html += QLatin1Char('>'); + if (block.begin().atEnd()) + html += "<br />"; QTextBlock::Iterator it = block.begin(); if (fragmentMarkers && !it.atEnd() && block == doc->begin()) diff --git a/src/gui/text/qtextdocumentfragment.cpp b/src/gui/text/qtextdocumentfragment.cpp index 042b1d01c2..0c8860e98e 100644 --- a/src/gui/text/qtextdocumentfragment.cpp +++ b/src/gui/text/qtextdocumentfragment.cpp @@ -545,8 +545,13 @@ void QTextHtmlImporter::import() } if (currentNode->isBlock()) { - if (processBlockNode() == ContinueWithNextNode) + QTextHtmlImporter::ProcessNodeResult result = processBlockNode(); + if (result == ContinueWithNextNode) { continue; + } else if (result == ContinueWithNextSibling) { + currentNodeIdx += currentNode->children.size(); + continue; + } } if (currentNode->charFormat.isAnchor() && !currentNode->charFormat.anchorName().isEmpty()) { @@ -1157,7 +1162,7 @@ QTextHtmlImporter::ProcessNodeResult QTextHtmlImporter::processBlockNode() if (currentNode->isEmptyParagraph) { hasBlock = false; - return ContinueWithNextNode; + return ContinueWithNextSibling; } hasBlock = true; diff --git a/src/gui/text/qtextdocumentfragment_p.h b/src/gui/text/qtextdocumentfragment_p.h index bfbec3075c..227123ed80 100644 --- a/src/gui/text/qtextdocumentfragment_p.h +++ b/src/gui/text/qtextdocumentfragment_p.h @@ -135,7 +135,7 @@ private: Table scanTable(int tableNodeIdx); - enum ProcessNodeResult { ContinueWithNextNode, ContinueWithCurrentNode }; + enum ProcessNodeResult { ContinueWithNextNode, ContinueWithCurrentNode, ContinueWithNextSibling }; void appendBlock(const QTextBlockFormat &format, QTextCharFormat charFmt = QTextCharFormat()); bool appendNodeText(); diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp index e386b5eb1f..03e00ed0df 100644 --- a/src/gui/text/qtextlayout.cpp +++ b/src/gui/text/qtextlayout.cpp @@ -2149,7 +2149,7 @@ QList<QGlyphRun> QTextLine::glyphRuns(int from, int length) const } int relativeFrom = qMax(iterator.itemStart, from) - si.position; - int relativeTo = qMin(iterator.itemEnd, from + length - 1) - si.position; + int relativeTo = qMin(iterator.itemEnd - 1, from + length - 1) - si.position; unsigned short *logClusters = eng->logClusters(&si); int glyphsStart = logClusters[relativeFrom]; @@ -2168,7 +2168,7 @@ QList<QGlyphRun> QTextLine::glyphRuns(int from, int length) const pos += QPointF((glyphLayout.advances_x[i] + justification).toReal(), glyphLayout.advances_y[i].toReal()); } - } else if (relativeTo != (iterator.itemEnd - si.position) && rtl) { + } else if (relativeTo != (iterator.itemEnd - si.position - 1) && rtl) { for (int i=glyphLayout.numGlyphs - 1; i>glyphsEnd; --i) { QFixed justification = QFixed::fromFixed(glyphLayout.justifications[i].space_18d6); pos += QPointF((glyphLayout.advances_x[i] + justification).toReal(), diff --git a/src/network/bearer/qnetworkconfigmanager.h b/src/network/bearer/qnetworkconfigmanager.h index 0323892923..e317cdfb44 100644 --- a/src/network/bearer/qnetworkconfigmanager.h +++ b/src/network/bearer/qnetworkconfigmanager.h @@ -42,10 +42,6 @@ #ifndef QNETWORKCONFIGURATIONMANAGER_H #define QNETWORKCONFIGURATIONMANAGER_H -#ifdef QT_MOBILITY_BEARER -# include "qmobilityglobal.h" -#endif - #include <QtCore/qobject.h> #include <QtNetwork/qnetworkconfiguration.h> @@ -53,17 +49,11 @@ QT_BEGIN_HEADER -#ifndef QT_MOBILITY_BEARER QT_BEGIN_NAMESPACE -#define QNetworkConfigurationManagerExport Q_NETWORK_EXPORT QT_MODULE(Network) -#else -QTM_BEGIN_NAMESPACE -#define QNetworkConfigurationManagerExport Q_BEARER_EXPORT -#endif class QNetworkConfigurationManagerPrivate; -class QNetworkConfigurationManagerExport QNetworkConfigurationManager : public QObject +class Q_NETWORK_EXPORT QNetworkConfigurationManager : public QObject { Q_OBJECT @@ -104,11 +94,7 @@ Q_SIGNALS: Q_DECLARE_OPERATORS_FOR_FLAGS(QNetworkConfigurationManager::Capabilities) -#ifndef QT_MOBILITY_BEARER QT_END_NAMESPACE -#else -QTM_END_NAMESPACE -#endif QT_END_HEADER diff --git a/src/network/bearer/qnetworkconfiguration.h b/src/network/bearer/qnetworkconfiguration.h index 86de72b2df..4839b7b809 100644 --- a/src/network/bearer/qnetworkconfiguration.h +++ b/src/network/bearer/qnetworkconfiguration.h @@ -42,11 +42,7 @@ #ifndef QNETWORKCONFIGURATION_H #define QNETWORKCONFIGURATION_H -#ifndef QT_MOBILITY_BEARER # include <QtCore/qglobal.h> -#else -# include "qmobilityglobal.h" -#endif #include <QtCore/qshareddata.h> #include <QtCore/qstring.h> @@ -58,17 +54,11 @@ QT_BEGIN_HEADER -#ifndef QT_MOBILITY_BEARER QT_BEGIN_NAMESPACE QT_MODULE(Network) -#define QNetworkConfigurationExport Q_NETWORK_EXPORT -#else -QTM_BEGIN_NAMESPACE -#define QNetworkConfigurationExport Q_BEARER_EXPORT -#endif class QNetworkConfigurationPrivate; -class QNetworkConfigurationExport QNetworkConfiguration +class Q_NETWORK_EXPORT QNetworkConfiguration { public: QNetworkConfiguration(); @@ -102,7 +92,6 @@ public: }; Q_DECLARE_FLAGS(StateFlags, StateFlag) -#ifndef QT_MOBILITY_BEARER enum BearerType { BearerUnknown, BearerEthernet, @@ -114,22 +103,17 @@ public: BearerBluetooth, BearerWiMAX }; -#endif StateFlags state() const; Type type() const; Purpose purpose() const; -#ifndef QT_MOBILITY_BEARER #ifdef QT_DEPRECATED // Required to maintain source compatibility with Qt Mobility. QT_DEPRECATED inline QString bearerName() const { return bearerTypeName(); } #endif BearerType bearerType() const; QString bearerTypeName() const; -#else - QString bearerName() const; -#endif QString identifier() const; bool isRoamingAvailable() const; @@ -146,11 +130,7 @@ private: QExplicitlySharedDataPointer<QNetworkConfigurationPrivate> d; }; -#ifndef QT_MOBILITY_BEARER QT_END_NAMESPACE -#else -QTM_END_NAMESPACE -#endif QT_END_HEADER diff --git a/src/network/bearer/qnetworksession.h b/src/network/bearer/qnetworksession.h index 4bc06eef2b..1eeea02ae1 100644 --- a/src/network/bearer/qnetworksession.h +++ b/src/network/bearer/qnetworksession.h @@ -56,19 +56,12 @@ QT_BEGIN_HEADER -#ifndef QT_MOBILITY_BEARER #include <QtCore/qshareddata.h> QT_BEGIN_NAMESPACE QT_MODULE(Network) -#define QNetworkSessionExport Q_NETWORK_EXPORT -#else -#include "qmobilityglobal.h" -QTM_BEGIN_NAMESPACE -#define QNetworkSessionExport Q_BEARER_EXPORT -#endif class QNetworkSessionPrivate; -class QNetworkSessionExport QNetworkSession : public QObject +class Q_NETWORK_EXPORT QNetworkSession : public QObject { Q_OBJECT @@ -140,13 +133,9 @@ private: QNetworkSessionPrivate *d; }; -#ifndef QT_MOBILITY_BEARER QT_END_NAMESPACE Q_DECLARE_METATYPE(QNetworkSession::State) Q_DECLARE_METATYPE(QNetworkSession::SessionError) -#else -QTM_END_NAMESPACE -#endif QT_END_HEADER diff --git a/src/network/kernel/qauthenticator.cpp b/src/network/kernel/qauthenticator.cpp index 818aab73a5..4f7f4ed80d 100644 --- a/src/network/kernel/qauthenticator.cpp +++ b/src/network/kernel/qauthenticator.cpp @@ -223,7 +223,7 @@ void QAuthenticator::setUser(const QString &user) } else if((separatorPosn = user.indexOf(QLatin1String("@"))) != -1) { //domain name is present d->realm.clear(); - d->userDomain = user.left(separatorPosn); + d->userDomain = user.mid(separatorPosn + 1); d->extractedUser = user.left(separatorPosn); d->user = user; } else { diff --git a/src/network/kernel/qhostaddress.cpp b/src/network/kernel/qhostaddress.cpp index 7eeb4e5a51..bff351c34f 100644 --- a/src/network/kernel/qhostaddress.cpp +++ b/src/network/kernel/qhostaddress.cpp @@ -134,15 +134,40 @@ QHostAddressPrivate::QHostAddressPrivate() void QHostAddressPrivate::setAddress(quint32 a_) { a = a_; + //create mapped address + memset(&a6, 0, sizeof(a6)); + int i; + for (i=15; a_ != 0; i--) { + a6[i] = a_ & 0xFF; + a_ >>=8; + } + Q_ASSERT(i >= 11); + a6[11] = 0xFF; + a6[10] = 0xFF; protocol = QAbstractSocket::IPv4Protocol; isParsed = true; } +static bool parseMappedAddress(quint32& a, const Q_IPV6ADDR &a6) +{ + int i; + for (i=0;i<10;i++) + if (a6[i]) return false; + for (;i<12;i++) + if (a6[i] != 0xFF) return false; + a=(a6[12] << 24) | (a6[13] << 16) | (a6[14] << 8) | a6[15]; + return true; +} + void QHostAddressPrivate::setAddress(const quint8 *a_) { for (int i = 0; i < 16; i++) a6[i] = a_[i]; - protocol = QAbstractSocket::IPv6Protocol; + a = 0; + if (parseMappedAddress(a, a6)) + protocol = QAbstractSocket::IPv4Protocol; + else + protocol = QAbstractSocket::IPv6Protocol; isParsed = true; } @@ -150,7 +175,10 @@ void QHostAddressPrivate::setAddress(const Q_IPV6ADDR &a_) { a6 = a_; a = 0; - protocol = QAbstractSocket::IPv6Protocol; + if (parseMappedAddress(a, a6)) + protocol = QAbstractSocket::IPv4Protocol; + else + protocol = QAbstractSocket::IPv6Protocol; isParsed = true; } @@ -447,8 +475,9 @@ void QNetmaskAddress::setPrefixLength(QAbstractSocket::NetworkLayerProtocol prot \value LocalHost The IPv4 localhost address. Equivalent to QHostAddress("127.0.0.1"). \value LocalHostIPv6 The IPv6 localhost address. Equivalent to QHostAddress("::1"). \value Broadcast The IPv4 broadcast address. Equivalent to QHostAddress("255.255.255.255"). - \value Any The IPv4 any-address. Equivalent to QHostAddress("0.0.0.0"). - \value AnyIPv6 The IPv6 any-address. Equivalent to QHostAddress("::"). + \value AnyIPv4 The IPv4 any-address. Equivalent to QHostAddress("0.0.0.0"). A socket bound with this address will listen only on IPv4 interaces. + \value AnyIPv6 The IPv6 any-address. Equivalent to QHostAddress("::"). A socket bound with this address will listen only on IPv6 interaces. + \value Any The dual stack any-address. A socket bound with this address will listen on both IPv4 and IPv6 interfaces. */ /*! Constructs a host address object with the IP address 0.0.0.0. @@ -548,12 +577,16 @@ QHostAddress::QHostAddress(SpecialAddress address) case LocalHostIPv6: setAddress(QLatin1String("::1")); break; - case Any: + case AnyIPv4: setAddress(QLatin1String("0.0.0.0")); break; case AnyIPv6: setAddress(QLatin1String("::")); break; + case Any: + d->clear(); + d->protocol = QAbstractSocket::AnyIPProtocol; + break; } } @@ -679,8 +712,11 @@ void QHostAddress::setAddress(const struct sockaddr *sockaddr) For example, if the address is 127.0.0.1, the returned value is 2130706433 (i.e. 0x7f000001). - This value is only valid if the Protocol() is - \l{QAbstractSocket::}{IPv4Protocol}. + This value is valid if the protocol() is + \l{QAbstractSocket::}{IPv4Protocol}, + or if the protocol is + \l{QAbstractSocket::}{IPv6Protocol}, + and the IPv6 address is an IPv4 mapped address. (RFC4291) \sa toString() */ @@ -705,8 +741,11 @@ QAbstractSocket::NetworkLayerProtocol QHostAddress::protocol() const \snippet doc/src/snippets/code/src_network_kernel_qhostaddress.cpp 0 - This value is only valid if the protocol() is + This value is valid if the protocol() is \l{QAbstractSocket::}{IPv6Protocol}. + If the protocol is + \l{QAbstractSocket::}{IPv4Protocol}, + then the address is returned an an IPv4 mapped IPv6 address. (RFC4291) \sa toString() */ @@ -722,13 +761,15 @@ Q_IPV6ADDR QHostAddress::toIPv6Address() const For example, if the address is the IPv4 address 127.0.0.1, the returned string is "127.0.0.1". For IPv6 the string format will follow the RFC5952 recommendation. + For QHostAddress::Any, its IPv4 address will be returned ("0.0.0.0") \sa toIPv4Address() */ QString QHostAddress::toString() const { QT_ENSURE_PARSED(this); - if (d->protocol == QAbstractSocket::IPv4Protocol) { + if (d->protocol == QAbstractSocket::IPv4Protocol + || d->protocol == QAbstractSocket::AnyIPProtocol) { quint32 i = toIPv4Address(); QString s; s.sprintf("%d.%d.%d.%d", (i>>24) & 0xff, (i>>16) & 0xff, @@ -1183,6 +1224,9 @@ QDataStream &operator>>(QDataStream &in, QHostAddress &address) address.setScopeId(scope); } break; + case QAbstractSocket::AnyIPProtocol: + address = QHostAddress::Any; + break; default: address.clear(); in.setStatus(QDataStream::ReadCorruptData); diff --git a/src/network/kernel/qhostaddress.h b/src/network/kernel/qhostaddress.h index 486f2322ae..efb3198fc0 100644 --- a/src/network/kernel/qhostaddress.h +++ b/src/network/kernel/qhostaddress.h @@ -76,7 +76,8 @@ public: LocalHost, LocalHostIPv6, Any, - AnyIPv6 + AnyIPv6, + AnyIPv4 }; QHostAddress(); diff --git a/src/network/socket/qabstractsocket.h b/src/network/socket/qabstractsocket.h index 1959fabdfc..2717ceb58a 100644 --- a/src/network/socket/qabstractsocket.h +++ b/src/network/socket/qabstractsocket.h @@ -74,6 +74,7 @@ public: enum NetworkLayerProtocol { IPv4Protocol, IPv6Protocol, + AnyIPProtocol, UnknownNetworkLayerProtocol = -1 }; enum SocketError { diff --git a/src/network/socket/qnativesocketengine_p.h b/src/network/socket/qnativesocketengine_p.h index c5c4b325d0..a024cd42d1 100644 --- a/src/network/socket/qnativesocketengine_p.h +++ b/src/network/socket/qnativesocketengine_p.h @@ -74,6 +74,11 @@ struct qt_sockaddr_storage { char __ss_pad2[QT_SS_PAD2SIZE]; }; +#ifdef Q_OS_WIN +#define QT_SOCKLEN_T int +#define QT_SOCKOPTLEN_T int +#endif + // sockaddr_in6 size changed between old and new SDK // Only the new version is the correct one, so always // use this structure. @@ -265,6 +270,10 @@ public: int nativeSelect(int timeout, bool selectForRead) const; int nativeSelect(int timeout, bool checkRead, bool checkWrite, bool *selectForRead, bool *selectForWrite) const; +#ifdef Q_OS_WIN + void setPortAndAddress(sockaddr_in * sockAddrIPv4, qt_sockaddr_in6 * sockAddrIPv6, + quint16 port, const QHostAddress & address, sockaddr ** sockAddrPtr, QT_SOCKLEN_T *sockAddrSize); +#endif void nativeClose(); diff --git a/src/network/socket/qnativesocketengine_unix.cpp b/src/network/socket/qnativesocketengine_unix.cpp index 39570c8c04..26053981ce 100644 --- a/src/network/socket/qnativesocketengine_unix.cpp +++ b/src/network/socket/qnativesocketengine_unix.cpp @@ -163,7 +163,7 @@ bool QNativeSocketEnginePrivate::createNewSocket(QAbstractSocket::SocketType soc QAbstractSocket::NetworkLayerProtocol socketProtocol) { #ifndef QT_NO_IPV6 - int protocol = (socketProtocol == QAbstractSocket::IPv6Protocol) ? AF_INET6 : AF_INET; + int protocol = (socketProtocol == QAbstractSocket::IPv6Protocol || socketProtocol == QAbstractSocket::AnyIPProtocol) ? AF_INET6 : AF_INET; #else Q_UNUSED(socketProtocol); int protocol = AF_INET; @@ -495,7 +495,14 @@ bool QNativeSocketEnginePrivate::nativeBind(const QHostAddress &address, quint16 #if !defined(QT_NO_IPV6) struct sockaddr_in6 sockAddrIPv6; - if (address.protocol() == QAbstractSocket::IPv6Protocol) { + if (address.protocol() == QAbstractSocket::IPv6Protocol || address.protocol() == QAbstractSocket::AnyIPProtocol) { +#ifdef IPV6_V6ONLY + int ipv6only = 0; + if (address.protocol() == QAbstractSocket::IPv6Protocol) + ipv6only = 1; + //default value of this socket option varies depending on unix variant (or system configuration on BSD), so always set it explicitly + ::setsockopt(socketDescriptor, IPPROTO_IPV6, IPV6_V6ONLY, (char*)&ipv6only, sizeof(ipv6only) ); +#endif memset(&sockAddrIPv6, 0, sizeof(sockAddrIPv6)); sockAddrIPv6.sin6_family = AF_INET6; sockAddrIPv6.sin6_port = htons(port); @@ -866,7 +873,8 @@ qint64 QNativeSocketEnginePrivate::nativeSendDatagram(const char *data, qint64 l #if !defined(QT_NO_IPV6) struct sockaddr_in6 sockAddrIPv6; - if (host.protocol() == QAbstractSocket::IPv6Protocol) { + if (host.protocol() == QAbstractSocket::IPv6Protocol + || socketProtocol == QAbstractSocket::IPv6Protocol) { memset(&sockAddrIPv6, 0, sizeof(sockAddrIPv6)); sockAddrIPv6.sin6_family = AF_INET6; sockAddrIPv6.sin6_port = htons(port); diff --git a/src/network/socket/qnativesocketengine_win.cpp b/src/network/socket/qnativesocketengine_win.cpp index 88b87b98fe..ba62bd6da2 100644 --- a/src/network/socket/qnativesocketengine_win.cpp +++ b/src/network/socket/qnativesocketengine_win.cpp @@ -159,11 +159,6 @@ static QByteArray qt_prettyDebug(const char *data, int len, int maxLength) #define SO_EXCLUSIVEADDRUSE ((int)(~SO_REUSEADDR)) /* disallow local address reuse */ #endif -//### -#define QT_SOCKLEN_T int -#define QT_SOCKOPTLEN_T int - - /* Extracts the port and address from a sockaddr, and stores them in \a port and \a addr if they are non-null. @@ -202,11 +197,13 @@ static inline void qt_socket_getPortAndAddress(SOCKET socketDescriptor, const qt Sets the port and address to a sockaddr. Requires that sa point to the IPv6 struct if the address is IPv6. */ -static inline void qt_socket_setPortAndAddress(SOCKET socketDescriptor, sockaddr_in * sockAddrIPv4, qt_sockaddr_in6 * sockAddrIPv6, +void QNativeSocketEnginePrivate::setPortAndAddress(sockaddr_in * sockAddrIPv4, qt_sockaddr_in6 * sockAddrIPv6, quint16 port, const QHostAddress & address, sockaddr ** sockAddrPtr, QT_SOCKLEN_T *sockAddrSize) { #if !defined(QT_NO_IPV6) - if (address.protocol() == QAbstractSocket::IPv6Protocol) { + if (address.protocol() == QAbstractSocket::IPv6Protocol + || address.protocol() == QAbstractSocket::AnyIPProtocol + || socketProtocol == QAbstractSocket::IPv6Protocol) { memset(sockAddrIPv6, 0, sizeof(qt_sockaddr_in6)); sockAddrIPv6->sin6_family = AF_INET6; sockAddrIPv6->sin6_scope_id = address.scopeId().toInt(); @@ -306,7 +303,9 @@ bool QNativeSocketEnginePrivate::createNewSocket(QAbstractSocket::SocketType soc } */ - int protocol = (socketProtocol == QAbstractSocket::IPv6Protocol) ? AF_INET6 : AF_INET; + //Windows XP and 2003 support IPv6 but not dual stack sockets + int protocol = (socketProtocol == QAbstractSocket::IPv6Protocol + || (socketProtocol == QAbstractSocket::AnyIPProtocol && QSysInfo::windowsVersion() >= QSysInfo::WV_6_0)) ? AF_INET6 : AF_INET; int type = (socketType == QAbstractSocket::UdpSocket) ? SOCK_DGRAM : SOCK_STREAM; // MSDN KB179942 states that on winnt 4 WSA_FLAG_OVERLAPPED is needed if socket is to be non blocking // and recomends alwasy doing it for cross windows version comapablity. @@ -602,7 +601,7 @@ bool QNativeSocketEnginePrivate::nativeConnect(const QHostAddress &address, quin struct sockaddr *sockAddrPtr = 0; QT_SOCKLEN_T sockAddrSize = 0; - qt_socket_setPortAndAddress(socketDescriptor, &sockAddrIPv4, &sockAddrIPv6, port, address, &sockAddrPtr, &sockAddrSize); + setPortAndAddress(&sockAddrIPv4, &sockAddrIPv6, port, address, &sockAddrPtr, &sockAddrSize); forever { int connectResult = ::WSAConnect(socketDescriptor, sockAddrPtr, sockAddrSize, 0,0,0,0); @@ -708,19 +707,35 @@ bool QNativeSocketEnginePrivate::nativeConnect(const QHostAddress &address, quin bool QNativeSocketEnginePrivate::nativeBind(const QHostAddress &a, quint16 port) { QHostAddress address = a; + DWORD ipv6only = 0; switch (address.protocol()) { case QAbstractSocket::IPv6Protocol: if (address.toIPv6Address()[0] == 0xff) { // binding to a multicast address address = QHostAddress(QHostAddress::AnyIPv6); } +#if !defined (QT_NO_IPV6) && defined (IPV6_V6ONLY) + //This is default in current windows versions, it may change in future so set it explicitly + if (QSysInfo::windowsVersion() >= QSysInfo::WV_6_0) { + ipv6only = 1; + ipv6only = ::setsockopt(socketDescriptor, IPPROTO_IPV6, IPV6_V6ONLY, (char*)&ipv6only, sizeof(ipv6only) ); + } +#endif break; case QAbstractSocket::IPv4Protocol: if ((address.toIPv4Address() & 0xffff0000) == 0xefff0000) { // binding to a multicast address - address = QHostAddress(QHostAddress::Any); + address = QHostAddress(QHostAddress::AnyIPv4); } break; + case QAbstractSocket::AnyIPProtocol: +#if !defined (QT_NO_IPV6) && defined (IPV6_V6ONLY) + if (QSysInfo::windowsVersion() >= QSysInfo::WV_6_0) + ipv6only = ::setsockopt(socketDescriptor, IPPROTO_IPV6, IPV6_V6ONLY, (char*)&ipv6only, sizeof(ipv6only) ); + else +#endif + address = QHostAddress(QHostAddress::AnyIPv4); //xp/WS2003 and earlier don't support dual stack, so bind to IPv4 + break; default: break; } @@ -730,7 +745,7 @@ bool QNativeSocketEnginePrivate::nativeBind(const QHostAddress &a, quint16 port) struct sockaddr *sockAddrPtr = 0; QT_SOCKLEN_T sockAddrSize = 0; - qt_socket_setPortAndAddress(socketDescriptor, &sockAddrIPv4, &sockAddrIPv6, port, address, &sockAddrPtr, &sockAddrSize); + setPortAndAddress(&sockAddrIPv4, &sockAddrIPv6, port, address, &sockAddrPtr, &sockAddrSize); int bindResult = ::bind(socketDescriptor, sockAddrPtr, sockAddrSize); @@ -1182,7 +1197,7 @@ qint64 QNativeSocketEnginePrivate::nativeSendDatagram(const char *data, qint64 l struct sockaddr *sockAddrPtr = 0; QT_SOCKLEN_T sockAddrSize = 0; - qt_socket_setPortAndAddress(socketDescriptor, &sockAddrIPv4, &sockAddrIPv6, port, address, &sockAddrPtr, &sockAddrSize); + setPortAndAddress(&sockAddrIPv4, &sockAddrIPv6, port, address, &sockAddrPtr, &sockAddrSize); WSABUF buf; #if !defined(Q_OS_WINCE) diff --git a/src/network/socket/qsocks5socketengine.cpp b/src/network/socket/qsocks5socketengine.cpp index ab757987f6..514a7a0f6f 100644 --- a/src/network/socket/qsocks5socketengine.cpp +++ b/src/network/socket/qsocks5socketengine.cpp @@ -827,7 +827,7 @@ void QSocks5SocketEnginePrivate::sendRequestMethod() //### set error code .... return; } else if (!peerName.isEmpty() && !qt_socks5_set_host_name_and_port(peerName, port, &buf)) { - QSOCKS5_DEBUG << "error setting address" << address << " : " << port; + QSOCKS5_DEBUG << "error setting peer name" << peerName << " : " << port; //### set error code .... return; } @@ -1325,12 +1325,18 @@ void QSocks5SocketEnginePrivate::_q_udpSocketReadNotification() } #endif // QT_NO_UDPSOCKET -bool QSocks5SocketEngine::bind(const QHostAddress &address, quint16 port) +bool QSocks5SocketEngine::bind(const QHostAddress &addr, quint16 port) { Q_D(QSocks5SocketEngine); // when bind wee will block until the bind is finished as the info from the proxy server is needed + QHostAddress address; + if (addr.protocol() == QAbstractSocket::AnyIPProtocol) + address = QHostAddress::AnyIPv4; //SOCKS5 doesnt support dual stack, and there isn't any implementation of udp on ipv6 yet + else + address = addr; + if (!d->data) { if (socketType() == QAbstractSocket::TcpSocket) { d->initialize(QSocks5SocketEnginePrivate::BindMode); diff --git a/src/network/ssl/qsslcertificate.cpp b/src/network/ssl/qsslcertificate.cpp index 76b7d41e46..6100c68a2d 100644 --- a/src/network/ssl/qsslcertificate.cpp +++ b/src/network/ssl/qsslcertificate.cpp @@ -123,6 +123,7 @@ #include <QtCore/qmap.h> #include <QtCore/qstring.h> #include <QtCore/qstringlist.h> +#include <QtCore/qvarlengtharray.h> QT_BEGIN_NAMESPACE @@ -522,6 +523,17 @@ QByteArray QSslCertificate::toDer() const } /*! + Returns this certificate converted to a human-readable text + representation. +*/ +QByteArray QSslCertificate::toText() const +{ + if (!d->x509) + return QByteArray(); + return d->text_from_X509(d->x509); +} + +/*! Searches all files in the \a path for certificates encoded in the specified \a format and returns them in a list. \e must be a file or a pattern matching one or more files, as specified by \a syntax. @@ -666,6 +678,31 @@ QByteArray QSslCertificatePrivate::QByteArray_from_X509(X509 *x509, QSsl::Encodi return BEGINCERTSTRING "\n" + tmp + ENDCERTSTRING "\n"; } +QByteArray QSslCertificatePrivate::text_from_X509(X509 *x509) +{ + if (!x509) { + qWarning("QSslSocketBackendPrivate::text_from_X509: null X509"); + return QByteArray(); + } + + QByteArray result; + BIO *bio = q_BIO_new(q_BIO_s_mem()); + if (!bio) + return result; + + q_X509_print(bio, x509); + + QVarLengthArray<char, 16384> data; + int count = q_BIO_read(bio, data.data(), 16384); + if ( count > 0 ) { + result = QByteArray( data.data(), count ); + } + + q_BIO_free(bio); + + return result; +} + static QMap<QString, QString> _q_mapFromX509Name(X509_NAME *name) { QMap<QString, QString> info; diff --git a/src/network/ssl/qsslcertificate.h b/src/network/ssl/qsslcertificate.h index e52f9c15c1..b942bd8a25 100644 --- a/src/network/ssl/qsslcertificate.h +++ b/src/network/ssl/qsslcertificate.h @@ -107,6 +107,7 @@ public: QByteArray toPem() const; QByteArray toDer() const; + QByteArray toText() const; static QList<QSslCertificate> fromPath( const QString &path, QSsl::EncodingFormat format = QSsl::Pem, diff --git a/src/network/ssl/qsslcertificate_p.h b/src/network/ssl/qsslcertificate_p.h index 448ca8dc58..eb192968c5 100644 --- a/src/network/ssl/qsslcertificate_p.h +++ b/src/network/ssl/qsslcertificate_p.h @@ -93,6 +93,7 @@ public: void init(const QByteArray &data, QSsl::EncodingFormat format); static QByteArray QByteArray_from_X509(X509 *x509, QSsl::EncodingFormat format); + static QByteArray text_from_X509(X509 *x509); static QSslCertificate QSslCertificate_from_X509(X509 *x509); static QList<QSslCertificate> certificatesFromPem(const QByteArray &pem, int count = -1); static QList<QSslCertificate> certificatesFromDer(const QByteArray &der, int count = -1); diff --git a/src/network/ssl/qsslsocket_openssl_symbols.cpp b/src/network/ssl/qsslsocket_openssl_symbols.cpp index a4cc3c493d..6d29b294a1 100644 --- a/src/network/ssl/qsslsocket_openssl_symbols.cpp +++ b/src/network/ssl/qsslsocket_openssl_symbols.cpp @@ -241,6 +241,7 @@ DEFINEFUNC2(int, X509_cmp, X509 *a, a, X509 *b, b, return -1, return) #ifndef SSLEAY_MACROS DEFINEFUNC(X509 *, X509_dup, X509 *a, a, return 0, return) #endif +DEFINEFUNC2(void, X509_print, BIO *a, a, X509 *b, b, return, DUMMYARG); DEFINEFUNC(ASN1_OBJECT *, X509_EXTENSION_get_object, X509_EXTENSION *a, a, return 0, return) DEFINEFUNC(void, X509_free, X509 *a, a, return, DUMMYARG) DEFINEFUNC2(X509_EXTENSION *, X509_get_ext, X509 *a, a, int b, b, return 0, return) @@ -629,6 +630,7 @@ bool q_resolveOpenSslSymbols() #ifndef SSLEAY_MACROS RESOLVEFUNC(X509_dup, 1997, libs.second ) #endif + RESOLVEFUNC(X509_print, 2046, libs.second ) RESOLVEFUNC(X509_EXTENSION_get_object, 1785, libs.second ) RESOLVEFUNC(X509_free, 2001, libs.second ) RESOLVEFUNC(X509_get_ext, 2012, libs.second ) @@ -761,6 +763,7 @@ bool q_resolveOpenSslSymbols() #ifndef SSLEAY_MACROS RESOLVEFUNC(X509_dup) #endif + RESOLVEFUNC(X509_print) RESOLVEFUNC(X509_EXTENSION_get_object) RESOLVEFUNC(X509_free) RESOLVEFUNC(X509_get_ext) diff --git a/src/network/ssl/qsslsocket_openssl_symbols_p.h b/src/network/ssl/qsslsocket_openssl_symbols_p.h index c0a3b4da6a..00f56d65af 100644 --- a/src/network/ssl/qsslsocket_openssl_symbols_p.h +++ b/src/network/ssl/qsslsocket_openssl_symbols_p.h @@ -353,6 +353,7 @@ void *q_ASN1_dup(i2d_of_void *i2d, d2i_of_void *d2i, char *x); #else X509 *q_X509_dup(X509 *a); #endif +void q_X509_print(BIO *a, X509*b); ASN1_OBJECT *q_X509_EXTENSION_get_object(X509_EXTENSION *a); void q_X509_free(X509 *a); X509_EXTENSION *q_X509_get_ext(X509 *a, int b); diff --git a/src/plugins/platforms/wayland/qwaylandclipboard.cpp b/src/plugins/platforms/wayland/qwaylandclipboard.cpp index feaa660bc6..da5da4285a 100644 --- a/src/plugins/platforms/wayland/qwaylandclipboard.cpp +++ b/src/plugins/platforms/wayland/qwaylandclipboard.cpp @@ -50,7 +50,7 @@ #include <QtCore/QtDebug> #include <QtGui/private/qdnd_p.h> -static QWaylandClipboard *clipboard; +static QWaylandClipboard *clipboard = 0; class QWaylandMimeData : public QInternalMimeData { @@ -162,10 +162,16 @@ void QWaylandSelection::cancelled(void *data, struct wl_selection *selection) delete static_cast<QWaylandSelection *>(data); } +QWaylandClipboard *QWaylandClipboard::instance(QWaylandDisplay *display) +{ + if (!clipboard) + clipboard = new QWaylandClipboard(display); + return clipboard; +} + QWaylandClipboard::QWaylandClipboard(QWaylandDisplay *display) : mDisplay(display), mMimeDataIn(0), mOffer(0) { - clipboard = this; } QWaylandClipboard::~QWaylandClipboard() diff --git a/src/plugins/platforms/wayland/qwaylandclipboard.h b/src/plugins/platforms/wayland/qwaylandclipboard.h index f45fb8da4c..87294342d7 100644 --- a/src/plugins/platforms/wayland/qwaylandclipboard.h +++ b/src/plugins/platforms/wayland/qwaylandclipboard.h @@ -61,7 +61,8 @@ public slots: class QWaylandClipboard : public QPlatformClipboard { public: - QWaylandClipboard(QWaylandDisplay *display); + static QWaylandClipboard *instance(QWaylandDisplay *display); + ~QWaylandClipboard(); QMimeData *mimeData(QClipboard::Mode mode = QClipboard::Clipboard); @@ -75,6 +76,8 @@ public: QVariant retrieveData(const QString &mimeType, QVariant::Type type) const; private: + QWaylandClipboard(QWaylandDisplay *display); + static void offer(void *data, struct wl_selection_offer *selection_offer, const char *type); diff --git a/src/plugins/platforms/wayland/qwaylanddisplay.cpp b/src/plugins/platforms/wayland/qwaylanddisplay.cpp index 9e8cfe3df6..f3e2e9fb94 100644 --- a/src/plugins/platforms/wayland/qwaylanddisplay.cpp +++ b/src/plugins/platforms/wayland/qwaylanddisplay.cpp @@ -125,9 +125,14 @@ const struct wl_shell_listener QWaylandDisplay::shellListener = { QWaylandDisplay::shellHandleConfigure, }; +static QWaylandDisplay *display = 0; + QWaylandDisplay::QWaylandDisplay(void) : argb_visual(0), premultiplied_argb_visual(0), rgb_visual(0) { + display = this; + qRegisterMetaType<uint32_t>("uint32_t"); + mDisplay = wl_display_connect(NULL); if (mDisplay == NULL) { qErrnoWarning(errno, "Failed to create display"); @@ -146,8 +151,6 @@ QWaylandDisplay::QWaylandDisplay(void) blockingReadEvents(); - qRegisterMetaType<uint32_t>("uint32_t"); - #ifdef QT_WAYLAND_GL_SUPPORT mEglIntegration->initialize(); #endif @@ -311,11 +314,7 @@ void QWaylandDisplay::displayHandleGlobal(uint32_t id, new QWaylandInputDevice(mDisplay, id); mInputDevices.append(inputDevice); } else if (interface == "wl_selection_offer") { - QPlatformIntegration *plat = QGuiApplicationPrivate::platformIntegration(); - if (!plat) - return; - QWaylandClipboard *clipboard = static_cast<QWaylandClipboard *>(plat->clipboard()); - clipboard->createSelectionOffer(id); + QWaylandClipboard::instance(display)->createSelectionOffer(id); } } diff --git a/src/plugins/platforms/wayland/qwaylandintegration.cpp b/src/plugins/platforms/wayland/qwaylandintegration.cpp index 1f1ecda0e6..9a581c265f 100644 --- a/src/plugins/platforms/wayland/qwaylandintegration.cpp +++ b/src/plugins/platforms/wayland/qwaylandintegration.cpp @@ -64,7 +64,6 @@ QWaylandIntegration::QWaylandIntegration() : mFontDb(new QGenericUnixFontDatabase()) , mDisplay(new QWaylandDisplay()) , mNativeInterface(new QWaylandNativeInterface) - , mClipboard(0) { } @@ -137,7 +136,5 @@ QPlatformFontDatabase *QWaylandIntegration::fontDatabase() const QPlatformClipboard *QWaylandIntegration::clipboard() const { - if (!mClipboard) - mClipboard = new QWaylandClipboard(mDisplay); - return mClipboard; + return QWaylandClipboard::instance(mDisplay); } diff --git a/src/plugins/platforms/wayland/qwaylandintegration.h b/src/plugins/platforms/wayland/qwaylandintegration.h index 6a5e4d3b28..c08c040261 100644 --- a/src/plugins/platforms/wayland/qwaylandintegration.h +++ b/src/plugins/platforms/wayland/qwaylandintegration.h @@ -74,7 +74,6 @@ private: QPlatformFontDatabase *mFontDb; QWaylandDisplay *mDisplay; QPlatformNativeInterface *mNativeInterface; - mutable QPlatformClipboard *mClipboard; }; QT_END_NAMESPACE diff --git a/src/testlib/qbenchmarkmeasurement_p.h b/src/testlib/qbenchmarkmeasurement_p.h index a4b676fd72..8242365f20 100644 --- a/src/testlib/qbenchmarkmeasurement_p.h +++ b/src/testlib/qbenchmarkmeasurement_p.h @@ -54,7 +54,9 @@ // #include <QtCore/qelapsedtimer.h> +#ifdef HAVE_TICK_COUNTER #include "3rdparty/cycle_p.h" +#endif #include "qbenchmark.h" QT_BEGIN_NAMESPACE diff --git a/src/tools/moc/main.cpp b/src/tools/moc/main.cpp index 41a3a4fc93..eaafd0a9fd 100644 --- a/src/tools/moc/main.cpp +++ b/src/tools/moc/main.cpp @@ -67,34 +67,7 @@ static QByteArray combinePath(const char *infile, const char *outfile) { QFileInfo inFileInfo(QDir::current(), QFile::decodeName(infile)); QFileInfo outFileInfo(QDir::current(), QFile::decodeName(outfile)); - int numCommonComponents = 0; - - QStringList inSplitted = inFileInfo.dir().canonicalPath().split(QLatin1Char('/')); - QStringList outSplitted = outFileInfo.dir().canonicalPath().split(QLatin1Char('/')); - - while (!inSplitted.isEmpty() && !outSplitted.isEmpty() && - inSplitted.first() == outSplitted.first()) { - inSplitted.removeFirst(); - outSplitted.removeFirst(); - numCommonComponents++; - } - - if (numCommonComponents < 2) - /* - The paths don't have the same drive, or they don't have the - same root directory. Use an absolute path. - */ - return QFile::encodeName(inFileInfo.absoluteFilePath()); - /* - The paths have something in common. Use a path relative to - the output file. - */ - while (!outSplitted.isEmpty()) { - outSplitted.removeFirst(); - inSplitted.prepend(QLatin1String("..")); - } - inSplitted.append(inFileInfo.fileName()); - return QFile::encodeName(inSplitted.join(QLatin1String("/"))); + return QFile::encodeName(outFileInfo.dir().relativeFilePath(inFileInfo.filePath())); } diff --git a/src/widgets/platforms/mac/qfontengine_coretext_p.h b/src/widgets/platforms/mac/qfontengine_coretext_p.h index 3ca8a0ad60..b531856a27 100644 --- a/src/widgets/platforms/mac/qfontengine_coretext_p.h +++ b/src/widgets/platforms/mac/qfontengine_coretext_p.h @@ -46,6 +46,10 @@ #if !defined(Q_WS_MAC) || (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5) +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + class QRawFontPrivate; class QCoreTextFontEngineMulti; class QCoreTextFontEngine : public QFontEngine @@ -143,6 +147,10 @@ private: CGAffineTransform qt_transform_from_fontdef(const QFontDef &fontDef); +QT_END_NAMESPACE + +QT_END_HEADER + #endif// !defined(Q_WS_MAC) || (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5) #endif // QFONTENGINE_CORETEXT_P_H diff --git a/src/widgets/platforms/mac/qwidget_mac.mm b/src/widgets/platforms/mac/qwidget_mac.mm index 3a025e9237..4adaa6b288 100644 --- a/src/widgets/platforms/mac/qwidget_mac.mm +++ b/src/widgets/platforms/mac/qwidget_mac.mm @@ -5018,7 +5018,7 @@ void QWidgetPrivate::registerTouchWindow(bool enable) if (enable == touchEventsEnabled) return; - QCocoaView *view = static_cast<QCocoaView *>(qt_mac_effectiveview_for(q)); + QT_MANGLE_NAMESPACE(QCocoaView) *view = static_cast<QT_MANGLE_NAMESPACE(QCocoaView) *>(qt_mac_effectiveview_for(q)); if (!view) return; diff --git a/src/widgets/platforms/x11/qfontdatabase_x11.cpp b/src/widgets/platforms/x11/qfontdatabase_x11.cpp index 754334c0c4..958daa2506 100644 --- a/src/widgets/platforms/x11/qfontdatabase_x11.cpp +++ b/src/widgets/platforms/x11/qfontdatabase_x11.cpp @@ -1566,9 +1566,8 @@ static FcPattern *getFcPattern(const QFontPrivate *fp, int script, const QFontDe qt_addPatternProps(pattern, fp->screen, script, request); - FcDefaultSubstitute(pattern); FcConfigSubstitute(0, pattern, FcMatchPattern); - FcConfigSubstitute(0, pattern, FcMatchFont); + FcDefaultSubstitute(pattern); // these should only get added to the pattern _after_ substitution // append the default fallback font for the specified script @@ -1606,35 +1605,20 @@ static void FcFontSetRemove(FcFontSet *fs, int at) memmove(fs->fonts + at, fs->fonts + at + 1, len); } -static QFontEngine *tryPatternLoad(FcPattern *p, int screen, - const QFontDef &request, int script, FcPattern **matchedPattern = 0) +static QFontEngine *tryPatternLoad(FcPattern *match, int screen, + const QFontDef &request, int script) { #ifdef FONT_MATCH_DEBUG FcChar8 *fam; - FcPatternGetString(p, FC_FAMILY, 0, &fam); + FcPatternGetString(match, FC_FAMILY, 0, &fam); FM_DEBUG("==== trying %s\n", fam); #endif FM_DEBUG("passes charset test\n"); - FcPattern *pattern = FcPatternDuplicate(p); - // add properties back in as the font selected from the - // list doesn't contain them. - qt_addPatternProps(pattern, screen, script, request); - - FcConfigSubstitute(0, pattern, FcMatchPattern); - FcDefaultSubstitute(pattern); - FcResult res; - FcPattern *match = FcFontMatch(0, pattern, &res); - - if (matchedPattern) - *matchedPattern = 0; QFontEngineX11FT *engine = 0; if (!match) // probably no fonts available. goto done; - if (matchedPattern) - *matchedPattern = FcPatternDuplicate(match); - if (script != QUnicodeTables::Common) { // skip font if it doesn't support the language we want if (specialChars[script]) { @@ -1673,11 +1657,6 @@ static QFontEngine *tryPatternLoad(FcPattern *p, int screen, } } done: - FcPatternDestroy(pattern); - if (!engine && matchedPattern && *matchedPattern) { - FcPatternDestroy(*matchedPattern); - *matchedPattern = 0; - } return engine; } @@ -1726,14 +1705,26 @@ static QFontEngine *loadFc(const QFontPrivate *fp, int script, const QFontDef &r #endif QFontEngine *fe = 0; - FcPattern *matchedPattern = 0; - fe = tryPatternLoad(pattern, fp->screen, request, script, &matchedPattern); + FcResult res; + FcPattern *match = FcFontMatch(0, pattern, &res); + fe = tryPatternLoad(match, fp->screen, request, script); if (!fe) { FcFontSet *fs = qt_fontSetForPattern(pattern, request); + if (match) { + FcPatternDestroy(match); + match = 0; + } + if (fs) { - for (int i = 0; !fe && i < fs->nfont; ++i) - fe = tryPatternLoad(fs->fonts[i], fp->screen, request, script, &matchedPattern); + for (int i = 0; !fe && i < fs->nfont; ++i) { + match = FcFontRenderPrepare(NULL, pattern, fs->fonts[i]); + fe = tryPatternLoad(match, fp->screen, request, script); + if (fe) + break; + FcPatternDestroy(match); + match = 0; + } FcFontSetDestroy(fs); } FM_DEBUG("engine for script %d is %s\n", script, fe ? fe->fontDef.family.toLatin1().data(): "(null)"); @@ -1741,11 +1732,11 @@ static QFontEngine *loadFc(const QFontPrivate *fp, int script, const QFontDef &r if (fe && script == QUnicodeTables::Common && !(request.styleStrategy & QFont::NoFontMerging) && !fe->symbol) { - fe = new QFontEngineMultiFT(fe, matchedPattern, pattern, fp->screen, request); + fe = new QFontEngineMultiFT(fe, match, pattern, fp->screen, request); } else { FcPatternDestroy(pattern); - if (matchedPattern) - FcPatternDestroy(matchedPattern); + if (match) + FcPatternDestroy(match); } return fe; } diff --git a/src/widgets/platforms/x11/qfontengine_x11.cpp b/src/widgets/platforms/x11/qfontengine_x11.cpp index 9918f82bf7..c23fb0c174 100644 --- a/src/widgets/platforms/x11/qfontengine_x11.cpp +++ b/src/widgets/platforms/x11/qfontengine_x11.cpp @@ -863,11 +863,8 @@ glyph_t QFontEngineXLFD::glyphIndexToFreetypeGlyphIndex(glyph_t g) const // Multi FT engine // ------------------------------------------------------------------ -static QFontEngine *engineForPattern(FcPattern *pattern, const QFontDef &request, - int screen) +static QFontEngine *engineForPattern(FcPattern *match, const QFontDef &request, int screen) { - FcResult res; - FcPattern *match = FcFontMatch(0, pattern, &res); QFontEngineX11FT *engine = new QFontEngineX11FT(match, request, screen); if (!engine->invalid()) return engine; @@ -879,9 +876,9 @@ static QFontEngine *engineForPattern(FcPattern *pattern, const QFontDef &request } QFontEngineMultiFT::QFontEngineMultiFT(QFontEngine *fe, FcPattern *matchedPattern, FcPattern *p, int s, const QFontDef &req) - : QFontEngineMulti(2), request(req), pattern(p), firstEnginePattern(matchedPattern), fontSet(0), screen(s) + : QFontEngineMulti(2), request(req), pattern(p), fontSet(0), screen(s) { - + firstEnginePattern = FcPatternDuplicate(matchedPattern); engines[0] = fe; engines.at(0)->ref.ref(); fontDef = engines[0]->fontDef; @@ -907,8 +904,6 @@ void QFontEngineMultiFT::loadEngine(int at) extern QMutex *qt_fontdatabase_mutex(); QMutexLocker locker(qt_fontdatabase_mutex()); - extern void qt_addPatternProps(FcPattern *pattern, int screen, int script, - const QFontDef &request); extern QFontDef qt_FcPatternToQFontDef(FcPattern *pattern, const QFontDef &); extern FcFontSet *qt_fontSetForPattern(FcPattern *pattern, const QFontDef &request); @@ -940,22 +935,18 @@ void QFontEngineMultiFT::loadEngine(int at) Q_ASSERT(at < engines.size()); Q_ASSERT(engines.at(at) == 0); - FcPattern *pattern = FcPatternDuplicate(fontSet->fonts[at + firstFontIndex - 1]); - qt_addPatternProps(pattern, screen, QUnicodeTables::Common, request); - - QFontDef fontDef = qt_FcPatternToQFontDef(pattern, this->request); + FcPattern *match = FcFontRenderPrepare(NULL, pattern, fontSet->fonts[at + firstFontIndex - 1]); + QFontDef fontDef = qt_FcPatternToQFontDef(match, this->request); // note: we use -1 for the script to make sure that we keep real // FT engines separate from Multi engines in the font cache QFontCache::Key key(fontDef, -1, screen); QFontEngine *fontEngine = QFontCache::instance()->findEngine(key); if (!fontEngine) { - FcConfigSubstitute(0, pattern, FcMatchPattern); - FcDefaultSubstitute(pattern); - fontEngine = engineForPattern(pattern, request, screen); + fontEngine = engineForPattern(match, request, screen); QFontCache::instance()->insertEngine(key, fontEngine); } - FcPatternDestroy(pattern); + FcPatternDestroy(match); fontEngine->ref.ref(); engines[at] = fontEngine; } @@ -1123,17 +1114,14 @@ QFontEngineX11FT::QFontEngineX11FT(FcPattern *pattern, const QFontDef &fd, int s } #endif - if (!init(face_id, antialias, defaultFormat)) { - FcPatternDestroy(pattern); + if (!init(face_id, antialias, defaultFormat)) return; - } if (!freetype->charset) { FcCharSet *cs; FcPatternGetCharSet (pattern, FC_CHARSET, 0, &cs); freetype->charset = FcCharSetCopy(cs); } - FcPatternDestroy(pattern); } QFontEngineX11FT::~QFontEngineX11FT() diff --git a/src/widgets/styles/qcommonstyle.cpp b/src/widgets/styles/qcommonstyle.cpp index e5171d854a..ad0e151051 100644 --- a/src/widgets/styles/qcommonstyle.cpp +++ b/src/widgets/styles/qcommonstyle.cpp @@ -5292,7 +5292,7 @@ QPixmap QCommonStyle::standardPixmap(StandardPixmap sp, const QStyleOption *opti pixmap = QIcon::fromTheme(QLatin1String("media-seek-backward")).pixmap(16); break; case SP_MediaSkipForward: - pixmap = QIcon::fromTheme(QLatin1String("media-skip-backward")).pixmap(16); + pixmap = QIcon::fromTheme(QLatin1String("media-skip-forward")).pixmap(16); break; case SP_MediaSkipBackward: pixmap = QIcon::fromTheme(QLatin1String("media-skip-backward")).pixmap(16); diff --git a/src/widgets/util/qscroller_mac.mm b/src/widgets/util/qscroller_mac.mm index c0ef4a1665..81d18aaf6b 100644 --- a/src/widgets/util/qscroller_mac.mm +++ b/src/widgets/util/qscroller_mac.mm @@ -47,6 +47,8 @@ #include "qscroller_p.h" +QT_BEGIN_NAMESPACE + QPointF QScrollerPrivate::realDpi(int screen) { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; @@ -68,4 +70,6 @@ QPointF QScrollerPrivate::realDpi(int screen) [pool release]; } +QT_END_NAMESPACE + #endif |