From 20526cb01466105c0e4ed1430ac9722f3dddf60a Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 15 Nov 2016 07:37:16 -0800 Subject: Make sure all pattern args get cleared when parsing a new pattern The user can call qSetMessagePattern after program start, so we need to be sure that the parsed argument data is properly cleared. Task-number: QTBUG-57144 Change-Id: I1978c6b95bd84639a8c4fffd1487429b04725522 Reviewed-by: Kai Koehne --- src/corelib/global/qlogging.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') diff --git a/src/corelib/global/qlogging.cpp b/src/corelib/global/qlogging.cpp index 22b75afac8..e1b8ef4b6d 100644 --- a/src/corelib/global/qlogging.cpp +++ b/src/corelib/global/qlogging.cpp @@ -1039,6 +1039,10 @@ void QMessagePattern::setPattern(const QString &pattern) delete [] literals; } delete [] tokens; + timeArgs.clear(); +#ifdef QLOGGING_HAVE_BACKTRACE + backtraceArgs.clear(); +#endif // scanner QList lexemes; -- cgit v1.2.3 From 1ff2acf20f6b2a0f7d49635bc46a19bc45d55fb1 Mon Sep 17 00:00:00 2001 From: Alexander Volkov Date: Thu, 24 Nov 2016 02:02:42 +0300 Subject: QtGui: Add missing override Change-Id: Ief5b0863d7649d5a8d421c05766513276c264776 Reviewed-by: hjk --- src/gui/image/qbmphandler_p.h | 14 ++++----- src/gui/image/qpnghandler_p.h | 14 ++++----- src/gui/image/qppmhandler_p.h | 14 ++++----- src/gui/image/qxbmhandler_p.h | 14 ++++----- src/gui/image/qxpmhandler_p.h | 14 ++++----- src/gui/opengl/qopenglpaintdevice.h | 6 ++-- src/gui/painting/qemulationpaintengine_p.h | 48 +++++++++++++++--------------- src/gui/painting/qpaintengine_raster_p.h | 2 +- src/gui/painting/qpdfwriter.h | 12 ++++---- src/gui/painting/qstroker_p.h | 8 ++--- 10 files changed, 73 insertions(+), 73 deletions(-) (limited to 'src') diff --git a/src/gui/image/qbmphandler_p.h b/src/gui/image/qbmphandler_p.h index c4800e3f97..ab164d9f83 100644 --- a/src/gui/image/qbmphandler_p.h +++ b/src/gui/image/qbmphandler_p.h @@ -93,17 +93,17 @@ public: }; explicit QBmpHandler(InternalFormat fmt = BmpFormat); - bool canRead() const; - bool read(QImage *image); - bool write(const QImage &image); + bool canRead() const override; + bool read(QImage *image) override; + bool write(const QImage &image) override; - QByteArray name() const; + QByteArray name() const override; static bool canRead(QIODevice *device); - QVariant option(ImageOption option) const; - void setOption(ImageOption option, const QVariant &value); - bool supportsOption(ImageOption option) const; + QVariant option(ImageOption option) const override; + void setOption(ImageOption option, const QVariant &value) override; + bool supportsOption(ImageOption option) const override; private: bool readHeader(); diff --git a/src/gui/image/qpnghandler_p.h b/src/gui/image/qpnghandler_p.h index fb5a830baa..00f9fa5921 100644 --- a/src/gui/image/qpnghandler_p.h +++ b/src/gui/image/qpnghandler_p.h @@ -64,15 +64,15 @@ public: QPngHandler(); ~QPngHandler(); - bool canRead() const; - bool read(QImage *image); - bool write(const QImage &image); + bool canRead() const override; + bool read(QImage *image) override; + bool write(const QImage &image) override; - QByteArray name() const; + QByteArray name() const override; - QVariant option(ImageOption option) const; - void setOption(ImageOption option, const QVariant &value); - bool supportsOption(ImageOption option) const; + QVariant option(ImageOption option) const override; + void setOption(ImageOption option, const QVariant &value) override; + bool supportsOption(ImageOption option) const override; static bool canRead(QIODevice *device); diff --git a/src/gui/image/qppmhandler_p.h b/src/gui/image/qppmhandler_p.h index 1e8ca2b81e..e790aafdcd 100644 --- a/src/gui/image/qppmhandler_p.h +++ b/src/gui/image/qppmhandler_p.h @@ -62,17 +62,17 @@ class QPpmHandler : public QImageIOHandler { public: QPpmHandler(); - bool canRead() const; - bool read(QImage *image); - bool write(const QImage &image); + bool canRead() const override; + bool read(QImage *image) override; + bool write(const QImage &image) override; - QByteArray name() const; + QByteArray name() const override; static bool canRead(QIODevice *device, QByteArray *subType = 0); - QVariant option(ImageOption option) const; - void setOption(ImageOption option, const QVariant &value); - bool supportsOption(ImageOption option) const; + QVariant option(ImageOption option) const override; + void setOption(ImageOption option, const QVariant &value) override; + bool supportsOption(ImageOption option) const override; private: bool readHeader(); diff --git a/src/gui/image/qxbmhandler_p.h b/src/gui/image/qxbmhandler_p.h index 5094a43ef6..8649857255 100644 --- a/src/gui/image/qxbmhandler_p.h +++ b/src/gui/image/qxbmhandler_p.h @@ -61,17 +61,17 @@ class QXbmHandler : public QImageIOHandler { public: QXbmHandler(); - bool canRead() const; - bool read(QImage *image); - bool write(const QImage &image); + bool canRead() const override; + bool read(QImage *image) override; + bool write(const QImage &image) override; - QByteArray name() const; + QByteArray name() const override; static bool canRead(QIODevice *device); - QVariant option(ImageOption option) const; - void setOption(ImageOption option, const QVariant &value); - bool supportsOption(ImageOption option) const; + QVariant option(ImageOption option) const override; + void setOption(ImageOption option, const QVariant &value) override; + bool supportsOption(ImageOption option) const override; private: bool readHeader(); diff --git a/src/gui/image/qxpmhandler_p.h b/src/gui/image/qxpmhandler_p.h index 9a2041be94..a54427e853 100644 --- a/src/gui/image/qxpmhandler_p.h +++ b/src/gui/image/qxpmhandler_p.h @@ -61,17 +61,17 @@ class QXpmHandler : public QImageIOHandler { public: QXpmHandler(); - bool canRead() const; - bool read(QImage *image); - bool write(const QImage &image); + bool canRead() const override; + bool read(QImage *image) override; + bool write(const QImage &image) override; static bool canRead(QIODevice *device); - QByteArray name() const; + QByteArray name() const override; - QVariant option(ImageOption option) const; - void setOption(ImageOption option, const QVariant &value); - bool supportsOption(ImageOption option) const; + QVariant option(ImageOption option) const override; + void setOption(ImageOption option, const QVariant &value) override; + bool supportsOption(ImageOption option) const override; private: bool readHeader(); diff --git a/src/gui/opengl/qopenglpaintdevice.h b/src/gui/opengl/qopenglpaintdevice.h index dffa68c29e..ce639e647e 100644 --- a/src/gui/opengl/qopenglpaintdevice.h +++ b/src/gui/opengl/qopenglpaintdevice.h @@ -61,8 +61,8 @@ public: QOpenGLPaintDevice(int width, int height); virtual ~QOpenGLPaintDevice(); - int devType() const { return QInternal::OpenGL; } - QPaintEngine *paintEngine() const; + int devType() const override { return QInternal::OpenGL; } + QPaintEngine *paintEngine() const override; QOpenGLContext *context() const; QSize size() const; @@ -82,7 +82,7 @@ public: protected: QOpenGLPaintDevice(QOpenGLPaintDevicePrivate &dd); - int metric(QPaintDevice::PaintDeviceMetric metric) const; + int metric(QPaintDevice::PaintDeviceMetric metric) const override; Q_DISABLE_COPY(QOpenGLPaintDevice) QScopedPointer d_ptr; diff --git a/src/gui/painting/qemulationpaintengine_p.h b/src/gui/painting/qemulationpaintengine_p.h index f3cf88af17..df58332479 100644 --- a/src/gui/painting/qemulationpaintengine_p.h +++ b/src/gui/painting/qemulationpaintengine_p.h @@ -61,37 +61,37 @@ class QEmulationPaintEngine : public QPaintEngineEx public: QEmulationPaintEngine(QPaintEngineEx *engine); - virtual bool begin(QPaintDevice *pdev); - virtual bool end(); + bool begin(QPaintDevice *pdev) override; + bool end() override; - virtual Type type() const; - virtual QPainterState *createState(QPainterState *orig) const; + Type type() const override; + QPainterState *createState(QPainterState *orig) const override; - virtual void fill(const QVectorPath &path, const QBrush &brush); - virtual void stroke(const QVectorPath &path, const QPen &pen); - virtual void clip(const QVectorPath &path, Qt::ClipOperation op); + void fill(const QVectorPath &path, const QBrush &brush) override; + void stroke(const QVectorPath &path, const QPen &pen) override; + void clip(const QVectorPath &path, Qt::ClipOperation op) override; - virtual void drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr); - virtual void drawTextItem(const QPointF &p, const QTextItem &textItem); - virtual void drawStaticTextItem(QStaticTextItem *item); - virtual void drawTiledPixmap(const QRectF &r, const QPixmap &pixmap, const QPointF &s); - virtual void drawImage(const QRectF &r, const QImage &pm, const QRectF &sr, Qt::ImageConversionFlags flags); + void drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr) override; + void drawTextItem(const QPointF &p, const QTextItem &textItem) override; + void drawStaticTextItem(QStaticTextItem *item) override; + void drawTiledPixmap(const QRectF &r, const QPixmap &pixmap, const QPointF &s) override; + void drawImage(const QRectF &r, const QImage &pm, const QRectF &sr, Qt::ImageConversionFlags flags) override; - virtual void clipEnabledChanged(); - virtual void penChanged(); - virtual void brushChanged(); - virtual void brushOriginChanged(); - virtual void opacityChanged(); - virtual void compositionModeChanged(); - virtual void renderHintsChanged(); - virtual void transformChanged(); + void clipEnabledChanged() override; + void penChanged() override; + void brushChanged() override; + void brushOriginChanged() override; + void opacityChanged() override; + void compositionModeChanged() override; + void renderHintsChanged() override; + void transformChanged() override; - virtual void setState(QPainterState *s); + void setState(QPainterState *s) override; - virtual void beginNativePainting(); - virtual void endNativePainting(); + void beginNativePainting() override; + void endNativePainting() override; - virtual uint flags() const {return QPaintEngineEx::IsEmulationEngine | QPaintEngineEx::DoNotEmulate;} + uint flags() const override { return QPaintEngineEx::IsEmulationEngine | QPaintEngineEx::DoNotEmulate; } inline QPainterState *state() { return (QPainterState *)QPaintEngine::state; } inline const QPainterState *state() const { return (const QPainterState *)QPaintEngine::state; } diff --git a/src/gui/painting/qpaintengine_raster_p.h b/src/gui/painting/qpaintengine_raster_p.h index 1afb119535..2a213fa238 100644 --- a/src/gui/painting/qpaintengine_raster_p.h +++ b/src/gui/painting/qpaintengine_raster_p.h @@ -286,7 +286,7 @@ public: void rasterize(QT_FT_Outline *outline, ProcessSpans callback, void *userData, QRasterBuffer *rasterBuffer); void updateMatrixData(QSpanData *spanData, const QBrush &brush, const QTransform &brushMatrix); - void systemStateChanged(); + void systemStateChanged() override; void drawImage(const QPointF &pt, const QImage &img, SrcOverBlendFunc func, const QRect &clip, int alpha, const QRect &sr = QRect()); diff --git a/src/gui/painting/qpdfwriter.h b/src/gui/painting/qpdfwriter.h index cf1da95bf1..c36f3c7a91 100644 --- a/src/gui/painting/qpdfwriter.h +++ b/src/gui/painting/qpdfwriter.h @@ -67,7 +67,7 @@ public: QString creator() const; void setCreator(const QString &creator); - bool newPage(); + bool newPage() override; void setResolution(int resolution); int resolution() const; @@ -83,14 +83,14 @@ public: using QPagedPaintDevice::setPageSize; #endif - void setPageSize(PageSize size); - void setPageSizeMM(const QSizeF &size); + void setPageSize(PageSize size) override; + void setPageSizeMM(const QSizeF &size) override; - void setMargins(const Margins &m); + void setMargins(const Margins &m) override; protected: - QPaintEngine *paintEngine() const; - int metric(PaintDeviceMetric id) const; + QPaintEngine *paintEngine() const override; + int metric(PaintDeviceMetric id) const override; private: Q_DISABLE_COPY(QPdfWriter) diff --git a/src/gui/painting/qstroker_p.h b/src/gui/painting/qstroker_p.h index e17e68b237..ac30f5b5e8 100644 --- a/src/gui/painting/qstroker_p.h +++ b/src/gui/painting/qstroker_p.h @@ -233,7 +233,7 @@ protected: static Qt::PenJoinStyle joinForJoinMode(LineJoinMode mode); static LineJoinMode joinModeForJoin(Qt::PenJoinStyle joinStyle); - virtual void processCurrentSubpath(); + void processCurrentSubpath() override; qfixed m_strokeWidth; qfixed m_miterLimit; @@ -264,14 +264,14 @@ public: void setDashOffset(qreal offset) { m_dashOffset = offset; } qreal dashOffset() const { return m_dashOffset; } - virtual void begin(void *data); - virtual void end(); + void begin(void *data) override; + void end() override; inline void setStrokeWidth(qreal width) { m_stroke_width = width; } inline void setMiterLimit(qreal limit) { m_miter_limit = limit; } protected: - virtual void processCurrentSubpath(); + void processCurrentSubpath() override; QStroker *m_stroker; QVector m_dashPattern; -- cgit v1.2.3 From 534c1ce76d499c680b1b5163346064e8b2bc4617 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 23 Nov 2016 17:38:05 -0800 Subject: Remove unnecessary warning disabling Qt 5.7 cannot be compiled in C++03 mode anymore. Change-Id: Iaeecaffe26af4535b416fffd1489d808edc3c996 Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/corelib/kernel/qmetatype.h | 5 ----- 1 file changed, 5 deletions(-) (limited to 'src') diff --git a/src/corelib/kernel/qmetatype.h b/src/corelib/kernel/qmetatype.h index b68dbacbd3..4c3435be53 100644 --- a/src/corelib/kernel/qmetatype.h +++ b/src/corelib/kernel/qmetatype.h @@ -1390,10 +1390,6 @@ namespace QtPrivate }; -QT_WARNING_PUSH -// In C++03 mode, clang consider local or unnamed type and throw a warning instead of ignoring them -QT_WARNING_DISABLE_CLANG("-Wunnamed-type-template-args") -QT_WARNING_DISABLE_CLANG("-Wlocal-type-template-args") template char qt_getEnumMetaObject(const T&); template @@ -1406,7 +1402,6 @@ QT_WARNING_DISABLE_CLANG("-Wlocal-type-template-args") enum { Value = sizeof(qt_getEnumMetaObject(declval())) == sizeof(QMetaObject*) }; }; template<> struct IsQEnumHelper { enum { Value = false }; }; -QT_WARNING_POP template struct MetaObjectForType -- cgit v1.2.3 From 1710947fde5b65cf27d274624459f17cda1f4700 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Tue, 29 Nov 2016 10:02:44 +0100 Subject: QMutex: small doc fixes Add parentheses after function names, replace is different -> differs Change-Id: I6332db1d1650ed8d8320c5f20cd79d0bf1870e27 Reviewed-by: Mitch Curtis --- src/corelib/thread/qmutex.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/corelib/thread/qmutex.cpp b/src/corelib/thread/qmutex.cpp index 0aee4aeda4..653c3efe1c 100644 --- a/src/corelib/thread/qmutex.cpp +++ b/src/corelib/thread/qmutex.cpp @@ -279,7 +279,7 @@ bool QMutex::tryLock(int timeout) QT_MUTEX_LOCK_NOEXCEPT for the mutex to become available. Note: Passing a negative duration as the \a duration is equivalent to - calling try_lock(). This behavior is different from tryLock. + calling try_lock(). This behavior differs from tryLock(). If the lock was obtained, the mutex must be unlocked with unlock() before another thread can successfully lock it. @@ -303,7 +303,7 @@ bool QMutex::tryLock(int timeout) QT_MUTEX_LOCK_NOEXCEPT for the mutex to become available. Note: Passing a \a timePoint which has already passed is equivalent - to calling try_lock. This behavior is different from tryLock. + to calling try_lock(). This behavior differs from tryLock(). If the lock was obtained, the mutex must be unlocked with unlock() before another thread can successfully lock it. -- cgit v1.2.3 From feb95effc4a694426acadc84364a938098186df7 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Tue, 29 Nov 2016 16:43:44 +0100 Subject: QDeadlineTimer: fix namespace for chrono literals in examples Change-Id: I6d39b4fe653cf89d2bd27af4b3f606d98ac83eba Reviewed-by: Thiago Macieira --- src/corelib/kernel/qdeadlinetimer.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/corelib/kernel/qdeadlinetimer.cpp b/src/corelib/kernel/qdeadlinetimer.cpp index d670637d53..1f554c9f2e 100644 --- a/src/corelib/kernel/qdeadlinetimer.cpp +++ b/src/corelib/kernel/qdeadlinetimer.cpp @@ -122,6 +122,7 @@ Q_DECL_CONST_FUNCTION static inline QPair toSecsAndNSecs(qint64 \code using namespace std::chrono; + using namespace std::chrono_literals; QDeadlineTimer deadline(30s); device->waitForReadyRead(deadline); @@ -141,6 +142,7 @@ Q_DECL_CONST_FUNCTION static inline QPair toSecsAndNSecs(qint64 \code using namespace std::chrono; + using namespace std::chrono_literals; auto now = steady_clock::now(); QDeadlineTimer deadline(now + 1s); Q_ASSERT(deadline == now + 1s); @@ -240,7 +242,7 @@ QDeadlineTimer::QDeadlineTimer(qint64 msecs, Qt::TimerType type) Q_DECL_NOTHROW This constructor can be used with C++14's user-defined literals for time, such as in: \code - using namespace std::chrono; + using namespace std::chrono_literals; QDeadlineTimer deadline(250ms); \endcode @@ -333,7 +335,7 @@ void QDeadlineTimer::setPreciseRemainingTime(qint64 secs, qint64 nsecs, Qt::Time This function can be used with C++14's user-defined literals for time, such as in: \code - using namespace std::chrono; + using namespace std::chrono_literals; deadline.setRemainingTime(250ms); \endcode -- cgit v1.2.3 From 448790eaedff47c8a8df9da964b988e309c06182 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 30 Nov 2016 10:07:43 +0100 Subject: Windows QPA: Fix build with MSVC2015 on Windows 7 The installation uses SDK 8.1 which does not have the required include files. Add a check depending on NTDDI_VERSION. Change-Id: I6323496aed2a2d6e22d41ec14bdf8c6cf1bf2f31 Reviewed-by: Konstantin Tokarev Reviewed-by: Maurice Kalinowski --- src/plugins/platforms/windows/qwin10helpers.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/plugins/platforms/windows/qwin10helpers.cpp b/src/plugins/platforms/windows/qwin10helpers.cpp index 3ded96b9d6..977bbfd11b 100644 --- a/src/plugins/platforms/windows/qwin10helpers.cpp +++ b/src/plugins/platforms/windows/qwin10helpers.cpp @@ -44,7 +44,8 @@ #if defined(Q_CC_MINGW) # define HAS_UI_VIEW_SETTINGS_INTEROP -#elif !defined(Q_CC_MSVC) || _MSC_VER >= 1900 // MSVC2013 is lacking both +// Present from MSVC2015 + SDK 10 onwards +#elif (!defined(Q_CC_MSVC) || _MSC_VER >= 1900) && NTDDI_VERSION >= 0xa000000 # define HAS_UI_VIEW_SETTINGS_INTEROP # define HAS_UI_VIEW_SETTINGS #endif -- cgit v1.2.3 From a55f36211efe1bb0d6717c8545366120bd6dfd9f Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 21 Nov 2016 15:17:03 -0800 Subject: Fix the JPEG EXIF reader to deal with some broken/corrupt files We parse the EXIF header in order to get the proper orientation, so let's be a bit more careful in what we accept. This patch adds better handling for reading past the end of the stream, plus it limits the number of IFDs read (to avoid processing too much data) and deals with a pathological case of the EXIF file format: EXIF (due to its TIFF origins) permits the offset to the next IFD to be backwards in the file, which means it could result in a loop or pointing to plain corrupt data. We disallow any backwards pointers, since it seems that's what other decoders do (libexif, for example). Change-Id: Iaeecaffe26af4535b416fffd1489332db92e3888 (cherry picked from 5.6 commit 02150649f95b8f46f826e6e002be3fa0b6d009bc) Reviewed-by: Allan Sandfeld Jensen --- src/gui/image/qjpeghandler.cpp | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/gui/image/qjpeghandler.cpp b/src/gui/image/qjpeghandler.cpp index 52e8b39f11..f3ba303d62 100644 --- a/src/gui/image/qjpeghandler.cpp +++ b/src/gui/image/qjpeghandler.cpp @@ -786,6 +786,10 @@ static bool readExifHeader(QDataStream &stream) */ static int getExifOrientation(QByteArray &exifData) { + // Current EXIF version (2.3) says there can be at most 5 IFDs, + // byte we allow for 10 so we're able to deal with future extensions. + const int maxIfdCount = 10; + QDataStream stream(&exifData, QIODevice::ReadOnly); if (!readExifHeader(stream)) @@ -793,7 +797,8 @@ static int getExifOrientation(QByteArray &exifData) quint16 val; quint32 offset; - const qint64 headerStart = stream.device()->pos(); + const qint64 headerStart = 6; // the EXIF header has a constant size + Q_ASSERT(headerStart == stream.device()->pos()); // read byte order marker stream >> val; @@ -804,7 +809,7 @@ static int getExifOrientation(QByteArray &exifData) else return -1; // unknown byte order - // read size + // confirm byte order stream >> val; if (val != 0x2a) return -1; @@ -812,18 +817,22 @@ static int getExifOrientation(QByteArray &exifData) stream >> offset; // read IFD - while (!stream.atEnd()) { + for (int n = 0; n < maxIfdCount; ++n) { quint16 numEntries; - // skip offset bytes to get the next IFD const qint64 bytesToSkip = offset - (stream.device()->pos() - headerStart); - - if (stream.skipRawData(bytesToSkip) != bytesToSkip) + if (bytesToSkip < 0 || (offset + headerStart >= exifData.size())) { + // disallow going backwards, though it's permitted in the spec return -1; + } else if (bytesToSkip != 0) { + // seek to the IFD + if (!stream.device()->seek(offset + headerStart)) + return -1; + } stream >> numEntries; - for (; numEntries > 0; --numEntries) { + for (; numEntries > 0 && stream.status() == QDataStream::Ok; --numEntries) { quint16 tag; quint16 type; quint32 components; @@ -847,12 +856,14 @@ static int getExifOrientation(QByteArray &exifData) // read offset to next IFD stream >> offset; + if (stream.status() != QDataStream::Ok) + return -1; if (offset == 0) // this is the last IFD - break; + return 0; // No Exif orientation was found } - // No Exif orientation was found - return 0; + // too many IFDs + return -1; } static QImageIOHandler::Transformations exif2Qt(int exifOrientation) -- cgit v1.2.3 From 048447346bc1b78992be3ce4bf3292fc272f7e1a Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 8 Sep 2016 10:10:12 +0200 Subject: QPointerUniqueId: make fit for release - Declare as Q_MOVABLE_TYPE - Prevent QList from being instantiated (use QVector instead) - Add equality relational operators - Add qHash() overload - Replace non-default ctor with named ctor. - Add Q_DECL_NOTHROW. - Add Q_DECL_CONSTEXPR. - Rename numeric() -> numericId(). - Update docs. The extension vector for this class calls for additional properties to be added later, but these are not user- settable. It thus suffices to rely on the only data member, a qint64, which can be reinterpreted to an index into an array or hash with actual objects. This allows to make the class a Trivial Type (ie. no overhead over an int) while still supporting later extension. Cf. QSslEllipticCurve as another example of such a class. The extension has to maintain the following invariants, encoded into user code by way of being used in inline functions: - m_numericId == -1 <=> !isValid() This is trivial to support. An extension could not and still cannot reinterpret the qint64 member as a d-pointer, but a d-pointer is only necessary for user-settable properties where updating a central private data structure would cause too much contention. Add a test. Since this type is used in other modules, keep the existing functions, but mark them as deprecated with the expectation that these compat functions be removed before 5.8.0 final. Task-number: QTBUG-54616 Change-Id: Ia3ede0ecaeeef4cd3ffa94a72b1050bd409713a5 Reviewed-by: Shawn Rutledge --- src/gui/kernel/qevent.cpp | 82 +++++++++++++++++++++++++++++++++++++++++------ src/gui/kernel/qevent.h | 36 +++++++++++++++++---- 2 files changed, 103 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp index 254b8926c8..72cd374419 100644 --- a/src/gui/kernel/qevent.cpp +++ b/src/gui/kernel/qevent.cpp @@ -44,6 +44,7 @@ #include "qpa/qplatformdrag.h" #include "private/qevent_p.h" #include "qfile.h" +#include "qhashfunctions.h" #include "qmetaobject.h" #include "qmimedata.h" #include "private/qdnd_p.h" @@ -4474,7 +4475,7 @@ int QTouchEvent::TouchPoint::id() const \since 5.8 Returns the unique ID of this touch point or token, if any. - It is normally invalid (with a \l {QPointerUniqueId::numeric()} {numeric()} value of -1), + It is normally invalid (see \l {QPointerUniqueId::isValid()} {isValid()}), because touchscreens cannot uniquely identify fingers. But when the \l {TouchPoint::InfoFlag} {Token} flag is set, it is expected to uniquely identify a specific token (fiducial object). @@ -4757,7 +4758,7 @@ void QTouchEvent::TouchPoint::setUniqueId(qint64 uid) { if (d->ref.load() != 1) d = d->detach(); - d->uniqueId = QPointerUniqueId(uid); + d->uniqueId = QPointerUniqueId::fromNumericId(uid); } /*! \internal */ @@ -5184,28 +5185,91 @@ Qt::ApplicationState QApplicationStateChangeEvent::applicationState() const \brief QPointerUniqueId identifies a unique object, such as a tagged token or stylus, which is used with a pointing device. + QPointerUniqueIds can be compared for equality, and can be used as keys in a QHash. + You get access to the numerical ID via numericId(), if the device supports such IDs. + For future extensions, though, you should not use that function, but compare objects + of this type using the equality operator. + + This class is a thin wrapper around an integer ID. You pass it into and out of + functions by value. + + This type actively prevents you from holding it in a QList, because doing so would + be very inefficient. Use a QVector instead, which has the same API as QList, but more + efficient storage. + \sa QTouchEvent::TouchPoint */ /*! - Constructs a unique pointer ID with a numeric \a id provided by the hardware. - The default is -1, which means an invalid pointer ID. + \fn QPointerUniqueId::QPointerUniqueId() + Constructs an invalid unique pointer ID. +*/ + +/*! + Constructs a unique pointer ID from numeric ID \a id. */ -QPointerUniqueId::QPointerUniqueId(qint64 id) - : m_numericId(id) +QPointerUniqueId QPointerUniqueId::fromNumericId(qint64 id) { + QPointerUniqueId result; + result.m_numericId = id; + return result; } /*! - \property QPointerUniqueId::numeric + \fn bool QPointerUniqueId::isValid() + + Returns whether this unique pointer ID is valid, that is, it represents an actual + pointer. +*/ + +/*! + \property QPointerUniqueId::numericId \brief the numeric unique ID of the token represented by a touchpoint - This is the numeric unique ID if the device provides that type of ID; + If the device provides a numeric ID, isValid() returns true, and this + property provides the numeric ID; otherwise it is -1. + + You should not use the value of this property in portable code, but + instead rely on equality to identify pointers. + + \sa isValid() */ -qint64 QPointerUniqueId::numeric() const +qint64 QPointerUniqueId::numericId() const Q_DECL_NOTHROW { return m_numericId; } +/*! + \relates QPointerUniqueId + \since 5.8 + + Returns whether the two unique pointer IDs \a lhs and \a rhs identify the same pointer + (\c true) or not (\c false). +*/ +bool operator==(QPointerUniqueId lhs, QPointerUniqueId rhs) Q_DECL_NOTHROW +{ + return lhs.numericId() == rhs.numericId(); +} + +/*! + \fn bool operator!=(QPointerUniqueId lhs, QPointerUniqueId rhs) + \relates QPointerUniqueId + \since 5.8 + + Returns whether the two unique pointer IDs \a lhs and \a rhs identify different pointers + (\c true) or not (\c false). +*/ + +/*! + \relates QPointerUniqueId + \since 5.8 + + Returns the hash value for \a key, using \a seed to seed the calculation. +*/ +uint qHash(QPointerUniqueId key, uint seed) Q_DECL_NOTHROW +{ + return qHash(key.numericId(), seed); +} + QT_END_NAMESPACE diff --git a/src/gui/kernel/qevent.h b/src/gui/kernel/qevent.h index a062331bd8..b7c0f3338e 100644 --- a/src/gui/kernel/qevent.h +++ b/src/gui/kernel/qevent.h @@ -793,21 +793,45 @@ inline bool operator==(QKeyEvent *e, QKeySequence::StandardKey key){return (e ? inline bool operator==(QKeySequence::StandardKey key, QKeyEvent *e){return (e ? e->matches(key) : false);} #endif // QT_NO_SHORTCUT -class QPointerUniqueIdPrivate; class Q_GUI_EXPORT QPointerUniqueId { Q_GADGET - Q_PROPERTY(qint64 numeric READ numeric CONSTANT) + // ### kept these to keep other modules compiling. Remove before 5.8.0 final! +#if QT_DEPRECATED_SINCE(5, 8) + Q_PROPERTY(qint64 numeric READ numericId CONSTANT) +#endif + Q_PROPERTY(qint64 numericId READ numericId CONSTANT) public: - explicit QPointerUniqueId(qint64 id = -1); + Q_ALWAYS_INLINE + Q_DECL_CONSTEXPR QPointerUniqueId() Q_DECL_NOTHROW : m_numericId(-1) {} + // compiler-generated copy/move ctor/assignment operators are ok! + // compiler-generated dtor is ok! + + static QPointerUniqueId fromNumericId(qint64 id); - qint64 numeric() const; + Q_ALWAYS_INLINE Q_DECL_CONSTEXPR bool isValid() const Q_DECL_NOTHROW { return m_numericId != -1; } + qint64 numericId() const Q_DECL_NOTHROW; + // ### kept these to keep other modules compiling. Remove before 5.8.0 final! +#if QT_DEPRECATED_SINCE(5, 8) + Q_ALWAYS_INLINE Q_DECL_DEPRECATED qint64 numeric() const { return numericId(); } + Q_ALWAYS_INLINE Q_DECL_DEPRECATED explicit QPointerUniqueId(qint64 id) : m_numericId(id) {} +#endif private: - // TODO for TUIO 2, or any other type of complex token ID, a d-pointer can replace - // m_numericId without changing the size of this class. + // TODO: for TUIO 2, or any other type of complex token ID, an internal + // array (or hash) can be added to hold additional properties. + // In this case, m_numericId will then turn into an index into that array (or hash). qint64 m_numericId; }; +Q_DECLARE_TYPEINFO(QPointerUniqueId, Q_MOVABLE_TYPE); +template <> class QList {}; // to prevent instantiation: use QVector instead + +Q_GUI_EXPORT bool operator==(QPointerUniqueId lhs, QPointerUniqueId rhs) Q_DECL_NOTHROW; +inline bool operator!=(QPointerUniqueId lhs, QPointerUniqueId rhs) Q_DECL_NOTHROW +{ return !operator==(lhs, rhs); } +Q_GUI_EXPORT uint qHash(QPointerUniqueId key, uint seed = 0) Q_DECL_NOTHROW; + + class QTouchEventTouchPointPrivate; class Q_GUI_EXPORT QTouchEvent : public QInputEvent -- cgit v1.2.3 From 32a7efe22527d6c1fccd8f9a2b817e4ed4b0168c Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 2 Dec 2016 21:24:44 -0800 Subject: Fix the warning number for ICC deprecated warnings That's what happens when you don't test and just rely on an the warning listing. ICC has two warning numbers for deprecated warnings: one that matches Q_DECL_DEPRECATED and one for Q_DECL_DEPRECATED_X. Change-Id: I73fa1e59a4844c43a109fffd148ca7a05eda8f13 Reviewed-by: Marc Mutz --- src/corelib/global/qcompilerdetection.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/corelib/global/qcompilerdetection.h b/src/corelib/global/qcompilerdetection.h index d978c141a4..4142c17b42 100644 --- a/src/corelib/global/qcompilerdetection.h +++ b/src/corelib/global/qcompilerdetection.h @@ -1273,7 +1273,7 @@ # define QT_WARNING_DISABLE_INTEL(number) __pragma(warning(disable: number)) # define QT_WARNING_DISABLE_CLANG(text) # define QT_WARNING_DISABLE_GCC(text) -# define QT_WARNING_DISABLE_DEPRECATED QT_WARNING_DISABLE_INTEL(1786) +# define QT_WARNING_DISABLE_DEPRECATED QT_WARNING_DISABLE_INTEL(1478 1786) #elif defined(Q_CC_INTEL) /* icc: Intel compiler on Linux or OS X */ # define QT_WARNING_PUSH QT_DO_PRAGMA(warning(push)) @@ -1282,7 +1282,7 @@ # define QT_WARNING_DISABLE_MSVC(number) # define QT_WARNING_DISABLE_CLANG(text) # define QT_WARNING_DISABLE_GCC(text) -# define QT_WARNING_DISABLE_DEPRECATED QT_WARNING_DISABLE_INTEL(1786) +# define QT_WARNING_DISABLE_DEPRECATED QT_WARNING_DISABLE_INTEL(1478 1786) #elif defined(Q_CC_MSVC) && _MSC_VER >= 1500 && !defined(Q_CC_CLANG) # undef QT_DO_PRAGMA /* not needed */ # define QT_WARNING_PUSH __pragma(warning(push)) -- cgit v1.2.3 From 6ae9dc3f379728a1aaee818a169c03954d6a445c Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 2 Dec 2016 20:24:11 -0800 Subject: Work around ICC compiler bug on template instantiation on ?: It doesn't like the access to the template instantiation in the ternary operator. error: operand types are incompatible ("FetchPixelFunc" and "") Intel-Issue-ID: 6000164201 Change-Id: I73fa1e59a4844c43a109fffd148ca452796eebb1 Reviewed-by: Allan Sandfeld Jensen Reviewed-by: Marc Mutz --- src/gui/painting/qdrawhelper.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp index 656b04fdf3..e1875d84b9 100644 --- a/src/gui/painting/qdrawhelper.cpp +++ b/src/gui/painting/qdrawhelper.cpp @@ -1572,7 +1572,7 @@ static const uint *QT_FASTCALL fetchTransformed(uint *buffer, const Operator *, if (bpp != QPixelLayout::BPPNone) // Like this to not ICE on GCC 5.3.1 Q_ASSERT(layout->bpp == bpp); // When templated 'fetch' should be inlined at compile time: - const FetchPixelFunc fetch = (bpp == QPixelLayout::BPPNone) ? qFetchPixel[layout->bpp] : fetchPixel; + const FetchPixelFunc fetch = (bpp == QPixelLayout::BPPNone) ? qFetchPixel[layout->bpp] : FetchPixelFunc(fetchPixel); uint *const end = buffer + length; uint *b = buffer; @@ -2519,8 +2519,8 @@ static const uint *QT_FASTCALL fetchTransformedBilinear(uint *buffer, const Oper if (bpp != QPixelLayout::BPPNone) // Like this to not ICE on GCC 5.3.1 Q_ASSERT(layout->bpp == bpp); // When templated 'fetch' should be inlined at compile time: - const FetchPixelsFunc fetch = (bpp == QPixelLayout::BPPNone) ? qFetchPixels[layout->bpp] : fetchPixels; - const FetchPixelFunc fetch1 = (bpp == QPixelLayout::BPPNone) ? qFetchPixel[layout->bpp] : fetchPixel; + const FetchPixelsFunc fetch = (bpp == QPixelLayout::BPPNone) ? qFetchPixels[layout->bpp] : FetchPixelsFunc(fetchPixels); + const FetchPixelFunc fetch1 = (bpp == QPixelLayout::BPPNone) ? qFetchPixel[layout->bpp] : FetchPixelFunc(fetchPixel); int image_width = data->texture.width; int image_height = data->texture.height; -- cgit v1.2.3 From 4f959b6b3004ecbd0d34b34f613ce9980ba42b55 Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov Date: Mon, 28 Nov 2016 16:02:26 +0100 Subject: ~QHttpNetworkConnectionPrivate - disconnect from socket's signals We have a 'channel' object connected to a socket with Qt::DirectConnection. QHttpNetworkConnectionPrivate in its dtor (note, it's a private object destroyed after its 'q' - QHttpNetworkConnection - was destroyed) calls socket->close() and this can end up in socket setting an error and emitting (for example, in QSslSocket::transmit). The slot (QHttpNetworkConnectionChannel::_q_error) will access the now-dead/non-existing connection then. So disconnect the channel from the socket early, before closing the socket. Task-number: QTBUG-54167 Change-Id: I3ed4ba4b00650c3a39e5c1f33aa786e47bfbbc57 Reviewed-by: Konstantin Tokarev Reviewed-by: Timur Pocheptsov Reviewed-by: Edward Welbourne Reviewed-by: Marc Mutz --- src/network/access/qhttpnetworkconnection.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/network/access/qhttpnetworkconnection.cpp b/src/network/access/qhttpnetworkconnection.cpp index 7f07403a73..1b1ecff21e 100644 --- a/src/network/access/qhttpnetworkconnection.cpp +++ b/src/network/access/qhttpnetworkconnection.cpp @@ -116,6 +116,7 @@ QHttpNetworkConnectionPrivate::~QHttpNetworkConnectionPrivate() { for (int i = 0; i < channelCount; ++i) { if (channels[i].socket) { + QObject::disconnect(channels[i].socket, Q_NULLPTR, &channels[i], Q_NULLPTR); channels[i].socket->close(); delete channels[i].socket; } -- cgit v1.2.3 From 14ea8759da0d5eb1888664a5b0d08c2bf142a6a2 Mon Sep 17 00:00:00 2001 From: Oliver Wolff Date: Wed, 30 Nov 2016 15:32:02 +0100 Subject: winrt: Change the way tcp packets are handled Similar to the way datagrams are handled for udp sockets the worker now takes care of tcp data. Thus we avoid race conditions which stopped data processing. It could happen that data was read from the socket into the buffer and before readyRead was emitted the buffer was completely read. In this case readNotification is set to false and no new data is processed afterwards. Additionally the buffer was replaced by a vector of QByteArray. The buffer kept growing and was never cleared (and there is no obvious way for clearing the buffer), so that an overflow happened eventually. pendingReadOperations (and its mutex) could be removed as well. There is only one situation where they could clash and that's the initial read. Having two members is preferred over having a list of operations and a mutex. Task-number: QTBUG-56438 Change-Id: Idbad58e47785996023748c310530892163f24594 Reviewed-by: Maurice Kalinowski --- src/network/socket/qnativesocketengine_winrt.cpp | 456 ++++++++++++++--------- src/network/socket/qnativesocketengine_winrt_p.h | 16 +- 2 files changed, 280 insertions(+), 192 deletions(-) (limited to 'src') diff --git a/src/network/socket/qnativesocketengine_winrt.cpp b/src/network/socket/qnativesocketengine_winrt.cpp index 8257eec9ea..8b36406c67 100644 --- a/src/network/socket/qnativesocketengine_winrt.cpp +++ b/src/network/socket/qnativesocketengine_winrt.cpp @@ -126,6 +126,33 @@ static HRESULT qt_winrt_try_create_thread_network_context(QString host, ComPtr= 1900 +typedef QHash TcpSocketHash; + +struct SocketHandler +{ + SocketHandler() : socketCount(0) {} + qintptr socketCount; + TcpSocketHash pendingTcpSockets; +}; + +Q_GLOBAL_STATIC(SocketHandler, gSocketHandler) + +struct SocketGlobal +{ + SocketGlobal() + { + HRESULT hr; + hr = GetActivationFactory(HString::MakeReference(RuntimeClass_Windows_Storage_Streams_Buffer).Get(), + &bufferFactory); + Q_ASSERT_SUCCEEDED(hr); + } + + ComPtr bufferFactory; +}; +Q_GLOBAL_STATIC(SocketGlobal, g) + +#define READ_BUFFER_SIZE 65536 + static inline QString qt_QStringFromHString(const HString &string) { UINT32 length; @@ -136,8 +163,43 @@ static inline QString qt_QStringFromHString(const HString &string) class SocketEngineWorker : public QObject { Q_OBJECT +public: + SocketEngineWorker(QNativeSocketEnginePrivate *engine) + : enginePrivate(engine) + { + } + + ~SocketEngineWorker() + { + if (Q_UNLIKELY(initialReadOp)) { + ComPtr info; + HRESULT hr = initialReadOp.As(&info); + Q_ASSERT_SUCCEEDED(hr); + if (info) { + hr = info->Cancel(); + Q_ASSERT_SUCCEEDED(hr); + hr = info->Close(); + Q_ASSERT_SUCCEEDED(hr); + } + } + + if (readOp) { + ComPtr info; + HRESULT hr = readOp.As(&info); + Q_ASSERT_SUCCEEDED(hr); + if (info) { + hr = info->Cancel(); + Q_ASSERT_SUCCEEDED(hr); + hr = info->Close(); + Q_ASSERT_SUCCEEDED(hr); + } + } + } + signals: void newDatagramsReceived(const QList &datagram); + void newDataReceived(const QVector &data); + void socketErrorOccured(QAbstractSocket::SocketError error); public slots: Q_INVOKABLE void notifyAboutNewDatagrams() @@ -148,7 +210,30 @@ public slots: emit newDatagramsReceived(datagrams); } + Q_INVOKABLE void notifyAboutNewData() + { + QMutexLocker locker(&mutex); + const QVector newData = std::move(pendingData); + pendingData.clear(); + emit newDataReceived(newData); + } + public: + void startReading() + { + ComPtr buffer; + HRESULT hr = g->bufferFactory->Create(READ_BUFFER_SIZE, &buffer); + Q_ASSERT_SUCCEEDED(hr); + ComPtr stream; + hr = tcpSocket->get_InputStream(&stream); + Q_ASSERT_SUCCEEDED(hr); + hr = stream->ReadAsync(buffer.Get(), READ_BUFFER_SIZE, InputStreamOptions_Partial, initialReadOp.GetAddressOf()); + Q_ASSERT_SUCCEEDED(hr); + enginePrivate->socketState = QAbstractSocket::ConnectedState; + hr = initialReadOp->put_Completed(Callback(this, &SocketEngineWorker::onReadyRead).Get()); + Q_ASSERT_SUCCEEDED(hr); + } + HRESULT OnNewDatagramReceived(IDatagramSocket *, IDatagramSocketMessageReceivedEventArgs *args) { WinRtDatagram datagram; @@ -184,9 +269,127 @@ public: return S_OK; } + HRESULT onReadyRead(IAsyncBufferOperation *asyncInfo, AsyncStatus status) + { + if (asyncInfo == initialReadOp.Get()) { + initialReadOp.Reset(); + } else if (asyncInfo == readOp.Get()) { + readOp.Reset(); + } else { + Q_ASSERT(false); + } + + // A read in UnconnectedState will close the socket and return -1 and thus tell the caller, + // that the connection was closed. The socket cannot be closed here, as the subsequent read + // might fail then. + if (status == Error || status == Canceled) { + emit socketErrorOccured(QAbstractSocket::RemoteHostClosedError); + return S_OK; + } + + ComPtr buffer; + HRESULT hr = asyncInfo->GetResults(&buffer); + if (FAILED(hr)) { + qErrnoWarning(hr, "Failed to get read results buffer"); + emit socketErrorOccured(QAbstractSocket::UnknownSocketError); + return S_OK; + } + + UINT32 bufferLength; + hr = buffer->get_Length(&bufferLength); + if (FAILED(hr)) { + qErrnoWarning(hr, "Failed to get buffer length"); + emit socketErrorOccured(QAbstractSocket::UnknownSocketError); + return S_OK; + } + // A zero sized buffer length signals, that the remote host closed the connection. The socket + // cannot be closed though, as the following read might have socket descriptor -1 and thus and + // the closing of the socket won't be communicated to the caller. So only the error is set. The + // actual socket close happens inside of read. + if (!bufferLength) { + emit socketErrorOccured(QAbstractSocket::RemoteHostClosedError); + return S_OK; + } + + ComPtr byteArrayAccess; + hr = buffer.As(&byteArrayAccess); + if (FAILED(hr)) { + qErrnoWarning(hr, "Failed to get cast buffer"); + emit socketErrorOccured(QAbstractSocket::UnknownSocketError); + return S_OK; + } + byte *data; + hr = byteArrayAccess->Buffer(&data); + if (FAILED(hr)) { + qErrnoWarning(hr, "Failed to access buffer data"); + emit socketErrorOccured(QAbstractSocket::UnknownSocketError); + return S_OK; + } + + QByteArray newData(reinterpret_cast(data), qint64(bufferLength)); + QMutexLocker readLocker(&mutex); + if (pendingData.isEmpty()) + QMetaObject::invokeMethod(this, "notifyAboutNewData", Qt::QueuedConnection); + pendingData << newData; + readLocker.unlock(); + + hr = QEventDispatcherWinRT::runOnXamlThread([buffer, this]() { + UINT32 readBufferLength; + ComPtr stream; + HRESULT hr = tcpSocket->get_InputStream(&stream); + if (FAILED(hr)) { + qErrnoWarning(hr, "Failed to obtain input stream"); + emit socketErrorOccured(QAbstractSocket::UnknownSocketError); + return S_OK; + } + + // Reuse the stream buffer + hr = buffer->get_Capacity(&readBufferLength); + if (FAILED(hr)) { + qErrnoWarning(hr, "Failed to get buffer capacity"); + emit socketErrorOccured(QAbstractSocket::UnknownSocketError); + return S_OK; + } + hr = buffer->put_Length(0); + if (FAILED(hr)) { + qErrnoWarning(hr, "Failed to set buffer length"); + emit socketErrorOccured(QAbstractSocket::UnknownSocketError); + return S_OK; + } + + hr = stream->ReadAsync(buffer.Get(), readBufferLength, InputStreamOptions_Partial, &readOp); + if (FAILED(hr)) { + qErrnoWarning(hr, "onReadyRead(): Could not read into socket stream buffer."); + emit socketErrorOccured(QAbstractSocket::UnknownSocketError); + return S_OK; + } + hr = readOp->put_Completed(Callback(this, &SocketEngineWorker::onReadyRead).Get()); + if (FAILED(hr)) { + qErrnoWarning(hr, "onReadyRead(): Failed to set socket read callback."); + emit socketErrorOccured(QAbstractSocket::UnknownSocketError); + return S_OK; + } + return S_OK; + }); + Q_ASSERT_SUCCEEDED(hr); + return S_OK; + } + + void setTcpSocket(ComPtr socket) { tcpSocket = socket; } + private: + ComPtr tcpSocket; + QList pendingDatagrams; + QVector pendingData; + + // Protects pendingData/pendingDatagrams which are accessed from native callbacks QMutex mutex; + + ComPtr> initialReadOp; + ComPtr> readOp; + + QNativeSocketEnginePrivate *enginePrivate; }; static QByteArray socketDescription(const QAbstractSocketEngine *s) @@ -239,33 +442,6 @@ static QByteArray socketDescription(const QAbstractSocketEngine *s) } } while (0) #define Q_TR(a) QT_TRANSLATE_NOOP(QNativeSocketEngine, a) -typedef QHash TcpSocketHash; - -struct SocketHandler -{ - SocketHandler() : socketCount(0) {} - qintptr socketCount; - TcpSocketHash pendingTcpSockets; -}; - -Q_GLOBAL_STATIC(SocketHandler, gSocketHandler) - -struct SocketGlobal -{ - SocketGlobal() - { - HRESULT hr; - hr = GetActivationFactory(HString::MakeReference(RuntimeClass_Windows_Storage_Streams_Buffer).Get(), - &bufferFactory); - Q_ASSERT_SUCCEEDED(hr); - } - - ComPtr bufferFactory; -}; -Q_GLOBAL_STATIC(SocketGlobal, g) - -#define READ_BUFFER_SIZE 65536 - template static AsyncStatus opStatus(const ComPtr &op) { @@ -315,6 +491,10 @@ QNativeSocketEngine::QNativeSocketEngine(QObject *parent) connect(this, SIGNAL(readReady()), SLOT(readNotification()), Qt::QueuedConnection); connect(this, SIGNAL(writeReady()), SLOT(writeNotification()), Qt::QueuedConnection); connect(d->worker, &SocketEngineWorker::newDatagramsReceived, this, &QNativeSocketEngine::handleNewDatagrams, Qt::QueuedConnection); + connect(d->worker, &SocketEngineWorker::newDataReceived, + this, &QNativeSocketEngine::handleNewData, Qt::QueuedConnection); + connect(d->worker, &SocketEngineWorker::socketErrorOccured, + this, &QNativeSocketEngine::handleTcpError, Qt::QueuedConnection); } QNativeSocketEngine::~QNativeSocketEngine() @@ -358,23 +538,9 @@ bool QNativeSocketEngine::initialize(qintptr socketDescriptor, QAbstractSocket:: // Start processing incoming data if (d->socketType == QAbstractSocket::TcpSocket) { - HRESULT hr = QEventDispatcherWinRT::runOnXamlThread([d, socket, socketState, this]() { - ComPtr buffer; - HRESULT hr = g->bufferFactory->Create(READ_BUFFER_SIZE, &buffer); - RETURN_HR_IF_FAILED("initialize(): Could not create buffer"); - ComPtr stream; - hr = socket->get_InputStream(&stream); - RETURN_HR_IF_FAILED("initialize(): Could not obtain input stream"); - ComPtr readOp; - hr = stream->ReadAsync(buffer.Get(), READ_BUFFER_SIZE, InputStreamOptions_Partial, readOp.GetAddressOf()); - RETURN_HR_IF_FAILED_WITH_ARGS("initialize(): Failed to read from the socket buffer (%s).", - socketDescription(this).constData()); - QMutexLocker locker(&d->readOperationsMutex); - d->pendingReadOps.append(readOp); - d->socketState = socketState; - hr = readOp->put_Completed(Callback(d, &QNativeSocketEnginePrivate::handleReadyRead).Get()); - RETURN_HR_IF_FAILED_WITH_ARGS("initialize(): Failed to set socket read callback (%s).", - socketDescription(this).constData()); + HRESULT hr = QEventDispatcherWinRT::runOnXamlThread([d, socket, this]() { + d->worker->setTcpSocket(socket); + d->worker->startReading(); return S_OK; }); if (FAILED(hr)) @@ -639,20 +805,6 @@ void QNativeSocketEngine::close() } #endif // _MSC_VER >= 1900 - QMutexLocker locker(&d->readOperationsMutex); - for (ComPtr readOp : d->pendingReadOps) { - ComPtr info; - hr = readOp.As(&info); - Q_ASSERT_SUCCEEDED(hr); - if (info) { - hr = info->Cancel(); - Q_ASSERT_SUCCEEDED(hr); - hr = info->Close(); - Q_ASSERT_SUCCEEDED(hr); - } - } - locker.unlock(); - if (d->socketDescriptor != -1) { ComPtr socket; if (d->socketType == QAbstractSocket::TcpSocket) { @@ -730,14 +882,32 @@ qint64 QNativeSocketEngine::read(char *data, qint64 maxlen) // happens and there isn't anything left in the buffer, we have to return -1 in order to signal // the closing of the socket. QMutexLocker mutexLocker(&d->readMutex); - if (d->readBytes.pos() == d->readBytes.size() && d->socketState != QAbstractSocket::ConnectedState) { + if (d->pendingData.isEmpty() && d->socketState != QAbstractSocket::ConnectedState) { close(); return -1; } - qint64 b = d->readBytes.read(data, maxlen); - d->bytesAvailable = d->readBytes.size() - d->readBytes.pos(); - return b; + QByteArray readData; + qint64 leftToMaxLen = maxlen; + while (leftToMaxLen > 0 && !d->pendingData.isEmpty()) { + QByteArray pendingData = d->pendingData.takeFirst(); + // Do not read the whole data. Put the rest of it back into the "queue" + if (leftToMaxLen < pendingData.length()) { + readData += pendingData.left(leftToMaxLen); + pendingData = pendingData.remove(0, maxlen); + d->pendingData.prepend(pendingData); + break; + } else { + readData += pendingData; + leftToMaxLen -= pendingData.length(); + } + } + const int copyLength = qMin(maxlen, qint64(readData.length())); + d->bytesAvailable -= copyLength; + mutexLocker.unlock(); + + memcpy(data, readData, copyLength); + return copyLength; } qint64 QNativeSocketEngine::write(const char *data, qint64 len) @@ -913,7 +1083,7 @@ bool QNativeSocketEngine::waitForRead(int msecs, bool *timedOut) // If we are a client, we are ready to read if our buffer has data QMutexLocker locker(&d->readMutex); - if (!d->readBytes.atEnd()) + if (!d->pendingData.isEmpty()) return true; // Nothing to do, wait for more events @@ -1001,21 +1171,8 @@ void QNativeSocketEngine::establishRead() HRESULT hr; hr = QEventDispatcherWinRT::runOnXamlThread([d]() { - ComPtr stream; - HRESULT hr = d->tcpSocket()->get_InputStream(&stream); - RETURN_HR_IF_FAILED("establishRead(): Failed to get socket input stream"); - - ComPtr buffer; - hr = g->bufferFactory->Create(READ_BUFFER_SIZE, &buffer); - RETURN_HR_IF_FAILED("establishRead(): Failed to create buffer"); - - ComPtr readOp; - hr = stream->ReadAsync(buffer.Get(), READ_BUFFER_SIZE, InputStreamOptions_Partial, readOp.GetAddressOf()); - RETURN_HR_IF_FAILED("establishRead(): Failed to initiate socket read"); - QMutexLocker locker(&d->readOperationsMutex); - d->pendingReadOps.append(readOp); - hr = readOp->put_Completed(Callback(d, &QNativeSocketEnginePrivate::handleReadyRead).Get()); - RETURN_HR_IF_FAILED("establishRead(): Failed to register read callback"); + d->worker->setTcpSocket(d->tcpSocket()); + d->worker->startReading(); return S_OK; }); Q_ASSERT_SUCCEEDED(hr); @@ -1032,6 +1189,32 @@ void QNativeSocketEngine::handleNewDatagrams(const QList &datagra emit readReady(); } +void QNativeSocketEngine::handleNewData(const QVector &data) +{ + // Defer putting the data into the list until the next event loop iteration + // (where the readyRead signal is emitted as well) + QMetaObject::invokeMethod(this, "putIntoPendingData", Qt::QueuedConnection, + Q_ARG(QVector, data)); +} + +void QNativeSocketEngine::handleTcpError(QAbstractSocket::SocketError error) +{ + Q_D(QNativeSocketEngine); + QNativeSocketEnginePrivate::ErrorString errorString; + switch (error) { + case QAbstractSocket::RemoteHostClosedError: + errorString = QNativeSocketEnginePrivate::RemoteHostClosedErrorString; + break; + default: + errorString = QNativeSocketEnginePrivate::UnknownSocketErrorString; + } + + d->setError(error, errorString); + d->socketState = QAbstractSocket::UnconnectedState; + if (d->notifyOnRead) + emit readReady(); +} + void QNativeSocketEngine::putIntoPendingDatagramsList(const QList &datagrams) { Q_D(QNativeSocketEngine); @@ -1039,6 +1222,18 @@ void QNativeSocketEngine::putIntoPendingDatagramsList(const QList d->pendingDatagrams.append(datagrams); } +void QNativeSocketEngine::putIntoPendingData(const QVector &data) +{ + Q_D(QNativeSocketEngine); + QMutexLocker locker(&d->readMutex); + d->pendingData.append(data); + for (const QByteArray &newData : data) + d->bytesAvailable += newData.length(); + locker.unlock(); + if (d->notifyOnRead) + readNotification(); +} + bool QNativeSocketEnginePrivate::createNewSocket(QAbstractSocket::SocketType socketType, QAbstractSocket::NetworkLayerProtocol &socketProtocol) { Q_UNUSED(socketProtocol); @@ -1093,7 +1288,7 @@ QNativeSocketEnginePrivate::QNativeSocketEnginePrivate() , notifyOnException(false) , closingDown(false) , socketDescriptor(-1) - , worker(new SocketEngineWorker) + , worker(new SocketEngineWorker(this)) , sslSocket(Q_NULLPTR) , connectionToken( { -1 } ) { @@ -1481,109 +1676,6 @@ HRESULT QNativeSocketEnginePrivate::handleConnectOpFinished(IAsyncAction *action return S_OK; } -HRESULT QNativeSocketEnginePrivate::handleReadyRead(IAsyncBufferOperation *asyncInfo, AsyncStatus status) -{ - if (closingDown || wasDeleted || isDeletingChildren - || socketState == QAbstractSocket::UnconnectedState) { - return S_OK; - } - - Q_Q(QNativeSocketEngine); - QMutexLocker locker(&readOperationsMutex); - for (int i = 0; i < pendingReadOps.count(); ++i) { - if (pendingReadOps.at(i).Get() == asyncInfo) { - pendingReadOps.takeAt(i); - break; - } - } - locker.unlock(); - - // A read in UnconnectedState will close the socket and return -1 and thus tell the caller, - // that the connection was closed. The socket cannot be closed here, as the subsequent read - // might fail then. - if (status == Error || status == Canceled) { - setError(QAbstractSocket::RemoteHostClosedError, RemoteHostClosedErrorString); - socketState = QAbstractSocket::UnconnectedState; - if (notifyOnRead) - emit q->readReady(); - return S_OK; - } - - ComPtr buffer; - HRESULT hr = asyncInfo->GetResults(&buffer); - RETURN_OK_IF_FAILED("Failed to get read results buffer"); - - UINT32 bufferLength; - hr = buffer->get_Length(&bufferLength); - Q_ASSERT_SUCCEEDED(hr); - // A zero sized buffer length signals, that the remote host closed the connection. The socket - // cannot be closed though, as the following read might have socket descriptor -1 and thus and - // the closing of the socket won't be communicated to the caller. So only the error is set. The - // actual socket close happens inside of read. - if (!bufferLength) { - setError(QAbstractSocket::RemoteHostClosedError, RemoteHostClosedErrorString); - socketState = QAbstractSocket::UnconnectedState; - if (notifyOnRead) - emit q->readReady(); - return S_OK; - } - - ComPtr byteArrayAccess; - hr = buffer.As(&byteArrayAccess); - Q_ASSERT_SUCCEEDED(hr); - byte *data; - hr = byteArrayAccess->Buffer(&data); - Q_ASSERT_SUCCEEDED(hr); - - QMutexLocker readLocker(&readMutex); - if (readBytes.atEnd()) // Everything has been read; the buffer is safe to reset - readBytes.close(); - if (!readBytes.isOpen()) - readBytes.open(QBuffer::ReadWrite|QBuffer::Truncate); - qint64 readPos = readBytes.pos(); - readBytes.seek(readBytes.size()); - Q_ASSERT(readBytes.atEnd()); - readBytes.write(reinterpret_cast(data), qint64(bufferLength)); - readBytes.seek(readPos); - bytesAvailable = readBytes.size() - readBytes.pos(); - readLocker.unlock(); - - if (notifyOnRead) - emit q->readReady(); - - hr = QEventDispatcherWinRT::runOnXamlThread([buffer, q, this]() { - UINT32 readBufferLength; - ComPtr stream; - HRESULT hr = tcpSocket()->get_InputStream(&stream); - RETURN_HR_IF_FAILED("handleReadyRead(): Could not obtain input stream"); - - // Reuse the stream buffer - hr = buffer->get_Capacity(&readBufferLength); - RETURN_HR_IF_FAILED("handleReadyRead(): Could not obtain buffer capacity"); - hr = buffer->put_Length(0); - RETURN_HR_IF_FAILED("handleReadyRead(): Could not set buffer length"); - - ComPtr readOp; - hr = stream->ReadAsync(buffer.Get(), readBufferLength, InputStreamOptions_Partial, &readOp); - if (FAILED(hr)) { - qErrnoWarning(hr, "handleReadyRead(): Could not read into socket stream buffer (%s).", - socketDescription(q).constData()); - return S_OK; - } - QMutexLocker locker(&readOperationsMutex); - pendingReadOps.append(readOp); - hr = readOp->put_Completed(Callback(this, &QNativeSocketEnginePrivate::handleReadyRead).Get()); - if (FAILED(hr)) { - qErrnoWarning(hr, "handleReadyRead(): Failed to set socket read callback (%s).", - socketDescription(q).constData()); - return S_OK; - } - return S_OK; - }); - Q_ASSERT_SUCCEEDED(hr); - return S_OK; -} - HRESULT QNativeSocketEnginePrivate::handleNewDatagram(IDatagramSocket *socket, IDatagramSocketMessageReceivedEventArgs *args) { Q_Q(QNativeSocketEngine); diff --git a/src/network/socket/qnativesocketengine_winrt_p.h b/src/network/socket/qnativesocketengine_winrt_p.h index 085704275c..9758310902 100644 --- a/src/network/socket/qnativesocketengine_winrt_p.h +++ b/src/network/socket/qnativesocketengine_winrt_p.h @@ -144,9 +144,12 @@ signals: private slots: void establishRead(); void handleNewDatagrams(const QList &datagram); + void handleNewData(const QVector &data); + void handleTcpError(QAbstractSocket::SocketError error); private: Q_INVOKABLE void putIntoPendingDatagramsList(const QList &datagrams); + Q_INVOKABLE void putIntoPendingData(const QVector &data); Q_DECLARE_PRIVATE(QNativeSocketEngine) Q_DISABLE_COPY(QNativeSocketEngine) @@ -215,23 +218,17 @@ private: Microsoft::WRL::ComPtr tcpListener; Microsoft::WRL::ComPtr connectOp; - // Protected by readOperationsMutex. Written in handleReadyRead (native callback) - QVector>> pendingReadOps; - - // Protected by readMutex. Written in handleReadyRead (native callback) - QBuffer readBytes; - // In case of TCP readMutex protects readBytes and bytesAvailable. In case of UDP it is // pendingDatagrams. They are written inside native callbacks (handleReadyRead and // handleNewDatagrams/putIntoPendingDatagramsList) mutable QMutex readMutex; - // As pendingReadOps is changed inside handleReadyRead(native callback) it has to be protected - QMutex readOperationsMutex; - // Protected by readMutex. Written in handleReadyRead (native callback) QAtomicInteger bytesAvailable; + // Protected by readMutex. Written in handleNewData/putIntoPendingData (native callback) + QVector pendingData; + // Protected by readMutex. Written in handleNewDatagrams/putIntoPendingDatagramsList QList pendingDatagrams; @@ -246,7 +243,6 @@ private: HRESULT handleClientConnection(ABI::Windows::Networking::Sockets::IStreamSocketListener *tcpListener, ABI::Windows::Networking::Sockets::IStreamSocketListenerConnectionReceivedEventArgs *args); HRESULT handleConnectOpFinished(ABI::Windows::Foundation::IAsyncAction *, ABI::Windows::Foundation::AsyncStatus); - HRESULT handleReadyRead(ABI::Windows::Foundation::IAsyncOperationWithProgress *asyncInfo, ABI::Windows::Foundation::AsyncStatus); }; QT_END_NAMESPACE -- cgit v1.2.3 From 7df0c7a309ada7f9ab70a2c20f86c0707288e31e Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Thu, 1 Dec 2016 12:47:55 +0100 Subject: rename QPointerUniqueId -> QPointingDeviceUniqueId Several people agreed that the name was confusing and that this one is better. Task-number: QTBUG-54616 Change-Id: I31cf057f4bc818332b0551a27d1711599440207c Reviewed-by: Marc Mutz Reviewed-by: Sune Vuorela --- src/gui/kernel/qevent.cpp | 36 ++++++++++++++++----------------- src/gui/kernel/qevent.h | 20 +++++++++--------- src/gui/kernel/qevent_p.h | 2 +- src/gui/kernel/qwindowsysteminterface.h | 2 +- 4 files changed, 30 insertions(+), 30 deletions(-) (limited to 'src') diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp index 72cd374419..b198fa0832 100644 --- a/src/gui/kernel/qevent.cpp +++ b/src/gui/kernel/qevent.cpp @@ -4475,14 +4475,14 @@ int QTouchEvent::TouchPoint::id() const \since 5.8 Returns the unique ID of this touch point or token, if any. - It is normally invalid (see \l {QPointerUniqueId::isValid()} {isValid()}), + It is normally invalid (see \l {QPointingDeviceUniqueId::isValid()} {isValid()}), because touchscreens cannot uniquely identify fingers. But when the \l {TouchPoint::InfoFlag} {Token} flag is set, it is expected to uniquely identify a specific token (fiducial object). \sa flags */ -QPointerUniqueId QTouchEvent::TouchPoint::uniqueId() const +QPointingDeviceUniqueId QTouchEvent::TouchPoint::uniqueId() const { return d->uniqueId; } @@ -4758,7 +4758,7 @@ void QTouchEvent::TouchPoint::setUniqueId(qint64 uid) { if (d->ref.load() != 1) d = d->detach(); - d->uniqueId = QPointerUniqueId::fromNumericId(uid); + d->uniqueId = QPointingDeviceUniqueId::fromNumericId(uid); } /*! \internal */ @@ -5177,15 +5177,15 @@ Qt::ApplicationState QApplicationStateChangeEvent::applicationState() const } /*! - \class QPointerUniqueId + \class QPointingDeviceUniqueId \since 5.8 \ingroup events \inmodule QtGui - \brief QPointerUniqueId identifies a unique object, such as a tagged token + \brief QPointingDeviceUniqueId identifies a unique object, such as a tagged token or stylus, which is used with a pointing device. - QPointerUniqueIds can be compared for equality, and can be used as keys in a QHash. + QPointingDeviceUniqueIds can be compared for equality, and can be used as keys in a QHash. You get access to the numerical ID via numericId(), if the device supports such IDs. For future extensions, though, you should not use that function, but compare objects of this type using the equality operator. @@ -5201,29 +5201,29 @@ Qt::ApplicationState QApplicationStateChangeEvent::applicationState() const */ /*! - \fn QPointerUniqueId::QPointerUniqueId() + \fn QPointingDeviceUniqueId::QPointingDeviceUniqueId() Constructs an invalid unique pointer ID. */ /*! Constructs a unique pointer ID from numeric ID \a id. */ -QPointerUniqueId QPointerUniqueId::fromNumericId(qint64 id) +QPointingDeviceUniqueId QPointingDeviceUniqueId::fromNumericId(qint64 id) { - QPointerUniqueId result; + QPointingDeviceUniqueId result; result.m_numericId = id; return result; } /*! - \fn bool QPointerUniqueId::isValid() + \fn bool QPointingDeviceUniqueId::isValid() Returns whether this unique pointer ID is valid, that is, it represents an actual pointer. */ /*! - \property QPointerUniqueId::numericId + \property QPointingDeviceUniqueId::numericId \brief the numeric unique ID of the token represented by a touchpoint If the device provides a numeric ID, isValid() returns true, and this @@ -5235,26 +5235,26 @@ QPointerUniqueId QPointerUniqueId::fromNumericId(qint64 id) \sa isValid() */ -qint64 QPointerUniqueId::numericId() const Q_DECL_NOTHROW +qint64 QPointingDeviceUniqueId::numericId() const Q_DECL_NOTHROW { return m_numericId; } /*! - \relates QPointerUniqueId + \relates QPointingDeviceUniqueId \since 5.8 Returns whether the two unique pointer IDs \a lhs and \a rhs identify the same pointer (\c true) or not (\c false). */ -bool operator==(QPointerUniqueId lhs, QPointerUniqueId rhs) Q_DECL_NOTHROW +bool operator==(QPointingDeviceUniqueId lhs, QPointingDeviceUniqueId rhs) Q_DECL_NOTHROW { return lhs.numericId() == rhs.numericId(); } /*! - \fn bool operator!=(QPointerUniqueId lhs, QPointerUniqueId rhs) - \relates QPointerUniqueId + \fn bool operator!=(QPointingDeviceUniqueId lhs, QPointingDeviceUniqueId rhs) + \relates QPointingDeviceUniqueId \since 5.8 Returns whether the two unique pointer IDs \a lhs and \a rhs identify different pointers @@ -5262,12 +5262,12 @@ bool operator==(QPointerUniqueId lhs, QPointerUniqueId rhs) Q_DECL_NOTHROW */ /*! - \relates QPointerUniqueId + \relates QPointingDeviceUniqueId \since 5.8 Returns the hash value for \a key, using \a seed to seed the calculation. */ -uint qHash(QPointerUniqueId key, uint seed) Q_DECL_NOTHROW +uint qHash(QPointingDeviceUniqueId key, uint seed) Q_DECL_NOTHROW { return qHash(key.numericId(), seed); } diff --git a/src/gui/kernel/qevent.h b/src/gui/kernel/qevent.h index b7c0f3338e..7d5b719e09 100644 --- a/src/gui/kernel/qevent.h +++ b/src/gui/kernel/qevent.h @@ -793,7 +793,7 @@ inline bool operator==(QKeyEvent *e, QKeySequence::StandardKey key){return (e ? inline bool operator==(QKeySequence::StandardKey key, QKeyEvent *e){return (e ? e->matches(key) : false);} #endif // QT_NO_SHORTCUT -class Q_GUI_EXPORT QPointerUniqueId +class Q_GUI_EXPORT QPointingDeviceUniqueId { Q_GADGET // ### kept these to keep other modules compiling. Remove before 5.8.0 final! @@ -803,11 +803,11 @@ class Q_GUI_EXPORT QPointerUniqueId Q_PROPERTY(qint64 numericId READ numericId CONSTANT) public: Q_ALWAYS_INLINE - Q_DECL_CONSTEXPR QPointerUniqueId() Q_DECL_NOTHROW : m_numericId(-1) {} + Q_DECL_CONSTEXPR QPointingDeviceUniqueId() Q_DECL_NOTHROW : m_numericId(-1) {} // compiler-generated copy/move ctor/assignment operators are ok! // compiler-generated dtor is ok! - static QPointerUniqueId fromNumericId(qint64 id); + static QPointingDeviceUniqueId fromNumericId(qint64 id); Q_ALWAYS_INLINE Q_DECL_CONSTEXPR bool isValid() const Q_DECL_NOTHROW { return m_numericId != -1; } qint64 numericId() const Q_DECL_NOTHROW; @@ -815,7 +815,7 @@ public: // ### kept these to keep other modules compiling. Remove before 5.8.0 final! #if QT_DEPRECATED_SINCE(5, 8) Q_ALWAYS_INLINE Q_DECL_DEPRECATED qint64 numeric() const { return numericId(); } - Q_ALWAYS_INLINE Q_DECL_DEPRECATED explicit QPointerUniqueId(qint64 id) : m_numericId(id) {} + Q_ALWAYS_INLINE Q_DECL_DEPRECATED explicit QPointingDeviceUniqueId(qint64 id) : m_numericId(id) {} #endif private: // TODO: for TUIO 2, or any other type of complex token ID, an internal @@ -823,13 +823,13 @@ private: // In this case, m_numericId will then turn into an index into that array (or hash). qint64 m_numericId; }; -Q_DECLARE_TYPEINFO(QPointerUniqueId, Q_MOVABLE_TYPE); -template <> class QList {}; // to prevent instantiation: use QVector instead +Q_DECLARE_TYPEINFO(QPointingDeviceUniqueId, Q_MOVABLE_TYPE); +template <> class QList {}; // to prevent instantiation: use QVector instead -Q_GUI_EXPORT bool operator==(QPointerUniqueId lhs, QPointerUniqueId rhs) Q_DECL_NOTHROW; -inline bool operator!=(QPointerUniqueId lhs, QPointerUniqueId rhs) Q_DECL_NOTHROW +Q_GUI_EXPORT bool operator==(QPointingDeviceUniqueId lhs, QPointingDeviceUniqueId rhs) Q_DECL_NOTHROW; +inline bool operator!=(QPointingDeviceUniqueId lhs, QPointingDeviceUniqueId rhs) Q_DECL_NOTHROW { return !operator==(lhs, rhs); } -Q_GUI_EXPORT uint qHash(QPointerUniqueId key, uint seed = 0) Q_DECL_NOTHROW; +Q_GUI_EXPORT uint qHash(QPointingDeviceUniqueId key, uint seed = 0) Q_DECL_NOTHROW; @@ -868,7 +868,7 @@ public: { qSwap(d, other.d); } int id() const; - QPointerUniqueId uniqueId() const; + QPointingDeviceUniqueId uniqueId() const; Qt::TouchPointState state() const; diff --git a/src/gui/kernel/qevent_p.h b/src/gui/kernel/qevent_p.h index 7e82b9c654..898ad16cf6 100644 --- a/src/gui/kernel/qevent_p.h +++ b/src/gui/kernel/qevent_p.h @@ -80,7 +80,7 @@ public: QAtomicInt ref; int id; - QPointerUniqueId uniqueId; + QPointingDeviceUniqueId uniqueId; Qt::TouchPointStates state; QRectF rect, sceneRect, screenRect; QPointF normalizedPos, diff --git a/src/gui/kernel/qwindowsysteminterface.h b/src/gui/kernel/qwindowsysteminterface.h index 3be3c3188c..a28d1c93df 100644 --- a/src/gui/kernel/qwindowsysteminterface.h +++ b/src/gui/kernel/qwindowsysteminterface.h @@ -129,7 +129,7 @@ public: TouchPoint() : id(0), uniqueId(-1), pressure(0), rotation(0), state(Qt::TouchPointStationary) { } int id; // for application use qint64 uniqueId; // for TUIO: object/token ID; otherwise empty - // TODO for TUIO 2.0: add registerPointerUniqueID(QPointerUniqueId) + // TODO for TUIO 2.0: add registerPointerUniqueID(QPointingDeviceUniqueId) QPointF normalPosition; // touch device coordinates, (0 to 1, 0 to 1) QRectF area; // the touched area, centered at position in screen coordinates qreal pressure; // 0 to 1 -- cgit v1.2.3 From 630f8e7ad6e94c703f85fa11a9926ba83c478e72 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Fri, 2 Dec 2016 14:22:55 +0100 Subject: Document 3rd party code in qimagetransform.cpp MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I685d3964617e3984b938bd9aafa0626acd75656f Reviewed-by: Topi Reiniö --- src/gui/image/qimage.cpp | 31 -------------- src/gui/painting/QIMAGETRANSFORM_LICENSE.txt | 60 ++++++++++++++++++++++++++++ src/gui/painting/qt_attribution.json | 43 ++++++++++++++------ 3 files changed, 90 insertions(+), 44 deletions(-) create mode 100644 src/gui/painting/QIMAGETRANSFORM_LICENSE.txt (limited to 'src') diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp index 9e911bdcea..9e9f01a46a 100644 --- a/src/gui/image/qimage.cpp +++ b/src/gui/image/qimage.cpp @@ -596,37 +596,6 @@ bool QImageData::checkForAlphaPixels() const \endtable - \target qimage-legalese - \section1 Legal Information - - For smooth scaling, the transformed() functions use code based on - smooth scaling algorithm by Daniel M. Duley. - - \badcode - Copyright (C) 2004, 2005 Daniel M. Duley - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - 1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - \endcode - \sa QImageReader, QImageWriter, QPixmap, QSvgRenderer, {Image Composition Example}, {Image Viewer Example}, {Scribble Example}, {Pixelator Example} */ diff --git a/src/gui/painting/QIMAGETRANSFORM_LICENSE.txt b/src/gui/painting/QIMAGETRANSFORM_LICENSE.txt new file mode 100644 index 0000000000..67c910826a --- /dev/null +++ b/src/gui/painting/QIMAGETRANSFORM_LICENSE.txt @@ -0,0 +1,60 @@ +qimagetransform.cpp was contributed by Daniel M. Duley based on code from Imlib2. + +Copyright (C) 2004, 2005 Daniel M. Duley + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + + +Imlib2 License + +Copyright (C) 2000 Carsten Haitzler and various contributors (see +AUTHORS) + +Permission is hereby granted, free of charge, to any person obtaining a +copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be included +in all copies of the Software and its Copyright notices. In addition +publicly documented acknowledgment must be given that this software has +been used if no source code of this software is made available publicly. +This includes acknowledgments in either Copyright notices, Manuals, +Publicity and Marketing documents or any documentation provided with any +product containing this software. This License does not apply to any +software that links to the libraries provided by this software +(statically or dynamically), but only to the software provided. + +Please see the COPYING.PLAIN for a plain-english explanation of this +notice and it's intent. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/src/gui/painting/qt_attribution.json b/src/gui/painting/qt_attribution.json index f635cf98ac..06a62d9d66 100644 --- a/src/gui/painting/qt_attribution.json +++ b/src/gui/painting/qt_attribution.json @@ -1,14 +1,31 @@ -{ - "Id": "grayraster", - "Name": "Anti-aliasing rasterizer from FreeType 2", - "QDocModule": "qtgui", - "QtUsage": "Used in Qt GUI.", - "Path": "qgrayraster.c", +[ + { + "Id": "grayraster", + "Name": "Anti-aliasing rasterizer from FreeType 2", + "QDocModule": "qtgui", + "QtUsage": "Used in Qt GUI.", + "Path": "qgrayraster.c", - "Description": "FreeType is a freely available software library to render fonts.", - "Homepage": "http://www.freetype.org", - "License": "Freetype Project License or GNU General Public License v2.0 only", - "LicenseId": "FTL or GPL-2.0", - "LicenseFile": "../../3rdparty/freetype/docs/LICENSE.TXT", - "Copyright": "Copyright 2006-2015 by David Turner, Robert Wilhelm, and Werner Lemberg." -} + "Description": "FreeType is a freely available software library to render fonts.", + "Homepage": "http://www.freetype.org", + "License": "Freetype Project License or GNU General Public License v2.0 only", + "LicenseId": "FTL or GPL-2.0", + "LicenseFile": "../../3rdparty/freetype/docs/LICENSE.TXT", + "Copyright": "Copyright 2006-2015 by David Turner, Robert Wilhelm, and Werner Lemberg." + }, + { + "Id": "smooth-scaling-algorithm", + "Name": "Smooth Scaling Algorithm", + "QDocModule": "qtgui", + "QtUsage": "Used in Qt Gui (QImage::transformed() functions).", + "Files": "qimagescale.cpp", + + "Description": "Normal smoothscale method, based on Imlib2's smoothscale.", + "LicenseId": "BSD-2-Clause AND Imlib2", + "License": "BSD 2-clause \"Simplified\" License and Imlib2 License", + "LicenseFile": "QIMAGETRANSFORM_LICENSE.txt", + "Copyright": "Copyright (C) 2004, 2005 Daniel M. Duley. + (C) Carsten Haitzler and various contributors. + (C) Willem Monsuwe " + } +] -- cgit v1.2.3 From 4077fcc6153493284b5e2b0812ff215b49e8c8b7 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Tue, 29 Nov 2016 15:30:52 +0100 Subject: QHostAddress: fix assignment operators QHostAddress allowed assignment from a QString, but the respective constructor is explicit, and rightfully so. So it does not make sense that the assignment operator is provided, because of the asymmetry caused between QHostAddress addr = funcReturningQString(); // ERROR addr = funcReturningQString(); // OK (until now) By the same token, since SpecialAddress is implicitly convertible to QHostAddress, provide the missing assignment operator from that enum. Add tests, rewriting the _data() function to use the enum instead of an int to pass SpecialAddress values, and to test !=, too. Added setAddress(SpecialAddress), since a) it was missing and b) to share code between the ctor and the assignment operator. Change-Id: Ief64c493be13ada8c6968801d9ed083b267fa902 Reviewed-by: Thiago Macieira --- src/network/kernel/qhostaddress.cpp | 28 ++++++++++++++++++++++++++++ src/network/kernel/qhostaddress.h | 5 +++++ 2 files changed, 33 insertions(+) (limited to 'src') diff --git a/src/network/kernel/qhostaddress.cpp b/src/network/kernel/qhostaddress.cpp index 7e3d2c5d6e..8fac76f86a 100644 --- a/src/network/kernel/qhostaddress.cpp +++ b/src/network/kernel/qhostaddress.cpp @@ -517,6 +517,19 @@ QHostAddress::QHostAddress(const QHostAddress &address) QHostAddress::QHostAddress(SpecialAddress address) : d(new QHostAddressPrivate) { + setAddress(address); +} + +/*! + \overload + \since 5.8 + + Sets the special address specified by \a address. +*/ +void QHostAddress::setAddress(SpecialAddress address) +{ + d->clear(); + Q_IPV6ADDR ip6; memset(&ip6, 0, sizeof ip6); quint32 ip4 = INADDR_ANY; @@ -567,6 +580,7 @@ QHostAddress &QHostAddress::operator=(const QHostAddress &address) return *this; } +#if QT_DEPRECATED_SINCE(5, 8) /*! Assigns the host address \a address to this object, and returns a reference to this object. @@ -578,6 +592,20 @@ QHostAddress &QHostAddress::operator=(const QString &address) setAddress(address); return *this; } +#endif + +/*! + \since 5.8 + Assigns the special address \a address to this object, and returns a + reference to this object. + + \sa setAddress() +*/ +QHostAddress &QHostAddress::operator=(SpecialAddress address) +{ + setAddress(address); + return *this; +} /*! \fn bool QHostAddress::operator!=(const QHostAddress &other) const diff --git a/src/network/kernel/qhostaddress.h b/src/network/kernel/qhostaddress.h index 58af14ee33..10fe33f6fa 100644 --- a/src/network/kernel/qhostaddress.h +++ b/src/network/kernel/qhostaddress.h @@ -108,7 +108,11 @@ public: #endif QHostAddress &operator=(const QHostAddress &other); +#if QT_DEPRECATED_SINCE(5, 8) + QT_DEPRECATED_X("use = QHostAddress(string) instead") QHostAddress &operator=(const QString &address); +#endif + QHostAddress &operator=(SpecialAddress address); void swap(QHostAddress &other) Q_DECL_NOTHROW { d.swap(other.d); } @@ -118,6 +122,7 @@ public: void setAddress(const Q_IPV6ADDR &ip6Addr); void setAddress(const sockaddr *address); bool setAddress(const QString &address); + void setAddress(SpecialAddress address); QAbstractSocket::NetworkLayerProtocol protocol() const; quint32 toIPv4Address() const; // ### Qt6: merge with next overload -- cgit v1.2.3 From b2f78b796b5b73d4f0732975ffd66f8aa392c001 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Mon, 5 Dec 2016 14:21:40 -0800 Subject: QCocoaMenu: Avoid exception when inserting item already in this menu This should not happen, but it's clearly not the user's fault. So we should try to carry on as gracefully as possible instead of letting Cocoa abort the application. The patch also factors the repeated calls to QCocoaMenuItem:: nsItem() in QCocoaMenu::insertNative() and improves a warning from QCocoaMenuIten::sync(). Change-Id: Id00135c219aaf40fb565b19a65cab68f6d9863b2 Task-number: QTBUG-57404 Reviewed-by: Richard Moe Gustavsen --- src/plugins/platforms/cocoa/qcocoamenu.mm | 20 +++++++++++++------- src/plugins/platforms/cocoa/qcocoamenuitem.mm | 2 +- 2 files changed, 14 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/cocoa/qcocoamenu.mm b/src/plugins/platforms/cocoa/qcocoamenu.mm index 88ffd48538..915463a52a 100644 --- a/src/plugins/platforms/cocoa/qcocoamenu.mm +++ b/src/plugins/platforms/cocoa/qcocoamenu.mm @@ -331,11 +331,12 @@ void QCocoaMenu::insertMenuItem(QPlatformMenuItem *menuItem, QPlatformMenuItem * void QCocoaMenu::insertNative(QCocoaMenuItem *item, QCocoaMenuItem *beforeItem) { - item->nsItem().target = m_nativeMenu.delegate; - item->nsItem().action = @selector(itemFired:); + NSMenuItem *nativeItem = item->nsItem(); + nativeItem.target = m_nativeMenu.delegate; + nativeItem.action = @selector(itemFired:); // Someone's adding new items after aboutToShow() was emitted - if (isOpen() && item->menu() && item->nsItem()) - item->menu()->setAttachedItem(item->nsItem()); + if (isOpen() && nativeItem) + item->menu()->setAttachedItem(nativeItem); item->setParentEnabled(isEnabled()); @@ -348,15 +349,20 @@ void QCocoaMenu::insertNative(QCocoaMenuItem *item, QCocoaMenuItem *beforeItem) beforeItem = itemOrNull(m_menuItems.indexOf(beforeItem) + 1); } + if (nativeItem.menu) { + qWarning() << "Menu item" << item->text() << "already in menu" << QString::fromNSString(nativeItem.menu.title); + return; + } + if (beforeItem) { if (beforeItem->isMerged()) { qWarning("No non-merged before menu item found"); return; } - NSUInteger nativeIndex = [m_nativeMenu indexOfItem:beforeItem->nsItem()]; - [m_nativeMenu insertItem: item->nsItem() atIndex: nativeIndex]; + const NSInteger nativeIndex = [m_nativeMenu indexOfItem:beforeItem->nsItem()]; + [m_nativeMenu insertItem:nativeItem atIndex:nativeIndex]; } else { - [m_nativeMenu addItem: item->nsItem()]; + [m_nativeMenu addItem:nativeItem]; } item->setMenuParent(this); } diff --git a/src/plugins/platforms/cocoa/qcocoamenuitem.mm b/src/plugins/platforms/cocoa/qcocoamenuitem.mm index e32ff26ff5..21f2b4de85 100644 --- a/src/plugins/platforms/cocoa/qcocoamenuitem.mm +++ b/src/plugins/platforms/cocoa/qcocoamenuitem.mm @@ -288,7 +288,7 @@ NSMenuItem *QCocoaMenuItem::sync() } default: - qWarning() << "menu item" << m_text << "has unsupported role" << (int)m_role; + qWarning() << "Menu item" << m_text << "has unsupported role" << m_role; } if (mergeItem) { -- cgit v1.2.3 From 093e1111ef68a8a83e42d5d82fc9d5c93d47071b Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Mon, 5 Dec 2016 14:38:12 -0800 Subject: QCocoaMenu: Don't rely on tags when we can get the actual NSMenuItem -[NSMenu itemWithTag:] clearly states that it'll return the first item with that tag. Furthermore, when and item has been synced more than once, it could be that more than one such item exists in the same menu (e.g. lately changing the role of Edit->Copy). Change-Id: I95a4f0a151659ae273ba03a3cab4a720b781fc3a Task-number: QTBUG-57404 Reviewed-by: Jake Petroules --- src/plugins/platforms/cocoa/qcocoamenu.mm | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/cocoa/qcocoamenu.mm b/src/plugins/platforms/cocoa/qcocoamenu.mm index 915463a52a..81db919627 100644 --- a/src/plugins/platforms/cocoa/qcocoamenu.mm +++ b/src/plugins/platforms/cocoa/qcocoamenu.mm @@ -419,9 +419,8 @@ void QCocoaMenu::syncMenuItem(QPlatformMenuItem *menuItem) return; } - bool wasMerged = cocoaItem->isMerged(); - NSMenu *oldMenu = wasMerged ? [[QCocoaMenuLoader sharedMenuLoader] applicationMenu] : m_nativeMenu; - NSMenuItem *oldItem = [oldMenu itemWithTag:(NSInteger) cocoaItem]; + const bool wasMerged = cocoaItem->isMerged(); + NSMenuItem *oldItem = cocoaItem->nsItem(); if (cocoaItem->sync() != oldItem) { // native item was changed for some reason -- cgit v1.2.3 From e1a70ce495928e8d81e80b11d7dbd4c4913ee438 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 6 Dec 2016 17:54:47 -0800 Subject: moc: force the Microsoft compiler not to define _MSC_EXTENSIONS This re-fixes commit d72ac3f35f4c6d6405e9675d54124b3ddb8d80ab, which simply removed the #define but did so at the wrong place. Instead of forcing the macro to be removed, let's simply not have it defined in the first place. Change-Id: Ie6dbad9bbbd9488887e8fffd148dd67d9a31b32e Reviewed-by: Jake Petroules --- src/tools/moc/main.cpp | 3 --- 1 file changed, 3 deletions(-) (limited to 'src') diff --git a/src/tools/moc/main.cpp b/src/tools/moc/main.cpp index 55cf7ed872..6128d5490b 100644 --- a/src/tools/moc/main.cpp +++ b/src/tools/moc/main.cpp @@ -477,9 +477,6 @@ int runMoc(int argc, char **argv) } moc.symbols += pp.preprocessed(moc.filename, &in); - // We obviously do not support MS extensions - pp.macros.remove("_MSC_EXTENSIONS"); - if (!pp.preprocessOnly) { // 2. parse moc.parse(); -- cgit v1.2.3 From 10143ea8030e6754b2021c84c30859ade79dc570 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Thu, 8 Dec 2016 10:00:21 +0100 Subject: QPointingDeviceUniqueId: remove deprecated numeric() and constructor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Followup to 0484473: this is all new stuff for 5.8 and we don't need to release it with pre-deprecated functions. Task-number: QTBUG-54616 Change-Id: If17a4bec6fc36ca78d87517992374f101ae13b4f Reviewed-by: Jan Arve Sæther --- src/gui/kernel/qevent.h | 9 --------- 1 file changed, 9 deletions(-) (limited to 'src') diff --git a/src/gui/kernel/qevent.h b/src/gui/kernel/qevent.h index 7d5b719e09..7881df205a 100644 --- a/src/gui/kernel/qevent.h +++ b/src/gui/kernel/qevent.h @@ -796,10 +796,6 @@ inline bool operator==(QKeySequence::StandardKey key, QKeyEvent *e){return (e ? class Q_GUI_EXPORT QPointingDeviceUniqueId { Q_GADGET - // ### kept these to keep other modules compiling. Remove before 5.8.0 final! -#if QT_DEPRECATED_SINCE(5, 8) - Q_PROPERTY(qint64 numeric READ numericId CONSTANT) -#endif Q_PROPERTY(qint64 numericId READ numericId CONSTANT) public: Q_ALWAYS_INLINE @@ -812,11 +808,6 @@ public: Q_ALWAYS_INLINE Q_DECL_CONSTEXPR bool isValid() const Q_DECL_NOTHROW { return m_numericId != -1; } qint64 numericId() const Q_DECL_NOTHROW; - // ### kept these to keep other modules compiling. Remove before 5.8.0 final! -#if QT_DEPRECATED_SINCE(5, 8) - Q_ALWAYS_INLINE Q_DECL_DEPRECATED qint64 numeric() const { return numericId(); } - Q_ALWAYS_INLINE Q_DECL_DEPRECATED explicit QPointingDeviceUniqueId(qint64 id) : m_numericId(id) {} -#endif private: // TODO: for TUIO 2, or any other type of complex token ID, an internal // array (or hash) can be added to hold additional properties. -- cgit v1.2.3 From 181860e1afa2f071a9cfcbf4d39b8526e9330ae2 Mon Sep 17 00:00:00 2001 From: Maurice Kalinowski Date: Thu, 24 Nov 2016 15:09:25 +0100 Subject: winrt: Fix input grabbing Beside its usage in widgets, mouse grabs are required for QML menus to work. Task-number: QTBUG-57079 Change-Id: I306cb68624186da69725470e147bc7b979dac8e4 Reviewed-by: Oliver Wolff --- src/plugins/platforms/winrt/qwinrtscreen.cpp | 76 ++++++++++++++++++++++++++-- src/plugins/platforms/winrt/qwinrtscreen.h | 7 +++ src/plugins/platforms/winrt/qwinrtwindow.cpp | 23 +++++++++ src/plugins/platforms/winrt/qwinrtwindow.h | 3 ++ 4 files changed, 106 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/winrt/qwinrtscreen.cpp b/src/plugins/platforms/winrt/qwinrtscreen.cpp index 6d4edcc8dc..f87ae9fd24 100644 --- a/src/plugins/platforms/winrt/qwinrtscreen.cpp +++ b/src/plugins/platforms/winrt/qwinrtscreen.cpp @@ -486,6 +486,9 @@ public: QHash view2Tokens; ComPtr view2; #endif // WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_PHONE_APP) + QAtomicPointer mouseGrabWindow; + QAtomicPointer keyboardGrabWindow; + QWindow *currentPressWindow = 0; }; // To be called from the XAML thread @@ -877,6 +880,44 @@ void QWinRTScreen::lower(QWindow *window) handleExpose(); } +bool QWinRTScreen::setMouseGrabWindow(QWinRTWindow *window, bool grab) +{ + Q_D(QWinRTScreen); + qCDebug(lcQpaWindows) << __FUNCTION__ << window + << "(" << window->window()->objectName() << "):" << grab; + + if (!grab || window == nullptr) + d->mouseGrabWindow = nullptr; + else if (d->mouseGrabWindow != window) + d->mouseGrabWindow = window; + return grab; +} + +QWinRTWindow *QWinRTScreen::mouseGrabWindow() const +{ + Q_D(const QWinRTScreen); + return d->mouseGrabWindow; +} + +bool QWinRTScreen::setKeyboardGrabWindow(QWinRTWindow *window, bool grab) +{ + Q_D(QWinRTScreen); + qCDebug(lcQpaWindows) << __FUNCTION__ << window + << "(" << window->window()->objectName() << "):" << grab; + + if (!grab || window == nullptr) + d->keyboardGrabWindow = nullptr; + else if (d->keyboardGrabWindow != window) + d->keyboardGrabWindow = window; + return grab; +} + +QWinRTWindow *QWinRTScreen::keyboardGrabWindow() const +{ + Q_D(const QWinRTScreen); + return d->keyboardGrabWindow; +} + void QWinRTScreen::updateWindowTitle(const QString &title) { Q_D(QWinRTScreen); @@ -1022,7 +1063,11 @@ HRESULT QWinRTScreen::onPointerEntered(ICoreWindow *, IPointerEventArgs *args) pointerPoint->get_Position(&point); QPoint pos(point.X * d->scaleFactor, point.Y * d->scaleFactor); - QWindowSystemInterface::handleEnterEvent(topWindow(), pos, pos); + QWindow *targetWindow = topWindow(); + if (d->mouseGrabWindow) + targetWindow = d->mouseGrabWindow.load()->window(); + + QWindowSystemInterface::handleEnterEvent(targetWindow, pos, pos); } return S_OK; } @@ -1041,7 +1086,11 @@ HRESULT QWinRTScreen::onPointerExited(ICoreWindow *, IPointerEventArgs *args) d->touchPoints.remove(id); - QWindowSystemInterface::handleLeaveEvent(0); + QWindow *targetWindow = nullptr; + if (d->mouseGrabWindow) + targetWindow = d->mouseGrabWindow.load()->window(); + + QWindowSystemInterface::handleLeaveEvent(targetWindow); return S_OK; } @@ -1063,7 +1112,12 @@ HRESULT QWinRTScreen::onPointerUpdated(ICoreWindow *, IPointerEventArgs *args) QPointF localPos = pos; const QPoint posPoint = pos.toPoint(); - QWindow *targetWindow = windowAt(posPoint); + QWindow *windowUnderPointer = windowAt(posPoint); + QWindow *targetWindow = windowUnderPointer; + + if (d->mouseGrabWindow) + targetWindow = d->mouseGrabWindow.load()->window(); + if (targetWindow) { const QPointF globalPosDelta = pos - posPoint; localPos = targetWindow->mapFromGlobal(posPoint) + globalPosDelta; @@ -1127,6 +1181,22 @@ HRESULT QWinRTScreen::onPointerUpdated(ICoreWindow *, IPointerEventArgs *args) if (isPressed) buttons |= Qt::XButton2; + // In case of a mouse grab we have to store the target of a press event + // to be able to send one additional release event to this target when the mouse + // button is released. This is a similar approach to AutoMouseCapture in the + // windows qpa backend. Otherwise the release might not be propagated and the original + // press event receiver considers a button to still be pressed, as in Qt Quick Controls 1 + // menus. + if (buttons != Qt::NoButton && d->currentPressWindow == nullptr && !d->mouseGrabWindow) + d->currentPressWindow = windowUnderPointer; + if (!isPressed && d->currentPressWindow && d->mouseGrabWindow) { + const QPointF globalPosDelta = pos - posPoint; + const QPointF localPressPos = d->currentPressWindow->mapFromGlobal(posPoint) + globalPosDelta; + + QWindowSystemInterface::handleMouseEvent(d->currentPressWindow, localPressPos, pos, buttons, mods); + d->currentPressWindow = nullptr; + } + QWindowSystemInterface::handleMouseEvent(targetWindow, localPos, pos, buttons, mods); break; diff --git a/src/plugins/platforms/winrt/qwinrtscreen.h b/src/plugins/platforms/winrt/qwinrtscreen.h index e489e208d5..04ab985699 100644 --- a/src/plugins/platforms/winrt/qwinrtscreen.h +++ b/src/plugins/platforms/winrt/qwinrtscreen.h @@ -83,6 +83,7 @@ class QTouchDevice; class QWinRTCursor; class QWinRTInputContext; class QWinRTScreenPrivate; +class QWinRTWindow; class QWinRTScreen : public QPlatformScreen { public: @@ -110,6 +111,12 @@ public: void raise(QWindow *window); void lower(QWindow *window); + bool setMouseGrabWindow(QWinRTWindow *window, bool grab); + QWinRTWindow* mouseGrabWindow() const; + + bool setKeyboardGrabWindow(QWinRTWindow *window, bool grab); + QWinRTWindow* keyboardGrabWindow() const; + void updateWindowTitle(const QString &title); ABI::Windows::UI::Core::ICoreWindow *coreWindow() const; diff --git a/src/plugins/platforms/winrt/qwinrtwindow.cpp b/src/plugins/platforms/winrt/qwinrtwindow.cpp index 297e6618d1..8f3b86ff3b 100644 --- a/src/plugins/platforms/winrt/qwinrtwindow.cpp +++ b/src/plugins/platforms/winrt/qwinrtwindow.cpp @@ -191,6 +191,11 @@ QWinRTWindow::~QWinRTWindow() }); RETURN_VOID_IF_FAILED("Failed to completely destroy window resources, likely because the application is shutting down"); + if (d->screen->mouseGrabWindow() == this) + d->screen->setMouseGrabWindow(this, false); + if (d->screen->keyboardGrabWindow() == this) + d->screen->setKeyboardGrabWindow(this, false); + d->screen->removeWindow(window()); if (!d->surface) @@ -384,6 +389,24 @@ void QWinRTWindow::setWindowState(Qt::WindowState state) d->state = state; } +bool QWinRTWindow::setMouseGrabEnabled(bool grab) +{ + Q_D(QWinRTWindow); + if (!isActive() && grab) { + qWarning("%s: Not setting mouse grab for invisible window %s/'%s'", + __FUNCTION__, window()->metaObject()->className(), + qPrintable(window()->objectName())); + return false; + } + return d->screen->setMouseGrabWindow(this, grab); +} + +bool QWinRTWindow::setKeyboardGrabEnabled(bool grab) +{ + Q_D(QWinRTWindow); + return d->screen->setKeyboardGrabWindow(this, grab); +} + EGLSurface QWinRTWindow::eglSurface() const { Q_D(const QWinRTWindow); diff --git a/src/plugins/platforms/winrt/qwinrtwindow.h b/src/plugins/platforms/winrt/qwinrtwindow.h index 48e092d455..35a4c493b6 100644 --- a/src/plugins/platforms/winrt/qwinrtwindow.h +++ b/src/plugins/platforms/winrt/qwinrtwindow.h @@ -70,6 +70,9 @@ public: qreal devicePixelRatio() const Q_DECL_OVERRIDE; void setWindowState(Qt::WindowState state) Q_DECL_OVERRIDE; + bool setMouseGrabEnabled(bool grab) Q_DECL_OVERRIDE; + bool setKeyboardGrabEnabled(bool grab) Q_DECL_OVERRIDE; + EGLSurface eglSurface() const; void createEglSurface(EGLDisplay display, EGLConfig config); -- cgit v1.2.3 From 84ea00d47049d882f2fabf1446ec6c6eb5fe3038 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Tue, 6 Dec 2016 16:30:31 +0100 Subject: QGtk3Dialog: don't crash on Wayland Check if it's an X11 window before calling XSetTransientForHint(). No transient parent will be set for GTK+ dialogs on Wayland. That has to be implemented separately. Task-number: QTBUG-55583 Change-Id: Iabc2a72681c8157bb2f2fe500892853aa397106b Reviewed-by: Dmitry Shachnev Reviewed-by: Shawn Rutledge --- src/plugins/platformthemes/gtk3/qgtk3dialoghelpers.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/plugins/platformthemes/gtk3/qgtk3dialoghelpers.cpp b/src/plugins/platformthemes/gtk3/qgtk3dialoghelpers.cpp index ba5089a8bc..699b058932 100644 --- a/src/plugins/platformthemes/gtk3/qgtk3dialoghelpers.cpp +++ b/src/plugins/platformthemes/gtk3/qgtk3dialoghelpers.cpp @@ -135,10 +135,12 @@ bool QGtk3Dialog::show(Qt::WindowFlags flags, Qt::WindowModality modality, QWind GdkWindow *gdkWindow = gtk_widget_get_window(gtkWidget); if (parent) { - GdkDisplay *gdkDisplay = gdk_window_get_display(gdkWindow); - XSetTransientForHint(gdk_x11_display_get_xdisplay(gdkDisplay), - gdk_x11_window_get_xid(gdkWindow), - parent->winId()); + if (GDK_IS_X11_WINDOW(gdkWindow)) { + GdkDisplay *gdkDisplay = gdk_window_get_display(gdkWindow); + XSetTransientForHint(gdk_x11_display_get_xdisplay(gdkDisplay), + gdk_x11_window_get_xid(gdkWindow), + parent->winId()); + } } if (modality != Qt::NonModal) { -- cgit v1.2.3 From c483945cf45547d3533674527470788809c79bfb Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Thu, 8 Dec 2016 12:31:58 +0100 Subject: REG: Fix missing glyphs with DirectWrite and stretch == QFont::AnyStretch A stretch equal to 0 is since 5.8 defined as "accept the stretch of the font", and this needs to be accounted for in the font engines. Task-number: QTBUG-57491 Change-Id: Idabbe44677c4b92cbd8ad8278b054de53e9cc7f9 Reviewed-by: Simon Hausmann Reviewed-by: Alessandro Portale Reviewed-by: Allan Sandfeld Jensen --- .../fontdatabases/windows/qwindowsfontenginedirectwrite.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/platformsupport/fontdatabases/windows/qwindowsfontenginedirectwrite.cpp b/src/platformsupport/fontdatabases/windows/qwindowsfontenginedirectwrite.cpp index 6130107cc8..683b7f65ad 100644 --- a/src/platformsupport/fontdatabases/windows/qwindowsfontenginedirectwrite.cpp +++ b/src/platformsupport/fontdatabases/windows/qwindowsfontenginedirectwrite.cpp @@ -663,7 +663,7 @@ QImage QWindowsFontEngineDirectWrite::imageForGlyph(glyph_t t, glyphRun.glyphOffsets = &glyphOffset; QTransform xform = originalTransform; - if (fontDef.stretch != 100) + if (fontDef.stretch != 100 && fontDef.stretch != QFont::AnyStretch) xform.scale(fontDef.stretch / 100.0, 1.0); DWRITE_MATRIX transform; @@ -933,7 +933,7 @@ glyph_metrics_t QWindowsFontEngineDirectWrite::alphaMapBoundingBox(glyph_t glyph Q_UNUSED(format); QTransform matrix = originalTransform; - if (fontDef.stretch != 100) + if (fontDef.stretch != 100 && fontDef.stretch != QFont::AnyStretch) matrix.scale(fontDef.stretch / 100.0, 1.0); glyph_metrics_t bbox = QFontEngine::boundingBox(glyph, matrix); // To get transformed advance -- cgit v1.2.3 From 2d1378836c90ab245290e4b4884bc1ad9e256d5c Mon Sep 17 00:00:00 2001 From: BogDan Vatra Date: Wed, 7 Dec 2016 10:51:39 +0200 Subject: Android: remove unused variable Fix compilation with -Werror Change-Id: Iae6068f9eeb92dd1a96b11f6bb7017b97a8486fb Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/plugins/platforms/android/androidjniaccessibility.cpp | 1 - src/plugins/platforms/android/androidjnimain.cpp | 2 -- 2 files changed, 3 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/android/androidjniaccessibility.cpp b/src/plugins/platforms/android/androidjniaccessibility.cpp index a987092862..3b1ce6d21d 100644 --- a/src/plugins/platforms/android/androidjniaccessibility.cpp +++ b/src/plugins/platforms/android/androidjniaccessibility.cpp @@ -54,7 +54,6 @@ static const char m_qtTag[] = "Qt A11Y"; static const char m_classErrorMsg[] = "Can't find class \"%s\""; -static const char m_methodErrorMsg[] = "Can't find method \"%s%s\""; QT_BEGIN_NAMESPACE diff --git a/src/plugins/platforms/android/androidjnimain.cpp b/src/plugins/platforms/android/androidjnimain.cpp index df8883ab34..1f681cc1a3 100644 --- a/src/plugins/platforms/android/androidjnimain.cpp +++ b/src/plugins/platforms/android/androidjnimain.cpp @@ -122,8 +122,6 @@ static int m_desktopHeightPixels = 0; static double m_scaledDensity = 0; static double m_density = 1.0; -static volatile bool m_pauseApplication; - static AndroidAssetsFileEngineHandler *m_androidAssetsFileEngineHandler = nullptr; -- cgit v1.2.3 From a76579d95654c75228058bbc62df9b9c7dc04d9b Mon Sep 17 00:00:00 2001 From: Alexander Volkov Date: Sun, 27 Nov 2016 11:00:50 +0300 Subject: Android: Add missing override Change-Id: I70b802517d8f7d129ffb71dc3e92cb2458a55acc Reviewed-by: BogDan Vatra (cherry picked from commit e3ad43843a6ddb20c901b6fba85c12fb0e6c5651) Reviewed-by: Eskil Abrahamsen Blomfeldt --- .../platforms/android/androidplatformplugin.cpp | 2 +- .../android/qandroidassetsfileenginehandler.cpp | 34 +++++++++++----------- .../android/qandroidassetsfileenginehandler.h | 2 +- .../platforms/android/qandroideventdispatcher.h | 2 +- .../platforms/android/qandroidinputcontext.h | 24 +++++++-------- .../android/qandroidplatformaccessibility.h | 2 +- .../android/qandroidplatformbackingstore.h | 8 ++--- .../platforms/android/qandroidplatformclipboard.h | 6 ++-- .../android/qandroidplatformdialoghelpers.h | 8 ++--- .../android/qandroidplatformfontdatabase.h | 10 +++---- .../android/qandroidplatformintegration.h | 34 +++++++++++----------- .../platforms/android/qandroidplatformmenu.h | 28 +++++++++--------- .../platforms/android/qandroidplatformmenubar.h | 10 +++---- .../platforms/android/qandroidplatformmenuitem.h | 28 +++++++++--------- .../android/qandroidplatformopenglcontext.h | 6 ++-- .../android/qandroidplatformopenglwindow.h | 8 ++--- .../platforms/android/qandroidplatformscreen.h | 22 +++++++------- .../platforms/android/qandroidplatformservices.h | 6 ++-- .../platforms/android/qandroidplatformtheme.h | 18 ++++++------ .../platforms/android/qandroidplatformwindow.h | 22 +++++++------- .../platforms/android/qandroidsystemlocale.h | 4 +-- 21 files changed, 142 insertions(+), 142 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/android/androidplatformplugin.cpp b/src/plugins/platforms/android/androidplatformplugin.cpp index 8e365e9a59..297e167f47 100644 --- a/src/plugins/platforms/android/androidplatformplugin.cpp +++ b/src/plugins/platforms/android/androidplatformplugin.cpp @@ -47,7 +47,7 @@ class QAndroidPlatformIntegrationPlugin: public QPlatformIntegrationPlugin Q_OBJECT Q_PLUGIN_METADATA(IID QPlatformIntegrationFactoryInterface_iid FILE "android.json") public: - QPlatformIntegration *create(const QString &key, const QStringList ¶mList); + QPlatformIntegration *create(const QString &key, const QStringList ¶mList) override; }; diff --git a/src/plugins/platforms/android/qandroidassetsfileenginehandler.cpp b/src/plugins/platforms/android/qandroidassetsfileenginehandler.cpp index 7e8e1ba9c5..e1dcebfa4c 100644 --- a/src/plugins/platforms/android/qandroidassetsfileenginehandler.cpp +++ b/src/plugins/platforms/android/qandroidassetsfileenginehandler.cpp @@ -75,12 +75,12 @@ public: m_path = path; } - virtual QFileInfo currentFileInfo() const + QFileInfo currentFileInfo() const override { return QFileInfo(currentFilePath()); } - virtual QString currentFileName() const + QString currentFileName() const override { if (m_index < 0 || m_index >= m_items.size()) return QString(); @@ -95,12 +95,12 @@ public: return m_path + currentFileName(); } - virtual bool hasNext() const + bool hasNext() const override { return m_items.size() && (m_index < m_items.size() - 1); } - virtual QString next() + QString next() override { if (!hasNext()) return QString(); @@ -137,12 +137,12 @@ public: close(); } - virtual bool open(QIODevice::OpenMode openMode) + bool open(QIODevice::OpenMode openMode) override { return m_assetFile != 0 && (openMode & QIODevice::WriteOnly) == 0; } - virtual bool close() + bool close() override { if (m_assetFile) { AAsset_close(m_assetFile); @@ -152,50 +152,50 @@ public: return false; } - virtual qint64 size() const + qint64 size() const override { if (m_assetFile) return AAsset_getLength(m_assetFile); return -1; } - virtual qint64 pos() const + qint64 pos() const override { if (m_assetFile) return AAsset_seek(m_assetFile, 0, SEEK_CUR); return -1; } - virtual bool seek(qint64 pos) + bool seek(qint64 pos) override { if (m_assetFile) return pos == AAsset_seek(m_assetFile, pos, SEEK_SET); return false; } - virtual qint64 read(char *data, qint64 maxlen) + qint64 read(char *data, qint64 maxlen) override { if (m_assetFile) return AAsset_read(m_assetFile, data, maxlen); return -1; } - virtual bool isSequential() const + bool isSequential() const override { return false; } - virtual bool caseSensitive() const + bool caseSensitive() const override { return true; } - virtual bool isRelativePath() const + bool isRelativePath() const override { return false; } - virtual FileFlags fileFlags(FileFlags type = FileInfoAll) const + FileFlags fileFlags(FileFlags type = FileInfoAll) const override { FileFlags flags(ReadOwnerPerm|ReadUserPerm|ReadGroupPerm|ReadOtherPerm|ExistsFlag); if (m_assetFile) @@ -206,7 +206,7 @@ public: return type & flags; } - virtual QString fileName(FileName file = DefaultName) const + QString fileName(FileName file = DefaultName) const override { int pos; switch (file) { @@ -231,7 +231,7 @@ public: } } - virtual void setFileName(const QString &file) + void setFileName(const QString &file) override { if (file == m_fileName) return; @@ -243,7 +243,7 @@ public: close(); } - virtual Iterator *beginEntryList(QDir::Filters filters, const QStringList &filterNames) + Iterator *beginEntryList(QDir::Filters filters, const QStringList &filterNames) override { if (!m_assetDir.isNull()) return new AndroidAbstractFileEngineIterator(filters, filterNames, m_assetDir, m_fileName); diff --git a/src/plugins/platforms/android/qandroidassetsfileenginehandler.h b/src/plugins/platforms/android/qandroidassetsfileenginehandler.h index b09d8090a4..f99dc9a11a 100644 --- a/src/plugins/platforms/android/qandroidassetsfileenginehandler.h +++ b/src/plugins/platforms/android/qandroidassetsfileenginehandler.h @@ -55,7 +55,7 @@ class AndroidAssetsFileEngineHandler: public QAbstractFileEngineHandler public: AndroidAssetsFileEngineHandler(); virtual ~AndroidAssetsFileEngineHandler(); - QAbstractFileEngine *create(const QString &fileName) const; + QAbstractFileEngine *create(const QString &fileName) const override; private: void prepopulateCache() const; diff --git a/src/plugins/platforms/android/qandroideventdispatcher.h b/src/plugins/platforms/android/qandroideventdispatcher.h index 86a7e460b3..057a1660c9 100644 --- a/src/plugins/platforms/android/qandroideventdispatcher.h +++ b/src/plugins/platforms/android/qandroideventdispatcher.h @@ -56,7 +56,7 @@ public: void goingToStop(bool stop); protected: - bool processEvents(QEventLoop::ProcessEventsFlags flags); + bool processEvents(QEventLoop::ProcessEventsFlags flags) override; private: QAtomicInt m_stopRequest; diff --git a/src/plugins/platforms/android/qandroidinputcontext.h b/src/plugins/platforms/android/qandroidinputcontext.h index 8a33ff71cc..ce0ec8724c 100644 --- a/src/plugins/platforms/android/qandroidinputcontext.h +++ b/src/plugins/platforms/android/qandroidinputcontext.h @@ -80,21 +80,21 @@ public: QAndroidInputContext(); ~QAndroidInputContext(); static QAndroidInputContext * androidInputContext(); - bool isValid() const { return true; } - - void reset(); - void commit(); - void update(Qt::InputMethodQueries queries); - void invokeAction(QInputMethod::Action action, int cursorPosition); - QRectF keyboardRect() const; - bool isAnimating() const; - void showInputPanel(); - void hideInputPanel(); - bool isInputPanelVisible() const; + bool isValid() const override { return true; } + + void reset() override; + void commit() override; + void update(Qt::InputMethodQueries queries) override; + void invokeAction(QInputMethod::Action action, int cursorPosition) override; + QRectF keyboardRect() const override; + bool isAnimating() const override; + void showInputPanel() override; + void hideInputPanel() override; + bool isInputPanelVisible() const override; bool isComposing() const; void clear(); - void setFocusObject(QObject *object); + void setFocusObject(QObject *object) override; void sendShortcut(const QKeySequence &); //---------------// diff --git a/src/plugins/platforms/android/qandroidplatformaccessibility.h b/src/plugins/platforms/android/qandroidplatformaccessibility.h index 3a428ca1ad..8216c05fa6 100644 --- a/src/plugins/platforms/android/qandroidplatformaccessibility.h +++ b/src/plugins/platforms/android/qandroidplatformaccessibility.h @@ -51,7 +51,7 @@ public: QAndroidPlatformAccessibility(); ~QAndroidPlatformAccessibility(); - virtual void notifyAccessibilityUpdate(QAccessibleEvent *event); + void notifyAccessibilityUpdate(QAccessibleEvent *event) override; }; QT_END_NAMESPACE diff --git a/src/plugins/platforms/android/qandroidplatformbackingstore.h b/src/plugins/platforms/android/qandroidplatformbackingstore.h index e4a161d608..a3a65aa30e 100644 --- a/src/plugins/platforms/android/qandroidplatformbackingstore.h +++ b/src/plugins/platforms/android/qandroidplatformbackingstore.h @@ -50,10 +50,10 @@ class QAndroidPlatformBackingStore : public QPlatformBackingStore { public: explicit QAndroidPlatformBackingStore(QWindow *window); - virtual QPaintDevice *paintDevice(); - virtual void flush(QWindow *window, const QRegion ®ion, const QPoint &offset); - virtual void resize(const QSize &size, const QRegion &staticContents); - QImage toImage() const { return m_image; } + QPaintDevice *paintDevice() override; + void flush(QWindow *window, const QRegion ®ion, const QPoint &offset) override; + void resize(const QSize &size, const QRegion &staticContents) override; + QImage toImage() const override { return m_image; } void setBackingStore(QWindow *window); protected: QImage m_image; diff --git a/src/plugins/platforms/android/qandroidplatformclipboard.h b/src/plugins/platforms/android/qandroidplatformclipboard.h index 47976c1693..dfc3629c10 100644 --- a/src/plugins/platforms/android/qandroidplatformclipboard.h +++ b/src/plugins/platforms/android/qandroidplatformclipboard.h @@ -51,9 +51,9 @@ class QAndroidPlatformClipboard: public QPlatformClipboard public: QAndroidPlatformClipboard(); - virtual QMimeData *mimeData(QClipboard::Mode mode = QClipboard::Clipboard); - virtual void setMimeData(QMimeData *data, QClipboard::Mode mode = QClipboard::Clipboard); - virtual bool supportsMode(QClipboard::Mode mode) const; + QMimeData *mimeData(QClipboard::Mode mode = QClipboard::Clipboard) override; + void setMimeData(QMimeData *data, QClipboard::Mode mode = QClipboard::Clipboard) override; + bool supportsMode(QClipboard::Mode mode) const override; private: QMimeData m_mimeData; diff --git a/src/plugins/platforms/android/qandroidplatformdialoghelpers.h b/src/plugins/platforms/android/qandroidplatformdialoghelpers.h index 5c3aef2bc1..694b4c7580 100644 --- a/src/plugins/platforms/android/qandroidplatformdialoghelpers.h +++ b/src/plugins/platforms/android/qandroidplatformdialoghelpers.h @@ -53,11 +53,11 @@ class QAndroidPlatformMessageDialogHelper: public QPlatformMessageDialogHelper Q_OBJECT public: QAndroidPlatformMessageDialogHelper(); - void exec(); + void exec() override; bool show(Qt::WindowFlags windowFlags, - Qt::WindowModality windowModality, - QWindow *parent); - void hide(); + Qt::WindowModality windowModality, + QWindow *parent) override; + void hide() override; public slots: void dialogResult(int buttonID); diff --git a/src/plugins/platforms/android/qandroidplatformfontdatabase.h b/src/plugins/platforms/android/qandroidplatformfontdatabase.h index b20fd75cb2..533d6e50a9 100644 --- a/src/plugins/platforms/android/qandroidplatformfontdatabase.h +++ b/src/plugins/platforms/android/qandroidplatformfontdatabase.h @@ -47,12 +47,12 @@ QT_BEGIN_NAMESPACE class QAndroidPlatformFontDatabase: public QBasicFontDatabase { public: - QString fontDir() const; - void populateFontDatabase(); + QString fontDir() const override; + void populateFontDatabase() override; QStringList fallbacksForFamily(const QString &family, - QFont::Style style, - QFont::StyleHint styleHint, - QChar::Script script) const; + QFont::Style style, + QFont::StyleHint styleHint, + QChar::Script script) const override; }; QT_END_NAMESPACE diff --git a/src/plugins/platforms/android/qandroidplatformintegration.h b/src/plugins/platforms/android/qandroidplatformintegration.h index bda0bee9ad..2337801250 100644 --- a/src/plugins/platforms/android/qandroidplatformintegration.h +++ b/src/plugins/platforms/android/qandroidplatformintegration.h @@ -63,7 +63,7 @@ struct AndroidStyle; class QAndroidPlatformNativeInterface: public QPlatformNativeInterface { public: - void *nativeResourceForIntegration(const QByteArray &resource); + void *nativeResourceForIntegration(const QByteArray &resource) override; std::shared_ptr m_androidStyle; }; @@ -75,39 +75,39 @@ public: QAndroidPlatformIntegration(const QStringList ¶mList); ~QAndroidPlatformIntegration(); - bool hasCapability(QPlatformIntegration::Capability cap) const; + bool hasCapability(QPlatformIntegration::Capability cap) const override; - QPlatformWindow *createPlatformWindow(QWindow *window) const; - QPlatformBackingStore *createPlatformBackingStore(QWindow *window) const; - QPlatformOpenGLContext *createPlatformOpenGLContext(QOpenGLContext *context) const; - QAbstractEventDispatcher *createEventDispatcher() const; + QPlatformWindow *createPlatformWindow(QWindow *window) const override; + QPlatformBackingStore *createPlatformBackingStore(QWindow *window) const override; + QPlatformOpenGLContext *createPlatformOpenGLContext(QOpenGLContext *context) const override; + QAbstractEventDispatcher *createEventDispatcher() const override; QAndroidPlatformScreen *screen() { return m_primaryScreen; } - QPlatformOffscreenSurface *createPlatformOffscreenSurface(QOffscreenSurface *surface) const; + QPlatformOffscreenSurface *createPlatformOffscreenSurface(QOffscreenSurface *surface) const override; virtual void setDesktopSize(int width, int height); virtual void setDisplayMetrics(int width, int height); void setScreenSize(int width, int height); bool isVirtualDesktop() { return true; } - QPlatformFontDatabase *fontDatabase() const; + QPlatformFontDatabase *fontDatabase() const override; #ifndef QT_NO_CLIPBOARD - QPlatformClipboard *clipboard() const; + QPlatformClipboard *clipboard() const override; #endif - QPlatformInputContext *inputContext() const; - QPlatformNativeInterface *nativeInterface() const; - QPlatformServices *services() const; + QPlatformInputContext *inputContext() const override; + QPlatformNativeInterface *nativeInterface() const override; + QPlatformServices *services() const override; #ifndef QT_NO_ACCESSIBILITY - virtual QPlatformAccessibility *accessibility() const; + virtual QPlatformAccessibility *accessibility() const override; #endif - QVariant styleHint(StyleHint hint) const; - Qt::WindowState defaultWindowState(Qt::WindowFlags flags) const; + QVariant styleHint(StyleHint hint) const override; + Qt::WindowState defaultWindowState(Qt::WindowFlags flags) const override; - QStringList themeNames() const; - QPlatformTheme *createPlatformTheme(const QString &name) const; + QStringList themeNames() const override; + QPlatformTheme *createPlatformTheme(const QString &name) const override; static void setDefaultDisplayMetrics(int gw, int gh, int sw, int sh, int width, int height); static void setDefaultDesktopSize(int gw, int gh); diff --git a/src/plugins/platforms/android/qandroidplatformmenu.h b/src/plugins/platforms/android/qandroidplatformmenu.h index cb1b431d31..00968672c5 100644 --- a/src/plugins/platforms/android/qandroidplatformmenu.h +++ b/src/plugins/platforms/android/qandroidplatformmenu.h @@ -56,25 +56,25 @@ public: QAndroidPlatformMenu(); ~QAndroidPlatformMenu(); - void insertMenuItem(QPlatformMenuItem *menuItem, QPlatformMenuItem *before); - void removeMenuItem(QPlatformMenuItem *menuItem); - void syncMenuItem(QPlatformMenuItem *menuItem); - void syncSeparatorsCollapsible(bool enable); + void insertMenuItem(QPlatformMenuItem *menuItem, QPlatformMenuItem *before) override; + void removeMenuItem(QPlatformMenuItem *menuItem) override; + void syncMenuItem(QPlatformMenuItem *menuItem) override; + void syncSeparatorsCollapsible(bool enable) override; - void setTag(quintptr tag); - quintptr tag() const; - void setText(const QString &text); + void setTag(quintptr tag) override; + quintptr tag() const override; + void setText(const QString &text) override; QString text() const; - void setIcon(const QIcon &icon); + void setIcon(const QIcon &icon) override; QIcon icon() const; - void setEnabled(bool enabled); - bool isEnabled() const; - void setVisible(bool visible); + void setEnabled(bool enabled) override; + bool isEnabled() const override; + void setVisible(bool visible) override; bool isVisible() const; - void showPopup(const QWindow *parentWindow, const QRect &targetRect, const QPlatformMenuItem *item); + void showPopup(const QWindow *parentWindow, const QRect &targetRect, const QPlatformMenuItem *item) override; - QPlatformMenuItem *menuItemAt(int position) const; - QPlatformMenuItem *menuItemForTag(quintptr tag) const; + QPlatformMenuItem *menuItemAt(int position) const override; + QPlatformMenuItem *menuItemForTag(quintptr tag) const override; PlatformMenuItemsType menuItems() const; QMutex *menuItemsMutex(); diff --git a/src/plugins/platforms/android/qandroidplatformmenubar.h b/src/plugins/platforms/android/qandroidplatformmenubar.h index d98d02d5de..0316ea9362 100644 --- a/src/plugins/platforms/android/qandroidplatformmenubar.h +++ b/src/plugins/platforms/android/qandroidplatformmenubar.h @@ -55,11 +55,11 @@ public: QAndroidPlatformMenuBar(); ~QAndroidPlatformMenuBar(); - void insertMenu(QPlatformMenu *menu, QPlatformMenu *before); - void removeMenu(QPlatformMenu *menu); - void syncMenu(QPlatformMenu *menu); - void handleReparent(QWindow *newParentWindow); - QPlatformMenu *menuForTag(quintptr tag) const; + void insertMenu(QPlatformMenu *menu, QPlatformMenu *before) override; + void removeMenu(QPlatformMenu *menu) override; + void syncMenu(QPlatformMenu *menu) override; + void handleReparent(QWindow *newParentWindow) override; + QPlatformMenu *menuForTag(quintptr tag) const override; QWindow *parentWindow() const; PlatformMenusType menus() const; diff --git a/src/plugins/platforms/android/qandroidplatformmenuitem.h b/src/plugins/platforms/android/qandroidplatformmenuitem.h index e843c9eedc..be5240cfa6 100644 --- a/src/plugins/platforms/android/qandroidplatformmenuitem.h +++ b/src/plugins/platforms/android/qandroidplatformmenuitem.h @@ -49,41 +49,41 @@ class QAndroidPlatformMenuItem: public QPlatformMenuItem { public: QAndroidPlatformMenuItem(); - void setTag(quintptr tag); - quintptr tag() const; + void setTag(quintptr tag) override; + quintptr tag() const override; - void setText(const QString &text); + void setText(const QString &text) override; QString text() const; - void setIcon(const QIcon &icon); + void setIcon(const QIcon &icon) override; QIcon icon() const; - void setMenu(QPlatformMenu *menu); + void setMenu(QPlatformMenu *menu) override; QAndroidPlatformMenu *menu() const; - void setVisible(bool isVisible); + void setVisible(bool isVisible) override; bool isVisible() const; - void setIsSeparator(bool isSeparator); + void setIsSeparator(bool isSeparator) override; bool isSeparator() const; - void setFont(const QFont &font); + void setFont(const QFont &font) override; - void setRole(MenuRole role); + void setRole(MenuRole role) override; MenuRole role() const; - void setCheckable(bool checkable); + void setCheckable(bool checkable) override; bool isCheckable() const; - void setChecked(bool isChecked); + void setChecked(bool isChecked) override; bool isChecked() const; - void setShortcut(const QKeySequence &shortcut); + void setShortcut(const QKeySequence &shortcut) override; - void setEnabled(bool enabled); + void setEnabled(bool enabled) override; bool isEnabled() const; - void setIconSize(int size); + void setIconSize(int size) override; private: quintptr m_tag; diff --git a/src/plugins/platforms/android/qandroidplatformopenglcontext.h b/src/plugins/platforms/android/qandroidplatformopenglcontext.h index d3f6cf13a4..87a0829655 100644 --- a/src/plugins/platforms/android/qandroidplatformopenglcontext.h +++ b/src/plugins/platforms/android/qandroidplatformopenglcontext.h @@ -49,11 +49,11 @@ class QAndroidPlatformOpenGLContext : public QEGLPlatformContext { public: QAndroidPlatformOpenGLContext(const QSurfaceFormat &format, QPlatformOpenGLContext *share, EGLDisplay display); - void swapBuffers(QPlatformSurface *surface); - bool makeCurrent(QPlatformSurface *surface); + void swapBuffers(QPlatformSurface *surface) override; + bool makeCurrent(QPlatformSurface *surface) override; private: - virtual EGLSurface eglSurfaceForPlatformSurface(QPlatformSurface *surface); + EGLSurface eglSurfaceForPlatformSurface(QPlatformSurface *surface) override; static bool needsFBOReadBackWorkaround(); }; diff --git a/src/plugins/platforms/android/qandroidplatformopenglwindow.h b/src/plugins/platforms/android/qandroidplatformopenglwindow.h index c7cb881973..12e86b3db4 100644 --- a/src/plugins/platforms/android/qandroidplatformopenglwindow.h +++ b/src/plugins/platforms/android/qandroidplatformopenglwindow.h @@ -56,18 +56,18 @@ public: explicit QAndroidPlatformOpenGLWindow(QWindow *window, EGLDisplay display); ~QAndroidPlatformOpenGLWindow(); - void setGeometry(const QRect &rect); + void setGeometry(const QRect &rect) override; EGLSurface eglSurface(EGLConfig config); - QSurfaceFormat format() const; + QSurfaceFormat format() const override; bool checkNativeSurface(EGLConfig config); - void applicationStateChanged(Qt::ApplicationState); + void applicationStateChanged(Qt::ApplicationState) override; void repaint(const QRegion ®ion) Q_DECL_OVERRIDE; protected: - virtual void surfaceChanged(JNIEnv *jniEnv, jobject surface, int w, int h); + void surfaceChanged(JNIEnv *jniEnv, jobject surface, int w, int h) override; void createEgl(EGLConfig config); void clearEgl(); diff --git a/src/plugins/platforms/android/qandroidplatformscreen.h b/src/plugins/platforms/android/qandroidplatformscreen.h index 6e601d5f87..923c9e8832 100644 --- a/src/plugins/platforms/android/qandroidplatformscreen.h +++ b/src/plugins/platforms/android/qandroidplatformscreen.h @@ -63,14 +63,14 @@ public: QAndroidPlatformScreen(); ~QAndroidPlatformScreen(); - QRect geometry() const { return QRect(QPoint(), m_size); } - QRect availableGeometry() const { return m_availableGeometry; } - int depth() const { return m_depth; } - QImage::Format format() const { return m_format; } - QSizeF physicalSize() const { return m_physicalSize; } + QRect geometry() const override { return QRect(QPoint(), m_size); } + QRect availableGeometry() const override { return m_availableGeometry; } + int depth() const override { return m_depth; } + QImage::Format format() const override { return m_format; } + QSizeF physicalSize() const override { return m_physicalSize; } inline QWindow *topWindow() const; - QWindow *topLevelAt(const QPoint & p) const; + QWindow *topLevelAt(const QPoint & p) const override; // compositor api void addWindow(QAndroidPlatformWindow *window); @@ -100,11 +100,11 @@ protected: QSizeF m_physicalSize; private: - QDpi logicalDpi() const; - qreal pixelDensity() const; - Qt::ScreenOrientation orientation() const; - Qt::ScreenOrientation nativeOrientation() const; - void surfaceChanged(JNIEnv *env, jobject surface, int w, int h); + QDpi logicalDpi() const override; + qreal pixelDensity() const override; + Qt::ScreenOrientation orientation() const override; + Qt::ScreenOrientation nativeOrientation() const override; + void surfaceChanged(JNIEnv *env, jobject surface, int w, int h) override; void releaseSurface(); void applicationStateChanged(Qt::ApplicationState); diff --git a/src/plugins/platforms/android/qandroidplatformservices.h b/src/plugins/platforms/android/qandroidplatformservices.h index 5cdc3e95b2..6f2f0a394f 100644 --- a/src/plugins/platforms/android/qandroidplatformservices.h +++ b/src/plugins/platforms/android/qandroidplatformservices.h @@ -49,9 +49,9 @@ class QAndroidPlatformServices: public QPlatformServices { public: QAndroidPlatformServices(); - bool openUrl(const QUrl &url); - bool openDocument(const QUrl &url); - QByteArray desktopEnvironment() const; + bool openUrl(const QUrl &url) override; + bool openDocument(const QUrl &url) override; + QByteArray desktopEnvironment() const override; }; QT_END_NAMESPACE diff --git a/src/plugins/platforms/android/qandroidplatformtheme.h b/src/plugins/platforms/android/qandroidplatformtheme.h index b4d8fa35b1..7405c3cdbd 100644 --- a/src/plugins/platforms/android/qandroidplatformtheme.h +++ b/src/plugins/platforms/android/qandroidplatformtheme.h @@ -65,16 +65,16 @@ class QAndroidPlatformTheme: public QPlatformTheme { public: QAndroidPlatformTheme(QAndroidPlatformNativeInterface * androidPlatformNativeInterface); - virtual QPlatformMenuBar *createPlatformMenuBar() const; - virtual QPlatformMenu *createPlatformMenu() const; - virtual QPlatformMenuItem *createPlatformMenuItem() const; - virtual void showPlatformMenuBar(); - virtual const QPalette *palette(Palette type = SystemPalette) const; - virtual const QFont *font(Font type = SystemFont) const; - virtual QVariant themeHint(ThemeHint hint) const; + QPlatformMenuBar *createPlatformMenuBar() const override; + QPlatformMenu *createPlatformMenu() const override; + QPlatformMenuItem *createPlatformMenuItem() const override; + void showPlatformMenuBar() override; + const QPalette *palette(Palette type = SystemPalette) const override; + const QFont *font(Font type = SystemFont) const override; + QVariant themeHint(ThemeHint hint) const override; QString standardButtonText(int button) const Q_DECL_OVERRIDE; - virtual bool usePlatformNativeDialog(DialogType type) const; - virtual QPlatformDialogHelper *createPlatformDialogHelper(DialogType type) const; + bool usePlatformNativeDialog(DialogType type) const override; + QPlatformDialogHelper *createPlatformDialogHelper(DialogType type) const override; private: diff --git a/src/plugins/platforms/android/qandroidplatformwindow.h b/src/plugins/platforms/android/qandroidplatformwindow.h index 8d69532d08..87e5cbaa4f 100644 --- a/src/plugins/platforms/android/qandroidplatformwindow.h +++ b/src/plugins/platforms/android/qandroidplatformwindow.h @@ -54,21 +54,21 @@ class QAndroidPlatformWindow: public QPlatformWindow public: explicit QAndroidPlatformWindow(QWindow *window); - void lower(); - void raise(); + void lower() override; + void raise() override; - void setVisible(bool visible); + void setVisible(bool visible) override; - void setWindowState(Qt::WindowState state); - void setWindowFlags(Qt::WindowFlags flags); + void setWindowState(Qt::WindowState state) override; + void setWindowFlags(Qt::WindowFlags flags) override; Qt::WindowFlags windowFlags() const; - void setParent(const QPlatformWindow *window); - WId winId() const { return m_windowId; } + void setParent(const QPlatformWindow *window) override; + WId winId() const override { return m_windowId; } QAndroidPlatformScreen *platformScreen() const; - void propagateSizeHints(); - void requestActivateWindow(); + void propagateSizeHints() override; + void requestActivateWindow() override; void updateStatusBarVisibility(); inline bool isRaster() const { if ((window()->flags() & Qt::ForeignWindow) == Qt::ForeignWindow) @@ -77,7 +77,7 @@ public: return window()->surfaceType() == QSurface::RasterSurface || window()->surfaceType() == QSurface::RasterGLSurface; } - bool isExposed() const; + bool isExposed() const override; virtual void applicationStateChanged(Qt::ApplicationState); @@ -87,7 +87,7 @@ public: virtual void repaint(const QRegion &) { } protected: - void setGeometry(const QRect &rect); + void setGeometry(const QRect &rect) override; protected: Qt::WindowFlags m_windowFlags; diff --git a/src/plugins/platforms/android/qandroidsystemlocale.h b/src/plugins/platforms/android/qandroidsystemlocale.h index 26af1ee51d..bc96d2e8f6 100644 --- a/src/plugins/platforms/android/qandroidsystemlocale.h +++ b/src/plugins/platforms/android/qandroidsystemlocale.h @@ -50,8 +50,8 @@ class QAndroidSystemLocale : public QSystemLocale public: QAndroidSystemLocale(); - virtual QVariant query(QueryType type, QVariant in) const; - virtual QLocale fallbackUiLocale() const; + QVariant query(QueryType type, QVariant in) const override; + QLocale fallbackUiLocale() const override; private: void getLocaleFromJava() const; -- cgit v1.2.3 From 5b8957247f5e2845dd9f59545ba567d051c4e436 Mon Sep 17 00:00:00 2001 From: Topi Reinio Date: Fri, 9 Dec 2016 12:34:33 +0100 Subject: Doc: QPointingDeviceUniqueId: Fix documentation warning Fix the following warning by adding a const qualifier: warning: No documentation for 'QPointingDeviceUniqueId::isValid()' Change-Id: I1ebeda8f45e88efb7cb844b67409352c695e6354 Reviewed-by: Shawn Rutledge --- src/gui/kernel/qevent.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp index b198fa0832..219f782737 100644 --- a/src/gui/kernel/qevent.cpp +++ b/src/gui/kernel/qevent.cpp @@ -5216,7 +5216,7 @@ QPointingDeviceUniqueId QPointingDeviceUniqueId::fromNumericId(qint64 id) } /*! - \fn bool QPointingDeviceUniqueId::isValid() + \fn bool QPointingDeviceUniqueId::isValid() const Returns whether this unique pointer ID is valid, that is, it represents an actual pointer. -- cgit v1.2.3 From 4c0760d327e390a37d0d6ce2016d3a8c5b87a119 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 30 Nov 2016 15:29:45 -0800 Subject: Re-fix the build with ICC and cmath & math.h Commit c35fef9d3b8bb77a7f303e3cd62c86cd00e57f5b wasn't sufficient. The problem is that there's a complex combination of libc headers (math.h), C++ headers (cmath), which may be provided by three different sources on Linux (glibc, gcc and ICC). On some combinations, the isnan macro leaks from math.h or cmath and that's what the the commit above tried to fix. On some other combinations, there's no macro but there's an ::isnan function defined. When we do "using namespace std; return isnan(x);", that causes a compilation error. This commit solves that by detecting whether there is a macro defined. error: more than one instance of overloaded function "isnan" matches the argument list function "isnan(double)" function "std::isnan(double)" argument types are: (double) Change-Id: Iaeecaffe26af4535b416fffd148bf71826541bdd Reviewed-by: Thiago Macieira --- src/corelib/global/qnumeric_p.h | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/corelib/global/qnumeric_p.h b/src/corelib/global/qnumeric_p.h index 23fcf340f1..01b8772ee1 100644 --- a/src/corelib/global/qnumeric_p.h +++ b/src/corelib/global/qnumeric_p.h @@ -68,7 +68,8 @@ #if !defined(Q_CC_MSVC) && (defined(Q_OS_QNX) || defined(Q_CC_INTEL) || !defined(__cplusplus)) # include -# define QT_MATH_H_DEFINES_MACROS +# ifdef isnan +# define QT_MATH_H_DEFINES_MACROS QT_BEGIN_NAMESPACE namespace qnumeric_std_wrapper { // the 'using namespace std' below is cases where the stdlib already put the math.h functions in the std namespace and undefined the macros. @@ -81,10 +82,11 @@ static inline bool math_h_isfinite(float f) { using namespace std; return isfini } QT_END_NAMESPACE // These macros from math.h conflict with the real functions in the std namespace. -#undef signbit -#undef isnan -#undef isinf -#undef isfinite +# undef signbit +# undef isnan +# undef isinf +# undef isfinite +# endif // defined(isnan) #endif QT_BEGIN_NAMESPACE -- cgit v1.2.3 From bb0f29f82b934b489f1679b7b72f094aa287be3c Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Mon, 12 Dec 2016 23:53:22 +0100 Subject: Fix gcc 6.4 builds The builtins clzs and ctzs have been removed. Additionally they were never proper internal GCC builtins and shouldn't have been used in a constexpr function in the first place. This patch removes the assumption that they exist when BMI is available, and let GCC fall back to using __builtin_clz and __builtin_ctz. Change-Id: I3e0b4e246098bb9ce6ede28b311948260ef881b9 Task-number: QTBUG-56813 Reviewed-by: Thiago Macieira --- src/corelib/tools/qalgorithms.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/corelib/tools/qalgorithms.h b/src/corelib/tools/qalgorithms.h index 303374b06d..51f73c3368 100644 --- a/src/corelib/tools/qalgorithms.h +++ b/src/corelib/tools/qalgorithms.h @@ -535,7 +535,7 @@ QT_DEPRECATED_X("Use std::binary_search") Q_OUTOFLINE_TEMPLATE RandomAccessItera # define QT_HAS_BUILTIN_CTZS Q_DECL_CONSTEXPR Q_ALWAYS_INLINE uint qt_builtin_ctzs(quint16 v) Q_DECL_NOTHROW { -# if QT_HAS_BUILTIN(__builtin_ctzs) || defined(__BMI__) +# if QT_HAS_BUILTIN(__builtin_ctzs) return __builtin_ctzs(v); # else return __builtin_ctz(v); @@ -544,7 +544,7 @@ Q_DECL_CONSTEXPR Q_ALWAYS_INLINE uint qt_builtin_ctzs(quint16 v) Q_DECL_NOTHROW #define QT_HAS_BUILTIN_CLZS Q_DECL_CONSTEXPR Q_ALWAYS_INLINE uint qt_builtin_clzs(quint16 v) Q_DECL_NOTHROW { -# if QT_HAS_BUILTIN(__builtin_clzs) || defined(__BMI__) +# if QT_HAS_BUILTIN(__builtin_clzs) return __builtin_clzs(v); # else return __builtin_clz(v) - 16U; -- cgit v1.2.3 From 36e4b13e29ef055c2b05a526cb65529d88b03582 Mon Sep 17 00:00:00 2001 From: BogDan Vatra Date: Thu, 8 Dec 2016 13:42:16 +0200 Subject: Android: fix (partially) text deletion when the cursor is moved - wait until the handle location changes the cursor position - don't update cursor position if: * a batchEdit is in progress * the UpdateSelection is blocked - finish the composing before update the cursor - add the missing .java files There are still corner situations when the text gets deleted/moved, but those are pretty rare and they will be fix in another patch. Task-number: QTBUG-57507 Change-Id: I230d7f64625fb556e1be3069694a71e9bc91323a Reviewed-by: Paul Olav Tvete --- src/android/jar/jar.pri | 4 +++- src/plugins/platforms/android/androidjniinput.cpp | 2 +- src/plugins/platforms/android/qandroidinputcontext.cpp | 5 +++++ src/plugins/platforms/android/qandroidinputcontext.h | 2 +- 4 files changed, 10 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/android/jar/jar.pri b/src/android/jar/jar.pri index 58caacb837..4535880536 100644 --- a/src/android/jar/jar.pri +++ b/src/android/jar/jar.pri @@ -17,7 +17,9 @@ JAVASOURCES += \ $$PATHPREFIX/QtNativeLibrariesDir.java \ $$PATHPREFIX/QtSurface.java \ $$PATHPREFIX/ExtractStyle.java \ - $$PATHPREFIX/QtServiceDelegate.java + $$PATHPREFIX/EditMenu.java \ + $$PATHPREFIX/EditPopupMenu.java \ + $$PATHPREFIX/CursorHandle.java # install target.path = $$[QT_INSTALL_PREFIX]/jar diff --git a/src/plugins/platforms/android/androidjniinput.cpp b/src/plugins/platforms/android/androidjniinput.cpp index 5f05ab395e..d3bb089aa4 100644 --- a/src/plugins/platforms/android/androidjniinput.cpp +++ b/src/plugins/platforms/android/androidjniinput.cpp @@ -810,7 +810,7 @@ namespace QtAndroidInput #endif QAndroidInputContext *inputContext = QAndroidInputContext::androidInputContext(); if (inputContext && qGuiApp) - QMetaObject::invokeMethod(inputContext, "handleLocationChanged", + QMetaObject::invokeMethod(inputContext, "handleLocationChanged", Qt::BlockingQueuedConnection, Q_ARG(int, id), Q_ARG(int, x), Q_ARG(int, y)); } diff --git a/src/plugins/platforms/android/qandroidinputcontext.cpp b/src/plugins/platforms/android/qandroidinputcontext.cpp index 2656d45d5f..12e85046f8 100644 --- a/src/plugins/platforms/android/qandroidinputcontext.cpp +++ b/src/plugins/platforms/android/qandroidinputcontext.cpp @@ -578,6 +578,11 @@ void QAndroidInputContext::updateSelectionHandles() */ void QAndroidInputContext::handleLocationChanged(int handleId, int x, int y) { + if (m_batchEditNestingLevel.load() || m_blockUpdateSelection) + return; + + finishComposingText(); + auto im = qGuiApp->inputMethod(); auto leftRect = im->cursorRectangle(); // The handle is down of the cursor, but we want the position in the middle. diff --git a/src/plugins/platforms/android/qandroidinputcontext.h b/src/plugins/platforms/android/qandroidinputcontext.h index ce0ec8724c..e7692bf720 100644 --- a/src/plugins/platforms/android/qandroidinputcontext.h +++ b/src/plugins/platforms/android/qandroidinputcontext.h @@ -152,7 +152,7 @@ private: CursorHandleShowPopup = 3 }; CursorHandleShowMode m_cursorHandleShown; - int m_batchEditNestingLevel; + QAtomicInt m_batchEditNestingLevel; QObject *m_focusObject; }; -- cgit v1.2.3 From c0842aceaf9881caba798f2569e6e1cf03ce7f70 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Thu, 8 Dec 2016 12:08:12 +0100 Subject: Make size grip work with high dpi scaling Task-number: QTBUG-53389 Change-Id: I6e922f0555ae296f3152d4df2598534fa73fb584 Reviewed-by: Friedemann Kleint --- src/plugins/platforms/xcb/qxcbwindow.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp index 5fa8541f26..ff01fa019e 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbwindow.cpp @@ -2738,7 +2738,7 @@ bool QXcbWindow::startSystemResize(const QPoint &pos, Qt::Corner corner) const xcb_atom_t moveResize = connection()->atom(QXcbAtom::_NET_WM_MOVERESIZE); if (!connection()->wmSupport()->isSupportedByWM(moveResize)) return false; - const QPoint globalPos = window()->mapToGlobal(pos); + const QPoint globalPos = QHighDpi::toNativePixels(window()->mapToGlobal(pos), window()->screen()); #ifdef XCB_USE_XINPUT22 if (connection()->startSystemResizeForTouchBegin(m_window, globalPos, corner)) return true; -- cgit v1.2.3 From 169a40d511165f6c3c9a71cd5c079786c22d2aca Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Thu, 24 Nov 2016 18:41:48 +0100 Subject: move generation of qconfig.cpp (and qt.conf) to qmake-based configure this moves us another step towards the "outer" configure doing just minimal bootstrapping of qmake. a challenge here was that so far, qmake itself needed qconfig.cpp. this was replaced by usage of a qt.conf file instead of compiled-in values. however, to make the executable still self-contained, that qt.conf is embedded into it (by simple appending of a fixed signature and the text file). the qmake with the embedded qt.conf is not used for the qt build itself, which instead relies on the qt.conf in bin/ as before. however, due to the missing built-in values, this file now needs to contain more information than before. but except for a minimal version that is needed to start up qmake/configure at all, that file is now also generated with qmake. as some of the newly set up properties are subsequently used by configure itself, qmake gains a (deliberately undocumented) function to reload the qt.conf after it's fully populated. unlike the old implementations, this one doesn't emit redundant qt.conf entries which match the hard-coded fallbacks. omitting them leads to leaner files which are more comprehensible. Started-by: Paolo Angelelli Change-Id: I4526ef64b3c89d9851e10f83965fe479ed7f39f6 Reviewed-by: Jake Petroules --- src/corelib/global/qlibraryinfo.cpp | 116 ++++++++++++++++++++++++++++++++---- src/corelib/global/qlibraryinfo.h | 2 + 2 files changed, 106 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/corelib/global/qlibraryinfo.cpp b/src/corelib/global/qlibraryinfo.cpp index 27fe10a79e..87ee75fa45 100644 --- a/src/corelib/global/qlibraryinfo.cpp +++ b/src/corelib/global/qlibraryinfo.cpp @@ -41,15 +41,18 @@ #include "qdir.h" #include "qstringlist.h" #include "qfile.h" +#include "qtemporaryfile.h" #include "qsettings.h" #include "qlibraryinfo.h" #include "qscopedpointer.h" #ifdef QT_BUILD_QMAKE QT_BEGIN_NAMESPACE +extern QString qmake_absoluteLocation(); extern QString qmake_libraryInfoFile(); QT_END_NAMESPACE #else +# include "qconfig.cpp" # include "qcoreapplication.h" #endif @@ -57,7 +60,6 @@ QT_END_NAMESPACE # include "private/qcore_mac_p.h" #endif -#include "qconfig.cpp" #include "archdetect.cpp" QT_BEGIN_NAMESPACE @@ -70,9 +72,16 @@ struct QLibrarySettings { QLibrarySettings(); void load(); +#ifdef QT_BUILD_QMAKE + void loadBuiltinValues(QSettings *config); +#endif QScopedPointer settings; #ifdef QT_BUILD_QMAKE + QString builtinValues[QLibraryInfo::LastHostPath + 1]; +# ifndef Q_OS_WIN + QString builtinSettingsPath; +# endif bool haveDevicePaths; bool haveEffectiveSourcePaths; bool haveEffectivePaths; @@ -88,6 +97,11 @@ class QLibraryInfoPrivate public: static QSettings *findConfiguration(); #ifdef QT_BUILD_QMAKE + static void reload() + { + if (qt_library_settings.exists()) + qt_library_settings->load(); + } static bool haveGroup(QLibraryInfo::PathGroup group) { QLibrarySettings *ls = qt_library_settings(); @@ -99,6 +113,25 @@ public: ? ls->haveDevicePaths : ls->havePaths) : false; } + static bool sysrootify() + { + // This is actually bogus, as it does not consider post-configure settings. + QLibrarySettings *ls = qt_library_settings(); + return ls ? (!ls->builtinValues[QLibraryInfo::SysrootPath].isEmpty() + && ls->builtinValues[QLibraryInfo::ExtPrefixPath].isEmpty()) : false; + } + static QString builtinValue(int loc) + { + QLibrarySettings *ls = qt_library_settings(); + return ls ? ls->builtinValues[loc] : QString(); + } +# ifndef Q_OS_WIN + static QString builtinSettingsPath() + { + QLibrarySettings *ls = qt_library_settings(); + return ls ? ls->builtinSettingsPath : QString(); + } +# endif #endif static QSettings *configuration() { @@ -122,6 +155,20 @@ QLibrarySettings::QLibrarySettings() load(); } +#ifdef QT_BUILD_QMAKE +static QByteArray qtconfSeparator() +{ +# ifdef Q_OS_WIN + QByteArray header = QByteArrayLiteral("\r\n===========================================================\r\n"); +# else + QByteArray header = QByteArrayLiteral("\n===========================================================\n"); +# endif + QByteArray content = QByteArrayLiteral("==================== qt.conf beginning ===================="); + // Assemble from pieces to avoid that the string appears in a raw executable + return header + content + header; +} +#endif + void QLibrarySettings::load() { // If we get any settings here, those won't change when the application shows up. @@ -159,6 +206,27 @@ void QLibrarySettings::load() havePaths = false; #endif } + +#ifdef QT_BUILD_QMAKE + // Try to use an embedded qt.conf appended to the QMake executable. + QFile qmakeFile(qmake_absoluteLocation()); + if (!qmakeFile.open(QIODevice::ReadOnly)) + return; + qmakeFile.seek(qmakeFile.size() - 10000); + QByteArray tail = qmakeFile.read(10000); + QByteArray separator = qtconfSeparator(); + int qtconfOffset = tail.lastIndexOf(separator); + if (qtconfOffset < 0) + return; + tail.remove(0, qtconfOffset + separator.size()); + // If QSettings had a c'tor taking a QIODevice, we'd pass a QBuffer ... + QTemporaryFile tmpFile; + tmpFile.open(); + tmpFile.write(tail); + tmpFile.close(); + QSettings builtinSettings(tmpFile.fileName(), QSettings::IniFormat); + loadBuiltinValues(&builtinSettings); +#endif } QSettings *QLibraryInfoPrivate::findConfiguration() @@ -420,10 +488,30 @@ static const struct { { "HostData", "." }, { "TargetSpec", "" }, { "HostSpec", "" }, + { "ExtPrefix", "" }, { "HostPrefix", "" }, #endif }; +#ifdef QT_BUILD_QMAKE +void QLibrarySettings::loadBuiltinValues(QSettings *config) +{ + config->beginGroup(QLatin1String("Paths")); + for (int i = 0; i <= QLibraryInfo::LastHostPath; i++) + builtinValues[i] = config->value(QLatin1String(qtConfEntries[i].key), + QLatin1String(qtConfEntries[i].value)).toString(); +# ifndef Q_OS_WIN + builtinSettingsPath = config->value(QLatin1String("Settings")).toString(); +# endif + config->endGroup(); +} + +void QLibraryInfo::reload() +{ + QLibraryInfoPrivate::reload(); +} +#endif + /*! Returns the location specified by \a loc. */ @@ -434,7 +522,7 @@ QLibraryInfo::location(LibraryLocation loc) QString ret = rawLocation(loc, FinalPaths); // Automatically prepend the sysroot to target paths - if ((loc < SysrootPath || loc > LastHostPath) && QT_CONFIGURE_SYSROOTIFY_PREFIX) { + if ((loc < SysrootPath || loc > LastHostPath) && QLibraryInfoPrivate::sysrootify()) { QString sysroot = rawLocation(SysrootPath, FinalPaths); if (!sysroot.isEmpty() && ret.length() > 2 && ret.at(1) == QLatin1Char(':') && (ret.at(2) == QLatin1Char('/') || ret.at(2) == QLatin1Char('\\'))) @@ -528,28 +616,32 @@ QLibraryInfo::rawLocation(LibraryLocation loc, PathGroup group) #endif // QT_NO_SETTINGS if (!fromConf) { +#ifdef QT_BUILD_QMAKE + if ((unsigned)loc <= (unsigned)LastHostPath) { + if (loc == PrefixPath && group != DevicePaths) + ret = QLibraryInfoPrivate::builtinValue(ExtPrefixPath); + else + ret = QLibraryInfoPrivate::builtinValue(loc); +# ifndef Q_OS_WIN // On Windows we use the registry + } else if (loc == SettingsPath) { + ret = QLibraryInfoPrivate::builtinSettingsPath(); +# endif + } +#else // QT_BUILD_QMAKE const char * volatile path = 0; if (loc == PrefixPath) { - path = -#ifdef QT_BUILD_QMAKE - (group != DevicePaths) ? - QT_CONFIGURE_EXT_PREFIX_PATH : -#endif - QT_CONFIGURE_PREFIX_PATH; + path = QT_CONFIGURE_PREFIX_PATH; } else if (unsigned(loc) <= sizeof(qt_configure_str_offsets)/sizeof(qt_configure_str_offsets[0])) { path = qt_configure_strs + qt_configure_str_offsets[loc - 1]; #ifndef Q_OS_WIN // On Windows we use the registry } else if (loc == SettingsPath) { path = QT_CONFIGURE_SETTINGS_PATH; -#endif -#ifdef QT_BUILD_QMAKE - } else if (loc == HostPrefixPath) { - path = QT_CONFIGURE_HOST_PREFIX_PATH; #endif } if (path) ret = QString::fromLocal8Bit(path); +#endif } #ifdef QT_BUILD_QMAKE diff --git a/src/corelib/global/qlibraryinfo.h b/src/corelib/global/qlibraryinfo.h index 55be706382..9d794ce1da 100644 --- a/src/corelib/global/qlibraryinfo.h +++ b/src/corelib/global/qlibraryinfo.h @@ -96,6 +96,7 @@ public: HostDataPath, TargetSpecPath, HostSpecPath, + ExtPrefixPath, HostPrefixPath, LastHostPath = HostPrefixPath, #endif @@ -105,6 +106,7 @@ public: #ifdef QT_BUILD_QMAKE enum PathGroup { FinalPaths, EffectivePaths, EffectiveSourcePaths, DevicePaths }; static QString rawLocation(LibraryLocation, PathGroup); + static void reload(); #endif static QStringList platformPluginArguments(const QString &platformName); -- cgit v1.2.3 From f92cfab225757084bd89638cd83dc7734f84b5e2 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 13 Dec 2016 13:08:40 -0800 Subject: Silence warning about non-void function without return value Q_UNREACHABLE() isn't enough for some compilers, especially if it expands to nothing. warning #1011: missing return statement at end of non-void function "fetchPixel(const uchar={unsigned char} *, int) [with bpp=QPixelLayout::BPPNone]" Change-Id: I3e3f0326f7234a26acf5fffd148fecf0b72ea7e0 Reviewed-by: Allan Sandfeld Jensen --- src/gui/painting/qdrawhelper.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp index ff7c8dfc28..af32811d34 100644 --- a/src/gui/painting/qdrawhelper.cpp +++ b/src/gui/painting/qdrawhelper.cpp @@ -843,6 +843,7 @@ template static uint QT_FASTCALL fetchPixel(const uchar *, int) { Q_UNREACHABLE(); + return 0; } template <> -- cgit v1.2.3 From 1d68e3386d7013152417b599be7798ff19331ce4 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 14 Dec 2016 08:36:03 +0100 Subject: eglfs/deviceintegration: Ensure eglfs_kms_support is added only once Use qmake operator *= to prevent adding it multiple times resulting in warnings on Linux/Desktop: Makefile:114: warning: overriding recipe for target 'sub-eglfs_kms_support-qmake_all' Makefile:64: warning: ignoring old recipe for target 'sub-eglfs_kms_support-qmake_all' Makefile:118: warning: overriding recipe for target 'sub-eglfs_kms_support' ... Change-Id: I18a926c9faeb8f9eafea5223d32c526c06c43724 Reviewed-by: Laszlo Agocs --- src/plugins/platforms/eglfs/deviceintegration/deviceintegration.pro | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/eglfs/deviceintegration/deviceintegration.pro b/src/plugins/platforms/eglfs/deviceintegration/deviceintegration.pro index d86a67b4f4..f936d05927 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/deviceintegration.pro +++ b/src/plugins/platforms/eglfs/deviceintegration/deviceintegration.pro @@ -2,8 +2,8 @@ TEMPLATE = subdirs QT_FOR_CONFIG += gui-private qtConfig(egl_x11): SUBDIRS += eglfs_x11 -qtConfig(eglfs_gbm): SUBDIRS += eglfs_kms_support eglfs_kms -qtConfig(eglfs_egldevice): SUBDIRS += eglfs_kms_support eglfs_kms_egldevice +qtConfig(eglfs_gbm): SUBDIRS *= eglfs_kms_support eglfs_kms +qtConfig(eglfs_egldevice): SUBDIRS *= eglfs_kms_support eglfs_kms_egldevice qtConfig(eglfs_brcm): SUBDIRS += eglfs_brcm qtConfig(eglfs_mali): SUBDIRS += eglfs_mali qtConfig(eglfs_viv): SUBDIRS += eglfs_viv -- cgit v1.2.3 From 5556308cbfabb1eef63359dfec24b8bcff44cb94 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 12 Dec 2016 16:33:14 -0800 Subject: MySQL: Make sure we clean the libraries from mysql_config It prints libraries necessary for linking against the MySQL static library. When linking against dynamic libraries, we end up with too many parameters. We don't want to explicitly link our plugin to OpenSSL and this is especially important on macOS since Sierra no longer comes with OpenSSL development files. On my Linux: -L/usr/lib64 -lmysqlclient -lpthread -lz -lm -lssl -lcrypto -ldl On my macOS: -L/usr/local/Cellar/mysql/5.7.16/lib -lmysqlclient -lssl -lcrypto Instead, keep only -L options (that haven't been removed by the function $$filterLibraryPath above) and the actual client library. Change-Id: I3e3f0326f7234a26acf5fffd148fa985d0fd9c93 Reviewed-by: Oswald Buddenhagen --- src/sql/configure.json | 6 ++++-- src/sql/configure.pri | 8 ++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/sql/configure.json b/src/sql/configure.json index 96c82e84f9..72671b6df9 100644 --- a/src/sql/configure.json +++ b/src/sql/configure.json @@ -58,8 +58,10 @@ "label": "MySQL", "test": "unix/mysql", "sources": [ - { "type": "mysqlConfig", "query": "--libs_r" }, - { "type": "mysqlConfig", "query": "--libs" }, + { "type": "mysqlConfig", "query": "--libs_r", "cleanlibs": true }, + { "type": "mysqlConfig", "query": "--libs", "cleanlibs": true }, + { "type": "mysqlConfig", "query": "--libs_r", "cleanlibs": false }, + { "type": "mysqlConfig", "query": "--libs", "cleanlibs": false }, { "libs": "-lmysqlclient_r", "condition": "!config.win32" }, { "libs": "-llibmysql", "condition": "config.win32" }, { "libs": "-lmysqlclient", "condition": "!config.win32" } diff --git a/src/sql/configure.pri b/src/sql/configure.pri index 1d8847b4bc..62d56e2186 100644 --- a/src/sql/configure.pri +++ b/src/sql/configure.pri @@ -57,6 +57,14 @@ defineTest(qtConfLibrary_mysqlConfig) { libs = $$filterLibraryPath($$libs) # -rdynamic should not be returned by mysql_config, but is on RHEL 6.6 libs -= -rdynamic + equals($${1}.cleanlibs, true) { + for(l, libs) { + # Drop all options besides the -L one and the -lmysqlclient one + # so we don't unnecessarily link to libs like OpenSSL + contains(l, "^(-L|-lmysqlclient).*"): cleanlibs += $$l + } + libs = $$cleanlibs + } $${1}.libs = "$$val_escape(libs)" eval(includedir = $$includedir) includedir ~= s/^-I//g -- cgit v1.2.3 From 1f665efa913bf55f215ceff27ebfc9f0e0769aee Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Mon, 12 Dec 2016 11:39:38 +0100 Subject: Q_CHECK_PTR the result of QDataBuffer's allocations We might run out of memory or malloc() or realloc() might fail for any other reason. We want to crash cleanly with a clear message in that case, rather than returning a null pointer. Change-Id: If09c1b9e905fc60a5d9d45e598a418df433cf83b Reviewed-by: Thiago Macieira --- src/gui/painting/qdatabuffer_p.h | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/gui/painting/qdatabuffer_p.h b/src/gui/painting/qdatabuffer_p.h index 77b5be0c4c..7cac2ac358 100644 --- a/src/gui/painting/qdatabuffer_p.h +++ b/src/gui/painting/qdatabuffer_p.h @@ -65,10 +65,12 @@ public: QDataBuffer(int res) { capacity = res; - if (res) + if (res) { buffer = (Type*) malloc(capacity * sizeof(Type)); - else + Q_CHECK_PTR(buffer); + } else { buffer = 0; + } siz = 0; } @@ -115,14 +117,16 @@ public: while (capacity < size) capacity *= 2; buffer = (Type*) realloc(buffer, capacity * sizeof(Type)); + Q_CHECK_PTR(buffer); } } inline void shrink(int size) { capacity = size; - if (size) + if (size) { buffer = (Type*) realloc(buffer, capacity * sizeof(Type)); - else { + Q_CHECK_PTR(buffer); + } else { free(buffer); buffer = 0; } -- cgit v1.2.3 From 87e553b58a8b59bfafb670272a33848bc415042d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Str=C3=B8mme?= Date: Tue, 13 Dec 2016 15:28:55 +0100 Subject: Android: Fix the bearer management plugin when running as a service Since Qt for Android now supports running as a service, we shouldn't use the activity context unconditionally, but instead query the current context from QtAndroidPrivate::context(). Change-Id: Ib793ba890fdbfc0cfe7b20115e41ff64cc73477a Reviewed-by: Andy Shaw Reviewed-by: BogDan Vatra --- .../org/qtproject/qt5/android/bearer/QtNetworkReceiver.java | 13 ++++++------- .../android/src/wrappers/androidconnectivitymanager.cpp | 12 ++++++------ 2 files changed, 12 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/plugins/bearer/android/jar/src/org/qtproject/qt5/android/bearer/QtNetworkReceiver.java b/src/plugins/bearer/android/jar/src/org/qtproject/qt5/android/bearer/QtNetworkReceiver.java index 8170188ecb..805c90548b 100644 --- a/src/plugins/bearer/android/jar/src/org/qtproject/qt5/android/bearer/QtNetworkReceiver.java +++ b/src/plugins/bearer/android/jar/src/org/qtproject/qt5/android/bearer/QtNetworkReceiver.java @@ -44,7 +44,6 @@ import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.util.Log; -import android.app.Activity; import android.net.ConnectivityManager; public class QtNetworkReceiver @@ -65,29 +64,29 @@ public class QtNetworkReceiver private QtNetworkReceiver() {} - public static void registerReceiver(final Activity activity) + public static void registerReceiver(final Context context) { synchronized (m_lock) { if (m_broadcastReceiver == null) { m_broadcastReceiver = new BroadcastReceiverPrivate(); IntentFilter intentFilter = new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION); - activity.registerReceiver(m_broadcastReceiver, intentFilter); + context.registerReceiver(m_broadcastReceiver, intentFilter); } } } - public static void unregisterReceiver(final Activity activity) + public static void unregisterReceiver(final Context context) { synchronized (m_lock) { if (m_broadcastReceiver == null) return; - activity.unregisterReceiver(m_broadcastReceiver); + context.unregisterReceiver(m_broadcastReceiver); } } - public static ConnectivityManager getConnectivityManager(final Activity activity) + public static ConnectivityManager getConnectivityManager(final Context context) { - return (ConnectivityManager)activity.getApplicationContext().getSystemService(Context.CONNECTIVITY_SERVICE); + return (ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE); } } diff --git a/src/plugins/bearer/android/src/wrappers/androidconnectivitymanager.cpp b/src/plugins/bearer/android/src/wrappers/androidconnectivitymanager.cpp index 3a5030d1f3..6787690246 100644 --- a/src/plugins/bearer/android/src/wrappers/androidconnectivitymanager.cpp +++ b/src/plugins/bearer/android/src/wrappers/androidconnectivitymanager.cpp @@ -250,15 +250,15 @@ AndroidConnectivityManager::AndroidConnectivityManager() m_connectivityManager = QJNIObjectPrivate::callStaticObjectMethod(networkReceiverClass, "getConnectivityManager", - "(Landroid/app/Activity;)Landroid/net/ConnectivityManager;", - QtAndroidPrivate::activity()); + "(Landroid/content/Context;)Landroid/net/ConnectivityManager;", + QtAndroidPrivate::context()); if (!m_connectivityManager.isValid()) return; QJNIObjectPrivate::callStaticMethod(networkReceiverClass, "registerReceiver", - "(Landroid/app/Activity;)V", - QtAndroidPrivate::activity()); + "(Landroid/content/Context;)V", + QtAndroidPrivate::context()); } AndroidConnectivityManager *AndroidConnectivityManager::getInstance() @@ -272,8 +272,8 @@ AndroidConnectivityManager::~AndroidConnectivityManager() { QJNIObjectPrivate::callStaticMethod(networkReceiverClass, "unregisterReceiver", - "(Landroid/app/Activity;)V", - QtAndroidPrivate::activity()); + "(Landroid/content/Context;)V", + QtAndroidPrivate::context()); } AndroidNetworkInfo AndroidConnectivityManager::getActiveNetworkInfo() const -- cgit v1.2.3 From b57e7c0963dbe5d6d85f6596d8264246ab339a7c Mon Sep 17 00:00:00 2001 From: Alexander Volkov Date: Wed, 7 Dec 2016 18:11:39 +0300 Subject: doc: Replace Q_DECL_OVERRIDE by override in snippets And remove redundant virtual. Change-Id: If0650409b88ad962f6713d082d9095675f4c68e8 Reviewed-by: Friedemann Kleint Reviewed-by: hjk --- .../doc/snippets/code/src_corelib_kernel_qabstractnativeeventfilter.cpp | 2 +- .../doc/snippets/code/src_corelib_kernel_qabstractnativeeventfilter.h | 2 +- src/corelib/doc/snippets/code/src_corelib_thread_qthread.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/corelib/doc/snippets/code/src_corelib_kernel_qabstractnativeeventfilter.cpp b/src/corelib/doc/snippets/code/src_corelib_kernel_qabstractnativeeventfilter.cpp index d222ca32a7..b84cf0ae2d 100644 --- a/src/corelib/doc/snippets/code/src_corelib_kernel_qabstractnativeeventfilter.cpp +++ b/src/corelib/doc/snippets/code/src_corelib_kernel_qabstractnativeeventfilter.cpp @@ -52,7 +52,7 @@ class MyXcbEventFilter : public QAbstractNativeEventFilter { public: - virtual bool nativeEventFilter(const QByteArray &eventType, void *message, long *) Q_DECL_OVERRIDE + bool nativeEventFilter(const QByteArray &eventType, void *message, long *) override { if (eventType == "xcb_generic_event_t") { xcb_generic_event_t* ev = static_cast(message); diff --git a/src/corelib/doc/snippets/code/src_corelib_kernel_qabstractnativeeventfilter.h b/src/corelib/doc/snippets/code/src_corelib_kernel_qabstractnativeeventfilter.h index 6666bc56c5..9734f99d50 100644 --- a/src/corelib/doc/snippets/code/src_corelib_kernel_qabstractnativeeventfilter.h +++ b/src/corelib/doc/snippets/code/src_corelib_kernel_qabstractnativeeventfilter.h @@ -44,6 +44,6 @@ class MyCocoaEventFilter : public QAbstractNativeEventFilter { public: - bool nativeEventFilter(const QByteArray &eventType, void *message, long *) Q_DECL_OVERRIDE; + bool nativeEventFilter(const QByteArray &eventType, void *message, long *) override; }; //! [0] diff --git a/src/corelib/doc/snippets/code/src_corelib_thread_qthread.cpp b/src/corelib/doc/snippets/code/src_corelib_thread_qthread.cpp index a621109c0d..7c687a0430 100644 --- a/src/corelib/doc/snippets/code/src_corelib_thread_qthread.cpp +++ b/src/corelib/doc/snippets/code/src_corelib_thread_qthread.cpp @@ -55,7 +55,7 @@ class MyObject; class WorkerThread : public QThread { Q_OBJECT - void run() Q_DECL_OVERRIDE { + void run() override { QString result; /* ... here is the expensive or blocking operation ... */ emit resultReady(result); -- cgit v1.2.3 From b08bdfb2e4de1f0b01e771dcd6d65afea0cbdd24 Mon Sep 17 00:00:00 2001 From: James McDonnell Date: Tue, 13 Dec 2016 14:33:04 -0500 Subject: Fix qtlibpng being built despite system libpng being found 90eee08b made system-png a subset of png, which is strictly speaking a porting error. However, as this is a good idea as such, fix it by adding the missing !system-png check. Change-Id: I1557a2130a22ac668be315dc9aea67845928ff4c Reviewed-by: Oswald Buddenhagen Reviewed-by: Andrew Knight --- src/src.pro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/src.pro b/src/src.pro index b13bc4fa43..90d7e2b76c 100644 --- a/src/src.pro +++ b/src/src.pro @@ -164,7 +164,7 @@ qtConfig(gui) { SUBDIRS += src_angle src_gui.depends += src_angle } - qtConfig(png) { + qtConfig(png):!qtConfig(system-png) { SUBDIRS += src_3rdparty_libpng src_3rdparty_freetype.depends += src_3rdparty_libpng src_gui.depends += src_3rdparty_libpng -- cgit v1.2.3 From cfbe5df48cb782294ea47ecf6c598707df8e0b69 Mon Sep 17 00:00:00 2001 From: Topi Reinio Date: Wed, 14 Dec 2016 14:24:08 +0100 Subject: qdoc: Define Q_COMPILER_UNICODE_STRINGS Some public functions in QString and QDebug are declared inside Q_COMPILER_UNICODE_STRINGS. This commit defines it for QDoc, and adds documentation for QDebug functions that are now visible to QDoc. Change-Id: Ia7f2501c1dc7b8244dcc3ce4adcd2019fdbffcb6 Reviewed-by: Martin Smith Reviewed-by: Thiago Macieira --- src/corelib/io/qdebug.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src') diff --git a/src/corelib/io/qdebug.cpp b/src/corelib/io/qdebug.cpp index fa919e9f10..be33ec2d23 100644 --- a/src/corelib/io/qdebug.cpp +++ b/src/corelib/io/qdebug.cpp @@ -578,6 +578,22 @@ QDebug &QDebug::resetFormat() output, but note that some QDebug backends might not be 8-bit clean. */ +/*! + \fn QDebug &QDebug::operator<<(char16_t t) + \since 5.5 + + Writes the UTF-16 character, \a t, to the stream and returns a reference + to the stream. +*/ + +/*! + \fn QDebug &QDebug::operator<<(char32_t t) + \since 5.5 + + Writes the UTF-32 character, \a t, to the stream and returns a reference + to the stream. +*/ + /*! \fn QDebug &QDebug::operator<<(const QString &s) -- cgit v1.2.3 From 56a167d30c48e163f6abd089b68edda3ed9d5be1 Mon Sep 17 00:00:00 2001 From: Oliver Wolff Date: Thu, 24 Nov 2016 15:44:57 +0100 Subject: winrt: Check for removed timers after sending events After all the check makes sense here. If a timer was removed as a result of sendEvent and it was not at the end of the list the list is not shrunk but the timer info's id is just set to INVALID_TIMER_ID. Additionally the timer's object should be fetched before we unlock the locker as timerIdToObject is changed in removeTimer and we might access a nullptr if the timer has been removed. Reverts c83ba01f7bc542368973f3f24dfb59c6052dd78a Task-number: QTBUG-56756 Change-Id: Ib1a04c02fbfcf4c939b4891d42f954dc9e87149e (cherry picked from commit 8f2088db171a6941feb1903a2912a8b7fdf3a9ec) Reviewed-by: Maurice Kalinowski --- src/corelib/kernel/qeventdispatcher_winrt.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/corelib/kernel/qeventdispatcher_winrt.cpp b/src/corelib/kernel/qeventdispatcher_winrt.cpp index ff397fc750..33753ed507 100644 --- a/src/corelib/kernel/qeventdispatcher_winrt.cpp +++ b/src/corelib/kernel/qeventdispatcher_winrt.cpp @@ -166,7 +166,7 @@ private: timerIdToHandle.insert(id, handle); timerIdToCancelHandle.insert(id, cancelHandle); } - timerIdToObject.insert(id, obj); + const quint64 targetTime = qt_msectime() + interval; const WinRTTimerInfo info(id, interval, type, obj, targetTime); QMutexLocker locker(&timerInfoLock); @@ -587,15 +587,18 @@ bool QEventDispatcherWinRT::event(QEvent *e) break; info.inEvent = true; + QObject *timerObj = d->timerIdToObject.value(id); locker.unlock(); QTimerEvent te(id); - QCoreApplication::sendEvent(d->timerIdToObject.value(id), &te); + QCoreApplication::sendEvent(timerObj, &te); locker.relock(); - // The timer might have been removed in the meanwhile - if (id >= d->timerInfos.size()) + // The timer might have been removed in the meanwhile. If the timer was + // the last one in the list, id is bigger than the list's size. + // Otherwise, the id will just be set to INVALID_TIMER_ID. + if (id >= d->timerInfos.size() || info.timerId == INVALID_TIMER_ID) break; if (info.interval == 0 && info.inEvent) { -- cgit v1.2.3 From 3a9801d568e2f7d5a95ed4f5886a7f5062869456 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Mon, 12 Dec 2016 13:35:30 +0100 Subject: doc: Specify which characters are replaced by toPlainText() Some formatting characters are replaced by ASCII in the output from toPlainText(). Since this is a bit inconsistent, we should document it. Task-number: QTBUG-57552 Change-Id: I46033588d37517056a8d4668d1d16d48c72ee1b5 Reviewed-by: Lars Knoll --- src/gui/text/qtextdocument.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src') diff --git a/src/gui/text/qtextdocument.cpp b/src/gui/text/qtextdocument.cpp index 0d05fee6ef..c006e7f427 100644 --- a/src/gui/text/qtextdocument.cpp +++ b/src/gui/text/qtextdocument.cpp @@ -1148,6 +1148,11 @@ void QTextDocument::setMetaInformation(MetaInformation info, const QString &stri Returns the plain text contained in the document. If you want formatting information use a QTextCursor instead. + Some formatting characters are replaced by ASCII equivalents. + In particular, no-break space (U+00A0) is replaced by a regular + space (U+0020), and both paragraph (U+2029) and line (U+2028) + separators are replaced by line feed (U+000A). + \note Embedded objects, such as images, are represented by a Unicode value U+FFFC (OBJECT REPLACEMENT CHARACTER). -- cgit v1.2.3 From 104854708cf610a4999cb0a3bde3c900045d1db9 Mon Sep 17 00:00:00 2001 From: BogDan Vatra Date: Thu, 15 Dec 2016 11:13:47 +0200 Subject: Update Ministro's url Task-number: QTBUG-57645 Change-Id: I014b1926c9b91e085baa5df563dc4cc06fe0596c Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/android/templates/res/values/libs.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/android/templates/res/values/libs.xml b/src/android/templates/res/values/libs.xml index 43296f2e7a..77f422cfb2 100644 --- a/src/android/templates/res/values/libs.xml +++ b/src/android/templates/res/values/libs.xml @@ -1,7 +1,7 @@ - https://download.qt.io/ministro/android/qt5/qt-5.7 + https://download.qt.io/ministro/android/qt5/qt-5.8