summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xconfigure5
-rw-r--r--src/corelib/global/qglobal.h4
-rw-r--r--src/corelib/global/qlogging.cpp36
-rw-r--r--src/corelib/kernel/qobject.cpp4
-rw-r--r--src/gui/kernel/qopenglcontext_p.h2
-rw-r--r--src/gui/painting/qblittable_p.h2
-rw-r--r--src/gui/painting/qpaintengine_blitter.cpp2
-rw-r--r--src/gui/painting/qpaintengine_raster.cpp33
-rw-r--r--src/gui/painting/qvectorpath_p.h28
-rw-r--r--src/platformsupport/eglconvenience/qeglconvenience.cpp50
-rw-r--r--src/plugins/bearer/networkmanager/qnetworkmanagerservice.h4
-rw-r--r--src/plugins/platforms/direct2d/qwindowsdirect2dhelpers.h2
-rw-r--r--src/plugins/platforms/direct2d/qwindowsdirect2dpaintengine.cpp304
-rw-r--r--src/plugins/platforms/direct2d/qwindowsdirect2dpaintengine.h15
-rw-r--r--src/plugins/platforms/direct2d/qwindowsdirect2dwindow.cpp5
-rw-r--r--src/plugins/platforms/eglfs/qeglfswindow.h2
-rw-r--r--src/plugins/platforms/qnx/qqnxwindow.cpp10
-rw-r--r--src/plugins/platforms/windows/qwindowscontext.cpp70
-rw-r--r--tests/auto/corelib/codecs/utf8/tst_utf8.cpp36
-rw-r--r--tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp31
-rw-r--r--tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp2
-rw-r--r--tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp59
-rw-r--r--tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp28
23 files changed, 458 insertions, 276 deletions
diff --git a/configure b/configure
index a05175b8c7..e7e4f4f59b 100755
--- a/configure
+++ b/configure
@@ -2387,6 +2387,9 @@ Third Party Libraries:
-no-alsa ........... Do not compile ALSA support.
+ -alsa .............. Compile ALSA support.
+ -no-gtkstyle ....... Do not compile GTK theme support.
+ + -gtkstyle .......... Compile GTK theme support.
+
Additional options:
-make <part> ....... Add part to the list of parts to be built at make time.
@@ -4637,7 +4640,7 @@ if [ "$CFG_GLIB" = "yes" -a "$CFG_QGTKSTYLE" != "no" ]; then
QMakeVar set QT_LIBS_QGTK2 "$QT_LIBS_QGTK2"
else
if [ "$CFG_QGTKSTYLE" = "yes" ] && [ "$CFG_CONFIGURE_EXIT_ON_ERROR" = "yes" ]; then
- echo "Gtk theme support cannot be enabled due to functionality tests!"
+ echo "GTK theme support cannot be enabled due to functionality tests!"
echo " Turn on verbose messaging (-v) to $0 to see the fin al report."
echo " If you believe this message is in error you may use the continue"
echo " switch (-continue) to $0 to continue."
diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h
index fba8b019e7..09f2d73db4 100644
--- a/src/corelib/global/qglobal.h
+++ b/src/corelib/global/qglobal.h
@@ -45,11 +45,11 @@
#include <stddef.h>
-#define QT_VERSION_STR "5.3.0"
+#define QT_VERSION_STR "5.3.1"
/*
QT_VERSION is (major << 16) + (minor << 8) + patch.
*/
-#define QT_VERSION 0x050300
+#define QT_VERSION 0x050301
/*
can be used like #if (QT_VERSION >= QT_VERSION_CHECK(4, 4, 0))
*/
diff --git a/src/corelib/global/qlogging.cpp b/src/corelib/global/qlogging.cpp
index da26490d18..4a602e4b2b 100644
--- a/src/corelib/global/qlogging.cpp
+++ b/src/corelib/global/qlogging.cpp
@@ -1207,6 +1207,23 @@ static void android_default_message_handler(QtMsgType type,
static void qDefaultMessageHandler(QtMsgType type, const QMessageLogContext &context,
const QString &buf)
{
+ // to determine logging destination and marking logging environment variable as deprecated
+ // ### remove when deprecated
+ struct LogDestination {
+ LogDestination(const char *deprecated, bool forceConsole) {
+ const char* replacement = "QT_LOGGING_TO_CONSOLE";
+ bool newEnv = qEnvironmentVariableIsSet(replacement);
+ bool oldEnv = qEnvironmentVariableIsSet(deprecated);
+ if (oldEnv && !newEnv && !forceConsole) {
+ fprintf(stderr, "Warning: Environment variable %s is deprecated, "
+ "use %s instead.\n", deprecated, replacement);
+ fflush(stderr);
+ }
+ toConsole = newEnv || oldEnv || forceConsole;
+ }
+ bool toConsole;
+ };
+
QString logMessage = qMessageFormatString(type, context, buf);
#if defined(Q_OS_WIN) && defined(QT_BUILD_CORE_LIB)
@@ -1217,12 +1234,19 @@ static void qDefaultMessageHandler(QtMsgType type, const QMessageLogContext &con
#endif // Q_OS_WIN
#if defined(QT_USE_SLOG2)
- slog2_default_handler(type, logMessage.toLocal8Bit().constData());
+ static const bool logToConsole = qEnvironmentVariableIsSet("QT_LOGGING_TO_CONSOLE");
+ if (!logToConsole) {
+ slog2_default_handler(type, logMessage.toLocal8Bit().constData());
+ } else {
+ fprintf(stderr, "%s", logMessage.toLocal8Bit().constData());
+ fflush(stderr);
+ }
#elif defined(QT_USE_JOURNALD) && !defined(QT_BOOTSTRAPPED)
// We use isatty to catch the obvious case of someone running something interactively.
- // We also support an environment variable for Qt Creator use, or more complicated cases like subprocesses.
- static bool logToConsole = isatty(fileno(stdin)) || !qEnvironmentVariableIsEmpty("QT_NO_JOURNALD_LOG");
- if (Q_LIKELY(!logToConsole)) {
+ // We also support environment variables for Qt Creator use, or more complicated cases
+ // like subprocesses.
+ static const LogDestination logdest("QT_NO_JOURNALD_LOG", isatty(fileno(stdin)));
+ if (Q_LIKELY(!logdest.toConsole)) {
// remove trailing \n, systemd appears to want them newline-less
logMessage.chop(1);
systemd_default_message_handler(type, context, logMessage);
@@ -1231,8 +1255,8 @@ static void qDefaultMessageHandler(QtMsgType type, const QMessageLogContext &con
fflush(stderr);
}
#elif defined(Q_OS_ANDROID)
- static bool logToAndroid = qEnvironmentVariableIsEmpty("QT_ANDROID_PLAIN_LOG");
- if (logToAndroid) {
+ static const LogDestination logdest("QT_ANDROID_PLAIN_LOG", false);
+ if (!logdest.toConsole) {
android_default_message_handler(type, context, logMessage);
} else {
fprintf(stderr, "%s", logMessage.toLocal8Bit().constData());
diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp
index 0a504657a3..0e9cbfe1c9 100644
--- a/src/corelib/kernel/qobject.cpp
+++ b/src/corelib/kernel/qobject.cpp
@@ -4436,6 +4436,8 @@ void qDeleteInEventHandler(QObject *o)
\snippet code/src_corelib_kernel_qobject.cpp 46
The connection will automatically disconnect if the sender is destroyed.
+ However, you should take care that any objects used within the functor
+ are still alive when the signal is emitted.
\note If the compiler does not support C++11 variadic templates, the number
of arguments in the signal or slot are limited to 6, and the functor object
@@ -4473,6 +4475,8 @@ void qDeleteInEventHandler(QObject *o)
The connection will automatically disconnect if the sender or the context
is destroyed.
+ However, you should take care that any objects used within the functor
+ are still alive when the signal is emitted.
\note If the compiler does not support C++11 variadic templates, the number
of arguments in the signal or slot are limited to 6, and the functor object
diff --git a/src/gui/kernel/qopenglcontext_p.h b/src/gui/kernel/qopenglcontext_p.h
index b21ff67068..aa1b3b6245 100644
--- a/src/gui/kernel/qopenglcontext_p.h
+++ b/src/gui/kernel/qopenglcontext_p.h
@@ -127,7 +127,7 @@ private:
class Q_GUI_EXPORT QOpenGLContextGroupPrivate : public QObjectPrivate
{
- Q_DECLARE_PUBLIC(QOpenGLContextGroup);
+ Q_DECLARE_PUBLIC(QOpenGLContextGroup)
public:
QOpenGLContextGroupPrivate()
: m_context(0)
diff --git a/src/gui/painting/qblittable_p.h b/src/gui/painting/qblittable_p.h
index 159e60079f..f65549d63c 100644
--- a/src/gui/painting/qblittable_p.h
+++ b/src/gui/painting/qblittable_p.h
@@ -68,7 +68,7 @@ public:
// Internal ones
OutlineCapability = 0x0001000
};
- Q_DECLARE_FLAGS (Capabilities, Capability);
+ Q_DECLARE_FLAGS (Capabilities, Capability)
QBlittable(const QSize &size, Capabilities caps);
virtual ~QBlittable();
diff --git a/src/gui/painting/qpaintengine_blitter.cpp b/src/gui/painting/qpaintengine_blitter.cpp
index 26eacacd49..67a692e2db 100644
--- a/src/gui/painting/qpaintengine_blitter.cpp
+++ b/src/gui/painting/qpaintengine_blitter.cpp
@@ -238,7 +238,7 @@ private:
class QBlitterPaintEnginePrivate : public QRasterPaintEnginePrivate
{
- Q_DECLARE_PUBLIC(QBlitterPaintEngine);
+ Q_DECLARE_PUBLIC(QBlitterPaintEngine)
public:
QBlitterPaintEnginePrivate(QBlittablePlatformPixmap *p)
: QRasterPaintEnginePrivate()
diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp
index bfcb24ae3a..ce8c1d1ca7 100644
--- a/src/gui/painting/qpaintengine_raster.cpp
+++ b/src/gui/painting/qpaintengine_raster.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -235,21 +235,6 @@ static const QRectF boundingRect(const QPointF *points, int pointCount)
}
#endif
-template <typename T> static inline bool isRect(const T *pts, int elementCount) {
- return (elementCount == 5 // 5-point polygon, check for closed rect
- && pts[0] == pts[8] && pts[1] == pts[9] // last point == first point
- && pts[0] == pts[6] && pts[2] == pts[4] // x values equal
- && pts[1] == pts[3] && pts[5] == pts[7] // y values equal...
- && pts[0] < pts[4] && pts[1] < pts[5]
- ) ||
- (elementCount == 4 // 4-point polygon, check for unclosed rect
- && pts[0] == pts[6] && pts[2] == pts[4] // x values equal
- && pts[1] == pts[3] && pts[5] == pts[7] // y values equal...
- && pts[0] < pts[4] && pts[1] < pts[5]
- );
-}
-
-
static void qt_ft_outline_move_to(qfixed x, qfixed y, void *data)
{
((QOutlineMapper *) data)->moveTo(QPointF(qt_fixed_to_real(x), qt_fixed_to_real(y)));
@@ -1193,22 +1178,14 @@ void QRasterPaintEngine::clip(const QVectorPath &path, Qt::ClipOperation op)
Q_D(QRasterPaintEngine);
QRasterPaintEngineState *s = state();
- const qreal *points = path.points();
- const QPainterPath::ElementType *types = path.elements();
-
// There are some cases that are not supported by clip(QRect)
if (op != Qt::IntersectClip || !s->clip || s->clip->hasRectClip || s->clip->hasRegionClip) {
if (s->matrix.type() <= QTransform::TxScale
- && ((path.shape() == QVectorPath::RectangleHint)
- || (isRect(points, path.elementCount())
- && (!types || (types[0] == QPainterPath::MoveToElement
- && types[1] == QPainterPath::LineToElement
- && types[2] == QPainterPath::LineToElement
- && types[3] == QPainterPath::LineToElement))))) {
+ && path.isRect()) {
#ifdef QT_DEBUG_DRAW
qDebug() << " --- optimizing vector clip to rect clip...";
#endif
-
+ const qreal *points = path.points();
QRectF r(points[0], points[1], points[4]-points[0], points[5]-points[1]);
if (setClipRectInDeviceCoords(s->matrix.mapRect(r).toRect(), op))
return;
@@ -1939,7 +1916,7 @@ void QRasterPaintEngine::drawPolygon(const QPointF *points, int pointCount, Poly
#endif
Q_ASSERT(pointCount >= 2);
- if (mode != PolylineMode && isRect((qreal *) points, pointCount)) {
+ if (mode != PolylineMode && QVectorPath::isRect((qreal *) points, pointCount)) {
QRectF r(points[0], points[2]);
drawRects(&r, 1);
return;
@@ -1980,7 +1957,7 @@ void QRasterPaintEngine::drawPolygon(const QPoint *points, int pointCount, Polyg
qDebug() << " - " << points[i];
#endif
Q_ASSERT(pointCount >= 2);
- if (mode != PolylineMode && isRect((int *) points, pointCount)) {
+ if (mode != PolylineMode && QVectorPath::isRect((int *) points, pointCount)) {
QRect r(points[0].x(),
points[0].y(),
points[2].x() - points[0].x(),
diff --git a/src/gui/painting/qvectorpath_p.h b/src/gui/painting/qvectorpath_p.h
index e97d6e1dce..ca95c32597 100644
--- a/src/gui/painting/qvectorpath_p.h
+++ b/src/gui/painting/qvectorpath_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -167,6 +167,32 @@ public:
return 0;
}
+ template <typename T> static inline bool isRect(const T *pts, int elementCount) {
+ return (elementCount == 5 // 5-point polygon, check for closed rect
+ && pts[0] == pts[8] && pts[1] == pts[9] // last point == first point
+ && pts[0] == pts[6] && pts[2] == pts[4] // x values equal
+ && pts[1] == pts[3] && pts[5] == pts[7] // y values equal...
+ && pts[0] < pts[4] && pts[1] < pts[5]
+ ) ||
+ (elementCount == 4 // 4-point polygon, check for unclosed rect
+ && pts[0] == pts[6] && pts[2] == pts[4] // x values equal
+ && pts[1] == pts[3] && pts[5] == pts[7] // y values equal...
+ && pts[0] < pts[4] && pts[1] < pts[5]
+ );
+ }
+
+ inline bool isRect() const
+ {
+ const QPainterPath::ElementType * const types = elements();
+
+ return (shape() == QVectorPath::RectangleHint)
+ || (isRect(points(), elementCount())
+ && (!types || (types[0] == QPainterPath::MoveToElement
+ && types[1] == QPainterPath::LineToElement
+ && types[2] == QPainterPath::LineToElement
+ && types[3] == QPainterPath::LineToElement)));
+ }
+
private:
Q_DISABLE_COPY(QVectorPath)
diff --git a/src/platformsupport/eglconvenience/qeglconvenience.cpp b/src/platformsupport/eglconvenience/qeglconvenience.cpp
index e6624fb9ff..ed18a23c4f 100644
--- a/src/platformsupport/eglconvenience/qeglconvenience.cpp
+++ b/src/platformsupport/eglconvenience/qeglconvenience.cpp
@@ -66,26 +66,30 @@ QVector<EGLint> q_createConfigAttributesFromFormat(const QSurfaceFormat &format)
int stencilSize = format.stencilBufferSize();
int sampleCount = format.samples();
- // We want to make sure 16-bit configs are chosen over 32-bit configs as they will provide
- // the best performance. The EGL config selection algorithm is a bit stange in this regard:
- // The selection criteria for EGL_BUFFER_SIZE is "AtLeast", so we can't use it to discard
- // 32-bit configs completely from the selection. So it then comes to the sorting algorithm.
- // The red/green/blue sizes have a sort priority of 3, so they are sorted by first. The sort
- // order is special and described as "by larger _total_ number of color bits.". So EGL will
- // put 32-bit configs in the list before the 16-bit configs. However, the spec also goes on
- // to say "If the requested number of bits in attrib_list for a particular component is 0,
- // then the number of bits for that component is not considered". This part of the spec also
- // seems to imply that setting the red/green/blue bits to zero means none of the components
- // are considered and EGL disregards the entire sorting rule. It then looks to the next
- // highest priority rule, which is EGL_BUFFER_SIZE. Despite the selection criteria being
- // "AtLeast" for EGL_BUFFER_SIZE, it's sort order is "smaller" meaning 16-bit configs are
- // put in the list before 32-bit configs. So, to make sure 16-bit is preffered over 32-bit,
- // we must set the red/green/blue sizes to zero. This has an unfortunate consequence that
- // if the application sets the red/green/blue size to 5/6/5 on the QSurfaceFormat,
- // they might still get a 32-bit config, even when there's an RGB565 config available.
-
QVector<EGLint> configAttributes;
+ // Map default, unspecified values (-1) to 0. This is important due to sorting rule #3
+ // in section 3.4.1 of the spec and allows picking a potentially faster 16-bit config
+ // over 32-bit ones when there is no explicit request for the color channel sizes:
+ //
+ // The red/green/blue sizes have a sort priority of 3, so they are sorted by
+ // first. (unless a caveat like SLOW or NON_CONFORMANT is present) The sort order is
+ // Special and described as "by larger _total_ number of color bits.". So EGL will put
+ // 32-bit configs in the list before the 16-bit configs. However, the spec also goes
+ // on to say "If the requested number of bits in attrib_list for a particular
+ // component is 0, then the number of bits for that component is not considered". This
+ // part of the spec also seems to imply that setting the red/green/blue bits to zero
+ // means none of the components are considered and EGL disregards the entire sorting
+ // rule. It then looks to the next highest priority rule, which is
+ // EGL_BUFFER_SIZE. Despite the selection criteria being "AtLeast" for
+ // EGL_BUFFER_SIZE, it's sort order is "smaller" meaning 16-bit configs are put in the
+ // list before 32-bit configs.
+ //
+ // This also means that explicitly specifying a size like 565 will still result in
+ // having larger (888) configs first in the returned list. We need to handle this
+ // ourselves later by manually filtering the list, instead of just blindly taking the
+ // first config from it.
+
configAttributes.append(EGL_RED_SIZE);
configAttributes.append(redSize > 0 ? redSize : 0);
@@ -293,6 +297,13 @@ EGLConfig QEglConfigChooser::chooseConfig()
if (!cfg && matching > 0)
cfg = configs.first();
+ // Filter the list. Due to the EGL sorting rules configs with higher depth are
+ // placed first when the minimum color channel sizes have been specified (i.e. the
+ // QSurfaceFormat contains color sizes > 0). To prevent returning a 888 config
+ // when the QSurfaceFormat explicitly asked for 565, go through the returned
+ // configs and look for one that exactly matches the requested sizes. When no
+ // sizes have been given, take the first, which will be a config with the smaller
+ // (e.g. 16-bit) depth.
for (int i = 0; i < configs.size(); ++i) {
if (filterConfig(configs[i]))
return configs.at(i);
@@ -306,6 +317,8 @@ EGLConfig QEglConfigChooser::chooseConfig()
bool QEglConfigChooser::filterConfig(EGLConfig config) const
{
+ // If we are fine with the highest depth (e.g. RGB888 configs) even when something
+ // smaller (565) was explicitly requested, do nothing.
if (m_ignore)
return true;
@@ -314,6 +327,7 @@ bool QEglConfigChooser::filterConfig(EGLConfig config) const
EGLint blue = 0;
EGLint alpha = 0;
+ // Compare only if a size was given. Otherwise just accept.
if (m_confAttrRed)
eglGetConfigAttrib(display(), config, EGL_RED_SIZE, &red);
if (m_confAttrGreen)
diff --git a/src/plugins/bearer/networkmanager/qnetworkmanagerservice.h b/src/plugins/bearer/networkmanager/qnetworkmanagerservice.h
index 74a25c1370..9493218024 100644
--- a/src/plugins/bearer/networkmanager/qnetworkmanagerservice.h
+++ b/src/plugins/bearer/networkmanager/qnetworkmanagerservice.h
@@ -197,7 +197,7 @@ public:
Privacy = 0x1
};
- Q_DECLARE_FLAGS(ApFlags, ApFlag);
+ Q_DECLARE_FLAGS(ApFlags, ApFlag)
enum ApSecurityFlag {
ApSecurityNone = 0x0,
@@ -213,7 +213,7 @@ public:
Key8021x = 0x200
};
- Q_DECLARE_FLAGS(ApSecurityFlags, ApSecurityFlag);
+ Q_DECLARE_FLAGS(ApSecurityFlags, ApSecurityFlag)
explicit QNetworkManagerInterfaceAccessPoint(const QString &dbusPathName, QObject *parent = 0);
~QNetworkManagerInterfaceAccessPoint();
diff --git a/src/plugins/platforms/direct2d/qwindowsdirect2dhelpers.h b/src/plugins/platforms/direct2d/qwindowsdirect2dhelpers.h
index 98248515e6..3be05ee1e0 100644
--- a/src/plugins/platforms/direct2d/qwindowsdirect2dhelpers.h
+++ b/src/plugins/platforms/direct2d/qwindowsdirect2dhelpers.h
@@ -84,8 +84,6 @@ Q_DECL_CONSTEXPR inline D2D1::ColorF to_d2d_color_f(const QColor &c)
Q_DECL_CONSTEXPR inline D2D1_MATRIX_3X2_F to_d2d_matrix_3x2_f(const QTransform &transform)
{
- Q_ASSERT(transform.isAffine());
-
return D2D1::Matrix3x2F(transform.m11(), transform.m12(),
transform.m21(), transform.m22(),
transform.m31(), transform.m32());
diff --git a/src/plugins/platforms/direct2d/qwindowsdirect2dpaintengine.cpp b/src/plugins/platforms/direct2d/qwindowsdirect2dpaintengine.cpp
index 86f78a35d5..1e7c175252 100644
--- a/src/plugins/platforms/direct2d/qwindowsdirect2dpaintengine.cpp
+++ b/src/plugins/platforms/direct2d/qwindowsdirect2dpaintengine.cpp
@@ -52,6 +52,7 @@
#include "qwindowsfontdatabase.h"
#include "qwindowsintegration.h"
+#include <QtCore/QStack>
#include <QtGui/private/qpaintengine_p.h>
#include <QtGui/private/qtextengine_p.h>
#include <QtGui/private/qfontengine_p.h>
@@ -80,9 +81,14 @@ enum {
//Clipping flags
enum {
- UserClip = 0x1,
- SimpleSystemClip = 0x2
+ SimpleSystemClip = 0x1
};
+
+enum ClipType {
+ AxisAlignedClip,
+ LayerClip
+};
+
#define D2D_TAG(tag) d->dc()->SetTags(tag, tag)
Q_GUI_EXPORT QImage qt_imageForBrush(int brushStyle, bool invert);
@@ -320,8 +326,8 @@ public:
QWindowsDirect2DBitmap *bitmap;
- QPainterPath clipPath;
unsigned int clipFlags;
+ QStack<ClipType> pushedClips;
QPointF currentBrushOrigin;
@@ -372,81 +378,97 @@ public:
: D2D1_ANTIALIAS_MODE_ALIASED;
}
- void updateTransform()
+ void updateTransform(const QTransform &transform)
{
- Q_Q(const QWindowsDirect2DPaintEngine);
- // Note the loss of info going from 3x3 to 3x2 matrix here
- dc()->SetTransform(to_d2d_matrix_3x2_f(q->state()->transform()));
+ dc()->SetTransform(to_d2d_matrix_3x2_f(transform));
}
- void updateOpacity()
+ void updateOpacity(qreal opacity)
{
- Q_Q(const QWindowsDirect2DPaintEngine);
- qreal opacity = q->state()->opacity;
if (brush.brush)
brush.brush->SetOpacity(opacity);
if (pen.brush)
pen.brush->SetOpacity(opacity);
}
- void pushClip()
+ void pushClip(const QVectorPath &path)
{
- popClip();
+ Q_Q(QWindowsDirect2DPaintEngine);
+
+ if (path.isEmpty()) {
+ D2D_RECT_F rect = {0, 0, 0, 0};
+ dc()->PushAxisAlignedClip(rect, antialiasMode());
+ pushedClips.push(AxisAlignedClip);
+ } else if (path.isRect() && (q->state()->matrix.type() <= QTransform::TxScale)) {
+ const qreal * const points = path.points();
+ D2D_RECT_F rect = {
+ points[0], // left
+ points[1], // top
+ points[2], // right,
+ points[5] // bottom
+ };
- ComPtr<ID2D1PathGeometry1> geometry = painterPathToID2D1PathGeometry(clipPath, antialiasMode() == D2D1_ANTIALIAS_MODE_ALIASED);
- if (!geometry)
- return;
+ dc()->PushAxisAlignedClip(rect, antialiasMode());
+ pushedClips.push(AxisAlignedClip);
+ } else {
+ ComPtr<ID2D1PathGeometry1> geometry = vectorPathToID2D1PathGeometry(path, antialiasMode() == D2D1_ANTIALIAS_MODE_ALIASED);
+ if (!geometry) {
+ qWarning("%s: Could not convert vector path to painter path!", __FUNCTION__);
+ return;
+ }
- dc()->PushLayer(D2D1::LayerParameters1(D2D1::InfiniteRect(),
- geometry.Get(),
- antialiasMode(),
- D2D1::IdentityMatrix(),
- 1.0,
- NULL,
- D2D1_LAYER_OPTIONS1_INITIALIZE_FROM_BACKGROUND),
- NULL);
- clipFlags |= UserClip;
+ dc()->PushLayer(D2D1::LayerParameters1(D2D1::InfiniteRect(),
+ geometry.Get(),
+ antialiasMode(),
+ D2D1::IdentityMatrix(),
+ 1.0,
+ NULL,
+ D2D1_LAYER_OPTIONS1_INITIALIZE_FROM_BACKGROUND),
+ NULL);
+ pushedClips.push(LayerClip);
+ }
}
- void popClip()
+ void clearClips()
{
- if (clipFlags & UserClip) {
- dc()->PopLayer();
- clipFlags &= ~UserClip;
+ while (!pushedClips.isEmpty()) {
+ switch (pushedClips.pop()) {
+ case AxisAlignedClip:
+ dc()->PopAxisAlignedClip();
+ break;
+ case LayerClip:
+ dc()->PopLayer();
+ break;
+ }
}
}
- void updateClipEnabled()
+ void updateClipEnabled(bool enabled)
{
- Q_Q(const QWindowsDirect2DPaintEngine);
- if (!q->state()->clipEnabled)
- popClip();
- else if (!(clipFlags & UserClip))
- pushClip();
+ if (!enabled)
+ clearClips();
+ else if (pushedClips.isEmpty())
+ replayClipOperations();
}
- void updateClipPath(const QPainterPath &path, Qt::ClipOperation operation)
+ void clip(const QVectorPath &path, Qt::ClipOperation operation)
{
switch (operation) {
case Qt::NoClip:
- popClip();
+ clearClips();
break;
case Qt::ReplaceClip:
- clipPath = path;
- pushClip();
+ clearClips();
+ pushClip(path);
break;
case Qt::IntersectClip:
- clipPath &= path;
- pushClip();
+ pushClip(path);
break;
}
}
- void updateCompositionMode()
+ void updateCompositionMode(QPainter::CompositionMode mode)
{
- Q_Q(const QWindowsDirect2DPaintEngine);
- QPainter::CompositionMode mode = q->state()->compositionMode();
-
switch (mode) {
case QPainter::CompositionMode_Source:
dc()->SetPrimitiveBlend(D2D1_PRIMITIVE_BLEND_COPY);
@@ -465,7 +487,7 @@ public:
{
Q_Q(const QWindowsDirect2DPaintEngine);
- if (qbrush_fast_equals(brush.qbrush, newBrush))
+ if (qbrush_fast_equals(brush.qbrush, newBrush) && (brush.brush || brush.emulate))
return;
brush.brush = to_d2d_brush(newBrush, &brush.emulate);
@@ -477,12 +499,10 @@ public:
}
}
- void updateBrushOrigin()
+ void updateBrushOrigin(const QPointF &brushOrigin)
{
- Q_Q(const QWindowsDirect2DPaintEngine);
-
negateCurrentBrushOrigin();
- applyBrushOrigin(q->state()->brushOrigin);
+ applyBrushOrigin(brushOrigin);
}
void negateCurrentBrushOrigin()
@@ -510,12 +530,10 @@ public:
currentBrushOrigin = origin;
}
- void updatePen()
+ void updatePen(const QPen &newPen)
{
Q_Q(const QWindowsDirect2DPaintEngine);
- const QPen &newPen = q->state()->pen;
-
- if (qpen_fast_equals(newPen, pen.qpen))
+ if (qpen_fast_equals(newPen, pen.qpen) && (pen.brush || pen.emulate))
return;
pen.reset();
@@ -863,7 +881,7 @@ bool QWindowsDirect2DPaintEngine::end()
{
Q_D(QWindowsDirect2DPaintEngine);
// First pop any user-applied clipping
- d->popClip();
+ d->clearClips();
// Now the system clip from begin() above
if (d->clipFlags & SimpleSystemClip) {
d->dc()->PopAxisAlignedClip();
@@ -879,6 +897,23 @@ QPaintEngine::Type QWindowsDirect2DPaintEngine::type() const
return QPaintEngine::Direct2D;
}
+void QWindowsDirect2DPaintEngine::setState(QPainterState *s)
+{
+ Q_D(QWindowsDirect2DPaintEngine);
+
+ QPaintEngineEx::setState(s);
+ d->clearClips();
+
+ clipEnabledChanged();
+ penChanged();
+ brushChanged();
+ brushOriginChanged();
+ opacityChanged();
+ compositionModeChanged();
+ renderHintsChanged();
+ transformChanged();
+}
+
void QWindowsDirect2DPaintEngine::fill(const QVectorPath &path, const QBrush &brush)
{
Q_D(QWindowsDirect2DPaintEngine);
@@ -887,35 +922,17 @@ void QWindowsDirect2DPaintEngine::fill(const QVectorPath &path, const QBrush &br
if (path.isEmpty())
return;
- d->updateBrush(brush);
-
- if (d->brush.emulate) {
- // We mostly (only?) get here when gradients are required.
- // We natively support only linear and radial gradients that have pad reflect due to D2D limitations
-
- QImage img(d->bitmap->size(), QImage::Format_ARGB32);
- img.fill(Qt::transparent);
-
- QPainter p;
- QPaintEngine *engine = img.paintEngine();
- if (engine->isExtended() && p.begin(&img)) {
- QPaintEngineEx *extended = static_cast<QPaintEngineEx *>(engine);
- extended->fill(path, brush);
- if (!p.end())
- qWarning("%s: Paint Engine end returned false", __FUNCTION__);
-
- drawImage(img.rect(), img, img.rect());
- } else {
- qWarning("%s: Could not fall back to QImage", __FUNCTION__);
- }
+ ensureBrush(brush);
+ if (!state()->matrix.isAffine() || d->brush.emulate) {
+ rasterFill(path, brush);
return;
}
if (!d->brush.brush)
return;
- if (path.hints() & QVectorPath::RectangleShapeMask) {
+ if (path.isRect()) {
const qreal * const points = path.points();
D2D_RECT_F rect = {
points[0], // left
@@ -936,46 +953,22 @@ void QWindowsDirect2DPaintEngine::fill(const QVectorPath &path, const QBrush &br
}
}
-// For clipping we convert everything to painter paths since it allows
-// calculating intersections easily. It might be faster to convert to
-// ID2D1Geometry and use its operations, although that needs to measured.
-// The implementation would be more complex in any case.
-
void QWindowsDirect2DPaintEngine::clip(const QVectorPath &path, Qt::ClipOperation op)
{
- clip(path.convertToPainterPath(), op);
-}
-
-void QWindowsDirect2DPaintEngine::clip(const QRect &rect, Qt::ClipOperation op)
-{
- QPainterPath p;
- p.addRect(rect);
- clip(p, op);
-}
-
-void QWindowsDirect2DPaintEngine::clip(const QRegion &region, Qt::ClipOperation op)
-{
- QPainterPath p;
- p.addRegion(region);
- clip(p, op);
-}
-
-void QWindowsDirect2DPaintEngine::clip(const QPainterPath &path, Qt::ClipOperation op)
-{
Q_D(QWindowsDirect2DPaintEngine);
- d->updateClipPath(path, op);
+ d->clip(path, op);
}
void QWindowsDirect2DPaintEngine::clipEnabledChanged()
{
Q_D(QWindowsDirect2DPaintEngine);
- d->updateClipEnabled();
+ d->updateClipEnabled(state()->clipEnabled);
}
void QWindowsDirect2DPaintEngine::penChanged()
{
Q_D(QWindowsDirect2DPaintEngine);
- d->updatePen();
+ d->updatePen(state()->pen);
}
void QWindowsDirect2DPaintEngine::brushChanged()
@@ -987,19 +980,19 @@ void QWindowsDirect2DPaintEngine::brushChanged()
void QWindowsDirect2DPaintEngine::brushOriginChanged()
{
Q_D(QWindowsDirect2DPaintEngine);
- d->updateBrushOrigin();
+ d->updateBrushOrigin(state()->brushOrigin);
}
void QWindowsDirect2DPaintEngine::opacityChanged()
{
Q_D(QWindowsDirect2DPaintEngine);
- d->updateOpacity();
+ d->updateOpacity(state()->opacity);
}
void QWindowsDirect2DPaintEngine::compositionModeChanged()
{
Q_D(QWindowsDirect2DPaintEngine);
- d->updateCompositionMode();
+ d->updateCompositionMode(state()->compositionMode());
}
void QWindowsDirect2DPaintEngine::renderHintsChanged()
@@ -1011,7 +1004,7 @@ void QWindowsDirect2DPaintEngine::renderHintsChanged()
void QWindowsDirect2DPaintEngine::transformChanged()
{
Q_D(QWindowsDirect2DPaintEngine);
- d->updateTransform();
+ d->updateTransform(state()->transform());
}
void QWindowsDirect2DPaintEngine::drawImage(const QRectF &rectangle, const QImage &image,
@@ -1045,6 +1038,8 @@ void QWindowsDirect2DPaintEngine::drawPixmap(const QRectF &r,
QWindowsDirect2DPlatformPixmap *pp = static_cast<QWindowsDirect2DPlatformPixmap *>(pm.handle());
QWindowsDirect2DBitmap *bitmap = pp->bitmap();
+ ensurePen();
+
if (bitmap->bitmap() != d->bitmap->bitmap()) {
// Good, src bitmap != dst bitmap
if (sr.isValid())
@@ -1143,12 +1138,11 @@ void QWindowsDirect2DPaintEngine::drawStaticTextItem(QStaticTextItem *staticText
Q_D(QWindowsDirect2DPaintEngine);
D2D_TAG(D2DDebugDrawStaticTextItemTag);
- if (qpen_style(d->pen.qpen) == Qt::NoPen && qbrush_style(d->brush.qbrush) == Qt::NoBrush)
- return;
-
if (staticTextItem->numGlyphs == 0)
return;
+ ensurePen();
+
// If we can't support the current configuration with Direct2D, fall back to slow path
// Most common cases are perspective transform and gradient brush as pen
if ((state()->transform().isAffine() == false) || d->pen.emulate) {
@@ -1193,13 +1187,12 @@ void QWindowsDirect2DPaintEngine::drawTextItem(const QPointF &p, const QTextItem
Q_D(QWindowsDirect2DPaintEngine);
D2D_TAG(D2DDebugDrawTextItemTag);
- if (qpen_style(d->pen.qpen) == Qt::NoPen && qbrush_style(d->brush.qbrush) == Qt::NoBrush)
- return;
-
const QTextItemInt &ti = static_cast<const QTextItemInt &>(textItem);
if (ti.glyphs.numGlyphs == 0)
return;
+ ensurePen();
+
// If we can't support the current configuration with Direct2D, fall back to slow path
// Most common cases are perspective transform and gradient brush as pen
if ((state()->transform().isAffine() == false) || d->pen.emulate) {
@@ -1301,4 +1294,89 @@ void QWindowsDirect2DPaintEngine::drawGlyphRun(const D2D1_POINT_2F &pos,
DWRITE_MEASURING_MODE_GDI_CLASSIC);
}
+void QWindowsDirect2DPaintEngine::ensureBrush()
+{
+ ensureBrush(state()->brush);
+}
+
+void QWindowsDirect2DPaintEngine::ensureBrush(const QBrush &brush)
+{
+ Q_D(QWindowsDirect2DPaintEngine);
+ d->updateBrush(brush);
+}
+
+void QWindowsDirect2DPaintEngine::ensurePen()
+{
+ ensurePen(state()->pen);
+}
+
+void QWindowsDirect2DPaintEngine::ensurePen(const QPen &pen)
+{
+ Q_D(QWindowsDirect2DPaintEngine);
+ d->updatePen(pen);
+}
+
+void QWindowsDirect2DPaintEngine::rasterFill(const QVectorPath &path, const QBrush &brush)
+{
+ Q_D(QWindowsDirect2DPaintEngine);
+
+ QImage img(d->bitmap->size(), QImage::Format_ARGB32);
+ img.fill(Qt::transparent);
+
+ QPainter p;
+ QPaintEngine *engine = img.paintEngine();
+
+ if (engine->isExtended() && p.begin(&img)) {
+ p.setRenderHints(state()->renderHints);
+ p.setCompositionMode(state()->compositionMode());
+ p.setOpacity(state()->opacity);
+ p.setBrushOrigin(state()->brushOrigin);
+ p.setBrush(state()->brush);
+ p.setPen(state()->pen);
+
+ QPaintEngineEx *extended = static_cast<QPaintEngineEx *>(engine);
+ foreach (const QPainterClipInfo &info, state()->clipInfo) {
+ extended->state()->matrix = info.matrix;
+ extended->transformChanged();
+
+ switch (info.clipType) {
+ case QPainterClipInfo::RegionClip:
+ extended->clip(info.region, info.operation);
+ break;
+ case QPainterClipInfo::PathClip:
+ extended->clip(info.path, info.operation);
+ break;
+ case QPainterClipInfo::RectClip:
+ extended->clip(info.rect, info.operation);
+ break;
+ case QPainterClipInfo::RectFClip:
+ qreal right = info.rectf.x() + info.rectf.width();
+ qreal bottom = info.rectf.y() + info.rectf.height();
+ qreal pts[] = { info.rectf.x(), info.rectf.y(),
+ right, info.rectf.y(),
+ right, bottom,
+ info.rectf.x(), bottom };
+ QVectorPath vp(pts, 4, 0, QVectorPath::RectangleHint);
+ extended->clip(vp, info.operation);
+ break;
+ }
+ }
+
+ extended->state()->matrix = state()->matrix;
+ extended->transformChanged();
+
+ extended->fill(path, brush);
+ if (!p.end())
+ qWarning("%s: Paint Engine end returned false", __FUNCTION__);
+
+ d->updateClipEnabled(false);
+ d->updateTransform(QTransform());
+ drawImage(img.rect(), img, img.rect());
+ transformChanged();
+ clipEnabledChanged();
+ } else {
+ qWarning("%s: Could not fall back to QImage", __FUNCTION__);
+ }
+}
+
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/direct2d/qwindowsdirect2dpaintengine.h b/src/plugins/platforms/direct2d/qwindowsdirect2dpaintengine.h
index 6c74a07e88..93ccf809e4 100644
--- a/src/plugins/platforms/direct2d/qwindowsdirect2dpaintengine.h
+++ b/src/plugins/platforms/direct2d/qwindowsdirect2dpaintengine.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the plugins of the Qt Toolkit.
@@ -65,12 +65,10 @@ public:
Type type() const Q_DECL_OVERRIDE;
- void fill(const QVectorPath &path, const QBrush &brush) Q_DECL_OVERRIDE;
+ void setState(QPainterState *s) Q_DECL_OVERRIDE;
+ void fill(const QVectorPath &path, const QBrush &brush) Q_DECL_OVERRIDE;
void clip(const QVectorPath &path, Qt::ClipOperation op) Q_DECL_OVERRIDE;
- void clip(const QRect &rect, Qt::ClipOperation op) Q_DECL_OVERRIDE;
- void clip(const QRegion &region, Qt::ClipOperation op) Q_DECL_OVERRIDE;
- void clip(const QPainterPath &path, Qt::ClipOperation op) Q_DECL_OVERRIDE;
void clipEnabledChanged() Q_DECL_OVERRIDE;
void penChanged() Q_DECL_OVERRIDE;
@@ -91,6 +89,13 @@ private:
void drawGlyphRun(const D2D1_POINT_2F &pos, IDWriteFontFace *fontFace, const QFont &font,
int numGlyphs, const UINT16 *glyphIndices, const FLOAT *glyphAdvances,
const DWRITE_GLYPH_OFFSET *glyphOffsets, bool rtl);
+
+ void ensureBrush();
+ void ensureBrush(const QBrush &brush);
+ void ensurePen();
+ void ensurePen(const QPen &pen);
+
+ void rasterFill(const QVectorPath &path, const QBrush &brush);
};
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/direct2d/qwindowsdirect2dwindow.cpp b/src/plugins/platforms/direct2d/qwindowsdirect2dwindow.cpp
index bf860f982e..50d0cb81f5 100644
--- a/src/plugins/platforms/direct2d/qwindowsdirect2dwindow.cpp
+++ b/src/plugins/platforms/direct2d/qwindowsdirect2dwindow.cpp
@@ -54,6 +54,9 @@ QWindowsDirect2DWindow::QWindowsDirect2DWindow(QWindow *window, const QWindowsWi
: QWindowsWindow(window, data)
, m_needsFullFlush(true)
{
+ if (window->type() == Qt::Desktop)
+ return; // No further handling for Qt::Desktop
+
DXGI_SWAP_CHAIN_DESC1 desc = {};
desc.Format = DXGI_FORMAT_B8G8R8A8_UNORM;
@@ -125,7 +128,7 @@ void QWindowsDirect2DWindow::flush(QWindowsDirect2DBitmap *bitmap, const QRegion
}
m_bitmap->deviceContext()->end();
- m_swapChain->Present(1, 0);
+ m_swapChain->Present(0, 0);
}
void QWindowsDirect2DWindow::resizeSwapChain(const QSize &size)
diff --git a/src/plugins/platforms/eglfs/qeglfswindow.h b/src/plugins/platforms/eglfs/qeglfswindow.h
index c8c31816a0..f3fd06037e 100644
--- a/src/plugins/platforms/eglfs/qeglfswindow.h
+++ b/src/plugins/platforms/eglfs/qeglfswindow.h
@@ -91,7 +91,7 @@ private:
Created = 0x01,
HasNativeWindow = 0x02
};
- Q_DECLARE_FLAGS(Flags, Flag);
+ Q_DECLARE_FLAGS(Flags, Flag)
Flags m_flags;
};
diff --git a/src/plugins/platforms/qnx/qqnxwindow.cpp b/src/plugins/platforms/qnx/qqnxwindow.cpp
index 2e0febff20..d7256b08aa 100644
--- a/src/plugins/platforms/qnx/qqnxwindow.cpp
+++ b/src/plugins/platforms/qnx/qqnxwindow.cpp
@@ -247,7 +247,6 @@ void QQnxWindow::setGeometry(const QRect &rect)
setGeometryHelper(newGeometry);
- QWindowSystemInterface::handleGeometryChange(window(), newGeometry);
if (isExposed())
QWindowSystemInterface::handleExposeEvent(window(), newGeometry);
}
@@ -278,6 +277,8 @@ void QQnxWindow::setGeometryHelper(const QRect &rect)
"Failed to set window source size");
screen_flush_context(m_screenContext, 0);
+
+ QWindowSystemInterface::handleGeometryChange(window(), rect);
}
void QQnxWindow::setVisible(bool visible)
@@ -711,12 +712,7 @@ void QQnxWindow::initWindow()
if (window()->parent() && window()->parent()->handle())
setParent(window()->parent()->handle());
- if (shouldMakeFullScreen())
- setGeometryHelper(screen()->geometry());
- else
- setGeometryHelper(window()->geometry());
-
- QWindowSystemInterface::handleGeometryChange(window(), screen()->geometry());
+ setGeometryHelper(shouldMakeFullScreen() ? screen()->geometry() : window()->geometry());
}
void QQnxWindow::createWindowGroup()
diff --git a/src/plugins/platforms/windows/qwindowscontext.cpp b/src/plugins/platforms/windows/qwindowscontext.cpp
index af7713ba6f..c210303e1e 100644
--- a/src/plugins/platforms/windows/qwindowscontext.cpp
+++ b/src/plugins/platforms/windows/qwindowscontext.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2013 Samuel Gaist <samuel.gaist@edeltech.ch>
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the plugins of the Qt Toolkit.
@@ -76,6 +76,9 @@
#include <stdlib.h>
#include <stdio.h>
#include <windowsx.h>
+#ifndef Q_OS_WINCE
+# include <comdef.h>
+#endif
QT_BEGIN_NAMESPACE
@@ -309,6 +312,10 @@ QWindowsContextPrivate::QWindowsContextPrivate()
m_systemInfo |= QWindowsContext::SI_RTL_Extensions;
m_keyMapper.setUseRTLExtensions(true);
}
+ if (FAILED(m_oleInitializeResult)) {
+ qWarning() << "QWindowsContext: OleInitialize() failed: "
+ << QWindowsContext::comErrorString(m_oleInitializeResult);
+ }
}
QWindowsContext::QWindowsContext() :
@@ -691,45 +698,70 @@ HWND QWindowsContext::createDummyWindow(const QString &classNameIn,
QByteArray QWindowsContext::comErrorString(HRESULT hr)
{
+ QByteArray result = QByteArrayLiteral("COM error 0x")
+ + QByteArray::number(quintptr(hr), 16) + ' ';
switch (hr) {
case S_OK:
- return QByteArrayLiteral("S_OK");
+ result += QByteArrayLiteral("S_OK");
+ break;
case S_FALSE:
- return QByteArrayLiteral("S_FALSE");
+ result += QByteArrayLiteral("S_FALSE");
+ break;
case E_UNEXPECTED:
- return QByteArrayLiteral("E_UNEXPECTED");
+ result += QByteArrayLiteral("E_UNEXPECTED");
+ break;
case CO_E_ALREADYINITIALIZED:
- return QByteArrayLiteral("CO_E_ALREADYINITIALIZED");
+ result += QByteArrayLiteral("CO_E_ALREADYINITIALIZED");
+ break;
case CO_E_NOTINITIALIZED:
- return QByteArrayLiteral("CO_E_NOTINITIALIZED");
+ result += QByteArrayLiteral("CO_E_NOTINITIALIZED");
+ break;
case RPC_E_CHANGED_MODE:
- return QByteArrayLiteral("RPC_E_CHANGED_MODE");
+ result += QByteArrayLiteral("RPC_E_CHANGED_MODE");
+ break;
case OLE_E_WRONGCOMPOBJ:
- return QByteArrayLiteral("OLE_E_WRONGCOMPOBJ");
+ result += QByteArrayLiteral("OLE_E_WRONGCOMPOBJ");
+ break;
case CO_E_NOT_SUPPORTED:
- return QByteArrayLiteral("CO_E_NOT_SUPPORTED");
+ result += QByteArrayLiteral("CO_E_NOT_SUPPORTED");
+ break;
case E_NOTIMPL:
- return QByteArrayLiteral("E_NOTIMPL");
+ result += QByteArrayLiteral("E_NOTIMPL");
+ break;
case E_INVALIDARG:
- return QByteArrayLiteral("E_INVALIDARG");
+ result += QByteArrayLiteral("E_INVALIDARG");
+ break;
case E_NOINTERFACE:
- return QByteArrayLiteral("E_NOINTERFACE");
+ result += QByteArrayLiteral("E_NOINTERFACE");
+ break;
case E_POINTER:
- return QByteArrayLiteral("E_POINTER");
+ result += QByteArrayLiteral("E_POINTER");
+ break;
case E_HANDLE:
- return QByteArrayLiteral("E_HANDLE");
+ result += QByteArrayLiteral("E_HANDLE");
+ break;
case E_ABORT:
- return QByteArrayLiteral("E_ABORT");
+ result += QByteArrayLiteral("E_ABORT");
+ break;
case E_FAIL:
- return QByteArrayLiteral("E_FAIL");
+ result += QByteArrayLiteral("E_FAIL");
+ break;
case RPC_E_WRONG_THREAD:
- return QByteArrayLiteral("RPC_E_WRONG_THREAD");
+ result += QByteArrayLiteral("RPC_E_WRONG_THREAD");
+ break;
case RPC_E_THREAD_NOT_INIT:
- return QByteArrayLiteral("RPC_E_THREAD_NOT_INIT");
+ result += QByteArrayLiteral("RPC_E_THREAD_NOT_INIT");
+ break;
default:
break;
}
- return "Unknown error 0x" + QByteArray::number(quint64(hr), 16);
+#ifndef Q_OS_WINCE
+ _com_error error(hr);
+ result += QByteArrayLiteral(" (");
+ result += QString::fromWCharArray(error.ErrorMessage()).toLocal8Bit();
+ result += ')';
+#endif // !Q_OS_WINCE
+ return result;
}
/*!
diff --git a/tests/auto/corelib/codecs/utf8/tst_utf8.cpp b/tests/auto/corelib/codecs/utf8/tst_utf8.cpp
index b00fd0dfd4..d1aadab7d8 100644
--- a/tests/auto/corelib/codecs/utf8/tst_utf8.cpp
+++ b/tests/auto/corelib/codecs/utf8/tst_utf8.cpp
@@ -53,11 +53,7 @@ public:
// test data:
QTextCodec *codec;
QString (*from8BitPtr)(const char *, int);
-#ifdef Q_COMPILER_REF_QUALIFIERS
- QByteArray (QString:: *to8Bit)() const &;
-#else
- QByteArray (QString:: *to8Bit)() const;
-#endif
+ static QByteArray to8Bit(const QString &);
inline QString from8Bit(const QByteArray &ba)
{ return from8BitPtr(ba.constData(), ba.length()); }
@@ -97,14 +93,21 @@ void tst_Utf8::init()
if (useLocale) {
codec = QTextCodec::codecForLocale();
from8BitPtr = &QString::fromLocal8Bit;
- to8Bit = &QString::toLocal8Bit;
} else {
codec = QTextCodec::codecForMib(106);
from8BitPtr = &QString::fromUtf8;
- to8Bit = &QString::toUtf8;
}
}
+QByteArray tst_Utf8::to8Bit(const QString &s)
+{
+ QFETCH_GLOBAL(bool, useLocale);
+ if (useLocale)
+ return s.toLocal8Bit();
+ else
+ return s.toUtf8();
+}
+
void tst_Utf8::roundTrip_data()
{
QTest::addColumn<QByteArray>("utf8");
@@ -114,10 +117,10 @@ void tst_Utf8::roundTrip_data()
QTest::newRow("nul") << QByteArray("", 1) << QString(QChar(QChar::Null));
static const char ascii[] = "This is a standard US-ASCII message";
- QTest::newRow("ascii") << QByteArray(ascii) << ascii;
+ QTest::newRow("ascii") << QByteArray(ascii) << QString::fromLatin1(ascii);
static const char ascii2[] = "\1This\2is\3an\4US-ASCII\020 message interspersed with control chars";
- QTest::newRow("ascii2") << QByteArray(ascii2) << ascii2;
+ QTest::newRow("ascii2") << QByteArray(ascii2) << QString::fromLatin1(ascii2);
static const char utf8_1[] = "\302\240"; // NBSP
QTest::newRow("utf8_1") << QByteArray(utf8_1) << QString(QChar(QChar::Nbsp));
@@ -161,11 +164,20 @@ void tst_Utf8::roundTrip()
QFETCH(QByteArray, utf8);
QFETCH(QString, utf16);
- QCOMPARE((utf16.*to8Bit)(), utf8);
+ QCOMPARE(to8Bit(utf16), utf8);
+ QCOMPARE(from8Bit(utf8), utf16);
+
+ QCOMPARE(to8Bit(from8Bit(utf8)), utf8);
+ QCOMPARE(from8Bit(to8Bit(utf16)), utf16);
+
+ // repeat with a longer message
+ utf8.prepend("12345678901234");
+ utf16.prepend(QLatin1String("12345678901234"));
+ QCOMPARE(to8Bit(utf16), utf8);
QCOMPARE(from8Bit(utf8), utf16);
- QCOMPARE((from8Bit(utf8).*to8Bit)(), utf8);
- QCOMPARE(from8Bit((utf16.*to8Bit)()), utf16);
+ QCOMPARE(to8Bit(from8Bit(utf8)), utf8);
+ QCOMPARE(from8Bit(to8Bit(utf16)), utf16);
}
void tst_Utf8::charByChar_data()
diff --git a/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp b/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp
index a58c7dfb4b..4f7ddce9c3 100644
--- a/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp
+++ b/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the test suite of the Qt Toolkit.
@@ -405,6 +405,13 @@ void tst_QFileSystemWatcher::removePaths()
watcher.removePaths(paths);
}
+static QByteArray msgFileOperationFailed(const char *what, const QFile &f)
+{
+ return what + QByteArrayLiteral(" failed on \"")
+ + QDir::toNativeSeparators(f.fileName()).toLocal8Bit()
+ + QByteArrayLiteral("\": ") + f.errorString().toLocal8Bit();
+}
+
void tst_QFileSystemWatcher::watchFileAndItsDirectory()
{
QFETCH(QString, backend);
@@ -420,14 +427,10 @@ void tst_QFileSystemWatcher::watchFileAndItsDirectory()
QString testFileName = testDir.filePath("testFile.txt");
QString secondFileName = testDir.filePath("testFile2.txt");
- QFile::remove(secondFileName);
QFile testFile(testFileName);
- testFile.setPermissions(QFile::ReadOwner | QFile::WriteOwner);
- testFile.remove();
-
- QVERIFY(testFile.open(QIODevice::WriteOnly | QIODevice::Truncate));
- testFile.write(QByteArray("hello"));
+ QVERIFY2(testFile.open(QIODevice::WriteOnly | QIODevice::Truncate), msgFileOperationFailed("open", testFile));
+ QVERIFY2(testFile.write(QByteArrayLiteral("hello")) > 0, msgFileOperationFailed("write", testFile));
testFile.close();
QFileSystemWatcher watcher;
@@ -449,8 +452,8 @@ void tst_QFileSystemWatcher::watchFileAndItsDirectory()
// wait before modifying the directory...
QTest::qWait(2000);
- QVERIFY(testFile.open(QIODevice::WriteOnly | QIODevice::Truncate));
- testFile.write(QByteArray("hello again"));
+ QVERIFY2(testFile.open(QIODevice::WriteOnly | QIODevice::Truncate), msgFileOperationFailed("open", testFile));
+ QVERIFY2(testFile.write(QByteArrayLiteral("hello again")), msgFileOperationFailed("write", testFile));
testFile.close();
#ifdef Q_OS_MAC
@@ -472,8 +475,8 @@ void tst_QFileSystemWatcher::watchFileAndItsDirectory()
fileChangedSpy.clear();
dirChangedSpy.clear();
QFile secondFile(secondFileName);
- secondFile.open(QIODevice::WriteOnly | QIODevice::Truncate);
- secondFile.write("Foo");
+ QVERIFY2(secondFile.open(QIODevice::WriteOnly | QIODevice::Truncate), msgFileOperationFailed("open", secondFile));
+ QVERIFY2(secondFile.write(QByteArrayLiteral("Foo")) > 0, msgFileOperationFailed("write", secondFile));
secondFile.close();
timer.start(3000);
@@ -491,17 +494,17 @@ void tst_QFileSystemWatcher::watchFileAndItsDirectory()
dirChangedSpy.clear();
- QFile::remove(testFileName);
+ QVERIFY(QFile::remove(testFileName));
QTRY_VERIFY(fileChangedSpy.count() > 0);
- QCOMPARE(dirChangedSpy.count(), 1);
+ QTRY_COMPARE(dirChangedSpy.count(), 1);
fileChangedSpy.clear();
dirChangedSpy.clear();
// removing a deleted file should fail
QVERIFY(!watcher.removePath(testFileName));
- QFile::remove(secondFileName);
+ QVERIFY(QFile::remove(secondFileName));
timer.start(3000);
eventLoop.exec();
diff --git a/tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp b/tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp
index 6e183f3212..cdcbd19ae8 100644
--- a/tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp
+++ b/tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp
@@ -1863,7 +1863,7 @@ void tst_QByteArray::reserve()
QCOMPARE(qba.capacity(), capacity);
QCOMPARE(copy.capacity(), capacity);
- copy = qba;
+ qba = copy;
qba.reserve(capacity * 2);
QCOMPARE(qba.size(), capacity);
QCOMPARE(qba.capacity(), capacity * 2);
diff --git a/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp b/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp
index d360a646f1..de8528216d 100644
--- a/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp
+++ b/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp
@@ -857,36 +857,38 @@ void tst_QFiledialog::selectFile()
{
QFETCH(QString, file);
QFETCH(int, count);
- QNonNativeFileDialog fd;
- QFileSystemModel *model = fd.findChild<QFileSystemModel*>("qt_filesystem_model");
+ QScopedPointer<QNonNativeFileDialog> fd(new QNonNativeFileDialog);
+ QFileSystemModel *model = fd->findChild<QFileSystemModel*>("qt_filesystem_model");
QVERIFY(model);
- fd.setDirectory(QDir::currentPath());
+ fd->setDirectory(QDir::currentPath());
// default value
- QCOMPARE(fd.selectedFiles().count(), 1);
+ QCOMPARE(fd->selectedFiles().count(), 1);
- QTemporaryFile tempFile(QDir::tempPath() + "/aXXXXXX");
- bool inTemp = (file == "temp");
- if (inTemp) {
- tempFile.open();
- file = tempFile.fileName();
+ QScopedPointer<QTemporaryFile> tempFile;
+ if (file == QLatin1String("temp")) {
+ tempFile.reset(new QTemporaryFile(QDir::tempPath() + QStringLiteral("/aXXXXXX")));
+ QVERIFY(tempFile->open());
+ file = tempFile->fileName();
}
- fd.selectFile(file);
- QCOMPARE(fd.selectedFiles().count(), count);
- if (inTemp) {
- QCOMPARE(model->index(fd.directory().path()), model->index(QDir::tempPath()));
+ fd->selectFile(file);
+ QCOMPARE(fd->selectedFiles().count(), count);
+ if (tempFile.isNull()) {
+ QCOMPARE(model->index(fd->directory().path()), model->index(QDir::currentPath()));
} else {
- QCOMPARE(model->index(fd.directory().path()), model->index(QDir::currentPath()));
+ QCOMPARE(model->index(fd->directory().path()), model->index(QDir::tempPath()));
}
+ fd.reset(); // Ensure the file dialog let's go of the temporary file for "temp".
}
void tst_QFiledialog::selectFiles()
{
- QNonNativeFileDialog fd;
- fd.setViewMode(QFileDialog::List);
QTemporaryDir tempDir;
QVERIFY(tempDir.isValid());
const QString tempPath = tempDir.path();
+ {
+ QNonNativeFileDialog fd;
+ fd.setViewMode(QFileDialog::List);
fd.setDirectory(tempPath);
QSignalSpy spyCurrentChanged(&fd, SIGNAL(currentChanged(QString)));
QSignalSpy spyDirectoryEntered(&fd, SIGNAL(directoryEntered(QString)));
@@ -931,17 +933,20 @@ void tst_QFiledialog::selectFiles()
QCOMPARE(spyFilesSelected.count(), 0);
QCOMPARE(spyFilterSelected.count(), 0);
- //If the selection is invalid then we fill the line edit but without the /
- QNonNativeFileDialog * dialog = new QNonNativeFileDialog( 0, "Save" );
- dialog->setFileMode( QFileDialog::AnyFile );
- dialog->setAcceptMode( QFileDialog::AcceptSave );
- dialog->selectFile(tempPath + QStringLiteral("/blah"));
- dialog->show();
- QVERIFY(QTest::qWaitForWindowExposed(dialog));
- QLineEdit *lineEdit = dialog->findChild<QLineEdit*>("fileNameEdit");
- QVERIFY(lineEdit);
- QCOMPARE(lineEdit->text(),QLatin1String("blah"));
- delete dialog;
+ }
+
+ {
+ //If the selection is invalid then we fill the line edit but without the /
+ QNonNativeFileDialog dialog( 0, "Save" );
+ dialog.setFileMode( QFileDialog::AnyFile );
+ dialog.setAcceptMode( QFileDialog::AcceptSave );
+ dialog.selectFile(tempPath + QStringLiteral("/blah"));
+ dialog.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&dialog));
+ QLineEdit *lineEdit = dialog.findChild<QLineEdit*>("fileNameEdit");
+ QVERIFY(lineEdit);
+ QCOMPARE(lineEdit->text(),QLatin1String("blah"));
+ }
}
void tst_QFiledialog::viewMode()
diff --git a/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp b/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp
index 9e0446388e..3925090465 100644
--- a/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp
+++ b/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the test suite of the Qt Toolkit.
@@ -476,13 +476,19 @@ void tst_QFileSystemModel::rowCount()
void tst_QFileSystemModel::rowsInserted_data()
{
QTest::addColumn<int>("count");
- QTest::addColumn<int>("assending");
+ QTest::addColumn<int>("ascending");
for (int i = 0; i < 4; ++i) {
QTest::newRow(QString("Qt::AscendingOrder %1").arg(i).toLocal8Bit().constData()) << i << (int)Qt::AscendingOrder;
QTest::newRow(QString("Qt::DescendingOrder %1").arg(i).toLocal8Bit().constData()) << i << (int)Qt::DescendingOrder;
}
}
+static inline QString lastEntry(const QModelIndex &root)
+{
+ const QAbstractItemModel *model = root.model();
+ return model->index(model->rowCount(root) - 1, 0, root).data().toString();
+}
+
void tst_QFileSystemModel::rowsInserted()
{
#if defined(Q_OS_WINCE)
@@ -492,9 +498,9 @@ void tst_QFileSystemModel::rowsInserted()
rowCount();
QModelIndex root = model->index(model->rootPath());
- QFETCH(int, assending);
+ QFETCH(int, ascending);
QFETCH(int, count);
- model->sort(0, (Qt::SortOrder)assending);
+ model->sort(0, (Qt::SortOrder)ascending);
QSignalSpy spy0(model, SIGNAL(rowsInserted(QModelIndex,int,int)));
QSignalSpy spy1(model, SIGNAL(rowsAboutToBeInserted(QModelIndex,int,int)));
@@ -505,7 +511,6 @@ void tst_QFileSystemModel::rowsInserted()
QVERIFY(createFiles(tmp, files, 5));
TRY_WAIT(model->rowCount(root) == oldCount + count);
QTRY_COMPARE(model->rowCount(root), oldCount + count);
- QTest::qWait(100); // Let the sort settle.
int totalRowsInserted = 0;
for (int i = 0; i < spy0.count(); ++i) {
int start = spy0[i].value(1).toInt();
@@ -513,12 +518,9 @@ void tst_QFileSystemModel::rowsInserted()
totalRowsInserted += end - start + 1;
}
QCOMPARE(totalRowsInserted, count);
- if (assending == (Qt::SortOrder)Qt::AscendingOrder) {
- QString letter = model->index(model->rowCount(root) - 1, 0, root).data().toString();
- QCOMPARE(letter, QString("j"));
- } else {
- QCOMPARE(model->index(model->rowCount(root) - 1, 0, root).data().toString(), QString("b"));
- }
+ const QString expected = ascending == Qt::AscendingOrder ? QStringLiteral("j") : QStringLiteral("b");
+ QTRY_COMPARE(lastEntry(root), expected);
+
if (spy0.count() > 0) {
if (count == 0)
QCOMPARE(spy0.count(), 0);
@@ -548,8 +550,8 @@ void tst_QFileSystemModel::rowsRemoved()
QModelIndex root = model->index(model->rootPath());
QFETCH(int, count);
- QFETCH(int, assending);
- model->sort(0, (Qt::SortOrder)assending);
+ QFETCH(int, ascending);
+ model->sort(0, (Qt::SortOrder)ascending);
QTest::qWait(WAITTIME);
QSignalSpy spy0(model, SIGNAL(rowsRemoved(QModelIndex,int,int)));