From d82ab0709286f6b6816064affee4705d821830ec Mon Sep 17 00:00:00 2001 From: Jens Bache-Wiig Date: Wed, 5 Aug 2009 18:19:11 +0200 Subject: Make QIconloader use resource directory as fallback Instead of using different paths on Mac and Windows we now simply use ":\icons" on all platforms. It is a little more effort to create resources but it is certainly the Qt way to do it. :) Reviewed-by: ogoffart --- src/gui/image/qicon.cpp | 13 ++++--------- src/gui/image/qiconloader.cpp | 7 +++++-- tests/auto/qicon/tst_qicon.cpp | 3 +-- tests/auto/qicon/tst_qicon.qrc | 14 ++++++++++++++ 4 files changed, 24 insertions(+), 13 deletions(-) diff --git a/src/gui/image/qicon.cpp b/src/gui/image/qicon.cpp index a4ea6af..e23677f 100644 --- a/src/gui/image/qicon.cpp +++ b/src/gui/image/qicon.cpp @@ -888,10 +888,9 @@ void QIcon::setThemeSearchPaths(const QStringList &paths) On X11, the search path will use the XDG_DATA_DIRS environment variable if available. - On Windows the search path defaults to [Application Directory]/icons - - On Mac the default search path will search in the - [Contents/Resources/icons] part of the application bundle. + By default all platforms will have the resource directory + ":\icons" as their fallback. You can use "rcc -project" + to generate a resource file from your icon theme. \sa setThemeSearchPaths(), fromTheme(), setThemeName() */ @@ -906,7 +905,7 @@ QStringList QIcon::themeSearchPaths() Sets the current icon theme to \a name. The \a name should correspond to a directory name in the - current themeSearchPath() containing an index.theme + themeSearchPath() containing an index.theme file describing it's contents. \sa themeSearchPaths(), themeName() @@ -939,10 +938,6 @@ QString QIcon::themeName() icon theme. If no such icon is found in the current theme \a fallback is return instead. - To use an icon theme on Windows or Mac, you will need to - bundle a compliant theme with your application and make sure - it is located in your themeSarchPaths. - The lastest version of the freedesktop icon specification and naming spesification can be obtained here: http://standards.freedesktop.org/icon-theme-spec/icon-theme-spec-latest.html diff --git a/src/gui/image/qiconloader.cpp b/src/gui/image/qiconloader.cpp index 279703c..cb1cc61 100644 --- a/src/gui/image/qiconloader.cpp +++ b/src/gui/image/qiconloader.cpp @@ -187,14 +187,17 @@ QStringList QIconLoader::themeSearchPaths() const QDir homeDir(QDir::homePath() + QLatin1String("/.icons")); if (homeDir.exists()) m_iconDirs.prepend(homeDir.path()); - -#elif defined(Q_WS_WIN) +#endif + +#if defined(Q_WS_WIN) m_iconDirs.append(qApp->applicationDirPath() + QLatin1String("/icons")); #elif defined(Q_WS_MAC) m_iconDirs.append(qApp->applicationDirPath() + QLatin1String("/../Resources/icons")); #endif + // Allways add resource directory as search path + m_iconDirs.append(QLatin1String(":/icons")); } return m_iconDirs; } diff --git a/tests/auto/qicon/tst_qicon.cpp b/tests/auto/qicon/tst_qicon.cpp index b614ab9..bacf7a5 100644 --- a/tests/auto/qicon/tst_qicon.cpp +++ b/tests/auto/qicon/tst_qicon.cpp @@ -609,8 +609,7 @@ void tst_QIcon::task184901_badCache() void tst_QIcon::fromTheme() { - const QString prefix = QLatin1String(SRCDIR) + QLatin1String("/"); - QString searchPath = prefix + QLatin1String("/icons"); + QString searchPath = QLatin1String(":/icons"); QIcon::setThemeSearchPaths(QStringList() << searchPath); QVERIFY(QIcon::themeSearchPaths().size() == 1); QCOMPARE(searchPath, QIcon::themeSearchPaths()[0]); diff --git a/tests/auto/qicon/tst_qicon.qrc b/tests/auto/qicon/tst_qicon.qrc index 1e1a030..7925a33 100644 --- a/tests/auto/qicon/tst_qicon.qrc +++ b/tests/auto/qicon/tst_qicon.qrc @@ -2,5 +2,19 @@ image.png rect.png +./icons/testtheme/16x16/actions/appointment-new.png +./icons/testtheme/22x22/actions/appointment-new.png +./icons/testtheme/32x32/actions/appointment-new.png +./icons/testtheme/index.theme +./icons/testtheme/scalable/actions/svg-only.svg +./icons/themeparent/16x16/actions/address-book-new.png +./icons/themeparent/16x16/actions/appointment-new.png +./icons/themeparent/22x22/actions/address-book-new.png +./icons/themeparent/22x22/actions/appointment-new.png +./icons/themeparent/32x32/actions/address-book-new.png +./icons/themeparent/32x32/actions/appointment-new.png +./icons/themeparent/index.theme +./icons/themeparent/scalable/actions/address-book-new.svg +./icons/themeparent/scalable/actions/appointment-new.svg -- cgit v0.12 From dcdbb81f28bc8fc4bb7fedf78421e473413da1a7 Mon Sep 17 00:00:00 2001 From: Jens Bache-Wiig Date: Tue, 11 Aug 2009 15:32:56 +0200 Subject: Fix reversed progress bars on Vista This issue seems to be caused by change a6782030 and was caused by incorrectly applying paranthesis to the expression. Task-number: 259515 Reviewed-by: joao --- src/gui/styles/qwindowsvistastyle.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/styles/qwindowsvistastyle.cpp b/src/gui/styles/qwindowsvistastyle.cpp index a54c701..3789854 100644 --- a/src/gui/styles/qwindowsvistastyle.cpp +++ b/src/gui/styles/qwindowsvistastyle.cpp @@ -1094,7 +1094,7 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption XPThemeData theme(widget, painter, QLatin1String("PROGRESS"), vertical ? PP_FILLVERT : PP_FILL); theme.rect = option->rect; - bool reverse = bar->direction == (Qt::LeftToRight && inverted) || (bar->direction == Qt::RightToLeft && !inverted); + bool reverse = (bar->direction == Qt::LeftToRight && inverted) || (bar->direction == Qt::RightToLeft && !inverted); QTime current = QTime::currentTime(); if (isIndeterminate) { -- cgit v0.12 From 6cf224de00ebf0681cd32a34866bdc3d16e0f45d Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Mon, 31 Aug 2009 07:04:12 +0200 Subject: Invalidate cached QVectorPath when QPainterPath changes Reviewed-by: Samuel --- src/gui/painting/qpainterpath.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gui/painting/qpainterpath.cpp b/src/gui/painting/qpainterpath.cpp index ff133b6..cb9ea80 100644 --- a/src/gui/painting/qpainterpath.cpp +++ b/src/gui/painting/qpainterpath.cpp @@ -3215,6 +3215,8 @@ void QPainterPath::setDirty(bool dirty) { d_func()->dirtyBounds = dirty; d_func()->dirtyControlBounds = dirty; + delete d_func()->pathConverter; + d_func()->pathConverter = 0; } void QPainterPath::computeBoundingRect() const -- cgit v0.12 From b0295e82d08605a5a40803895544e57eeb6c8dc3 Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Mon, 31 Aug 2009 07:19:23 +0200 Subject: Don't crash when convert Indexed8 without colortable to QPixmap This implicitly adds "grayscale" support for indexed 8, but only for the conversion. The alternative would be leave the pixels uninitialized which would be less nice... Reviewed-by: Samuel --- src/gui/image/qimage.cpp | 6 ++++++ tests/auto/qpixmap/tst_qpixmap.cpp | 29 +++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp index d48d427..0358ba0 100644 --- a/src/gui/image/qimage.cpp +++ b/src/gui/image/qimage.cpp @@ -2904,6 +2904,12 @@ static void convert_Indexed8_to_X32(QImageData *dest, const QImageData *src, Qt: Q_ASSERT(src->height == dest->height); QVector colorTable = fix_color_table(src->colortable, dest->format); + if (colorTable.size() == 0) { + colorTable.resize(256); + for (int i=0; i<256; ++i) + colorTable[i] = qRgb(i, i, i); + + } int w = src->width; const uchar *src_data = src->data; diff --git a/tests/auto/qpixmap/tst_qpixmap.cpp b/tests/auto/qpixmap/tst_qpixmap.cpp index 8dd5f5f..9422327 100644 --- a/tests/auto/qpixmap/tst_qpixmap.cpp +++ b/tests/auto/qpixmap/tst_qpixmap.cpp @@ -83,6 +83,9 @@ private slots: void fromImage_data(); void fromImage(); + void fromUninitializedImage_data(); + void fromUninitializedImage(); + void convertFromImage_data(); void convertFromImage(); @@ -266,6 +269,32 @@ void tst_QPixmap::fromImage() QCOMPARE(result, image); } + +void tst_QPixmap::fromUninitializedImage_data() +{ + QTest::addColumn("format"); + + QTest::newRow("Format_Mono") << QImage::Format_Mono; + QTest::newRow("Format_MonoLSB") << QImage::Format_MonoLSB; + QTest::newRow("Format_Indexed8") << QImage::Format_Indexed8; + QTest::newRow("Format_RGB32") << QImage::Format_RGB32; + QTest::newRow("Format_ARGB32") << QImage::Format_ARGB32; + QTest::newRow("Format_ARGB32_Premultiplied") << QImage::Format_ARGB32_Premultiplied; + QTest::newRow("Format_RGB16") << QImage::Format_RGB16; +} + +void tst_QPixmap::fromUninitializedImage() +{ + QFETCH(QImage::Format, format); + + QImage image(100, 100, format); + QPixmap pix = QPixmap::fromImage(image); + + // it simply shouldn't crash... + QVERIFY(true); + +} + void tst_QPixmap::convertFromImage_data() { QTest::addColumn("img1"); -- cgit v0.12 From 1fc237371f98672854331e5855de4d9af2586a51 Mon Sep 17 00:00:00 2001 From: David Boddie Date: Mon, 31 Aug 2009 14:05:17 +0200 Subject: Doc: Updated the requirements information about OpenSSL. Task-number: 158631 Reviewed-by: Andreas Aardal Hanssen --- doc/src/getting-started/installation.qdoc | 4 +++- doc/src/network-programming/ssl.qdoc | 26 ++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/doc/src/getting-started/installation.qdoc b/doc/src/getting-started/installation.qdoc index ec50060..4fb3792 100644 --- a/doc/src/getting-started/installation.qdoc +++ b/doc/src/getting-started/installation.qdoc @@ -652,7 +652,9 @@ If you are using pre-built binaries, follow the instructions \section1 OpenSSL (version 0.9.7 or later) Support for \l{SSL}{Secure Sockets Layer (SSL)} communication is provided by the - \l{OpenSSL Toolkit}, which must be obtained separately. + \l{OpenSSL Toolkit}, which must be obtained separately. More information about + enabling SSL support can be found in the \l{Secure Sockets Layer (SSL) Classes} + document. \section1 Platform-Specific Requirements diff --git a/doc/src/network-programming/ssl.qdoc b/doc/src/network-programming/ssl.qdoc index 44d4196..e66216a 100644 --- a/doc/src/network-programming/ssl.qdoc +++ b/doc/src/network-programming/ssl.qdoc @@ -54,6 +54,32 @@ See the \l{General Qt Requirements} page for information about the versions of OpenSSL that are known to work with Qt. + \section1 Enabling and Disabling SSL Support + + When building Qt from source, the configuration system checks for the presence + of the \c{openssl/opensslv.h} header provided by source or developer packages + of OpenSSL. + + By default, an SSL-enabled Qt library dynamically loads any installed OpenSSL + library at run-time. However, it is possible to link against the library at + compile-time by configuring Qt with the \c{-openssl-linked} option. + + When building a version of Qt linked against OpenSSL, the build system will + attempt to link with libssl and libcrypt libraries located in the default + location on the developer's system. This location is configurable: + set the \c OPENSSL_LIBS environment variable to contain the linker options + required to link Qt against the installed library. For example, on a Unix/Linux + system: + + \code + ./configure -openssl-linked OPENSSL_LIBS='-L/opt/ssl/lib -lssl -lcrypto' + \endcode + + To disable SSL support in a Qt build, configure Qt with the \c{-no-openssl} + option. + + \section1 Licensing Information + \note Due to import and export restrictions in some parts of the world, we are unable to supply the OpenSSL Toolkit with Qt packages. Developers wishing to use SSL communication in their deployed applications should either ensure -- cgit v0.12 From 444ddca247cacc5376821e82588b1d8b76133437 Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Mon, 31 Aug 2009 15:10:32 +0200 Subject: doc: Fixed several qdoc errors. --- src/corelib/io/qprocess.cpp | 5 +++++ src/corelib/io/qprocess_symbian.cpp | 2 -- src/corelib/io/qprocess_unix.cpp | 2 -- src/gui/kernel/qwidget.cpp | 2 +- src/opengl/qglshaderprogram.cpp | 2 +- src/script/bridge/qscriptactivationobject.cpp | 4 ++-- src/testlib/qtestcase.cpp | 4 ++++ 7 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/corelib/io/qprocess.cpp b/src/corelib/io/qprocess.cpp index f7049d3..5b6830c 100644 --- a/src/corelib/io/qprocess.cpp +++ b/src/corelib/io/qprocess.cpp @@ -411,6 +411,11 @@ void QProcessPrivate::Channel::clear() process = 0; } +/*! \fn bool QProcessPrivate::startDetached(const QString &program, const QStringList &arguments, const QString &workingDirectory, qint64 *pid) + +\internal + */ + /*! \class QProcess diff --git a/src/corelib/io/qprocess_symbian.cpp b/src/corelib/io/qprocess_symbian.cpp index e558387..d41321b 100644 --- a/src/corelib/io/qprocess_symbian.cpp +++ b/src/corelib/io/qprocess_symbian.cpp @@ -1009,8 +1009,6 @@ void QProcessPrivate::_q_notified() // Nothing to do in Symbian } -/*! \internal - */ bool QProcessPrivate::startDetached(const QString &program, const QStringList &arguments, const QString &workingDirectory, qint64 *pid) { QPROCESS_DEBUG_PRINT("QProcessPrivate::startDetached()"); diff --git a/src/corelib/io/qprocess_unix.cpp b/src/corelib/io/qprocess_unix.cpp index baf90c4..d45ff03 100644 --- a/src/corelib/io/qprocess_unix.cpp +++ b/src/corelib/io/qprocess_unix.cpp @@ -1163,8 +1163,6 @@ void QProcessPrivate::_q_notified() { } -/*! \internal - */ bool QProcessPrivate::startDetached(const QString &program, const QStringList &arguments, const QString &workingDirectory, qint64 *pid) { processManager()->start(); diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index ab809df..ff644b8 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -919,7 +919,7 @@ void QWidget::setAutoFillBackground(bool enabled) any amount of widgets there might be physical restrictions to amount of softkeys that can be used by the device. - \o Series60: For series60 menu button is automatically mapped to left + \e Series60: For series60 menu button is automatically mapped to left soft key if there is QMainWindow with QMenuBar in widgets parent hierarchy. \sa softKeys() diff --git a/src/opengl/qglshaderprogram.cpp b/src/opengl/qglshaderprogram.cpp index c9bfd08..6e8474c 100644 --- a/src/opengl/qglshaderprogram.cpp +++ b/src/opengl/qglshaderprogram.cpp @@ -194,7 +194,7 @@ QT_BEGIN_NAMESPACE */ /*! - \enum QGLShader::ShaderType + \enum QGLShader::ShaderTypeBits This enum specifies the type of QGLShader that is being created. \value VertexShader Vertex shader written in the OpenGL Shading Language (GLSL). diff --git a/src/script/bridge/qscriptactivationobject.cpp b/src/script/bridge/qscriptactivationobject.cpp index c6d405e..1c7b912 100644 --- a/src/script/bridge/qscriptactivationobject.cpp +++ b/src/script/bridge/qscriptactivationobject.cpp @@ -52,8 +52,8 @@ namespace JSC QT_BEGIN_NAMESPACE /*! -\class QScriptActivationObject -\internal + \class QScript::QScriptActivationObject + \internal Represent a scope for native function call. */ diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp index c655cad..b9636c9 100644 --- a/src/testlib/qtestcase.cpp +++ b/src/testlib/qtestcase.cpp @@ -2121,6 +2121,10 @@ bool QTest::compare_string_helper(const char *t1, const char *t2, const char *ac \internal */ +/*! \fn bool QTest::qCompare(bool const &t1, int const &t2, const char *actual, const char *expected, const char *file, int line) + \internal + */ + /*! \fn bool QTest::qTest(const T& actual, const char *elementName, const char *actualStr, const char *expected, const char *file, int line) \internal */ -- cgit v0.12 From 2b950244a3615c2611a636afbf372411c9db491c Mon Sep 17 00:00:00 2001 From: Ariya Hidayat Date: Mon, 31 Aug 2009 15:15:19 +0200 Subject: Fix wrong checks in commit fd8ced2f. We should use the newly create QStringRef, after all that is the idea of the optimization. --- src/svg/qsvghandler.cpp | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/svg/qsvghandler.cpp b/src/svg/qsvghandler.cpp index d0b52da..344e2b1 100644 --- a/src/svg/qsvghandler.cpp +++ b/src/svg/qsvghandler.cpp @@ -181,21 +181,21 @@ QSvgAttributes::QSvgAttributes(const QXmlStreamAttributes &xmlAttributes, QSvgHa case 's': if (name.length() > 5 && QStringRef(name.string(), name.position() + 1, 5) == QLatin1String("troke")) { QStringRef strokeRef(name.string(), name.position() + 6, name.length() - 6); - if (name.isEmpty()) + if (strokeRef.isEmpty()) stroke = value; - else if (name == QLatin1String("-dasharray")) + else if (strokeRef == QLatin1String("-dasharray")) strokeDashArray = value; - else if (name == QLatin1String("-dashoffset")) + else if (strokeRef == QLatin1String("-dashoffset")) strokeDashOffset = value; - else if (name == QLatin1String("-linecap")) + else if (strokeRef == QLatin1String("-linecap")) strokeLineCap = value; - else if (name == QLatin1String("-linejoin")) + else if (strokeRef == QLatin1String("-linejoin")) strokeLineJoin = value; - else if (name == QLatin1String("-miterlimit")) + else if (strokeRef == QLatin1String("-miterlimit")) strokeMiterLimit = value; - else if (name == QLatin1String("-opacity")) + else if (strokeRef == QLatin1String("-opacity")) strokeOpacity = value; - else if (name == QLatin1String("-width")) + else if (strokeRef == QLatin1String("-width")) strokeWidth = value; } else if (name == QLatin1String("stop-color")) @@ -276,21 +276,21 @@ QSvgAttributes::QSvgAttributes(const QXmlStreamAttributes &xmlAttributes, QSvgHa case 's': if (name.length() > 5 && QStringRef(name.string(), name.position() + 1, 5) == QLatin1String("troke")) { QStringRef strokeRef(name.string(), name.position() + 6, name.length() - 6); - if (name.isEmpty()) + if (strokeRef.isEmpty()) stroke = value; - else if (name == QLatin1String("-dasharray")) + else if (strokeRef == QLatin1String("-dasharray")) strokeDashArray = value; - else if (name == QLatin1String("-dashoffset")) + else if (strokeRef == QLatin1String("-dashoffset")) strokeDashOffset = value; - else if (name == QLatin1String("-linecap")) + else if (strokeRef == QLatin1String("-linecap")) strokeLineCap = value; - else if (name == QLatin1String("-linejoin")) + else if (strokeRef == QLatin1String("-linejoin")) strokeLineJoin = value; - else if (name == QLatin1String("-miterlimit")) + else if (strokeRef == QLatin1String("-miterlimit")) strokeMiterLimit = value; - else if (name == QLatin1String("-opacity")) + else if (strokeRef == QLatin1String("-opacity")) strokeOpacity = value; - else if (name == QLatin1String("-width")) + else if (strokeRef == QLatin1String("-width")) strokeWidth = value; } else if (name == QLatin1String("stop-color")) -- cgit v0.12 From f776327408d828a2556e8f9a35df5fe3c2976ef6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Mon, 31 Aug 2009 14:49:33 +0200 Subject: Fixed having a QPainter active on several FBOs at the same time. It's insufficient to use a single paint engine to render to all FBOs. If the default engine is already in used we need to create our own engine. Reviewed-by: Trond --- src/opengl/qglframebufferobject.cpp | 39 +++++++++++++++++++++++++++---------- 1 file changed, 29 insertions(+), 10 deletions(-) diff --git a/src/opengl/qglframebufferobject.cpp b/src/opengl/qglframebufferobject.cpp index fe967e7..9659654 100644 --- a/src/opengl/qglframebufferobject.cpp +++ b/src/opengl/qglframebufferobject.cpp @@ -262,7 +262,7 @@ GLenum QGLFramebufferObjectFormat::internalFormat() const class QGLFramebufferObjectPrivate { public: - QGLFramebufferObjectPrivate() : depth_stencil_buffer(0), valid(false), bound(false), ctx(0), previous_fbo(0) {} + QGLFramebufferObjectPrivate() : depth_stencil_buffer(0), valid(false), bound(false), ctx(0), previous_fbo(0), engine(0) {} ~QGLFramebufferObjectPrivate() {} void init(const QSize& sz, QGLFramebufferObject::Attachment attachment, @@ -280,6 +280,7 @@ public: QGLFramebufferObject::Attachment fbo_attachment; QGLContext *ctx; // for Windows extension ptrs GLuint previous_fbo; + mutable QPaintEngine *engine; }; bool QGLFramebufferObjectPrivate::checkFramebufferStatus() const @@ -723,6 +724,8 @@ QGLFramebufferObject::~QGLFramebufferObject() Q_D(QGLFramebufferObject); QGL_FUNC_CONTEXT; + delete d->engine; + if (isValid() && (d->ctx == QGLContext::currentContext() || qgl_share_reg()->checkSharing(d->ctx, QGLContext::currentContext()))) @@ -890,16 +893,32 @@ Q_GLOBAL_STATIC(QOpenGLPaintEngine, qt_buffer_engine) /*! \reimp */ QPaintEngine *QGLFramebufferObject::paintEngine() const { -#if defined(QT_OPENGL_ES_1) || defined(QT_OPENGL_ES_1_CL) - return qt_buffer_engine(); -#elif defined(QT_OPENGL_ES_2) - return qt_buffer_2_engine(); -#else Q_D(const QGLFramebufferObject); - if (qt_gl_preferGL2Engine()) - return qt_buffer_2_engine(); - else - return qt_buffer_engine(); + if (d->engine) + return d->engine; + +#if !defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL) +#if !defined (QT_OPENGL_ES_2) + if (qt_gl_preferGL2Engine()) { +#endif + QPaintEngine *engine = qt_buffer_2_engine(); + if (engine->isActive() && engine->paintDevice() != this) { + d->engine = new QGL2PaintEngineEx; + return d->engine; + } + return engine; +#if !defined (QT_OPENGL_ES_2) + } +#endif +#endif + +#if !defined(QT_OPENGL_ES_2) + QPaintEngine *engine = qt_buffer_engine(); + if (engine->isActive() && engine->paintDevice() != this) { + d->engine = new QOpenGLPaintEngine; + return d->engine; + } + return engine; #endif } -- cgit v0.12 From 8a3f912f7cbe6d019f847ed1eb67efb1a29a5851 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Mon, 31 Aug 2009 14:52:38 +0200 Subject: Fixed rendering bug in blurpicker example with -graphicssystem opengl Made the GL blur filter code slightly less hacky by not reusing the same paint engine for rendering both to the offscreen FBO and to the actual target device. This should make the code less reliant on paint engine implementation details and thus more robust with regards to changes in the paint engine. Task-number: 260402 Reviewed-by: Trond --- src/opengl/qglpixmapfilter.cpp | 53 ++++++++++++++++++++---------------------- 1 file changed, 25 insertions(+), 28 deletions(-) diff --git a/src/opengl/qglpixmapfilter.cpp b/src/opengl/qglpixmapfilter.cpp index 808038b..c51ccc7 100644 --- a/src/opengl/qglpixmapfilter.cpp +++ b/src/opengl/qglpixmapfilter.cpp @@ -119,6 +119,8 @@ private: mutable QSize m_textureSize; + mutable bool m_horizontalBlur; + QGLShaderProgram *m_program; }; @@ -336,46 +338,37 @@ bool QGLPixmapBlurFilter::processGL(QPainter *painter, const QPointF &pos, const glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glBindTexture(GL_TEXTURE_2D, 0); - QGL2PaintEngineEx *engine = static_cast(painter->paintEngine()); - - painter->save(); - - // ensure GL_LINEAR filtering is used - painter->setRenderHint(QPainter::SmoothPixmapTransform); - // prepare for updateUniforms m_textureSize = src.size(); - // first pass, to fbo - fbo->bind(); + // horizontal pass, to pixmap + m_horizontalBlur = true; + + QPainter fboPainter(fbo); + if (src.hasAlphaChannel()) { glClearColor(0, 0, 0, 0); glClear(GL_COLOR_BUFFER_BIT); } - filter->setOnPainter(painter); - - QTransform transform = engine->state()->matrix; - if (!transform.isIdentity()) { - engine->state()->matrix = QTransform(); - engine->transformChanged(); - } - - engine->drawPixmap(src.rect().translated(0, painter->device()->height() - fbo->height()), - src, src.rect()); + // ensure GL_LINEAR filtering is used + fboPainter.setRenderHint(QPainter::SmoothPixmapTransform); + filter->setOnPainter(&fboPainter); + fboPainter.drawPixmap(0, 0, src); + filter->removeFromPainter(&fboPainter); + fboPainter.end(); - if (!transform.isIdentity()) { - engine->state()->matrix = transform; - engine->transformChanged(); - } + QGL2PaintEngineEx *engine = static_cast(painter->paintEngine()); - fbo->release(); + // vertical pass, to painter + m_horizontalBlur = false; - // second pass, to widget - m_program->setUniformValue("delta", 0.0, 1.0); + painter->save(); + // ensure GL_LINEAR filtering is used + painter->setRenderHint(QPainter::SmoothPixmapTransform); + filter->setOnPainter(painter); engine->drawTexture(src.rect().translated(pos.x(), pos.y()), fbo->texture(), fbo->size(), src.rect().translated(0, fbo->height() - src.height())); filter->removeFromPainter(painter); - painter->restore(); qgl_fbo_pool()->release(fbo); @@ -386,7 +379,11 @@ bool QGLPixmapBlurFilter::processGL(QPainter *painter, const QPointF &pos, const void QGLPixmapBlurFilter::setUniforms(QGLShaderProgram *program) { program->setUniformValue("invTextureSize", 1.0 / m_textureSize.width(), 1.0 / m_textureSize.height()); - program->setUniformValue("delta", 1.0, 0.0); + + if (m_horizontalBlur) + program->setUniformValue("delta", 1.0, 0.0); + else + program->setUniformValue("delta", 0.0, 1.0); m_program = program; } -- cgit v0.12 From a8c5ded0de4b466b348080bfdef3107af39ed508 Mon Sep 17 00:00:00 2001 From: Ariya Hidayat Date: Mon, 31 Aug 2009 15:28:30 +0200 Subject: Speed-up parseCoreNode() for SVG parsing. Instead of doing an attribute look-up via QXmlAttributes::value(), we just iterate by ourselves. Thus, we need to carry out the iteration and comparison only once, instead of every call to the said value(). Reviewed-by: Kim --- src/svg/qsvghandler.cpp | 52 +++++++++++++++++++++++++++++++++++-------------- 1 file changed, 37 insertions(+), 15 deletions(-) diff --git a/src/svg/qsvghandler.cpp b/src/svg/qsvghandler.cpp index 344e2b1..2fec215 100644 --- a/src/svg/qsvghandler.cpp +++ b/src/svg/qsvghandler.cpp @@ -1819,27 +1819,49 @@ static inline QStringList stringToList(const QString &str) static bool parseCoreNode(QSvgNode *node, const QXmlStreamAttributes &attributes) { - QString featuresStr = attributes.value(QLatin1String("requiredFeatures")).toString(); - QString extensionsStr = attributes.value(QLatin1String("requiredExtensions")).toString(); - QString languagesStr = attributes.value(QLatin1String("systemLanguage")).toString(); - QString formatsStr = attributes.value(QLatin1String("requiredFormats")).toString(); - QString fontsStr = attributes.value(QLatin1String("requiredFonts")).toString(); - QString nodeIdStr = someId(attributes); - QString xmlClassStr = attributes.value(QLatin1String("class")).toString(); - - - QStringList features = stringToList(featuresStr); - QStringList extensions = stringToList(extensionsStr); - QStringList languages = stringToList(languagesStr); - QStringList formats = stringToList(formatsStr); - QStringList fonts = stringToList(fontsStr); + QStringList features; + QStringList extensions; + QStringList languages; + QStringList formats; + QStringList fonts; + QString xmlClassStr; + + for (int i = 0; i < attributes.count(); ++i) { + const QXmlStreamAttribute &attribute = attributes.at(i); + QStringRef name = attribute.qualifiedName(); + if (name.isEmpty()) + continue; + QStringRef value = attribute.value(); + switch (name.at(0).unicode()) { + case 'c': + if (name == QLatin1String("class")) + xmlClassStr = value.toString(); + break; + case 'r': + if (name == QLatin1String("requiredFeatures")) + features = stringToList(value.toString()); + else if (name == QLatin1String("requiredExtensions")) + extensions = stringToList(value.toString()); + else if (name == QLatin1String("requiredFormats")) + formats = stringToList(value.toString()); + else if (name == QLatin1String("requiredFonts")) + fonts = stringToList(value.toString()); + break; + case 's': + if (name == QLatin1String("systemLanguage")) + languages = stringToList(value.toString()); + break; + default: + break; + } + } node->setRequiredFeatures(features); node->setRequiredExtensions(extensions); node->setRequiredLanguages(languages); node->setRequiredFormats(formats); node->setRequiredFonts(fonts); - node->setNodeId(nodeIdStr); + node->setNodeId(someId(attributes)); node->setXmlClass(xmlClassStr); return true; -- cgit v0.12 From 940b0b9e51f234f251d332f729531d6e9c3cea84 Mon Sep 17 00:00:00 2001 From: Ariya Hidayat Date: Mon, 31 Aug 2009 15:42:43 +0200 Subject: Faster cut-off when SVG "display" attribute is not explicitly set. Reviewed-by: Kim --- src/svg/qsvghandler.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/svg/qsvghandler.cpp b/src/svg/qsvghandler.cpp index 2fec215..8a68cc3 100644 --- a/src/svg/qsvghandler.cpp +++ b/src/svg/qsvghandler.cpp @@ -2003,8 +2003,9 @@ static void parseOthers(QSvgNode *node, const QSvgAttributes &attributes, QSvgHandler *) { - QString displayStr = attributes.display.toString(); - displayStr = displayStr.trimmed(); + if (attributes.display.isEmpty()) + return; + QString displayStr = attributes.display.toString().trimmed(); if (!displayStr.isEmpty()) { node->setDisplayMode(displayStringToEnum(displayStr)); -- cgit v0.12 From 62ca28a96d200fe55ed5bc2d0d1df327ab44c97e Mon Sep 17 00:00:00 2001 From: Andreas Aardal Hanssen Date: Mon, 31 Aug 2009 14:06:47 +0200 Subject: Fix activation behavior for panels, and add QGraphicsItem::setActive(). Allow delayed activation for more fine grained control over which panels are activated or left inactive when the scene is created. Autotests included. Reviewed-by: Brad --- src/gui/graphicsview/qgraphicsitem.cpp | 37 +++++- src/gui/graphicsview/qgraphicsitem.h | 2 + src/gui/graphicsview/qgraphicsitem_p.h | 8 +- src/gui/graphicsview/qgraphicsscene.cpp | 149 +++++++++++++++---------- src/gui/graphicsview/qgraphicsscene_p.h | 2 + tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp | 140 +++++++++++++++++++---- 6 files changed, 255 insertions(+), 83 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index 86c589d..31fd53a 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -2669,6 +2669,37 @@ bool QGraphicsItem::isActive() const } /*! + \since 4.6 + + If \a active is true, and the scene is active, this item's panel will be + activated. Otherwise, the panel is deactivated. + + If the item is not part of an active scene, \a active will decide what + happens to the panel when the scene becomes active or the item is added to + the scene. If true, the item's panel will be activated when the item is + either added to the scene or the scene is activated. Otherwise, the item + will stay inactive independent of the scene's activated state. + + \sa isPanel(), QGraphicsScene::setActivePanel(), QGraphicsScene::isActive() +*/ +void QGraphicsItem::setActive(bool active) +{ + d_ptr->explicitActivate = 1; + d_ptr->wantsActive = active; + if (d_ptr->scene) { + if (active) { + // Activate this item. + d_ptr->scene->setActivePanel(this); + } else { + // Deactivate this item, and reactivate the last active item + // (if any). + QGraphicsItem *lastActive = d_ptr->scene->d_func()->lastActivePanel; + d_ptr->scene->setActivePanel(lastActive != this ? lastActive : 0); + } + } +} + +/*! Returns true if this item is active, and it or its \l{focusProxy()}{focus proxy} has keyboard input focus; otherwise, returns false. @@ -6099,8 +6130,10 @@ bool QGraphicsItem::sceneEvent(QEvent *event) if (d_ptr->scene) { for (int i = 0; i < d_ptr->children.size(); ++i) { QGraphicsItem *child = d_ptr->children.at(i); - if (!(child->d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorHandlesChildEvents)) - d_ptr->scene->sendEvent(child, event); + if (child->isVisible() && !child->isPanel()) { + if (!(child->d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorHandlesChildEvents)) + d_ptr->scene->sendEvent(child, event); + } } } break; diff --git a/src/gui/graphicsview/qgraphicsitem.h b/src/gui/graphicsview/qgraphicsitem.h index 04fe0cb..df25e6a 100644 --- a/src/gui/graphicsview/qgraphicsitem.h +++ b/src/gui/graphicsview/qgraphicsitem.h @@ -235,6 +235,8 @@ public: void setHandlesChildEvents(bool enabled); bool isActive() const; + void setActive(bool active); + bool hasFocus() const; void setFocus(Qt::FocusReason focusReason = Qt::OtherFocusReason); void clearFocus(); diff --git a/src/gui/graphicsview/qgraphicsitem_p.h b/src/gui/graphicsview/qgraphicsitem_p.h index 2bc876c..1090620 100644 --- a/src/gui/graphicsview/qgraphicsitem_p.h +++ b/src/gui/graphicsview/qgraphicsitem_p.h @@ -171,6 +171,8 @@ public: notifyBoundingRectChanged(0), notifyInvalidated(0), mouseSetsFocus(1), + explicitActivate(0), + wantsActive(0), globalStackingOrder(-1), q_ptr(0) { @@ -461,7 +463,7 @@ public: quint32 needSortChildren : 1; quint32 allChildrenDirty : 1; - // New 32 bits + // Packed 32 bits quint32 fullUpdatePending : 1; quint32 flags : 16; quint32 dirtyChildrenBoundingRect : 1; @@ -480,6 +482,10 @@ public: quint32 notifyInvalidated : 1; quint32 mouseSetsFocus : 1; + // New 32 bits + quint32 explicitActivate : 1; + quint32 wantsActive : 1; + // Optional stacking order int globalStackingOrder; QGraphicsItem *q_ptr; diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp index ac30668..2ac1dca 100644 --- a/src/gui/graphicsview/qgraphicsscene.cpp +++ b/src/gui/graphicsview/qgraphicsscene.cpp @@ -291,6 +291,7 @@ QGraphicsScenePrivate::QGraphicsScenePrivate() activePanel(0), lastActivePanel(0), activationRefCount(0), + childExplicitActivation(0), lastMouseGrabberItem(0), lastMouseGrabberItemHasImplicitMouseGrab(false), dragDropItem(0), @@ -571,6 +572,66 @@ void QGraphicsScenePrivate::removeItemHelper(QGraphicsItem *item) /*! \internal */ +void QGraphicsScenePrivate::setActivePanelHelper(QGraphicsItem *item, bool duringActivationEvent) +{ + Q_Q(QGraphicsScene); + if (item && item->scene() != q) { + qWarning("QGraphicsScene::setActivePanel: item %p must be part of this scene", + item); + return; + } + + // Find the item's panel. + QGraphicsItem *panel = item ? item->panel() : 0; + lastActivePanel = panel ? activePanel : 0; + if (panel == activePanel || (!q->isActive() && !duringActivationEvent)) + return; + + // Deactivate the last active panel. + if (activePanel) { + if (QGraphicsItem *fi = activePanel->focusItem()) { + // Remove focus from the current focus item. + if (fi == q->focusItem()) + q->setFocusItem(0, Qt::ActiveWindowFocusReason); + } + + QEvent event(QEvent::WindowDeactivate); + q->sendEvent(activePanel, &event); + } else if (panel && !duringActivationEvent) { + // Deactivate the scene if changing activation to a panel. + QEvent event(QEvent::WindowDeactivate); + foreach (QGraphicsItem *item, q->items()) { + if (item->isVisible() && !item->isPanel() && !item->parentItem()) + q->sendEvent(item, &event); + } + } + + // Update activate state. + activePanel = panel; + QEvent event(QEvent::ActivationChange); + QApplication::sendEvent(q, &event); + + // Activate + if (panel) { + QEvent event(QEvent::WindowActivate); + q->sendEvent(panel, &event); + + // Set focus on the panel's focus item. + if (QGraphicsItem *focusItem = panel->focusItem()) + focusItem->setFocus(Qt::ActiveWindowFocusReason); + } else if (q->isActive()) { + // Activate the scene + QEvent event(QEvent::WindowActivate); + foreach (QGraphicsItem *item, q->items()) { + if (item->isVisible() && !item->isPanel() && !item->parentItem()) + q->sendEvent(item, &event); + } + } +} + +/*! + \internal +*/ void QGraphicsScenePrivate::setFocusItemHelper(QGraphicsItem *item, Qt::FocusReason focusReason) { @@ -2351,9 +2412,29 @@ void QGraphicsScene::addItem(QGraphicsItem *item) // Deliver post-change notification item->itemChange(QGraphicsItem::ItemSceneHasChanged, newSceneVariant); - // Auto-activate the first inactive panel if the scene is active. - if (isActive() && !d->activePanel && item->isPanel()) - setActivePanel(item); + // Update explicit activation + bool autoActivate = true; + if (!d->childExplicitActivation && item->d_ptr->explicitActivate) + d->childExplicitActivation = item->d_ptr->wantsActive ? 1 : 2; + if (d->childExplicitActivation && item->isPanel()) { + if (d->childExplicitActivation == 1) + setActivePanel(item); + else + autoActivate = false; + d->childExplicitActivation = 0; + } else if (!item->d_ptr->parent) { + d->childExplicitActivation = 0; + } + + // Auto-activate this item's panel if nothing else has been activated + if (autoActivate) { + if (!d->lastActivePanel && !d->activePanel && item->isPanel()) { + if (isActive()) + setActivePanel(item); + else + d->lastActivePanel = item; + } + } // Ensure that newly added items that have subfocus set, gain // focus automatically if there isn't a focus item already. @@ -3129,11 +3210,11 @@ bool QGraphicsScene::event(QEvent *event) if (!d->activationRefCount++) { if (d->lastActivePanel) { // Activate the last panel. - setActivePanel(d->lastActivePanel); + d->setActivePanelHelper(d->lastActivePanel, true); } else if (d->tabFocusFirst && d->tabFocusFirst->isPanel()) { // Activate the panel of the first item in the tab focus // chain. - setActivePanel(d->tabFocusFirst); + d->setActivePanelHelper(d->tabFocusFirst, true); } else { // Activate all toplevel items. QEvent event(QEvent::WindowActivate); @@ -3150,7 +3231,7 @@ bool QGraphicsScene::event(QEvent *event) // Deactivate the active panel (but keep it so we can // reactivate it later). QGraphicsItem *lastActivePanel = d->activePanel; - setActivePanel(0); + d->setActivePanelHelper(0, true); d->lastActivePanel = lastActivePanel; } else { // Activate all toplevel items. @@ -5095,63 +5176,15 @@ QGraphicsItem *QGraphicsScene::activePanel() const can also pass 0 for \a item, in which case QGraphicsScene will deactivate any currently active panel. + If the scene is currently inactive, \a item remains inactive until the + scene becomes active (or, ir \a item is 0, no item will be activated). + \sa activePanel(), isActive(), QGraphicsItem::isActive() */ void QGraphicsScene::setActivePanel(QGraphicsItem *item) { Q_D(QGraphicsScene); - if (item && item->scene() != this) { - qWarning("QGraphicsScene::setActivePanel: item %p must be part of this scene", - item); - return; - } - - // Find the item's panel. - QGraphicsItem *panel = item ? item->panel() : 0; - d->lastActivePanel = panel ? d->activePanel : 0; - if (panel == d->activePanel) - return; - - // Deactivate the last active panel. - if (d->activePanel) { - if (QGraphicsItem *fi = d->activePanel->focusItem()) { - // Remove focus from the current focus item. - if (fi == focusItem()) - setFocusItem(0, Qt::ActiveWindowFocusReason); - } - - QEvent event(QEvent::WindowDeactivate); - sendEvent(d->activePanel, &event); - } else if (panel) { - // Deactivate the scene if changing activation to a panel. - QEvent event(QEvent::WindowDeactivate); - foreach (QGraphicsItem *item, items()) { - if (item->isVisible() && !item->isPanel() && !item->parentItem()) - sendEvent(item, &event); - } - } - - // Update activate state. - d->activePanel = panel; - QEvent event(QEvent::ActivationChange); - QApplication::sendEvent(this, &event); - - // Activate - if (panel) { - QEvent event(QEvent::WindowActivate); - sendEvent(panel, &event); - - // Set focus on the panel's focus item. - if (QGraphicsItem *focusItem = panel->focusItem()) - focusItem->setFocus(Qt::ActiveWindowFocusReason); - } else if (isActive()) { - // Activate the scene - QEvent event(QEvent::WindowActivate); - foreach (QGraphicsItem *item, items()) { - if (item->isVisible() && !item->isPanel() && !item->parentItem()) - sendEvent(item, &event); - } - } + d->setActivePanelHelper(item, false); } /*! diff --git a/src/gui/graphicsview/qgraphicsscene_p.h b/src/gui/graphicsview/qgraphicsscene_p.h index c1b78ff..1f66eb4 100644 --- a/src/gui/graphicsview/qgraphicsscene_p.h +++ b/src/gui/graphicsview/qgraphicsscene_p.h @@ -132,6 +132,8 @@ public: QGraphicsItem *activePanel; QGraphicsItem *lastActivePanel; int activationRefCount; + int childExplicitActivation; + void setActivePanelHelper(QGraphicsItem *item, bool duringActivationEvent); void setFocusItemHelper(QGraphicsItem *item, Qt::FocusReason focusReason); QList popupWidgets; diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp index 541b5ba..517380e 100644 --- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp @@ -289,6 +289,8 @@ private slots: void setGraphicsEffect(); void panel(); void addPanelToActiveScene(); + void activate(); + void setActivePanelOnInactiveScene(); // task specific tests below me void task141694_textItemEnsureVisible(); @@ -7823,26 +7825,15 @@ void tst_QGraphicsItem::panel() // No previous activation, so the scene is active. QVERIFY(scene.isActive()); - QVERIFY(!scene.activePanel()); - QVERIFY(!panel1->isActive()); - QVERIFY(!panel2->isActive()); - QVERIFY(!panel3->isActive()); - QVERIFY(!panel4->isActive()); - QVERIFY(notPanel1->isActive()); - QVERIFY(notPanel2->isActive()); - QCOMPARE(spy_activate_notPanel1.count(), 1); - QCOMPARE(spy_activate_notPanel2.count(), 1); - - // Switch to panel1. - scene.setActivePanel(panel1); + QCOMPARE(scene.activePanel(), (QGraphicsItem *)panel1); QVERIFY(panel1->isActive()); QVERIFY(!panel2->isActive()); QVERIFY(!panel3->isActive()); QVERIFY(!panel4->isActive()); QVERIFY(!notPanel1->isActive()); QVERIFY(!notPanel2->isActive()); - QCOMPARE(spy_deactivate_notPanel1.count(), 1); - QCOMPARE(spy_deactivate_notPanel2.count(), 1); + QCOMPARE(spy_deactivate_notPanel1.count(), 0); + QCOMPARE(spy_deactivate_notPanel2.count(), 0); QCOMPARE(spy_activate_panel1.count(), 1); QCOMPARE(spy_activate_panel2.count(), 0); QCOMPARE(spy_activate_panel3.count(), 0); @@ -7857,8 +7848,8 @@ void tst_QGraphicsItem::panel() QVERIFY(!panel4->isActive()); QVERIFY(notPanel1->isActive()); QVERIFY(notPanel2->isActive()); - QCOMPARE(spy_activate_notPanel1.count(), 2); - QCOMPARE(spy_activate_notPanel2.count(), 2); + QCOMPARE(spy_activate_notPanel1.count(), 1); + QCOMPARE(spy_activate_notPanel2.count(), 1); // Deactivate the scene QApplication::sendEvent(&scene, &deactivate); @@ -7869,8 +7860,8 @@ void tst_QGraphicsItem::panel() QVERIFY(!panel4->isActive()); QVERIFY(!notPanel1->isActive()); QVERIFY(!notPanel2->isActive()); - QCOMPARE(spy_deactivate_notPanel1.count(), 2); - QCOMPARE(spy_deactivate_notPanel2.count(), 2); + QCOMPARE(spy_deactivate_notPanel1.count(), 1); + QCOMPARE(spy_deactivate_notPanel2.count(), 1); // Reactivate the scene QApplication::sendEvent(&scene, &activate); @@ -7881,14 +7872,14 @@ void tst_QGraphicsItem::panel() QVERIFY(!panel4->isActive()); QVERIFY(notPanel1->isActive()); QVERIFY(notPanel2->isActive()); - QCOMPARE(spy_activate_notPanel1.count(), 3); - QCOMPARE(spy_activate_notPanel2.count(), 3); + QCOMPARE(spy_activate_notPanel1.count(), 2); + QCOMPARE(spy_activate_notPanel2.count(), 2); // Switch to panel1 scene.setActivePanel(panel1); QVERIFY(panel1->isActive()); - QCOMPARE(spy_deactivate_notPanel1.count(), 3); - QCOMPARE(spy_deactivate_notPanel2.count(), 3); + QCOMPARE(spy_deactivate_notPanel1.count(), 2); + QCOMPARE(spy_deactivate_notPanel2.count(), 2); QCOMPARE(spy_activate_panel1.count(), 2); // Deactivate the scene @@ -7942,5 +7933,110 @@ void tst_QGraphicsItem::addPanelToActiveScene() QCOMPARE(scene.activePanel(), (QGraphicsItem *)rect); } +void tst_QGraphicsItem::activate() +{ + QGraphicsScene scene; + QGraphicsRectItem *rect = scene.addRect(-10, -10, 20, 20); + QVERIFY(!rect->isActive()); + + QEvent activate(QEvent::WindowActivate); + QEvent deactivate(QEvent::WindowDeactivate); + + QApplication::sendEvent(&scene, &activate); + + // Non-panel item (active when scene is active). + QVERIFY(rect->isActive()); + + QGraphicsRectItem *rect2 = new QGraphicsRectItem; + rect2->setFlag(QGraphicsItem::ItemIsPanel); + QGraphicsRectItem *rect3 = new QGraphicsRectItem; + rect3->setFlag(QGraphicsItem::ItemIsPanel); + + // Test normal activation. + QVERIFY(!rect2->isActive()); + scene.addItem(rect2); + QVERIFY(rect2->isActive()); // first panel item is activated + scene.addItem(rect3); + QVERIFY(!rect3->isActive()); // second panel item is _not_ activated + rect3->setActive(true); + QVERIFY(rect3->isActive()); + scene.removeItem(rect3); + QVERIFY(!rect3->isActive()); // no panel is active anymore + QCOMPARE(scene.activePanel(), (QGraphicsItem *)0); + scene.addItem(rect3); + QVERIFY(rect3->isActive()); // second panel item is activated + + // Test pending activation. + scene.removeItem(rect3); + rect2->setActive(true); + QVERIFY(rect2->isActive()); // first panel item is activated + rect3->setActive(true); + QVERIFY(!rect3->isActive()); // not active (yet) + scene.addItem(rect3); + QVERIFY(rect3->isActive()); // now becomes active + + // Test pending deactivation. + scene.removeItem(rect3); + rect3->setActive(false); + scene.addItem(rect3); + QVERIFY(!rect3->isActive()); // doesn't become active + + // Child of panel activation. + rect3->setActive(true); + QGraphicsRectItem *rect4 = new QGraphicsRectItem; + rect4->setFlag(QGraphicsItem::ItemIsPanel); + QGraphicsRectItem *rect5 = new QGraphicsRectItem(rect4); + QGraphicsRectItem *rect6 = new QGraphicsRectItem(rect5); + scene.addItem(rect4); + QCOMPARE(scene.activePanel(), (QGraphicsItem *)rect3); + scene.removeItem(rect4); + rect6->setActive(true); + scene.addItem(rect4); + QVERIFY(rect4->isActive()); + QVERIFY(rect5->isActive()); + QVERIFY(rect6->isActive()); + QCOMPARE(scene.activePanel(), (QGraphicsItem *)rect4); + scene.removeItem(rect4); // no active panel + rect6->setActive(false); + scene.addItem(rect4); + QVERIFY(!rect4->isActive()); + QVERIFY(!rect5->isActive()); + QVERIFY(!rect6->isActive()); + QCOMPARE(scene.activePanel(), (QGraphicsItem *)0); + + // Controlling auto-activation when the scene changes activation. + rect4->setActive(true); + QApplication::sendEvent(&scene, &deactivate); + QVERIFY(!scene.isActive()); + QVERIFY(!rect4->isActive()); + rect4->setActive(false); + QApplication::sendEvent(&scene, &activate); + QVERIFY(scene.isActive()); + QVERIFY(!scene.activePanel()); + QVERIFY(!rect4->isActive()); +} + +void tst_QGraphicsItem::setActivePanelOnInactiveScene() +{ + QGraphicsScene scene; + QGraphicsRectItem *item = scene.addRect(QRectF()); + QGraphicsRectItem *panel = scene.addRect(QRectF()); + panel->setFlag(QGraphicsItem::ItemIsPanel); + + EventSpy itemActivateSpy(&scene, item, QEvent::WindowActivate); + EventSpy itemDeactivateSpy(&scene, item, QEvent::WindowDeactivate); + EventSpy panelActivateSpy(&scene, panel, QEvent::WindowActivate); + EventSpy panelDeactivateSpy(&scene, panel, QEvent::WindowDeactivate); + EventSpy sceneActivationChangeSpy(&scene, QEvent::ActivationChange); + + scene.setActivePanel(panel); + QCOMPARE(scene.activePanel(), (QGraphicsItem *)0); + QCOMPARE(itemActivateSpy.count(), 0); + QCOMPARE(itemDeactivateSpy.count(), 0); + QCOMPARE(panelActivateSpy.count(), 0); + QCOMPARE(panelDeactivateSpy.count(), 0); + QCOMPARE(sceneActivationChangeSpy.count(), 0); +} + QTEST_MAIN(tst_QGraphicsItem) #include "tst_qgraphicsitem.moc" -- cgit v0.12 From 46624cfb90986e1977a539d279516bd5ade3675f Mon Sep 17 00:00:00 2001 From: Andreas Aardal Hanssen Date: Mon, 31 Aug 2009 16:03:34 +0200 Subject: Add auto-activation on show/hide and setParentItem(). If you show a child panel of an active panel, the child will now be activated and the parent deactivated. Hiding the child panel will reactive the parent. If the parent is 0, no other panel is activated. Reparenting a panel onto an active panel will also activate the (new) child. Reparenting away does not affect activation in any way. This change also fixes QGraphicsWidget::isActiveWindow(), which returned true for all toplevel widgets (not in a panel/window). This is wrong; either the non-panel items are active, or a panel is active. The correct behavior is the same as calling QGraphicsItem::isActive(). Fixed the autotests (which wrongly tested that both a panel and a non-panel item were active at the same time). This change causes popups (QGraphics{Proxy,}Widget) to deactivate the parent widget. On the positive side this activates the popup, and ensures that the parent regains proper focus when the popup is closed. However it also means the parent widget is inactive while the popup is open, which (e.g.) causes editable combobox line edit cursors to stop blinking. This is to be fixed soon, but the fix is a bit big so we'll do that later. Autotests included. Reviewed-by: Brad --- src/gui/graphicsview/qgraphicsitem.cpp | 14 +++++ src/gui/graphicsview/qgraphicsproxywidget.cpp | 2 +- src/gui/graphicsview/qgraphicswidget.cpp | 6 +- tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp | 64 ++++++++++++++++++++++ tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp | 6 +- 5 files changed, 83 insertions(+), 9 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index 31fd53a..4f8755e 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -1007,6 +1007,9 @@ void QGraphicsItemPrivate::setParentItemHelper(QGraphicsItem *newParent) setEnabledHelper(parent->isEnabled(), /* explicit = */ false, /* update = */ !implicitUpdate); } + // Auto-activate if visible and the parent is active. + if (q->isVisible() && parent->isActive()) + q->setActive(true); } else { // Inherit ancestor flags from the new parent. updateAncestorFlag(QGraphicsItem::GraphicsItemFlag(-2)); @@ -1941,6 +1944,17 @@ void QGraphicsItemPrivate::setVisibleHelper(bool newVisible, bool explicitly, bo child->d_ptr->setVisibleHelper(newVisible, false, updateChildren); } + // Update activation + if (scene && q->isPanel()) { + if (newVisible) { + if (parent && parent->isActive()) + q->setActive(true); + } else { + if (q->isActive()) + scene->setActivePanel(parent); + } + } + // Enable subfocus if (newVisible && isWidget) { QGraphicsWidget *widget = static_cast(q_ptr); diff --git a/src/gui/graphicsview/qgraphicsproxywidget.cpp b/src/gui/graphicsview/qgraphicsproxywidget.cpp index 447fc50..c710c55 100644 --- a/src/gui/graphicsview/qgraphicsproxywidget.cpp +++ b/src/gui/graphicsview/qgraphicsproxywidget.cpp @@ -390,7 +390,7 @@ QWidget *QGraphicsProxyWidgetPrivate::findFocusChild(QWidget *child, bool next) if (child->isEnabled() && child->isVisibleTo(widget) && (child->focusPolicy() & Qt::TabFocus)) { - return child; + return child; } child = next ? child->d_func()->focus_next : child->d_func()->focus_prev; } while (child != oldChild && !(next && child == widget) && !(!next && child == widget->d_func()->focus_prev)); diff --git a/src/gui/graphicsview/qgraphicswidget.cpp b/src/gui/graphicsview/qgraphicswidget.cpp index 9972223..afabf49 100644 --- a/src/gui/graphicsview/qgraphicswidget.cpp +++ b/src/gui/graphicsview/qgraphicswidget.cpp @@ -1665,11 +1665,7 @@ void QGraphicsWidget::setWindowFlags(Qt::WindowFlags wFlags) */ bool QGraphicsWidget::isActiveWindow() const { - Q_D(const QGraphicsWidget); - if (!d->scene) - return false; - const QGraphicsWidget *w = window(); - return (!w && d->scene->isActive()) || (w && d->scene->activeWindow() == w); + return isActive(); } /*! diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp index 517380e..2acb76d 100644 --- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp @@ -291,6 +291,7 @@ private slots: void addPanelToActiveScene(); void activate(); void setActivePanelOnInactiveScene(); + void activationOnShowHide(); // task specific tests below me void task141694_textItemEnsureVisible(); @@ -8038,5 +8039,68 @@ void tst_QGraphicsItem::setActivePanelOnInactiveScene() QCOMPARE(sceneActivationChangeSpy.count(), 0); } +void tst_QGraphicsItem::activationOnShowHide() +{ + QGraphicsScene scene; + QEvent activate(QEvent::WindowActivate); + QApplication::sendEvent(&scene, &activate); + + QGraphicsRectItem *rootPanel = scene.addRect(QRectF()); + rootPanel->setFlag(QGraphicsItem::ItemIsPanel); + rootPanel->setActive(true); + + QGraphicsRectItem *subPanel = new QGraphicsRectItem; + subPanel->setFlag(QGraphicsItem::ItemIsPanel); + + // Reparenting onto an active panel auto-activates the child panel. + subPanel->setParentItem(rootPanel); + QVERIFY(subPanel->isActive()); + QVERIFY(!rootPanel->isActive()); + + // Hiding an active child panel will reactivate the parent panel. + subPanel->hide(); + QVERIFY(rootPanel->isActive()); + + // Showing a child panel will auto-activate it. + subPanel->show(); + QVERIFY(subPanel->isActive()); + QVERIFY(!rootPanel->isActive()); + + // Adding an unrelated panel doesn't affect activation. + QGraphicsRectItem *otherPanel = new QGraphicsRectItem; + otherPanel->setFlag(QGraphicsItem::ItemIsPanel); + scene.addItem(otherPanel); + QVERIFY(subPanel->isActive()); + + // Showing an unrelated panel doesn't affect activation. + otherPanel->hide(); + otherPanel->show(); + QVERIFY(subPanel->isActive()); + + // Add a non-panel item. + QGraphicsRectItem *otherItem = new QGraphicsRectItem; + scene.addItem(otherItem); + otherItem->setActive(true); + QVERIFY(otherItem->isActive()); + + // Reparent a panel onto an active non-panel item. + subPanel->setParentItem(otherItem); + QVERIFY(subPanel->isActive()); + + // Showing a child panel of a non-panel item will activate it. + subPanel->hide(); + QVERIFY(!subPanel->isActive()); + QVERIFY(otherItem->isActive()); + subPanel->show(); + QVERIFY(subPanel->isActive()); + + // Hiding a toplevel active panel will pass activation back + // to the non-panel items. + rootPanel->setActive(true); + rootPanel->hide(); + QVERIFY(!rootPanel->isActive()); + QVERIFY(otherItem->isActive()); +} + QTEST_MAIN(tst_QGraphicsItem) #include "tst_qgraphicsitem.moc" diff --git a/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp b/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp index 663de22..65e6e56 100644 --- a/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp +++ b/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp @@ -352,12 +352,12 @@ void tst_QGraphicsWidget::activation() QEvent activateEvent(QEvent::WindowActivate); QApplication::sendEvent(&scene, &activateEvent); - QVERIFY(widget->isActiveWindow()); - QVERIFY(!window1->isActiveWindow()); + QVERIFY(!widget->isActiveWindow()); + QVERIFY(window1->isActiveWindow()); QVERIFY(!window2->isActiveWindow()); scene.setActiveWindow(window1); - QVERIFY(widget->isActiveWindow()); + QVERIFY(!widget->isActiveWindow()); QVERIFY(window1->isActiveWindow()); QVERIFY(!window2->isActiveWindow()); -- cgit v0.12 From b2d0d7e2c9103354044d34a2b69410a0aed1f5d1 Mon Sep 17 00:00:00 2001 From: hjk Date: Mon, 31 Aug 2009 16:12:01 +0200 Subject: Add license headers to lupdate autotest data The data is essentially random line noise that happens to live in a .cpp file. --- .../lupdate/testdata/good/parsecpp2/main.cpp | 41 ++++++++++++++++++++++ .../lupdate/testdata/good/parsecpp2/main2.cpp | 41 ++++++++++++++++++++++ .../lupdate/testdata/good/parsecpp2/main3.cpp | 41 ++++++++++++++++++++++ 3 files changed, 123 insertions(+) diff --git a/tests/auto/linguist/lupdate/testdata/good/parsecpp2/main.cpp b/tests/auto/linguist/lupdate/testdata/good/parsecpp2/main.cpp index eb4a09b..e6668a9 100644 --- a/tests/auto/linguist/lupdate/testdata/good/parsecpp2/main.cpp +++ b/tests/auto/linguist/lupdate/testdata/good/parsecpp2/main.cpp @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.1, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + // IMPORTANT!!!! If you want to add testdata to this file, // always add it to the end in order to not change the linenumbers of translations!!! diff --git a/tests/auto/linguist/lupdate/testdata/good/parsecpp2/main2.cpp b/tests/auto/linguist/lupdate/testdata/good/parsecpp2/main2.cpp index 1c72ac2..61029b3 100644 --- a/tests/auto/linguist/lupdate/testdata/good/parsecpp2/main2.cpp +++ b/tests/auto/linguist/lupdate/testdata/good/parsecpp2/main2.cpp @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.1, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + // IMPORTANT!!!! If you want to add testdata to this file, // always add it to the end in order to not change the linenumbers of translations!!! diff --git a/tests/auto/linguist/lupdate/testdata/good/parsecpp2/main3.cpp b/tests/auto/linguist/lupdate/testdata/good/parsecpp2/main3.cpp index 731d5cdf..6a80349 100644 --- a/tests/auto/linguist/lupdate/testdata/good/parsecpp2/main3.cpp +++ b/tests/auto/linguist/lupdate/testdata/good/parsecpp2/main3.cpp @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.1, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + // IMPORTANT!!!! If you want to add testdata to this file, // always add it to the end in order to not change the linenumbers of translations!!! -- cgit v0.12 From efb30e2d080e18b8deca4778f82cbc6cc1da7e74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Trond=20Kjern=C3=A5sen?= Date: Mon, 31 Aug 2009 16:31:56 +0200 Subject: Fixed a problem with corrupted text in the GL 2 engine. Blending should not be enabled when copying the font cache texture into the fbo. It *may* cause artifacts with some drivers. Reviewed-by: Samuel --- src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp index 895dd65..a976a02 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp @@ -226,6 +226,7 @@ void QGLTextureGlyphCache::resizeTextureData(int width, int height) glDisable(GL_DEPTH_TEST); glDisable(GL_SCISSOR_TEST); + glDisable(GL_BLEND); glViewport(0, 0, oldWidth, oldHeight); -- cgit v0.12 From c38384b33d9aeaa4acd353442f5b17cf31769dee Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Mon, 31 Aug 2009 16:33:49 +0200 Subject: Removed the obsolete gestures autotest Oops, forgot to remove the autotest after rewriting the gestures api. Reviewed-by: trustme --- tests/auto/gestures/customgesturerecognizer.cpp | 208 ----- tests/auto/gestures/customgesturerecognizer.h | 228 ------ tests/auto/gestures/gestures.pro | 3 - tests/auto/gestures/tst_gestures.cpp | 962 ------------------------ 4 files changed, 1401 deletions(-) delete mode 100644 tests/auto/gestures/customgesturerecognizer.cpp delete mode 100644 tests/auto/gestures/customgesturerecognizer.h delete mode 100644 tests/auto/gestures/gestures.pro delete mode 100644 tests/auto/gestures/tst_gestures.cpp diff --git a/tests/auto/gestures/customgesturerecognizer.cpp b/tests/auto/gestures/customgesturerecognizer.cpp deleted file mode 100644 index 96028be..0000000 --- a/tests/auto/gestures/customgesturerecognizer.cpp +++ /dev/null @@ -1,208 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the test suite module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.1, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "customgesturerecognizer.h" -#include "qgesture.h" - -const char* SingleshotGestureRecognizer::Name = "SingleshotGesture"; -const char* PinchGestureRecognizer::Name = "PinchGesture"; -const char* SecondFingerGestureRecognizer::Name = "SecondFingerGesture"; -const char* PanGestureRecognizer::Name = "PanGesture"; - -SingleshotGestureRecognizer::SingleshotGestureRecognizer(QObject *parent) - : QGestureRecognizer(QString(SingleshotGestureRecognizer::Name), parent) -{ - gesture = new SingleshotGesture(this, SingleshotGestureRecognizer::Name); -} - -QGestureRecognizer::Result SingleshotGestureRecognizer::filterEvent(const QEvent *event) -{ - if (event->type() == SingleshotEvent::Type) { - gesture->setHotSpot(static_cast(event)->point); - return QGestureRecognizer::GestureFinished; - } - return QGestureRecognizer::NotGesture; -} - -void SingleshotGestureRecognizer::reset() -{ - gesture->setHotSpot(QPoint()); - gesture->offset = QPoint(); -} - -PinchGestureRecognizer::PinchGestureRecognizer(QObject *parent) - : QGestureRecognizer(PinchGestureRecognizer::Name, parent) -{ - gesture = new PinchGesture(this, PinchGestureRecognizer::Name); -} - -QGestureRecognizer::Result PinchGestureRecognizer::filterEvent(const QEvent *event) -{ - if (event->type() != TouchEvent::Type) - return QGestureRecognizer::Ignore; - - const TouchEvent *e = static_cast(event); - if (e->points[0].state == TouchPoint::Begin) - gesture->startPoints[0] = e->points[0]; - if (e->points[1].state == TouchPoint::Begin) - gesture->startPoints[1] = e->points[1]; - gesture->lastPoints[0] = gesture->points[0]; - gesture->lastPoints[1] = gesture->points[1]; - gesture->points[0] = e->points[0]; - gesture->points[1] = e->points[1]; - if (((e->points[0].state == TouchPoint::Begin || e->points[0].state == TouchPoint::Update))) { - if (e->points[1].state == TouchPoint::End || e->points[1].state == TouchPoint::None) - return MaybeGesture; - return GestureStarted; - } else if (((e->points[1].state == TouchPoint::Begin || e->points[1].state == TouchPoint::Update))) { - if (e->points[0].state == TouchPoint::End || e->points[0].state == TouchPoint::None) - return MaybeGesture; - return GestureStarted; - } else if ((e->points[0].state == TouchPoint::End && e->points[1].state == TouchPoint::End) || - (e->points[0].state == TouchPoint::End && e->points[1].state == TouchPoint::None) || - (e->points[0].state == TouchPoint::None && e->points[1].state == TouchPoint::End)) { - return QGestureRecognizer::NotGesture; - } - return QGestureRecognizer::NotGesture; -} - -void PinchGestureRecognizer::reset() -{ - gesture->startPoints[0] = TouchPoint(); - gesture->startPoints[1] = TouchPoint(); - gesture->lastPoints[0] = TouchPoint(); - gesture->lastPoints[1] = TouchPoint(); - gesture->points[0] = TouchPoint(); - gesture->points[1] = TouchPoint(); - gesture->offset = QPoint(); -} - -SecondFingerGestureRecognizer::SecondFingerGestureRecognizer(QObject *parent) - : QGestureRecognizer(SecondFingerGestureRecognizer::Name, parent) -{ - gesture = new SecondFingerGesture(this, SecondFingerGestureRecognizer::Name); -} - -QGestureRecognizer::Result SecondFingerGestureRecognizer::filterEvent(const QEvent *event) -{ - if (event->type() != TouchEvent::Type) - return QGestureRecognizer::Ignore; - - const TouchEvent *e = static_cast(event); - if (e->points[1].state != TouchPoint::None) { - if (e->points[1].state == TouchPoint::Begin) - gesture->startPoint = e->points[1]; - gesture->lastPoint = gesture->point; - gesture->point = e->points[1]; - if (e->points[1].state == TouchPoint::End) - return QGestureRecognizer::GestureFinished; - else if (e->points[1].state != TouchPoint::None) - return QGestureRecognizer::GestureStarted; - } - return QGestureRecognizer::NotGesture; -} - -void SecondFingerGestureRecognizer::reset() -{ - gesture->startPoint = TouchPoint(); - gesture->lastPoint = TouchPoint(); - gesture->point = TouchPoint(); - gesture->offset = QPoint(); -} - -PanGestureRecognizer::PanGestureRecognizer(QObject *parent) - : QGestureRecognizer(PanGestureRecognizer::Name, parent) -{ - gesture = new PanGesture(this, PanGestureRecognizer::Name); -} - -QGestureRecognizer::Result PanGestureRecognizer::filterEvent(const QEvent *event) -{ - if (event->type() != QEvent::TouchBegin && - event->type() != QEvent::TouchUpdate && - event->type() != QEvent::TouchEnd) - return QGestureRecognizer::Ignore; - - const QTouchEvent *e = static_cast(event); - const QList &points = e->touchPoints(); - - if (points.size() >= 1) { - gesture->lastPoints[0] = gesture->points[0]; - gesture->points[0].id = points.at(0).id(); - gesture->points[0].pt = points.at(0).startPos().toPoint(); - gesture->points[0].state = (TouchPoint::State)points.at(0).state(); - if (points.at(0).state() == Qt::TouchPointPressed) { - gesture->startPoints[0] = gesture->points[0]; - gesture->lastPoints[0] = gesture->points[0]; - } - } - if (points.size() >= 2) { - gesture->lastPoints[1] = gesture->points[1]; - gesture->points[1].id = points.at(1).id(); - gesture->points[1].pt = points.at(1).startPos().toPoint(); - gesture->points[1].state = (TouchPoint::State)points.at(1).state(); - if (points.at(1).state() == Qt::TouchPointPressed) { - gesture->startPoints[1] = gesture->points[1]; - gesture->lastPoints[1] = gesture->points[1]; - } - } - - if (points.size() == 2) - return QGestureRecognizer::GestureStarted; - if (points.size() > 2) - return QGestureRecognizer::MaybeGesture; - if (points.at(0).state() == Qt::TouchPointPressed) - return QGestureRecognizer::MaybeGesture; - if (points.at(0).state() == Qt::TouchPointReleased) - return QGestureRecognizer::GestureFinished; - return QGestureRecognizer::GestureStarted; -} - -void PanGestureRecognizer::reset() -{ - gesture->startPoints[0] = TouchPoint(); - gesture->startPoints[1] = TouchPoint(); - gesture->lastPoints[0] = TouchPoint(); - gesture->lastPoints[1] = TouchPoint(); - gesture->points[0] = TouchPoint(); - gesture->points[1] = TouchPoint(); - gesture->offset = QPoint(); -} diff --git a/tests/auto/gestures/customgesturerecognizer.h b/tests/auto/gestures/customgesturerecognizer.h deleted file mode 100644 index 2a24efb..0000000 --- a/tests/auto/gestures/customgesturerecognizer.h +++ /dev/null @@ -1,228 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.1, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef CUSTOMGESTURERECOGNIZER_H -#define CUSTOMGESTURERECOGNIZER_H - -#include "qgesturerecognizer.h" -#include "qgesture.h" -#include "qevent.h" - -class SingleshotEvent : public QEvent -{ -public: - static const int Type = QEvent::User + 1; - - QPoint point; - - explicit SingleshotEvent(int x = 0, int y = 0) - : QEvent(QEvent::Type(Type)), point(x, y) { } -}; - -class SingleshotGesture : public QGesture -{ - Q_OBJECT -public: - SingleshotGesture(QObject *parent, const QString &type) - : QGesture(parent, type) { } - - QPoint offset; - -protected: - void translate(const QPoint &pt) - { - offset += pt; - } -}; - -class SingleshotGestureRecognizer : public QGestureRecognizer -{ - Q_OBJECT -public: - static const char *Name; - - SingleshotGestureRecognizer(QObject *parent = 0); - - QGestureRecognizer::Result filterEvent(const QEvent *event); - QGesture* getGesture() { return gesture; } - void reset(); - -private: - SingleshotGesture *gesture; -}; - -struct TouchPoint { - enum State - { - None = 0, - Begin = Qt::TouchPointPressed, - Update = Qt::TouchPointMoved, - End = Qt::TouchPointReleased - }; - int id; - QPoint pt; - State state; - TouchPoint() : id(0), state(None) { } - TouchPoint(int id_, int x_, int y_, State state_) : id(id_), pt(x_, y_), state(state_) { } -}; - -class TouchEvent : public QEvent -{ -public: - static const int Type = QEvent::User + 2; - - TouchEvent() - : QEvent(QEvent::Type(Type)) - { - } - - TouchPoint points[2]; -}; - -class PinchGesture : public QGesture -{ - Q_OBJECT -public: - PinchGesture(QObject *parent, const QString &type) - : QGesture(parent, type) { } - - TouchPoint startPoints[2]; - TouchPoint lastPoints[2]; - TouchPoint points[2]; - - QPoint offset; - -protected: - void translate(const QPoint &pt) - { - offset += pt; - } -}; - -class PinchGestureRecognizer : public QGestureRecognizer -{ - Q_OBJECT -public: - static const char *Name; - - PinchGestureRecognizer(QObject *parent = 0); - - QGestureRecognizer::Result filterEvent(const QEvent *event); - QGesture* getGesture() { return gesture; } - void reset(); - -private: - PinchGesture *gesture; -}; - -class SecondFingerGesture : public QGesture -{ - Q_OBJECT -public: - SecondFingerGesture(QObject *parent, const QString &type) - : QGesture(parent, type) { } - - TouchPoint startPoint; - TouchPoint lastPoint; - TouchPoint point; - - QPoint offset; - -protected: - void translate(const QPoint &pt) - { - offset += pt; - } -}; - -class SecondFingerGestureRecognizer : public QGestureRecognizer -{ - Q_OBJECT -public: - static const char *Name; - - SecondFingerGestureRecognizer(QObject *parent = 0); - - QGestureRecognizer::Result filterEvent(const QEvent *event); - QGesture* getGesture() { return gesture; } - void reset(); - -private: - SecondFingerGesture *gesture; -}; - -class PanGesture : public QGesture -{ - Q_OBJECT -public: - PanGesture(QObject *parent, const QString &type) - : QGesture(parent, type) { } - - TouchPoint startPoints[2]; - TouchPoint lastPoints[2]; - TouchPoint points[2]; - - QPoint offset; - -protected: - void translate(const QPoint &pt) - { - offset += pt; - } -}; - -class PanGestureRecognizer : public QGestureRecognizer -{ - Q_OBJECT -public: - static const char *Name; - - PanGestureRecognizer(QObject *parent = 0); - - QGestureRecognizer::Result filterEvent(const QEvent *event); - QGesture* getGesture() { return gesture; } - void reset(); - -private: - PanGesture *gesture; -}; - -#endif diff --git a/tests/auto/gestures/gestures.pro b/tests/auto/gestures/gestures.pro deleted file mode 100644 index ac99b19..0000000 --- a/tests/auto/gestures/gestures.pro +++ /dev/null @@ -1,3 +0,0 @@ -load(qttest_p4) -SOURCES += tst_gestures.cpp customgesturerecognizer.cpp -HEADERS += customgesturerecognizer.h diff --git a/tests/auto/gestures/tst_gestures.cpp b/tests/auto/gestures/tst_gestures.cpp deleted file mode 100644 index 85fd355..0000000 --- a/tests/auto/gestures/tst_gestures.cpp +++ /dev/null @@ -1,962 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.1, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - - -#include - -#include - -#include "customgesturerecognizer.h" - -//TESTED_CLASS= -//TESTED_FILES= - -// color generator for syntax highlighting from QQ-26 by Helder Correia -QVector highlight(const QColor &bg, const - QColor &fg, int noColors) -{ - QVector colors; - const int HUE_BASE = (bg.hue() == -1) ? 90 : bg.hue(); - int h, s, v; - for (int i = 0; i < noColors; i++) { - h = int(HUE_BASE + (360.0 / noColors * i)) % 360; - s = 240; - v = int(qMax(bg.value(), fg.value()) * 0.85); - - const int M = 35; - if ((h < bg.hue() + M && h > bg.hue() - M) - || (h < fg.hue() + M && h > fg.hue() - M)) - { - h = ((bg.hue() + fg.hue()) / (i+1)) % 360; - s = ((bg.saturation() + fg.saturation() + 2*i) - / 2) % 256; - v = ((bg.value() + fg.value() + 2*i) / 2) - % 256; - } - colors.append(QColor::fromHsv(h, s, v)); - } - return colors; -} - - -// a hack to mark an event as spontaneous. -class QETWidget -{ -public: - static void setSpont(QEvent *event, bool spont) { event->spont = spont; } -}; - -struct GestureState -{ - int seenGestureEvent; - struct LastGestureEvent - { - struct SingleshotGesture - { - bool delivered; - QPoint offset; - } singleshot; - struct PinchGesture - { - bool delivered; - TouchPoint startPoints[2]; - TouchPoint lastPoints[2]; - TouchPoint points[2]; - QPoint offset; - } pinch; - struct SecondFingerGesture - { - bool delivered; - TouchPoint startPoint; - TouchPoint lastPoint; - TouchPoint point; - QPoint offset; - } secondfinger; - struct PanGesture - { - bool delivered; - TouchPoint startPoints[2]; - TouchPoint lastPoints[2]; - TouchPoint points[2]; - QPoint offset; - } pan; - QSet cancelled; - } last; - - GestureState() { reset(); } - void reset() - { - seenGestureEvent = 0; - last.singleshot.delivered = false; - last.singleshot.offset = QPoint(); - last.pinch.delivered = false; - last.pinch.startPoints[0] = TouchPoint(); - last.pinch.startPoints[1] = TouchPoint(); - last.pinch.lastPoints[0] = TouchPoint(); - last.pinch.lastPoints[1] = TouchPoint(); - last.pinch.points[0] = TouchPoint(); - last.pinch.points[1] = TouchPoint(); - last.pinch.offset = QPoint(); - last.secondfinger.delivered = false; - last.secondfinger.startPoint = TouchPoint(); - last.secondfinger.lastPoint = TouchPoint(); - last.secondfinger.point = TouchPoint(); - last.secondfinger.offset = QPoint(); - last.pan.delivered = false; - last.pan.startPoints[0] = TouchPoint(); - last.pan.startPoints[1] = TouchPoint(); - last.pan.lastPoints[0] = TouchPoint(); - last.pan.lastPoints[1] = TouchPoint(); - last.pan.points[0] = TouchPoint(); - last.pan.points[1] = TouchPoint(); - last.cancelled.clear(); - } -}; - -struct TouchState -{ - int seenTouchBeginEvent; - int seenTouchUpdateEvent; - int seenTouchEndEvent; - - TouchState() { reset(); } - void reset() - { - seenTouchBeginEvent = seenTouchUpdateEvent = seenTouchEndEvent = 0; - } -}; - -class GestureWidget : public QWidget -{ - Q_OBJECT - static QVector colors; - static int numberOfWidgets; - -public: - enum Type { DoNotGrabGestures, GrabAllGestures, GrabSingleshot, - GrabPinch, GrabSecondFinger, GrabPan }; - - static const int LeftMargin = 10; - static const int TopMargin = 20; - - GestureWidget(Type type = GrabAllGestures) - { - if (colors.isEmpty()) { - colors = highlight(palette().color(QPalette::Window), palette().color(QPalette::Text), 5); - } - QPalette p = palette(); - p.setColor(QPalette::Window, colors[numberOfWidgets % colors.size()]); - setPalette(p); - setAutoFillBackground(true); - ++numberOfWidgets; - - QVBoxLayout *l = new QVBoxLayout(this); - l->setSpacing(0); - l->setContentsMargins(LeftMargin, TopMargin, LeftMargin, TopMargin); - - singleshotGestureId = -1; - pinchGestureId = -1; - secondFingerGestureId = -1; - panGestureId = -1; - if (type == GrabAllGestures || type == GrabSingleshot) { - singleshotGestureId = grabGesture(SingleshotGestureRecognizer::Name); - } - if (type == GrabAllGestures || type == GrabPinch) { - pinchGestureId = grabGesture(PinchGestureRecognizer::Name); - } - if (type == GrabAllGestures || type == GrabSecondFinger) { - secondFingerGestureId = grabGesture(SecondFingerGestureRecognizer::Name); - } - if (type == GrabAllGestures || type == GrabPan) { - panGestureId = grabGesture(PanGestureRecognizer::Name); - } - reset(); - } - ~GestureWidget() - { - --numberOfWidgets; - ungrabGestures(); - } - - void grabSingleshotGesture() - { - singleshotGestureId = grabGesture(SingleshotGestureRecognizer::Name); - } - void grabPinchGesture() - { - pinchGestureId = grabGesture(PinchGestureRecognizer::Name); - } - void grabSecondFingerGesture() - { - secondFingerGestureId = grabGesture(SecondFingerGestureRecognizer::Name); - } - void grabPanGesture() - { - panGestureId = grabGesture(PanGestureRecognizer::Name); - } - void ungrabGestures() - { - releaseGesture(singleshotGestureId); - singleshotGestureId = -1; - releaseGesture(pinchGestureId); - pinchGestureId = -1; - releaseGesture(secondFingerGestureId); - secondFingerGestureId = -1; - releaseGesture(panGestureId); - panGestureId = -1; - } - - int singleshotGestureId; - int pinchGestureId; - int secondFingerGestureId; - int panGestureId; - - bool shouldAcceptSingleshotGesture; - bool shouldAcceptPinchGesture; - bool shouldAcceptSecondFingerGesture; - bool shouldAcceptPanGesture; - - GestureState gesture; - TouchState touch; - - void reset() - { - shouldAcceptSingleshotGesture = true; - shouldAcceptPinchGesture = true; - shouldAcceptSecondFingerGesture = true; - shouldAcceptPanGesture = true; - gesture.reset(); - touch.reset(); - } -protected: - bool event(QEvent *event) - { - if (event->type() == QEvent::TouchBegin) { - event->accept(); - ++touch.seenTouchBeginEvent; - return true; - } else if (event->type() == QEvent::TouchUpdate) { - ++touch.seenTouchUpdateEvent; - } else if (event->type() == QEvent::TouchEnd) { - ++touch.seenTouchEndEvent; - } else if (event->type() == QEvent::Gesture) { - QGestureEvent *e = static_cast(event); - ++gesture.seenGestureEvent; - if (SingleshotGesture *g = (SingleshotGesture*)e->gesture(SingleshotGestureRecognizer::Name)) { - gesture.last.singleshot.delivered = true; - gesture.last.singleshot.offset = g->offset; - if (shouldAcceptSingleshotGesture) - g->accept(); - } - if (PinchGesture *g = (PinchGesture*)e->gesture(PinchGestureRecognizer::Name)) { - gesture.last.pinch.delivered = true; - gesture.last.pinch.startPoints[0] = g->startPoints[0]; - gesture.last.pinch.startPoints[1] = g->startPoints[1]; - gesture.last.pinch.lastPoints[0] = g->lastPoints[0]; - gesture.last.pinch.lastPoints[1] = g->lastPoints[1]; - gesture.last.pinch.points[0] = g->points[0]; - gesture.last.pinch.points[1] = g->points[1]; - gesture.last.pinch.offset = g->offset; - if (shouldAcceptPinchGesture) - g->accept(); - } - if (SecondFingerGesture *g = (SecondFingerGesture*)e->gesture(SecondFingerGestureRecognizer::Name)) { - gesture.last.secondfinger.delivered = true; - gesture.last.secondfinger.startPoint = g->startPoint; - gesture.last.secondfinger.lastPoint = g->lastPoint; - gesture.last.secondfinger.point = g->point; - gesture.last.secondfinger.offset = g->offset; - if (shouldAcceptSecondFingerGesture) - g->accept(); - } - if (PanGesture *g = (PanGesture*)e->gesture(PanGestureRecognizer::Name)) { - gesture.last.pan.delivered = true; - gesture.last.pan.startPoints[0] = g->startPoints[0]; - gesture.last.pan.startPoints[1] = g->startPoints[1]; - gesture.last.pan.lastPoints[0] = g->lastPoints[0]; - gesture.last.pan.lastPoints[1] = g->lastPoints[1]; - gesture.last.pan.points[0] = g->points[0]; - gesture.last.pan.points[1] = g->points[1]; - gesture.last.pan.offset = g->offset; - if (shouldAcceptPanGesture) - g->accept(); - } - gesture.last.cancelled = e->cancelledGestures(); - return true; - } - return QWidget::event(event); - } -}; -QVector GestureWidget::colors; -int GestureWidget::numberOfWidgets = 0; - -class GraphicsScene : public QGraphicsScene -{ -public: - GraphicsScene() - { - reset(); - } - bool shouldAcceptSingleshotGesture; - bool shouldAcceptPinchGesture; - bool shouldAcceptSecondFingerGesture; - GestureState gesture; - - void reset() - { - shouldAcceptSingleshotGesture = false; - shouldAcceptPinchGesture = false; - shouldAcceptSecondFingerGesture = false; - gesture.reset(); - } -protected: - bool event(QEvent *event) - { - if (event->type() == QEvent::GraphicsSceneGesture) { - QGraphicsSceneGestureEvent *e = static_cast(event); - ++gesture.seenGestureEvent; - QGraphicsScene::event(event); - if (SingleshotGesture *g = (SingleshotGesture*)e->gesture(SingleshotGestureRecognizer::Name)) { - gesture.last.singleshot.delivered = true; - gesture.last.singleshot.offset = g->offset; - if (shouldAcceptSingleshotGesture) - g->accept(); - } - if (PinchGesture *g = (PinchGesture*)e->gesture(PinchGestureRecognizer::Name)) { - gesture.last.pinch.delivered = true; - gesture.last.pinch.startPoints[0] = g->startPoints[0]; - gesture.last.pinch.startPoints[1] = g->startPoints[1]; - gesture.last.pinch.lastPoints[0] = g->lastPoints[0]; - gesture.last.pinch.lastPoints[1] = g->lastPoints[1]; - gesture.last.pinch.points[0] = g->points[0]; - gesture.last.pinch.points[1] = g->points[1]; - gesture.last.pinch.offset = g->offset; - if (shouldAcceptPinchGesture) - g->accept(); - } - if (SecondFingerGesture *g = (SecondFingerGesture*)e->gesture(SecondFingerGestureRecognizer::Name)) { - gesture.last.secondfinger.delivered = true; - gesture.last.secondfinger.startPoint = g->startPoint; - gesture.last.secondfinger.lastPoint = g->lastPoint; - gesture.last.secondfinger.point = g->point; - gesture.last.secondfinger.offset = g->offset; - if (shouldAcceptSecondFingerGesture) - g->accept(); - } - gesture.last.cancelled = e->cancelledGestures(); - return true; - } - return QGraphicsScene::event(event); - } -}; - -class GraphicsItem : public QGraphicsItem -{ -public: - GraphicsItem(int w = 100, int h = 100) - : width(w), height(h) - { - reset(); - } - - QRectF boundingRect() const - { - return QRectF(0, 0, width, height); - } - - void paint(QPainter *painter, const QStyleOptionGraphicsItem*, QWidget*) - { - painter->setBrush(Qt::green); - painter->drawRect(0, 0, width, height); - } - - void grabSingleshotGesture() - { - singleshotGestureId = grabGesture(SingleshotGestureRecognizer::Name); - } - void grabPinchGesture() - { - pinchGestureId = grabGesture(PinchGestureRecognizer::Name); - } - void grabSecondFingerGesture() - { - secondFingerGestureId = grabGesture(SecondFingerGestureRecognizer::Name); - } - void ungrabGestures() - { - releaseGesture(singleshotGestureId); - singleshotGestureId = -1; - releaseGesture(pinchGestureId); - pinchGestureId = -1; - releaseGesture(secondFingerGestureId); - secondFingerGestureId = -1; - } - - int width; - int height; - - int singleshotGestureId; - int pinchGestureId; - int secondFingerGestureId; - - bool shouldAcceptSingleshotGesture; - bool shouldAcceptPinchGesture; - bool shouldAcceptSecondFingerGesture; - GestureState gesture; - - TouchState touch; - - void reset() - { - shouldAcceptSingleshotGesture = true; - shouldAcceptPinchGesture = true; - shouldAcceptSecondFingerGesture = true; - gesture.reset(); - } -protected: - bool sceneEvent(QEvent *event) - { - if (event->type() == QEvent::TouchBegin) { - event->accept(); - ++touch.seenTouchBeginEvent; - return true; - } else if (event->type() == QEvent::TouchUpdate) { - ++touch.seenTouchUpdateEvent; - } else if (event->type() == QEvent::TouchEnd) { - ++touch.seenTouchEndEvent; - } else if (event->type() == QEvent::GraphicsSceneGesture) { - QGraphicsSceneGestureEvent *e = static_cast(event); - ++gesture.seenGestureEvent; - if (SingleshotGesture *g = (SingleshotGesture*)e->gesture(SingleshotGestureRecognizer::Name)) { - gesture.last.singleshot.delivered = true; - gesture.last.singleshot.offset = g->offset; - if (shouldAcceptSingleshotGesture) - g->accept(); - } - if (PinchGesture *g = (PinchGesture*)e->gesture(PinchGestureRecognizer::Name)) { - gesture.last.pinch.delivered = true; - gesture.last.pinch.startPoints[0] = g->startPoints[0]; - gesture.last.pinch.startPoints[1] = g->startPoints[1]; - gesture.last.pinch.lastPoints[0] = g->lastPoints[0]; - gesture.last.pinch.lastPoints[1] = g->lastPoints[1]; - gesture.last.pinch.points[0] = g->points[0]; - gesture.last.pinch.points[1] = g->points[1]; - gesture.last.pinch.offset = g->offset; - if (shouldAcceptPinchGesture) - g->accept(); - } - if (SecondFingerGesture *g = (SecondFingerGesture*)e->gesture(SecondFingerGestureRecognizer::Name)) { - gesture.last.secondfinger.delivered = true; - gesture.last.secondfinger.startPoint = g->startPoint; - gesture.last.secondfinger.lastPoint = g->lastPoint; - gesture.last.secondfinger.point = g->point; - gesture.last.secondfinger.offset = g->offset; - if (shouldAcceptSecondFingerGesture) - g->accept(); - } - gesture.last.cancelled = e->cancelledGestures(); - return true; - } - return QGraphicsItem::sceneEvent(event); - } -}; - -class tst_Gestures : public QObject -{ - Q_OBJECT - -public: - tst_Gestures(); - virtual ~tst_Gestures(); - -public slots: - void initTestCase(); - void cleanupTestCase(); - void init(); - void cleanup(); - -private slots: - void singleshotGesture(); - void pinchGesture(); - - void simplePropagation(); - void simplePropagation2(); - void acceptedGesturePropagation(); - - void simpleGraphicsView(); - void simpleGraphicsItem(); - void overlappingGraphicsItems(); - - void touch_widget(); - void touch_graphicsView(); - - void panOnWidgets(); - -private: - SingleshotGestureRecognizer *singleshotRecognizer; - PinchGestureRecognizer *pinchRecognizer; - SecondFingerGestureRecognizer *secondFingerRecognizer; - PanGestureRecognizer *panGestureRecognizer; - GestureWidget *mainWidget; - - void sendPinchEvents(QWidget *receiver, const QPoint &fromFinger1, const QPoint &fromFinger2); -}; - -tst_Gestures::tst_Gestures() -{ - singleshotRecognizer = new SingleshotGestureRecognizer; - pinchRecognizer = new PinchGestureRecognizer; - secondFingerRecognizer = new SecondFingerGestureRecognizer; - panGestureRecognizer = new PanGestureRecognizer; - qApp->addGestureRecognizer(singleshotRecognizer); - qApp->addGestureRecognizer(pinchRecognizer); - qApp->addGestureRecognizer(secondFingerRecognizer); - qApp->addGestureRecognizer(panGestureRecognizer); -} - -tst_Gestures::~tst_Gestures() -{ -} - - -void tst_Gestures::initTestCase() -{ - mainWidget = new GestureWidget(GestureWidget::DoNotGrabGestures); - mainWidget->setObjectName("MainGestureWidget"); - mainWidget->resize(500, 600); - mainWidget->show(); -} - -void tst_Gestures::cleanupTestCase() -{ - delete mainWidget; mainWidget = 0; -} - -void tst_Gestures::init() -{ - // TODO: Add initialization code here. - // This will be executed immediately before each test is run. - mainWidget->reset(); -} - -void tst_Gestures::cleanup() -{ -} - -bool sendSpontaneousEvent(QWidget *receiver, QEvent *event) -{ - QETWidget::setSpont(event, true); - return qApp->notify(receiver, event); -} - -void tst_Gestures::singleshotGesture() -{ - mainWidget->grabSingleshotGesture(); - SingleshotEvent event; - sendSpontaneousEvent(mainWidget, &event); - QVERIFY(mainWidget->gesture.seenGestureEvent); - QVERIFY(mainWidget->gesture.last.singleshot.delivered); - QVERIFY(mainWidget->gesture.last.cancelled.isEmpty()); -} - -void tst_Gestures::sendPinchEvents(QWidget *receiver, const QPoint &fromFinger1, const QPoint &fromFinger2) -{ - int x1 = fromFinger1.x(); - int y1 = fromFinger1.x(); - int x2 = fromFinger2.x(); - int y2 = fromFinger2.x(); - - TouchEvent event; - event.points[0] = TouchPoint(0,x1,y1, TouchPoint::Begin); - event.points[1] = TouchPoint(); - sendSpontaneousEvent(receiver, &event); - event.points[0] = TouchPoint(0, x1+=2,y1+=2, TouchPoint::Update); - event.points[1] = TouchPoint(); - sendSpontaneousEvent(receiver, &event); - event.points[0] = TouchPoint(0, x1,y1, TouchPoint::Update); - event.points[1] = TouchPoint(1, x2,y2, TouchPoint::Begin); - sendSpontaneousEvent(receiver, &event); - event.points[0] = TouchPoint(0, x1+=5,y1+=10, TouchPoint::End); - event.points[1] = TouchPoint(1, x2+=3,y2+=6, TouchPoint::Update); - sendSpontaneousEvent(receiver, &event); - event.points[0] = TouchPoint(); - event.points[1] = TouchPoint(1, x2+=10,y2+=15, TouchPoint::Update); - sendSpontaneousEvent(receiver, &event); - event.points[0] = TouchPoint(); - event.points[1] = TouchPoint(1, x2,y2, TouchPoint::End); - sendSpontaneousEvent(receiver, &event); -} - -void tst_Gestures::pinchGesture() -{ - mainWidget->grabPinchGesture(); - sendPinchEvents(mainWidget, QPoint(10,10), QPoint(20,20)); - - QVERIFY(mainWidget->gesture.seenGestureEvent); - QVERIFY(!mainWidget->gesture.last.singleshot.delivered); - QVERIFY(mainWidget->gesture.last.cancelled.isEmpty()); - QVERIFY(mainWidget->gesture.last.pinch.delivered); - QCOMPARE(mainWidget->gesture.last.pinch.startPoints[0].pt, QPoint(10,10)); - QCOMPARE(mainWidget->gesture.last.pinch.startPoints[1].pt, QPoint(20,20)); - QCOMPARE(mainWidget->gesture.last.pinch.offset, QPoint(0,0)); -} - -void tst_Gestures::simplePropagation() -{ - mainWidget->grabSingleshotGesture(); - GestureWidget offsetWidget(GestureWidget::DoNotGrabGestures); - offsetWidget.setFixedSize(30, 30); - mainWidget->layout()->addWidget(&offsetWidget); - GestureWidget nonGestureWidget(GestureWidget::DoNotGrabGestures); - mainWidget->layout()->addWidget(&nonGestureWidget); - QApplication::processEvents(); - - SingleshotEvent event; - sendSpontaneousEvent(&nonGestureWidget, &event); - QVERIFY(!offsetWidget.gesture.seenGestureEvent); - QVERIFY(!nonGestureWidget.gesture.seenGestureEvent); - QVERIFY(mainWidget->gesture.seenGestureEvent); - QVERIFY(mainWidget->gesture.last.cancelled.isEmpty()); - QVERIFY(mainWidget->gesture.last.singleshot.delivered); - QCOMPARE(mainWidget->gesture.last.singleshot.offset, QPoint(GestureWidget::LeftMargin, 30 + GestureWidget::TopMargin)); -} - -void tst_Gestures::simplePropagation2() -{ - mainWidget->grabSingleshotGesture(); - mainWidget->grabPinchGesture(); - GestureWidget nonGestureMiddleWidget(GestureWidget::DoNotGrabGestures); - GestureWidget secondGestureWidget(GestureWidget::GrabPinch); - nonGestureMiddleWidget.layout()->addWidget(&secondGestureWidget); - mainWidget->layout()->addWidget(&nonGestureMiddleWidget); - QApplication::processEvents(); - - SingleshotEvent event; - sendSpontaneousEvent(&secondGestureWidget, &event); - QVERIFY(!secondGestureWidget.gesture.seenGestureEvent); - QVERIFY(!nonGestureMiddleWidget.gesture.seenGestureEvent); - QVERIFY(mainWidget->gesture.seenGestureEvent); - QVERIFY(mainWidget->gesture.last.singleshot.delivered); - QVERIFY(mainWidget->gesture.last.cancelled.isEmpty()); - QCOMPARE(mainWidget->gesture.last.singleshot.offset, QPoint(GestureWidget::LeftMargin*2,GestureWidget::TopMargin*2)); - - mainWidget->reset(); - nonGestureMiddleWidget.reset(); - secondGestureWidget.reset(); - - sendPinchEvents(&secondGestureWidget, QPoint(10,10), QPoint(20,20)); - QVERIFY(secondGestureWidget.gesture.seenGestureEvent); - QVERIFY(!secondGestureWidget.gesture.last.singleshot.delivered); - QVERIFY(secondGestureWidget.gesture.last.pinch.delivered); - QCOMPARE(secondGestureWidget.gesture.last.pinch.startPoints[0].pt, QPoint(10,10)); - QCOMPARE(secondGestureWidget.gesture.last.pinch.startPoints[1].pt, QPoint(20,20)); - QCOMPARE(secondGestureWidget.gesture.last.pinch.offset, QPoint(0,0)); - QVERIFY(!nonGestureMiddleWidget.gesture.seenGestureEvent); - QVERIFY(!mainWidget->gesture.seenGestureEvent); -} - -void tst_Gestures::acceptedGesturePropagation() -{ - mainWidget->grabSingleshotGesture(); - mainWidget->grabPinchGesture(); - mainWidget->grabSecondFingerGesture(); - GestureWidget nonGestureMiddleWidget(GestureWidget::DoNotGrabGestures); - nonGestureMiddleWidget.setObjectName("nonGestureMiddleWidget"); - GestureWidget secondGestureWidget(GestureWidget::GrabSecondFinger); - secondGestureWidget.setObjectName("secondGestureWidget"); - nonGestureMiddleWidget.layout()->addWidget(&secondGestureWidget); - mainWidget->layout()->addWidget(&nonGestureMiddleWidget); - QApplication::processEvents(); - - sendPinchEvents(&secondGestureWidget, QPoint(10, 10), QPoint(40, 40)); - QVERIFY(secondGestureWidget.gesture.seenGestureEvent); - QVERIFY(!secondGestureWidget.gesture.last.singleshot.delivered); - QVERIFY(!secondGestureWidget.gesture.last.pinch.delivered); - QVERIFY(secondGestureWidget.gesture.last.secondfinger.delivered); - QCOMPARE(secondGestureWidget.gesture.last.secondfinger.startPoint.pt, QPoint(40,40)); - QVERIFY(!nonGestureMiddleWidget.gesture.seenGestureEvent); - QVERIFY(mainWidget->gesture.seenGestureEvent); - QVERIFY(!mainWidget->gesture.last.singleshot.delivered); - QVERIFY(!mainWidget->gesture.last.secondfinger.delivered); - QVERIFY(mainWidget->gesture.last.pinch.delivered); - QCOMPARE(mainWidget->gesture.last.pinch.startPoints[0].pt, QPoint(10,10)); - QCOMPARE(mainWidget->gesture.last.pinch.startPoints[1].pt, QPoint(40,40)); - - mainWidget->reset(); - nonGestureMiddleWidget.reset(); - secondGestureWidget.reset(); - - // don't accept it and make sure it propagates to parent - secondGestureWidget.shouldAcceptSecondFingerGesture = false; - sendPinchEvents(&secondGestureWidget, QPoint(10, 10), QPoint(40, 40)); - QVERIFY(secondGestureWidget.gesture.seenGestureEvent); - QVERIFY(secondGestureWidget.gesture.last.secondfinger.delivered); - QVERIFY(!nonGestureMiddleWidget.gesture.seenGestureEvent); - QVERIFY(mainWidget->gesture.seenGestureEvent); - QVERIFY(!mainWidget->gesture.last.singleshot.delivered); - QVERIFY(mainWidget->gesture.last.secondfinger.delivered); - QVERIFY(mainWidget->gesture.last.pinch.delivered); -} - -void tst_Gestures::simpleGraphicsView() -{ - mainWidget->grabSingleshotGesture(); - GraphicsScene scene; - QGraphicsView view(&scene); - view.grabGesture(SingleshotGestureRecognizer::Name); - mainWidget->layout()->addWidget(&view); - QApplication::processEvents(); - - scene.shouldAcceptSingleshotGesture = true; - - SingleshotEvent event; - sendSpontaneousEvent(&view, &event); - QVERIFY(!mainWidget->gesture.seenGestureEvent); - QVERIFY(scene.gesture.seenGestureEvent); - QVERIFY(scene.gesture.last.singleshot.delivered); - QVERIFY(scene.gesture.last.cancelled.isEmpty()); -} - -void tst_Gestures::simpleGraphicsItem() -{ - mainWidget->grabSingleshotGesture(); - GraphicsScene scene; - QGraphicsView view(&scene); - mainWidget->layout()->addWidget(&view); - GraphicsItem *item = new GraphicsItem; - item->grabSingleshotGesture(); - item->setPos(30, 50); - scene.addItem(item); - QApplication::processEvents(); - - QPoint pt = view.mapFromScene(item->mapToScene(30, 30)); - SingleshotEvent event(pt.x(), pt.y()); - sendSpontaneousEvent(&view, &event); - QVERIFY(item->gesture.seenGestureEvent); - QVERIFY(scene.gesture.seenGestureEvent); - QVERIFY(!mainWidget->gesture.seenGestureEvent); - - item->reset(); - scene.reset(); - mainWidget->reset(); - - item->shouldAcceptSingleshotGesture = false; - // outside of the graphicsitem - pt = view.mapFromScene(item->mapToScene(-10, -10)); - SingleshotEvent event2(pt.x(), pt.y()); - sendSpontaneousEvent(&view, &event2); - QVERIFY(!item->gesture.seenGestureEvent); - QVERIFY(scene.gesture.seenGestureEvent); - QVERIFY(mainWidget->gesture.seenGestureEvent); -} - -void tst_Gestures::overlappingGraphicsItems() -{ - mainWidget->grabSingleshotGesture(); - GraphicsScene scene; - QGraphicsView view(&scene); - mainWidget->layout()->addWidget(&view); - - GraphicsItem *item = new GraphicsItem(300, 100); - item->setPos(30, 50); - scene.addItem(item); - GraphicsItem *subitem1 = new GraphicsItem(50, 70); - subitem1->setPos(70, 70); - subitem1->setZValue(1); - scene.addItem(subitem1); - GraphicsItem *subitem2 = new GraphicsItem(50, 70); - subitem2->setPos(250, 70); - subitem2->setZValue(1); - scene.addItem(subitem2); - QApplication::processEvents(); - - item->grabSingleshotGesture(); - item->grabPinchGesture(); - item->grabSecondFingerGesture(); - subitem1->grabSingleshotGesture(); - subitem2->grabSecondFingerGesture(); - - QPoint pt = view.mapFromScene(subitem1->mapToScene(20, 20)); - SingleshotEvent event(pt.x(), pt.y()); - sendSpontaneousEvent(&view, &event); - QVERIFY(scene.gesture.seenGestureEvent); - QVERIFY(!subitem2->gesture.seenGestureEvent); - QVERIFY(!item->gesture.seenGestureEvent); - QVERIFY(!mainWidget->gesture.seenGestureEvent); - QVERIFY(subitem1->gesture.seenGestureEvent); - QVERIFY(subitem1->gesture.last.singleshot.delivered); - - item->reset(); - subitem1->reset(); - subitem2->reset(); - scene.reset(); - mainWidget->reset(); - - subitem1->shouldAcceptSingleshotGesture = false; - SingleshotEvent event2(pt.x(), pt.y()); - sendSpontaneousEvent(&view, &event2); - QVERIFY(scene.gesture.seenGestureEvent); - QVERIFY(!subitem2->gesture.seenGestureEvent); - QVERIFY(subitem1->gesture.seenGestureEvent); - QVERIFY(item->gesture.seenGestureEvent); - QVERIFY(!mainWidget->gesture.seenGestureEvent); - QVERIFY(subitem1->gesture.last.singleshot.delivered); - QVERIFY(item->gesture.last.singleshot.delivered); -} - -void tst_Gestures::touch_widget() -{ - GestureWidget leftWidget(GestureWidget::DoNotGrabGestures); - leftWidget.setObjectName("leftWidget"); - leftWidget.setAttribute(Qt::WA_AcceptTouchEvents); - GestureWidget rightWidget(GestureWidget::DoNotGrabGestures); - rightWidget.setObjectName("rightWidget"); - rightWidget.setAttribute(Qt::WA_AcceptTouchEvents); - delete mainWidget->layout(); - (void)new QHBoxLayout(mainWidget); - mainWidget->layout()->addWidget(&leftWidget); - mainWidget->layout()->addWidget(&rightWidget); - QApplication::processEvents(); - - QTest::touchEvent() - .press(0, QPoint(10, 10), &leftWidget); - QTest::touchEvent() - .move(0, QPoint(12, 30), &leftWidget); - QTest::touchEvent() - .stationary(0) - .press(1, QPoint(15, 15), &rightWidget); - QTest::touchEvent() - .move(0, QPoint(10, 35), &leftWidget) - .press(1, QPoint(15, 15), &rightWidget); - QTest::touchEvent() - .move(0, QPoint(10, 40), &leftWidget) - .move(1, QPoint(20, 50), &rightWidget); - QTest::touchEvent() - .release(0, QPoint(10, 40), &leftWidget) - .release(1, QPoint(20, 50), &rightWidget); - QVERIFY(!mainWidget->touch.seenTouchBeginEvent); - QVERIFY(leftWidget.touch.seenTouchBeginEvent); - QVERIFY(leftWidget.touch.seenTouchUpdateEvent); - QVERIFY(leftWidget.touch.seenTouchEndEvent); - QVERIFY(rightWidget.touch.seenTouchBeginEvent); - QVERIFY(rightWidget.touch.seenTouchUpdateEvent); - QVERIFY(rightWidget.touch.seenTouchEndEvent); -} - -void tst_Gestures::touch_graphicsView() -{ - mainWidget->setAttribute(Qt::WA_AcceptTouchEvents); - GraphicsScene scene; - QGraphicsView view(&scene); - view.viewport()->setAttribute(Qt::WA_AcceptTouchEvents); - mainWidget->layout()->addWidget(&view); - - GraphicsItem *item = new GraphicsItem(300, 100); - item->setAcceptTouchEvents(true); - item->setPos(30, 50); - scene.addItem(item); - GraphicsItem *subitem1 = new GraphicsItem(50, 70); - subitem1->setAcceptTouchEvents(true); - subitem1->setPos(70, 70); - scene.addItem(subitem1); - GraphicsItem *subitem2 = new GraphicsItem(50, 70); - subitem2->setAcceptTouchEvents(true); - subitem2->setPos(250, 70); - scene.addItem(subitem2); - QApplication::processEvents(); - - QRect itemRect = view.mapFromScene(item->mapRectToScene(item->boundingRect())).boundingRect(); - QPoint pt = itemRect.center(); - QTest::touchEvent(view.viewport()) - .press(0, pt) - .press(1, pt); - QTest::touchEvent(view.viewport()) - .move(0, pt + QPoint(20, 30)) - .move(1, QPoint(300, 300)); - QTest::touchEvent(view.viewport()) - .stationary(0) - .move(1, QPoint(330, 330)); - QTest::touchEvent(view.viewport()) - .release(0, QPoint(120, 120)) - .release(1, QPoint(300, 300)); - - QVERIFY(item->touch.seenTouchBeginEvent); - QVERIFY(item->touch.seenTouchUpdateEvent); - QVERIFY(item->touch.seenTouchEndEvent); -} - -void tst_Gestures::panOnWidgets() -{ - GestureWidget leftWidget(GestureWidget::GrabPan); - leftWidget.setObjectName("leftWidget"); - leftWidget.setAttribute(Qt::WA_AcceptTouchEvents); - GestureWidget rightWidget(GestureWidget::GrabPan); - rightWidget.setObjectName("rightWidget"); - rightWidget.setAttribute(Qt::WA_AcceptTouchEvents); - delete mainWidget->layout(); - (void)new QHBoxLayout(mainWidget); - mainWidget->layout()->addWidget(&leftWidget); - mainWidget->layout()->addWidget(&rightWidget); - QApplication::processEvents(); - - QTest::touchEvent() - .press(0, QPoint(10, 10), &leftWidget); - QTest::touchEvent() - .move(0, QPoint(12, 30), &leftWidget); - QTest::touchEvent() - .stationary(0) - .press(1, QPoint(15, 15), &rightWidget); - QTest::touchEvent() - .move(0, QPoint(10, 35), &leftWidget) - .press(1, QPoint(15, 15), &rightWidget); - QTest::touchEvent() - .move(0, QPoint(10, 40), &leftWidget) - .move(1, QPoint(20, 50), &rightWidget); - QTest::touchEvent() - .release(0, QPoint(10, 40), &leftWidget) - .release(1, QPoint(20, 50), &rightWidget); - - QVERIFY(leftWidget.gesture.last.pan.delivered); - QVERIFY(rightWidget.gesture.last.pan.delivered); -} - -QTEST_MAIN(tst_Gestures) -#include "tst_gestures.moc" -- cgit v0.12 From c94439e3d20b79db7df3e6b23b6753652b812e1f Mon Sep 17 00:00:00 2001 From: Andreas Aardal Hanssen Date: Mon, 31 Aug 2009 16:42:59 +0200 Subject: Don't show the pad navigator example full screen. This reverts a change added by 6a3de1f5 by mistake (according to the S60 guys). The proper fix may be to add a -small-screen argument, or to run fullscreen on embedded only. Reviewed-by: jbarron --- examples/graphicsview/padnavigator/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/graphicsview/padnavigator/main.cpp b/examples/graphicsview/padnavigator/main.cpp index a984eab..30e1dc3 100644 --- a/examples/graphicsview/padnavigator/main.cpp +++ b/examples/graphicsview/padnavigator/main.cpp @@ -53,7 +53,7 @@ int main(int argc, char *argv[]) Panel panel(3, 3); panel.setFocus(); - panel.showFullScreen(); + panel.show(); return app.exec(); } -- cgit v0.12 From 9d24605add8daabfa55e1085e71ed47b14ed7d83 Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Mon, 31 Aug 2009 16:46:59 +0200 Subject: QNAM HTTP Code: Some tests where failing ietf.org changed their server to use gzip, therefore our check for the content-length reply header was bogus. Rev-By: Peter Hartmann --- tests/auto/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp | 8 ++++++-- tests/auto/qnetworkreply/tst_qnetworkreply.cpp | 6 ++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/tests/auto/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp b/tests/auto/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp index c54bf3c..639464e 100644 --- a/tests/auto/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp +++ b/tests/auto/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp @@ -177,7 +177,9 @@ void tst_QHttpNetworkConnection::head() QCOMPARE(reply->statusCode(), statusCode); QCOMPARE(reply->reasonPhrase(), statusString); - QCOMPARE(reply->contentLength(), qint64(contentLength)); + // only check it if it is set + if (reply->contentLength() != -1) + QCOMPARE(reply->contentLength(), qint64(contentLength)); QVERIFY(reply->isFinished()); @@ -237,7 +239,9 @@ void tst_QHttpNetworkConnection::get() QCOMPARE(reply->statusCode(), statusCode); QCOMPARE(reply->reasonPhrase(), statusString); - QCOMPARE(reply->contentLength(), qint64(contentLength)); + // only check it if it is set + if (reply->contentLength() != -1) + QCOMPARE(reply->contentLength(), qint64(contentLength)); stopWatch.start(); QByteArray ba; diff --git a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp index 3216a6a..48a48f4 100644 --- a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp @@ -1081,8 +1081,10 @@ void tst_QNetworkReply::getFromHttp() QCOMPARE(reply->url(), request.url()); QCOMPARE(reply->error(), QNetworkReply::NoError); QCOMPARE(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(), 200); - - QCOMPARE(reply->header(QNetworkRequest::ContentLengthHeader).toLongLong(), reference.size()); + QCOMPARE(reply->size(), reference.size()); + // only compare when the header is set. + if (reply->header(QNetworkRequest::ContentLengthHeader).isValid()) + QCOMPARE(reply->header(QNetworkRequest::ContentLengthHeader).toLongLong(), reference.size()); QCOMPARE(reply->readAll(), reference.readAll()); } -- cgit v0.12 From 89030379ea1c2621fca24d91eaff92aea44686da Mon Sep 17 00:00:00 2001 From: Ariya Hidayat Date: Mon, 31 Aug 2009 16:14:45 +0200 Subject: Speed-up floating-point decoding for SVG parsing. Instead of comparing the character to '0' and '9', use bit fiddling to detect that the character is a digit between '0' and '9'. Loading tiger.svg (tests/benchmarks/qsvgrenderer) is now 10% faster, going down from 85.3 millions instructions to 77.2 millions. Mostly this is due 46% speed-up in parseNumbersList() function, from 26.9 millions instructions to just 18.4 millions. Reviewed-by: Kim --- src/svg/qsvghandler.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/svg/qsvghandler.cpp b/src/svg/qsvghandler.cpp index 8a68cc3..6ff885a 100644 --- a/src/svg/qsvghandler.cpp +++ b/src/svg/qsvghandler.cpp @@ -474,6 +474,13 @@ public: } }; +// '0' is 0x30 and '9' is 0x39 +static inline bool isDigit(ushort ch) +{ + static quint16 magic = 0x3ff; + return ((ch >> 4) == 3) && (magic >> (ch & 15)); +} + static qreal toDouble(const QChar *&str) { const int maxLen = 255;//technically doubles can go til 308+ but whatever @@ -486,7 +493,7 @@ static qreal toDouble(const QChar *&str) } else if (*str == QLatin1Char('+')) { ++str; } - while (*str >= QLatin1Char('0') && *str <= QLatin1Char('9') && pos < maxLen) { + while (isDigit(str->unicode()) && pos < maxLen) { temp[pos++] = str->toLatin1(); ++str; } @@ -494,7 +501,7 @@ static qreal toDouble(const QChar *&str) temp[pos++] = '.'; ++str; } - while (*str >= QLatin1Char('0') && *str <= QLatin1Char('9') && pos < maxLen) { + while (isDigit(str->unicode()) && pos < maxLen) { temp[pos++] = str->toLatin1(); ++str; } @@ -507,7 +514,7 @@ static qreal toDouble(const QChar *&str) temp[pos++] = str->toLatin1(); ++str; } - while (*str >= QLatin1Char('0') && *str <= QLatin1Char('9') && pos < maxLen) { + while (isDigit(str->unicode()) && pos < maxLen) { temp[pos++] = str->toLatin1(); ++str; } @@ -587,7 +594,7 @@ static QVector parseNumbersList(const QChar *&str) while (*str == QLatin1Char(' ')) ++str; - while ((*str >= QLatin1Char('0') && *str <= QLatin1Char('9')) || + while (isDigit(str->unicode()) || *str == QLatin1Char('-') || *str == QLatin1Char('+') || *str == QLatin1Char('.')) { -- cgit v0.12 From 48e07d39124068fef1734cfabc1c50a2f6a42007 Mon Sep 17 00:00:00 2001 From: Ariya Hidayat Date: Mon, 31 Aug 2009 16:44:34 +0200 Subject: Minor improvement when parsing matrix transformation in SVG. Create a specialized version of numbers parsing that works on a short QVarLengthArray since a transformation matrix has at most 6 elements. Reviewed-by: Kim --- src/svg/qsvghandler.cpp | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/svg/qsvghandler.cpp b/src/svg/qsvghandler.cpp index 6ff885a..371b845 100644 --- a/src/svg/qsvghandler.cpp +++ b/src/svg/qsvghandler.cpp @@ -64,6 +64,7 @@ #include "qdebug.h" #include "qmath.h" #include "qnumeric.h" +#include "qvarlengtharray.h" #include "private/qmath_p.h" #include "float.h" @@ -613,6 +614,27 @@ static QVector parseNumbersList(const QChar *&str) return points; } +static inline void parseNumbersArray(const QChar *&str, QVarLengthArray &points) +{ + while (*str == QLatin1Char(' ')) + ++str; + while (isDigit(str->unicode()) || + *str == QLatin1Char('-') || *str == QLatin1Char('+') || + *str == QLatin1Char('.')) { + + points.append(toDouble(str)); + + while (*str == QLatin1Char(' ')) + ++str; + if (*str == QLatin1Char(',')) + ++str; + + //eat the rest of space + while (*str == QLatin1Char(' ')) + ++str; + } +} + static QVector parsePercentageList(const QChar *&str) { QVector points; @@ -956,7 +978,8 @@ static QMatrix parseTransformationMatrix(const QString &value) if (*str != QLatin1Char('(')) goto error; ++str; - QVector points = parseNumbersList(str); + QVarLengthArray points; + parseNumbersArray(str, points); if (*str != QLatin1Char(')')) goto error; ++str; -- cgit v0.12 From be51485f9d302eedfdb565c486e24ddab4098463 Mon Sep 17 00:00:00 2001 From: Kim Motoyoshi Kalland Date: Mon, 31 Aug 2009 17:11:01 +0200 Subject: Added context pointer to QGLContextGroupResources. I renamed QGLContextGroupResources to QGLContextGroup because we are using it to identify context groups. I also added a pointer to one of the contexts in the group. Together with qgl_share_reg(), the pointer can be used to find all contexts in a group. I renamed QGLContextPrivate::qt_get_extension_funcs() to QGLContextPrivate::extensionFuncs() to follow Qt's naming convention. Reviewed-by: Trond --- src/opengl/qgl.cpp | 34 ++++++--- src/opengl/qgl_p.h | 41 ++++++---- src/opengl/qglextensions_p.h | 162 ++++++++++++++++++++-------------------- src/opengl/qglshaderprogram.cpp | 40 +++++----- 4 files changed, 151 insertions(+), 126 deletions(-) diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index f8a9196..8b7674e 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -1273,6 +1273,14 @@ bool operator!=(const QGLFormat& a, const QGLFormat& b) /***************************************************************************** QGLContext implementation *****************************************************************************/ +QGLContextPrivate::~QGLContextPrivate() +{ + if (!group->m_refs.deref()) { + Q_ASSERT(group->context() == q_ptr); + delete group; + } +} + void QGLContextPrivate::init(QPaintDevice *dev, const QGLFormat &format) { Q_Q(QGLContext); @@ -4861,40 +4869,40 @@ bool QGLDrawable::autoFillBackground() const bool QGLShareRegister::checkSharing(const QGLContext *context1, const QGLContext *context2) { - bool sharing = (context1 && context2 && context1->d_ptr->groupResources == context2->d_ptr->groupResources); + bool sharing = (context1 && context2 && context1->d_ptr->group == context2->d_ptr->group); return sharing; } void QGLShareRegister::addShare(const QGLContext *context, const QGLContext *share) { Q_ASSERT(context && share); - if (context->d_ptr->groupResources == share->d_ptr->groupResources) + if (context->d_ptr->group == share->d_ptr->group) return; // Make sure 'context' is not already shared with another group of contexts. - Q_ASSERT(reg.find(context->d_ptr->groupResources) == reg.end()); - Q_ASSERT(context->d_ptr->groupResources->refs == 1); + Q_ASSERT(reg.find(context->d_ptr->group) == reg.end()); + Q_ASSERT(context->d_ptr->group->m_refs == 1); // Free 'context' group resources and make it use the same resources as 'share'. - delete context->d_ptr->groupResources; - context->d_ptr->groupResources = share->d_ptr->groupResources; - context->d_ptr->groupResources->refs.ref(); + delete context->d_ptr->group; + context->d_ptr->group = share->d_ptr->group; + context->d_ptr->group->m_refs.ref(); // Maintain a list of all the contexts in each group of sharing contexts. - SharingHash::iterator it = reg.find(share->d_ptr->groupResources); + SharingHash::iterator it = reg.find(share->d_ptr->group); if (it == reg.end()) - it = reg.insert(share->d_ptr->groupResources, ContextList() << share); + it = reg.insert(share->d_ptr->group, ContextList() << share); it.value() << context; } QList QGLShareRegister::shares(const QGLContext *context) { - SharingHash::const_iterator it = reg.find(context->d_ptr->groupResources); + SharingHash::const_iterator it = reg.find(context->d_ptr->group); if (it == reg.end()) return ContextList(); return it.value(); } void QGLShareRegister::removeShare(const QGLContext *context) { - SharingHash::iterator it = reg.find(context->d_ptr->groupResources); + SharingHash::iterator it = reg.find(context->d_ptr->group); if (it == reg.end()) return; @@ -4902,6 +4910,10 @@ void QGLShareRegister::removeShare(const QGLContext *context) { Q_ASSERT(count == 1); Q_UNUSED(count); + // Update context group representative. + if (context->d_ptr->group->m_context == context) + context->d_ptr->group->m_context = it.value().first(); + Q_ASSERT(it.value().size() != 0); if (it.value().size() == 1) reg.erase(it); diff --git a/src/opengl/qgl_p.h b/src/opengl/qgl_p.h index 2fd3070..dceb3f5 100644 --- a/src/opengl/qgl_p.h +++ b/src/opengl/qgl_p.h @@ -193,11 +193,24 @@ public: #endif }; -struct QGLContextGroupResources +// QGLContextPrivate has the responsibility of creating context groups. +// QGLContextPrivate and QGLShareRegister will both maintain the reference counter and destroy +// context groups when needed. +// QGLShareRegister has the responsibility of keeping the context pointer up to date. +class QGLContextGroup { - QGLContextGroupResources() : refs(1) { } - QGLExtensionFuncs extensionFuncs; - QAtomicInt refs; +public: + QGLExtensionFuncs &extensionFuncs() {return m_extensionFuncs;} + const QGLContext *context() const {return m_context;} +private: + QGLContextGroup(const QGLContext *context) : m_refs(1), m_context(context) { } + + QGLExtensionFuncs m_extensionFuncs; + const QGLContext *m_context; // context group's representative + QAtomicInt m_refs; + + friend class QGLShareRegister; + friend class QGLContextPrivate; }; class QGLTexture; @@ -206,8 +219,8 @@ class QGLContextPrivate { Q_DECLARE_PUBLIC(QGLContext) public: - explicit QGLContextPrivate(QGLContext *context) : internal_context(false), q_ptr(context) {groupResources = new QGLContextGroupResources;} - ~QGLContextPrivate() {if (!groupResources->refs.deref()) delete groupResources;} + explicit QGLContextPrivate(QGLContext *context) : internal_context(false), q_ptr(context) {group = new QGLContextGroup(context);} + ~QGLContextPrivate(); QGLTexture *bindTexture(const QImage &image, GLenum target, GLint format, QGLContext::BindOptions options); QGLTexture *bindTexture(const QImage &image, GLenum target, GLint format, const qint64 key, @@ -269,23 +282,23 @@ public: QGLContext *q_ptr; QGLFormat::OpenGLVersionFlags version_flags; - QGLContextGroupResources *groupResources; + QGLContextGroup *group; GLint max_texture_size; GLuint current_fbo; QPaintEngine *active_engine; - static inline QGLContextGroupResources *qt_get_context_group(const QGLContext *ctx) { return ctx->d_ptr->groupResources; } + static inline QGLContextGroup *contextGroup(const QGLContext *ctx) { return ctx->d_ptr->group; } #ifdef Q_WS_WIN - static inline QGLExtensionFuncs& qt_get_extension_funcs(const QGLContext *ctx) { return ctx->d_ptr->groupResources->extensionFuncs; } - static inline QGLExtensionFuncs& qt_get_extension_funcs(QGLContextGroupResources *ctx) { return ctx->extensionFuncs; } + static inline QGLExtensionFuncs& extensionFuncs(const QGLContext *ctx) { return ctx->d_ptr->group->extensionFuncs(); } + static inline QGLExtensionFuncs& extensionFuncs(QGLContextGroup *ctx) { return ctx->extensionFuncs(); } #endif #if defined(Q_WS_X11) || defined(Q_WS_MAC) || defined(Q_WS_QWS) static QGLExtensionFuncs qt_extensionFuncs; - static inline QGLExtensionFuncs& qt_get_extension_funcs(const QGLContext *) { return qt_extensionFuncs; } - static inline QGLExtensionFuncs& qt_get_extension_funcs(QGLContextGroupResources *ctx) { return qt_extensionFuncs; } + static inline QGLExtensionFuncs& extensionFuncs(const QGLContext *) { return qt_extensionFuncs; } + static inline QGLExtensionFuncs& extensionFuncs(QGLContextGroup *ctx) { return qt_extensionFuncs; } #endif QPixmapFilter *createPixmapFilter(int type) const; @@ -402,9 +415,9 @@ public: QList shares(const QGLContext *context); void removeShare(const QGLContext *context); private: - // Use a context's 'groupResources' pointer to uniquely identify a group. + // Use a context's 'group' pointer to uniquely identify a group. typedef QList ContextList; - typedef QHash SharingHash; + typedef QHash SharingHash; SharingHash reg; }; diff --git a/src/opengl/qglextensions_p.h b/src/opengl/qglextensions_p.h index 60a4173..8839f60 100644 --- a/src/opengl/qglextensions_p.h +++ b/src/opengl/qglextensions_p.h @@ -605,114 +605,114 @@ struct QGLExtensionFuncs #if !defined(QT_OPENGL_ES_2) -#define glProgramStringARB QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glProgramStringARB -#define glBindProgramARB QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glBindProgramARB -#define glDeleteProgramsARB QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glDeleteProgramsARB -#define glGenProgramsARB QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glGenProgramsARB -#define glProgramLocalParameter4fvARB QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glProgramLocalParameter4fvARB +#define glProgramStringARB QGLContextPrivate::extensionFuncs(ctx).qt_glProgramStringARB +#define glBindProgramARB QGLContextPrivate::extensionFuncs(ctx).qt_glBindProgramARB +#define glDeleteProgramsARB QGLContextPrivate::extensionFuncs(ctx).qt_glDeleteProgramsARB +#define glGenProgramsARB QGLContextPrivate::extensionFuncs(ctx).qt_glGenProgramsARB +#define glProgramLocalParameter4fvARB QGLContextPrivate::extensionFuncs(ctx).qt_glProgramLocalParameter4fvARB -#define glActiveStencilFaceEXT QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glActiveStencilFaceEXT +#define glActiveStencilFaceEXT QGLContextPrivate::extensionFuncs(ctx).qt_glActiveStencilFaceEXT -#define glMultiTexCoord4f QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glMultiTexCoord4f +#define glMultiTexCoord4f QGLContextPrivate::extensionFuncs(ctx).qt_glMultiTexCoord4f -#define glActiveTexture QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glActiveTexture +#define glActiveTexture QGLContextPrivate::extensionFuncs(ctx).qt_glActiveTexture #endif // !defined(QT_OPENGL_ES_2) // FBOs #if !defined(QT_OPENGL_ES_2) -#define glIsRenderbuffer QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glIsRenderbuffer -#define glBindRenderbuffer QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glBindRenderbuffer -#define glDeleteRenderbuffers QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glDeleteRenderbuffers -#define glGenRenderbuffers QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glGenRenderbuffers -#define glRenderbufferStorage QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glRenderbufferStorage -#define glGetRenderbufferParameteriv QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glGetRenderbufferParameteriv -#define glIsFramebuffer QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glIsFramebuffer -#define glBindFramebuffer QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glBindFramebuffer -#define glDeleteFramebuffers QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glDeleteFramebuffers -#define glGenFramebuffers QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glGenFramebuffers -#define glCheckFramebufferStatus QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glCheckFramebufferStatus -#define glFramebufferTexture2D QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glFramebufferTexture2D -#define glFramebufferRenderbuffer QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glFramebufferRenderbuffer -#define glGetFramebufferAttachmentParameteriv QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glGetFramebufferAttachmentParameteriv -#define glGenerateMipmap QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glGenerateMipmap +#define glIsRenderbuffer QGLContextPrivate::extensionFuncs(ctx).qt_glIsRenderbuffer +#define glBindRenderbuffer QGLContextPrivate::extensionFuncs(ctx).qt_glBindRenderbuffer +#define glDeleteRenderbuffers QGLContextPrivate::extensionFuncs(ctx).qt_glDeleteRenderbuffers +#define glGenRenderbuffers QGLContextPrivate::extensionFuncs(ctx).qt_glGenRenderbuffers +#define glRenderbufferStorage QGLContextPrivate::extensionFuncs(ctx).qt_glRenderbufferStorage +#define glGetRenderbufferParameteriv QGLContextPrivate::extensionFuncs(ctx).qt_glGetRenderbufferParameteriv +#define glIsFramebuffer QGLContextPrivate::extensionFuncs(ctx).qt_glIsFramebuffer +#define glBindFramebuffer QGLContextPrivate::extensionFuncs(ctx).qt_glBindFramebuffer +#define glDeleteFramebuffers QGLContextPrivate::extensionFuncs(ctx).qt_glDeleteFramebuffers +#define glGenFramebuffers QGLContextPrivate::extensionFuncs(ctx).qt_glGenFramebuffers +#define glCheckFramebufferStatus QGLContextPrivate::extensionFuncs(ctx).qt_glCheckFramebufferStatus +#define glFramebufferTexture2D QGLContextPrivate::extensionFuncs(ctx).qt_glFramebufferTexture2D +#define glFramebufferRenderbuffer QGLContextPrivate::extensionFuncs(ctx).qt_glFramebufferRenderbuffer +#define glGetFramebufferAttachmentParameteriv QGLContextPrivate::extensionFuncs(ctx).qt_glGetFramebufferAttachmentParameteriv +#define glGenerateMipmap QGLContextPrivate::extensionFuncs(ctx).qt_glGenerateMipmap #endif // QT_OPENGL_ES_2 -#define glBlitFramebufferEXT QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glBlitFramebufferEXT -#define glRenderbufferStorageMultisampleEXT QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glRenderbufferStorageMultisampleEXT +#define glBlitFramebufferEXT QGLContextPrivate::extensionFuncs(ctx).qt_glBlitFramebufferEXT +#define glRenderbufferStorageMultisampleEXT QGLContextPrivate::extensionFuncs(ctx).qt_glRenderbufferStorageMultisampleEXT // Buffer objects #if !defined(QT_OPENGL_ES_2) -#define glBindBuffer QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glBindBuffer -#define glDeleteBuffers QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glDeleteBuffers -#define glGenBuffers QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glGenBuffers -#define glBufferData QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glBufferData +#define glBindBuffer QGLContextPrivate::extensionFuncs(ctx).qt_glBindBuffer +#define glDeleteBuffers QGLContextPrivate::extensionFuncs(ctx).qt_glDeleteBuffers +#define glGenBuffers QGLContextPrivate::extensionFuncs(ctx).qt_glGenBuffers +#define glBufferData QGLContextPrivate::extensionFuncs(ctx).qt_glBufferData #endif -#define glMapBufferARB QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glMapBufferARB -#define glUnmapBufferARB QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glUnmapBufferARB +#define glMapBufferARB QGLContextPrivate::extensionFuncs(ctx).qt_glMapBufferARB +#define glUnmapBufferARB QGLContextPrivate::extensionFuncs(ctx).qt_glUnmapBufferARB // GLSL #if !defined(QT_OPENGL_ES_2) -#define glCreateShader QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glCreateShader -#define glShaderSource QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glShaderSource -#define glShaderBinary QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glShaderBinary -#define glCompileShader QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glCompileShader -#define glDeleteShader QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glDeleteShader -#define glIsShader QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glIsShader - -#define glCreateProgram QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glCreateProgram -#define glAttachShader QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glAttachShader -#define glDetachShader QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glDetachShader -#define glLinkProgram QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glLinkProgram -#define glUseProgram QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glUseProgram -#define glDeleteProgram QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glDeleteProgram -#define glIsProgram QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glIsProgram - -#define glGetShaderInfoLog QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glGetShaderInfoLog -#define glGetShaderiv QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glGetShaderiv -#define glGetShaderSource QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glGetShaderSource -#define glGetProgramiv QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glGetProgramiv -#define glGetProgramInfoLog QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glGetProgramInfoLog - -#define glGetUniformLocation QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glGetUniformLocation -#define glUniform4fv QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glUniform4fv -#define glUniform3fv QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glUniform3fv -#define glUniform2fv QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glUniform2fv -#define glUniform1fv QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glUniform1fv -#define glUniform1i QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glUniform1i -#define glUniform1iv QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glUniform1iv -#define glUniformMatrix2fv QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glUniformMatrix2fv -#define glUniformMatrix3fv QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glUniformMatrix3fv -#define glUniformMatrix4fv QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glUniformMatrix4fv -#define glUniformMatrix2x3fv QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glUniformMatrix2x3fv -#define glUniformMatrix2x4fv QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glUniformMatrix2x4fv -#define glUniformMatrix3x2fv QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glUniformMatrix3x2fv -#define glUniformMatrix3x4fv QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glUniformMatrix3x4fv -#define glUniformMatrix4x2fv QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glUniformMatrix4x2fv -#define glUniformMatrix4x3fv QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glUniformMatrix4x3fv - -#define glBindAttribLocation QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glBindAttribLocation -#define glGetAttribLocation QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glGetAttribLocation -#define glVertexAttrib1fv QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glVertexAttrib1fv -#define glVertexAttrib2fv QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glVertexAttrib2fv -#define glVertexAttrib3fv QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glVertexAttrib3fv -#define glVertexAttrib4fv QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glVertexAttrib4fv -#define glVertexAttribPointer QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glVertexAttribPointer -#define glDisableVertexAttribArray QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glDisableVertexAttribArray -#define glEnableVertexAttribArray QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glEnableVertexAttribArray +#define glCreateShader QGLContextPrivate::extensionFuncs(ctx).qt_glCreateShader +#define glShaderSource QGLContextPrivate::extensionFuncs(ctx).qt_glShaderSource +#define glShaderBinary QGLContextPrivate::extensionFuncs(ctx).qt_glShaderBinary +#define glCompileShader QGLContextPrivate::extensionFuncs(ctx).qt_glCompileShader +#define glDeleteShader QGLContextPrivate::extensionFuncs(ctx).qt_glDeleteShader +#define glIsShader QGLContextPrivate::extensionFuncs(ctx).qt_glIsShader + +#define glCreateProgram QGLContextPrivate::extensionFuncs(ctx).qt_glCreateProgram +#define glAttachShader QGLContextPrivate::extensionFuncs(ctx).qt_glAttachShader +#define glDetachShader QGLContextPrivate::extensionFuncs(ctx).qt_glDetachShader +#define glLinkProgram QGLContextPrivate::extensionFuncs(ctx).qt_glLinkProgram +#define glUseProgram QGLContextPrivate::extensionFuncs(ctx).qt_glUseProgram +#define glDeleteProgram QGLContextPrivate::extensionFuncs(ctx).qt_glDeleteProgram +#define glIsProgram QGLContextPrivate::extensionFuncs(ctx).qt_glIsProgram + +#define glGetShaderInfoLog QGLContextPrivate::extensionFuncs(ctx).qt_glGetShaderInfoLog +#define glGetShaderiv QGLContextPrivate::extensionFuncs(ctx).qt_glGetShaderiv +#define glGetShaderSource QGLContextPrivate::extensionFuncs(ctx).qt_glGetShaderSource +#define glGetProgramiv QGLContextPrivate::extensionFuncs(ctx).qt_glGetProgramiv +#define glGetProgramInfoLog QGLContextPrivate::extensionFuncs(ctx).qt_glGetProgramInfoLog + +#define glGetUniformLocation QGLContextPrivate::extensionFuncs(ctx).qt_glGetUniformLocation +#define glUniform4fv QGLContextPrivate::extensionFuncs(ctx).qt_glUniform4fv +#define glUniform3fv QGLContextPrivate::extensionFuncs(ctx).qt_glUniform3fv +#define glUniform2fv QGLContextPrivate::extensionFuncs(ctx).qt_glUniform2fv +#define glUniform1fv QGLContextPrivate::extensionFuncs(ctx).qt_glUniform1fv +#define glUniform1i QGLContextPrivate::extensionFuncs(ctx).qt_glUniform1i +#define glUniform1iv QGLContextPrivate::extensionFuncs(ctx).qt_glUniform1iv +#define glUniformMatrix2fv QGLContextPrivate::extensionFuncs(ctx).qt_glUniformMatrix2fv +#define glUniformMatrix3fv QGLContextPrivate::extensionFuncs(ctx).qt_glUniformMatrix3fv +#define glUniformMatrix4fv QGLContextPrivate::extensionFuncs(ctx).qt_glUniformMatrix4fv +#define glUniformMatrix2x3fv QGLContextPrivate::extensionFuncs(ctx).qt_glUniformMatrix2x3fv +#define glUniformMatrix2x4fv QGLContextPrivate::extensionFuncs(ctx).qt_glUniformMatrix2x4fv +#define glUniformMatrix3x2fv QGLContextPrivate::extensionFuncs(ctx).qt_glUniformMatrix3x2fv +#define glUniformMatrix3x4fv QGLContextPrivate::extensionFuncs(ctx).qt_glUniformMatrix3x4fv +#define glUniformMatrix4x2fv QGLContextPrivate::extensionFuncs(ctx).qt_glUniformMatrix4x2fv +#define glUniformMatrix4x3fv QGLContextPrivate::extensionFuncs(ctx).qt_glUniformMatrix4x3fv + +#define glBindAttribLocation QGLContextPrivate::extensionFuncs(ctx).qt_glBindAttribLocation +#define glGetAttribLocation QGLContextPrivate::extensionFuncs(ctx).qt_glGetAttribLocation +#define glVertexAttrib1fv QGLContextPrivate::extensionFuncs(ctx).qt_glVertexAttrib1fv +#define glVertexAttrib2fv QGLContextPrivate::extensionFuncs(ctx).qt_glVertexAttrib2fv +#define glVertexAttrib3fv QGLContextPrivate::extensionFuncs(ctx).qt_glVertexAttrib3fv +#define glVertexAttrib4fv QGLContextPrivate::extensionFuncs(ctx).qt_glVertexAttrib4fv +#define glVertexAttribPointer QGLContextPrivate::extensionFuncs(ctx).qt_glVertexAttribPointer +#define glDisableVertexAttribArray QGLContextPrivate::extensionFuncs(ctx).qt_glDisableVertexAttribArray +#define glEnableVertexAttribArray QGLContextPrivate::extensionFuncs(ctx).qt_glEnableVertexAttribArray #else // QT_OPENGL_ES_2 -#define glGetProgramBinaryOES QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glGetProgramBinaryOES -#define glProgramBinaryOES QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glProgramBinaryOES +#define glGetProgramBinaryOES QGLContextPrivate::extensionFuncs(ctx).qt_glGetProgramBinaryOES +#define glProgramBinaryOES QGLContextPrivate::extensionFuncs(ctx).qt_glProgramBinaryOES #endif // QT_OPENGL_ES_2 #if !defined(QT_OPENGL_ES_2) -#define glStencilOpSeparate QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glStencilOpSeparate +#define glStencilOpSeparate QGLContextPrivate::extensionFuncs(ctx).qt_glStencilOpSeparate #endif #if defined(QT_OPENGL_ES_2) diff --git a/src/opengl/qglshaderprogram.cpp b/src/opengl/qglshaderprogram.cpp index 6e8474c..61d8b10 100644 --- a/src/opengl/qglshaderprogram.cpp +++ b/src/opengl/qglshaderprogram.cpp @@ -246,10 +246,10 @@ QT_BEGIN_NAMESPACE #define GL_NUM_SHADER_BINARY_FORMATS 0x8DF9 #endif -inline bool qt_check_sharing_with_current_context(QGLContextGroupResources *group) +inline bool qt_check_sharing_with_current_context(QGLContextGroup *group) { const QGLContext *context = QGLContext::currentContext(); - return context && QGLContextPrivate::qt_get_context_group(context) == group; + return context && QGLContextPrivate::contextGroup(context) == group; } class QGLShaderPrivate @@ -265,7 +265,7 @@ public: { } - QGLContextGroupResources *ctx; + QGLContextGroup *ctx; GLuint shader; QGLShader::ShaderType shaderType; bool compiled; @@ -284,7 +284,7 @@ bool QGLShaderPrivate::create(const QGLContext *context) context = QGLContext::currentContext(); if (!context) return false; - ctx = QGLContextPrivate::qt_get_context_group(context); + ctx = QGLContextPrivate::contextGroup(context); if (isPartial) return true; if (qt_resolve_glsl_extensions(const_cast(context))) { @@ -367,7 +367,7 @@ QGLShader::QGLShader d = new QGLShaderPrivate(type); if (d->create(QGLContext::currentContext()) && !compileFile(fileName)) { if (d->shader) { - QGLContextGroupResources *ctx = d->ctx; + QGLContextGroup *ctx = d->ctx; glDeleteShader(d->shader); } d->shader = 0; @@ -421,7 +421,7 @@ QGLShader::QGLShader #endif if (d->create(context) && !compileFile(fileName)) { if (d->shader) { - QGLContextGroupResources *ctx = d->ctx; + QGLContextGroup *ctx = d->ctx; glDeleteShader(d->shader); } d->shader = 0; @@ -436,7 +436,7 @@ QGLShader::QGLShader QGLShader::~QGLShader() { if (d->shader) { - QGLContextGroupResources *ctx = d->ctx; + QGLContextGroup *ctx = d->ctx; #ifndef QT_NO_DEBUG if (!qt_check_sharing_with_current_context(ctx)) qWarning("QGLShader::~QGLShader: Shader is not associated with current context."); @@ -510,7 +510,7 @@ bool QGLShader::compile(const char *source) src.append(redefineHighp); #endif src.append(source); - QGLContextGroupResources *ctx = d->ctx; + QGLContextGroup *ctx = d->ctx; glShaderSource(d->shader, src.size(), src.data(), 0); return d->compile(this); } else { @@ -593,7 +593,7 @@ bool QGLShader::compileFile(const QString& fileName) */ bool QGLShader::setShaderBinary(GLenum format, const void *binary, int length) { - QGLContextGroupResources *ctx = d->ctx; + QGLContextGroup *ctx = d->ctx; #ifndef QT_NO_DEBUG if (!qt_check_sharing_with_current_context(ctx)) { qWarning("QGLShader::setShaderBinary: Shader is not associated with current context."); @@ -633,7 +633,7 @@ bool QGLShader::setShaderBinary(GLenum format, const void *binary, int length) bool QGLShader::setShaderBinary (QGLShader& otherShader, GLenum format, const void *binary, int length) { - QGLContextGroupResources *ctx = d->ctx; + QGLContextGroup *ctx = d->ctx; #ifndef QT_NO_DEBUG if (!qt_check_sharing_with_current_context(ctx)) { qWarning("QGLShader::setShaderBinary: Shader is not associated with current context."); @@ -699,7 +699,7 @@ QByteArray QGLShader::sourceCode() const if (!d->shader) return QByteArray(); GLint size = 0; - QGLContextGroupResources *ctx = d->ctx; + QGLContextGroup *ctx = d->ctx; glGetShaderiv(d->shader, GL_SHADER_SOURCE_LENGTH, &size); if (size <= 0) return QByteArray(); @@ -749,7 +749,7 @@ class QGLShaderProgramPrivate { public: QGLShaderProgramPrivate(const QGLContext *context) - : ctx(context ? QGLContextPrivate::qt_get_context_group(context) : 0) + : ctx(context ? QGLContextPrivate::contextGroup(context) : 0) , program(0) , linked(false) , inited(false) @@ -761,7 +761,7 @@ public: } ~QGLShaderProgramPrivate(); - QGLContextGroupResources *ctx; + QGLContextGroup *ctx; GLuint program; bool linked; bool inited; @@ -832,7 +832,7 @@ bool QGLShaderProgram::init() if (!context) return false; if (!d->ctx) - d->ctx = QGLContextPrivate::qt_get_context_group(context); + d->ctx = QGLContextPrivate::contextGroup(context); #ifndef QT_NO_DEBUG else if (!qt_check_sharing_with_current_context(d->ctx)) { qWarning("QGLShaderProgram: Shader program is not associated with current context."); @@ -840,7 +840,7 @@ bool QGLShaderProgram::init() } #endif if (qt_resolve_glsl_extensions(const_cast(context))) { - QGLContextGroupResources *ctx = d->ctx; + QGLContextGroup *ctx = d->ctx; d->program = glCreateProgram(); if (!(d->program)) { qWarning() << "QGLShaderProgram: could not create shader program"; @@ -886,7 +886,7 @@ bool QGLShaderProgram::addShader(QGLShader *shader) if (!shader->d->isPartial) { if (!shader->d->shader) return false; - QGLContextGroupResources *ctx = d->ctx; + QGLContextGroup *ctx = d->ctx; glAttachShader(d->program, shader->d->shader); } else { d->hasPartialShaders = true; @@ -999,7 +999,7 @@ bool QGLShaderProgram::addShaderFromFile void QGLShaderProgram::removeShader(QGLShader *shader) { if (d->program && shader && shader->d->shader) { - QGLContextGroupResources *ctx = d->ctx; + QGLContextGroup *ctx = d->ctx; #ifndef QT_NO_DEBUG if (!qt_check_sharing_with_current_context(ctx)) qWarning("QGLShaderProgram::removeShader: Program is not associated with current context."); @@ -1037,7 +1037,7 @@ QList QGLShaderProgram::shaders() const void QGLShaderProgram::removeAllShaders() { d->removingShaders = true; - QGLContextGroupResources *ctx = d->ctx; + QGLContextGroup *ctx = d->ctx; #ifndef QT_NO_DEBUG if (!qt_check_sharing_with_current_context(ctx)) qWarning("QGLShaderProgram::removeAllShaders: Program is not associated with current context."); @@ -1193,7 +1193,7 @@ bool QGLShaderProgram::link() { if (!d->program) return false; - QGLContextGroupResources *ctx = d->ctx; + QGLContextGroup *ctx = d->ctx; #ifndef QT_NO_DEBUG if (!qt_check_sharing_with_current_context(ctx)) { qWarning("QGLShaderProgram::link: Program is not associated with current context."); @@ -1303,7 +1303,7 @@ bool QGLShaderProgram::enable() return false; if (!d->linked && !link()) return false; - QGLContextGroupResources *ctx = d->ctx; + QGLContextGroup *ctx = d->ctx; #ifndef QT_NO_DEBUG if (!qt_check_sharing_with_current_context(ctx)) { qWarning("QGLShaderProgram::enable: Program is not associated with current context."); -- cgit v0.12 From 6afcce6781845a2dfea1f78ddb4259b90c587e0d Mon Sep 17 00:00:00 2001 From: Kim Motoyoshi Kalland Date: Mon, 31 Aug 2009 17:40:15 +0200 Subject: Remove unused variable in GL2 engine. Reviewed-by: Trust Me --- src/opengl/qgl_p.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/opengl/qgl_p.h b/src/opengl/qgl_p.h index dceb3f5..517cdb3 100644 --- a/src/opengl/qgl_p.h +++ b/src/opengl/qgl_p.h @@ -298,7 +298,7 @@ public: #if defined(Q_WS_X11) || defined(Q_WS_MAC) || defined(Q_WS_QWS) static QGLExtensionFuncs qt_extensionFuncs; static inline QGLExtensionFuncs& extensionFuncs(const QGLContext *) { return qt_extensionFuncs; } - static inline QGLExtensionFuncs& extensionFuncs(QGLContextGroup *ctx) { return qt_extensionFuncs; } + static inline QGLExtensionFuncs& extensionFuncs(QGLContextGroup *) { return qt_extensionFuncs; } #endif QPixmapFilter *createPixmapFilter(int type) const; -- cgit v0.12 From 06a4cdba05e4865d02a09a5633c31c462ac00014 Mon Sep 17 00:00:00 2001 From: Kim Motoyoshi Kalland Date: Mon, 31 Aug 2009 17:42:50 +0200 Subject: Fixed initialization order in QGLContextGroup constructor. Reviewed-by: Trond --- src/opengl/qgl_p.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/opengl/qgl_p.h b/src/opengl/qgl_p.h index 517cdb3..a39c52c 100644 --- a/src/opengl/qgl_p.h +++ b/src/opengl/qgl_p.h @@ -203,7 +203,7 @@ public: QGLExtensionFuncs &extensionFuncs() {return m_extensionFuncs;} const QGLContext *context() const {return m_context;} private: - QGLContextGroup(const QGLContext *context) : m_refs(1), m_context(context) { } + QGLContextGroup(const QGLContext *context) : m_context(context), m_refs(1) { } QGLExtensionFuncs m_extensionFuncs; const QGLContext *m_context; // context group's representative -- cgit v0.12 From e70980b2aacbc758a0cd1e2246633278f7c505ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Mon, 31 Aug 2009 17:05:51 +0200 Subject: Refactoring qatomic_windows.h Consolidated Interlocked* declarations and API implementation through macro hackery, (hopefully) for improved readability and maintainability. Fixes anti-aliasing warnings with MinGW in qatomic_windows.h. Gcc builds now use inline assembly for atomic operations, instead of relying on Interlocked* functions which aren't consistently declared across implementations (mingw32, mingw-w64, wine... others?). Drops support for VC 6 and MetroWerks. Reviewed-by: Thiago Macieira --- src/corelib/arch/arch.pri | 3 + src/corelib/arch/qatomic_windows.h | 558 ++++++++++------------- src/corelib/thread/qbasicatomic.h | 15 + tests/auto/qatomicint/tst_qatomicint.cpp | 44 ++ tests/auto/qatomicpointer/tst_qatomicpointer.cpp | 48 ++ 5 files changed, 345 insertions(+), 323 deletions(-) diff --git a/src/corelib/arch/arch.pri b/src/corelib/arch/arch.pri index a25027b..57bc80a 100644 --- a/src/corelib/arch/arch.pri +++ b/src/corelib/arch/arch.pri @@ -1,6 +1,9 @@ win32:HEADERS += arch/qatomic_windows.h \ arch/qatomic_generic.h +win32-g++*:HEADERS += arch/qatomic_i386.h \ + arch/qatomic_x86_64.h + mac:HEADERS += arch/qatomic_macosx.h \ arch/qatomic_generic.h diff --git a/src/corelib/arch/qatomic_windows.h b/src/corelib/arch/qatomic_windows.h index a826bd3..50dedc1 100644 --- a/src/corelib/arch/qatomic_windows.h +++ b/src/corelib/arch/qatomic_windows.h @@ -42,6 +42,195 @@ #ifndef QATOMIC_WINDOWS_H #define QATOMIC_WINDOWS_H +#ifndef Q_CC_MSVC + +// Mingw and other GCC platforms get inline assembly + +# ifdef __i386__ +# include "QtCore/qatomic_i386.h" +# else +# include "QtCore/qatomic_x86_64.h" +# endif + +#else // Q_CC_MSVC + +//////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef Q_OS_WINCE + +// use compiler intrinsics for all atomic functions +# define QT_INTERLOCKED_PREFIX _ +# define QT_INTERLOCKED_PROTOTYPE __cdecl +# define QT_INTERLOCKED_DECLARE_PROTOTYPES +# define QT_INTERLOCKED_INTRINSIC + +#else // Q_OS_WINCE + +# if _WIN32_WCE < 0x600 && defined(_X86_) +// For X86 Windows CE, include winbase.h to catch inline functions which +// overwrite the regular definitions inside of coredll.dll. +// Though one could use the original version of Increment/Decrement, others are +// not exported at all. +# include + +// It's safer to remove the volatile and let the compiler add it as needed. +# define QT_INTERLOCKED_NO_VOLATILE + +# else // _WIN32_WCE >= 0x600 || _X86_ + +# define QT_INTERLOCKED_PROTOTYPE __cdecl +# define QT_INTERLOCKED_DECLARE_PROTOTYPES + +# if _WIN32_WCE >= 0x600 && defined(_X86_) +# define QT_INTERLOCKED_PREFIX _ +# define QT_INTERLOCKED_INTRINSIC +# else +# define QT_INTERLOCKED_NO_VOLATILE +# endif + +# endif // _WIN32_WCE >= 0x600 || _X86_ + +#endif // Q_OS_WINCE + +//////////////////////////////////////////////////////////////////////////////////////////////////// +// Prototype declaration + +#define QT_INTERLOCKED_CONCAT_I(prefix, suffix) \ + prefix ## suffix +#define QT_INTERLOCKED_CONCAT(prefix, suffix) \ + QT_INTERLOCKED_CONCAT_I(prefix, suffix) + +// MSVC intrinsics prefix function names with an underscore +#define QT_INTERLOCKED_FUNCTION(name) \ + QT_INTERLOCKED_CONCAT(QT_INTERLOCKED_PREFIX, name) + +#ifdef QT_INTERLOCKED_NO_VOLATILE +# define QT_INTERLOCKED_VOLATILE +# define QT_INTERLOCKED_REMOVE_VOLATILE(a) qt_interlocked_remove_volatile(a) +#else +# define QT_INTERLOCKED_VOLATILE volatile +# define QT_INTERLOCKED_REMOVE_VOLATILE(a) a +#endif + +#ifndef QT_INTERLOCKED_PREFIX +#define QT_INTERLOCKED_PREFIX +#endif + +#ifndef QT_INTERLOCKED_PROTOTYPE +#define QT_INTERLOCKED_PROTOTYPE +#endif + +#ifdef QT_INTERLOCKED_DECLARE_PROTOTYPES +#undef QT_INTERLOCKED_DECLARE_PROTOTYPES + +extern "C" { + + long QT_INTERLOCKED_PROTOTYPE QT_INTERLOCKED_FUNCTION( InterlockedIncrement )(long QT_INTERLOCKED_VOLATILE *); + long QT_INTERLOCKED_PROTOTYPE QT_INTERLOCKED_FUNCTION( InterlockedDecrement )(long QT_INTERLOCKED_VOLATILE *); + long QT_INTERLOCKED_PROTOTYPE QT_INTERLOCKED_FUNCTION( InterlockedCompareExchange )(long QT_INTERLOCKED_VOLATILE *, long, long); + long QT_INTERLOCKED_PROTOTYPE QT_INTERLOCKED_FUNCTION( InterlockedExchange )(long QT_INTERLOCKED_VOLATILE *, long); + long QT_INTERLOCKED_PROTOTYPE QT_INTERLOCKED_FUNCTION( InterlockedExchangeAdd )(long QT_INTERLOCKED_VOLATILE *, long); + +# if !defined(__i386__) && !defined(_M_IX86) + long QT_INTERLOCKED_FUNCTION( InterlockedCompareExchangePointer )(void * QT_INTERLOCKED_VOLATILE *, void *, void *); + long QT_INTERLOCKED_FUNCTION( InterlockedExchangePointer )(void * QT_INTERLOCKED_VOLATILE *, void *); + __int64 QT_INTERLOCKED_FUNCTION( InterlockedExchangeAdd64 )(__int64 QT_INTERLOCKED_VOLATILE *, long); +# endif + +} + +#endif // QT_INTERLOCKED_DECLARE_PROTOTYPES + +#undef QT_INTERLOCKED_PROTOTYPE +#undef QT_INTERLOCKED_VOLATILE + +//////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef QT_INTERLOCKED_INTRINSIC +#undef QT_INTERLOCKED_INTRINSIC + +# pragma intrinsic (_InterlockedIncrement) +# pragma intrinsic (_InterlockedDecrement) +# pragma intrinsic (_InterlockedExchange) +# pragma intrinsic (_InterlockedCompareExchange) +# pragma intrinsic (_InterlockedExchangeAdd) + +# ifndef _M_IX86 +# pragma intrinsic (_InterlockedCompareExchangePointer) +# pragma intrinsic (_InterlockedExchangePointer) +# pragma intrinsic (_InterlockedExchangeAdd64) +# endif + +#endif // QT_INTERLOCKED_INTRINSIC + +//////////////////////////////////////////////////////////////////////////////////////////////////// +// Interlocked* replacement macros + +#define QT_INTERLOCKED_INCREMENT(value) \ + QT_INTERLOCKED_FUNCTION(InterlockedIncrement)( \ + QT_INTERLOCKED_REMOVE_VOLATILE( value ) ) + +#define QT_INTERLOCKED_DECREMENT(value) \ + QT_INTERLOCKED_FUNCTION(InterlockedDecrement)( \ + QT_INTERLOCKED_REMOVE_VOLATILE( value ) ) + +#define QT_INTERLOCKED_COMPARE_EXCHANGE(value, newValue, expectedValue) \ + QT_INTERLOCKED_FUNCTION(InterlockedCompareExchange)( \ + QT_INTERLOCKED_REMOVE_VOLATILE( value ), \ + newValue, \ + expectedValue ) + +#define QT_INTERLOCKED_EXCHANGE(value, newValue) \ + QT_INTERLOCKED_FUNCTION(InterlockedExchange)( \ + QT_INTERLOCKED_REMOVE_VOLATILE( value ), \ + newValue ) + +#define QT_INTERLOCKED_EXCHANGE_ADD(value, valueToAdd) \ + QT_INTERLOCKED_FUNCTION(InterlockedExchangeAdd)( \ + QT_INTERLOCKED_REMOVE_VOLATILE( value ), \ + valueToAdd ) + +#if defined(__i386__) || defined(_M_IX86) + +# define QT_INTERLOCKED_COMPARE_EXCHANGE_POINTER(value, newValue, expectedValue) \ + reinterpret_cast( \ + QT_INTERLOCKED_FUNCTION(InterlockedCompareExchange)( \ + QT_INTERLOCKED_REMOVE_VOLATILE( value ## _integral ), \ + (long)( newValue ), \ + (long)( expectedValue ) )) + +# define QT_INTERLOCKED_EXCHANGE_POINTER(value, newValue) \ + QT_INTERLOCKED_FUNCTION(InterlockedExchange)( \ + QT_INTERLOCKED_REMOVE_VOLATILE( value ## _integral ), \ + (quintptr)( newValue ) ) + +# define QT_INTERLOCKED_EXCHANGE_ADD_POINTER(value, valueToAdd) \ + QT_INTERLOCKED_FUNCTION(InterlockedExchangeAdd)( \ + QT_INTERLOCKED_REMOVE_VOLATILE( value ## _integral ), \ + valueToAdd ) + +#else // !defined(__i386__) && !defined(_M_IX86) + +# define QT_INTERLOCKED_COMPARE_EXCHANGE_POINTER(value, newValue, expectedValue) \ + QT_INTERLOCKED_FUNCTION(InterlockedCompareExchangePointer)( \ + QT_INTERLOCKED_REMOVE_VOLATILE( value ), \ + newValue, \ + expectedValue ) + +# define QT_INTERLOCKED_EXCHANGE_POINTER(value, newValue) \ + QT_INTERLOCKED_FUNCTION(InterlockedExchangePointer)( \ + QT_INTERLOCKED_REMOVE_VOLATILE( value ), \ + newValue ) + +# define QT_INTERLOCKED_EXCHANGE_ADD_POINTER(value, valueToAdd) \ + QT_INTERLOCKED_FUNCTION(InterlockedExchangeAdd64)( \ + QT_INTERLOCKED_REMOVE_VOLATILE( value ## _integral ), \ + valueToAdd ) + +#endif // !defined(__i386__) && !defined(_M_IX86) + +//////////////////////////////////////////////////////////////////////////////////////////////////// + QT_BEGIN_HEADER QT_BEGIN_NAMESPACE @@ -107,369 +296,68 @@ template Q_INLINE_TEMPLATE bool QBasicAtomicPointer::isFetchAndAddWaitFree() { return true; } -#if defined(Q_CC_MSVC) || defined(Q_CC_MWERKS) - -// MSVC++ 6.0 doesn't generate correct code when optimizations are turned on! -#if _MSC_VER < 1300 && defined (_M_IX86) - -inline bool QBasicAtomicInt::ref() -{ - volatile int *pointer = &_q_value; - unsigned char retVal; - __asm { - mov ECX,pointer - lock inc DWORD ptr[ECX] - setne retVal - } - return retVal != 0; -} - -inline bool QBasicAtomicInt::deref() -{ - volatile int *pointer = &_q_value; - unsigned char retVal; - __asm { - mov ECX,pointer - lock dec DWORD ptr[ECX] - setne retVal - } - return retVal != 0; -} - -inline bool QBasicAtomicInt::testAndSetOrdered(int expectedValue, int newValue) -{ - volatile int *pointer = &_q_value; - __asm { - mov EDX,pointer - mov EAX,expectedValue - mov ECX,newValue - lock cmpxchg dword ptr[EDX],ECX - mov newValue,EAX - } - return newValue == expectedValue; -} - - -inline int QBasicAtomicInt::fetchAndStoreOrdered(int newValue) -{ - volatile int *pointer = &_q_value; - __asm { - mov EDX,pointer - mov ECX,newValue - lock xchg dword ptr[EDX],ECX - mov newValue,ECX - } - return newValue; -} - - -inline int QBasicAtomicInt::fetchAndAddOrdered(int valueToAdd) -{ - volatile int *pointer = &_q_value; - __asm { - mov EDX,pointer - mov ECX,valueToAdd - lock xadd dword ptr[EDX],ECX - mov valueToAdd,ECX - } - return valueToAdd; -} +//////////////////////////////////////////////////////////////////////////////////////////////////// -template -Q_INLINE_TEMPLATE bool QBasicAtomicPointer::testAndSetOrdered(T *expectedValue, T *newValue) -{ - volatile void *pointer = &_q_value; - __asm { - mov EDX,pointer - mov EAX,expectedValue - mov ECX,newValue - lock cmpxchg dword ptr[EDX],ECX - mov newValue,EAX - } - return newValue == expectedValue; -} - -template -Q_INLINE_TEMPLATE T *QBasicAtomicPointer::fetchAndStoreOrdered(T *newValue) -{ - volatile void *pointer = &_q_value; - __asm { - mov EDX,pointer - mov ECX,newValue - lock xchg dword ptr[EDX],ECX - mov newValue,ECX - } - return reinterpret_cast(newValue); -} - -template -Q_INLINE_TEMPLATE T *QBasicAtomicPointer::fetchAndAddOrdered(qptrdiff valueToAdd) +#ifdef QT_INTERLOCKED_NO_VOLATILE +template +Q_INLINE_TEMPLATE T *qt_interlocked_remove_volatile(T volatile *t) { - volatile void *pointer = &_q_value; - valueToAdd *= sizeof(T); - __asm { - mov EDX,pointer - mov ECX,valueToAdd - lock xadd dword ptr[EDX],ECX - mov pointer,ECX - } - return reinterpret_cast(const_cast(pointer)); + return const_cast(t); } +#endif // !QT_INTERLOCKED_NO_VOLATILE -#else - -#if !defined(Q_OS_WINCE) && !defined(Q_CC_MWERKS) -// use compiler intrinsics for all atomic functions -//those functions need to be define in the global namespace -QT_END_NAMESPACE - -extern "C" { - long __cdecl _InterlockedIncrement(volatile long *); - long __cdecl _InterlockedDecrement(volatile long *); - long __cdecl _InterlockedExchange(volatile long *, long); - long __cdecl _InterlockedCompareExchange(volatile long *, long, long); - long __cdecl _InterlockedExchangeAdd(volatile long *, long); -} -# pragma intrinsic (_InterlockedIncrement) -# pragma intrinsic (_InterlockedDecrement) -# pragma intrinsic (_InterlockedExchange) -# pragma intrinsic (_InterlockedCompareExchange) -# pragma intrinsic (_InterlockedExchangeAdd) - -# ifndef _M_IX86 -extern "C" { - void *_InterlockedCompareExchangePointer(void * volatile *, void *, void *); - void *_InterlockedExchangePointer(void * volatile *, void *); - __int64 _InterlockedExchangeAdd64(__int64 volatile * Addend, __int64 Value); -} -# pragma intrinsic (_InterlockedCompareExchangePointer) -# pragma intrinsic (_InterlockedExchangePointer) -# pragma intrinsic (_InterlockedExchangeAdd64) -# define _InterlockedExchangeAddPointer(a,b) \ - _InterlockedExchangeAdd64(reinterpret_cast(a), __int64(b)) -# else -# define _InterlockedCompareExchangePointer(a,b,c) \ - _InterlockedCompareExchange(reinterpret_cast(a), long(b), long(c)) -# define _InterlockedExchangePointer(a, b) \ - _InterlockedExchange(reinterpret_cast(a), long(b)) -# define _InterlockedExchangeAddPointer(a,b) \ - _InterlockedExchangeAdd(reinterpret_cast(a), long(b)) -# endif - -QT_BEGIN_NAMESPACE +//////////////////////////////////////////////////////////////////////////////////////////////////// inline bool QBasicAtomicInt::ref() { - return _InterlockedIncrement(reinterpret_cast(&_q_value)) != 0; + return QT_INTERLOCKED_INCREMENT(&_q_value) != 0; } inline bool QBasicAtomicInt::deref() { - return _InterlockedDecrement(reinterpret_cast(&_q_value)) != 0; + return QT_INTERLOCKED_DECREMENT(&_q_value) != 0; } inline bool QBasicAtomicInt::testAndSetOrdered(int expectedValue, int newValue) { - return _InterlockedCompareExchange(reinterpret_cast(&_q_value), newValue, expectedValue) == expectedValue; + return QT_INTERLOCKED_COMPARE_EXCHANGE(&_q_value, newValue, expectedValue) + == expectedValue; } inline int QBasicAtomicInt::fetchAndStoreOrdered(int newValue) { - return _InterlockedExchange(reinterpret_cast(&_q_value), newValue); + return QT_INTERLOCKED_EXCHANGE(&_q_value, newValue); } inline int QBasicAtomicInt::fetchAndAddOrdered(int valueToAdd) { - return _InterlockedExchangeAdd(reinterpret_cast(&_q_value), valueToAdd); + return QT_INTERLOCKED_EXCHANGE_ADD(&_q_value, valueToAdd); } -#if defined(Q_CC_MSVC) -#pragma warning( push ) -#pragma warning( disable : 4311 ) // ignoring the warning from /Wp64 -#endif +//////////////////////////////////////////////////////////////////////////////////////////////////// template Q_INLINE_TEMPLATE bool QBasicAtomicPointer::testAndSetOrdered(T *expectedValue, T *newValue) { - return (_InterlockedCompareExchangePointer(reinterpret_cast(&_q_value), - newValue, expectedValue) == -#ifndef _M_IX86 - (void *) -#else - (long) -#endif - (expectedValue)); -} - -#if defined(Q_CC_MSVC) -#pragma warning( pop ) -#endif - -template -Q_INLINE_TEMPLATE T *QBasicAtomicPointer::fetchAndStoreOrdered(T *newValue) -{ - return reinterpret_cast(_InterlockedExchangePointer(reinterpret_cast(&_q_value), newValue)); + return QT_INTERLOCKED_COMPARE_EXCHANGE_POINTER(&_q_value, newValue, expectedValue) + == expectedValue; } template -Q_INLINE_TEMPLATE T *QBasicAtomicPointer::fetchAndAddOrdered(qptrdiff valueToAdd) -{ - return reinterpret_cast(_InterlockedExchangeAddPointer(reinterpret_cast(&_q_value), valueToAdd * sizeof(T))); -} - -#else // Q_OS_WINCE - -#if (_WIN32_WCE < 0x600 && defined(_X86_)) || defined(Q_CC_MWERKS) -// For X86 Windows CE build we need to include winbase.h to be able -// to catch the inline functions which overwrite the regular -// definitions inside of coredll.dll. Though one could use the -// original version of Increment/Decrement, the others are not -// exported at all. -#include -#else -#if _WIN32_WCE >= 0x600 || defined(Q_CC_MWERKS) -#define Q_ARGUMENT_TYPE volatile -# if defined(_X86_) -# define InterlockedIncrement _InterlockedIncrement -# define InterlockedDecrement _InterlockedDecrement -# define InterlockedExchange _InterlockedExchange -# define InterlockedCompareExchange _InterlockedCompareExchange -# define InterlockedExchangeAdd _InterlockedExchangeAdd -# endif -#else -#define Q_ARGUMENT_TYPE -#endif - -QT_END_NAMESPACE - -extern "C" { -long __cdecl InterlockedIncrement(long Q_ARGUMENT_TYPE * lpAddend); -long __cdecl InterlockedDecrement(long Q_ARGUMENT_TYPE * lpAddend); -long __cdecl InterlockedExchange(long Q_ARGUMENT_TYPE * Target, long Value); -long __cdecl InterlockedCompareExchange(long Q_ARGUMENT_TYPE * Destination, long Exchange, long Comperand); -long __cdecl InterlockedExchangeAdd(long Q_ARGUMENT_TYPE * Addend, long Value); -} - -#if _WIN32_WCE >= 0x600 && defined(_X86_) -# pragma intrinsic (_InterlockedIncrement) -# pragma intrinsic (_InterlockedDecrement) -# pragma intrinsic (_InterlockedExchange) -# pragma intrinsic (_InterlockedCompareExchange) -# pragma intrinsic (_InterlockedExchangeAdd) -#endif - -QT_BEGIN_NAMESPACE - -#endif - - -inline bool QBasicAtomicInt::ref() -{ - return InterlockedIncrement((long*)(&_q_value)) != 0; -} - -inline bool QBasicAtomicInt::deref() -{ - return InterlockedDecrement((long*)(&_q_value)) != 0; -} - -inline bool QBasicAtomicInt::testAndSetOrdered(int expectedValue, int newValue) -{ - return InterlockedCompareExchange((long*)(&_q_value), newValue, expectedValue) == expectedValue; -} - -inline int QBasicAtomicInt::fetchAndStoreOrdered(int newValue) -{ - return InterlockedExchange((long*)(&_q_value), newValue); -} - -inline int QBasicAtomicInt::fetchAndAddOrdered(int valueToAdd) -{ - return InterlockedExchangeAdd((long*)(&_q_value), valueToAdd); -} - -template -Q_INLINE_TEMPLATE bool QBasicAtomicPointer::testAndSetOrdered(T *expectedValue, T *newValue) -{ - return (InterlockedCompareExchange((long*)(&_q_value), - (long)newValue, (long)expectedValue) == - (long)(expectedValue)); -} - -template -Q_INLINE_TEMPLATE T *QBasicAtomicPointer::fetchAndStoreOrdered(T *newValue) +Q_INLINE_TEMPLATE T *QBasicAtomicPointer::fetchAndStoreOrdered(T* newValue) { - return reinterpret_cast(InterlockedExchange((long*)(&_q_value), (long)newValue)); + return reinterpret_cast( + QT_INTERLOCKED_EXCHANGE_POINTER(&_q_value, newValue)); } template Q_INLINE_TEMPLATE T *QBasicAtomicPointer::fetchAndAddOrdered(qptrdiff valueToAdd) { - return reinterpret_cast(InterlockedExchangeAdd((long*)(&_q_value), valueToAdd * sizeof(T))); -} - -#endif //Q_OS_WINCE - -#endif // _MSC_VER ... - -#else - -// __INTERLOCKED_DECLARED is defined in MinGW's winbase.h. Simply, preferrably we use -// MinGW's definition, such that we pick up variations in the headers. -#ifndef __INTERLOCKED_DECLARED -#define __INTERLOCKED_DECLARED -QT_END_NAMESPACE - -extern "C" { - __declspec(dllimport) long __stdcall InterlockedCompareExchange(long *, long, long); - __declspec(dllimport) long __stdcall InterlockedIncrement(long *); - __declspec(dllimport) long __stdcall InterlockedDecrement(long *); - __declspec(dllimport) long __stdcall InterlockedExchange(long *, long); - __declspec(dllimport) long __stdcall InterlockedExchangeAdd(long *, long); -} - -QT_BEGIN_NAMESPACE -#endif - -inline bool QBasicAtomicInt::ref() -{ - return InterlockedIncrement(reinterpret_cast(const_cast(&_q_value))) != 0; -} - -inline bool QBasicAtomicInt::deref() -{ - return InterlockedDecrement(reinterpret_cast(const_cast(&_q_value))) != 0; + return reinterpret_cast( + QT_INTERLOCKED_EXCHANGE_ADD_POINTER(&_q_value, valueToAdd * sizeof(T))); } -inline bool QBasicAtomicInt::testAndSetOrdered(int expectedValue, int newValue) -{ - return InterlockedCompareExchange(reinterpret_cast(const_cast(&_q_value)), newValue, expectedValue) == expectedValue; -} - -inline int QBasicAtomicInt::fetchAndStoreOrdered(int newValue) -{ return InterlockedExchange(reinterpret_cast(const_cast(&_q_value)), newValue); } - -inline int QBasicAtomicInt::fetchAndAddOrdered(int valueToAdd) -{ - return InterlockedExchangeAdd(reinterpret_cast(const_cast(&_q_value)), valueToAdd); -} - -template -Q_INLINE_TEMPLATE bool QBasicAtomicPointer::testAndSetOrdered(T *expectedValue, T* newValue) -{ return InterlockedCompareExchange(reinterpret_cast(const_cast(&_q_value)), - reinterpret_cast(newValue), - reinterpret_cast(expectedValue)) == reinterpret_cast(expectedValue); } - -template -Q_INLINE_TEMPLATE T *QBasicAtomicPointer::fetchAndStoreOrdered(T* newValue) -{ return reinterpret_cast(InterlockedExchange(reinterpret_cast(const_cast(&_q_value)), - reinterpret_cast(newValue))); } - -template -Q_INLINE_TEMPLATE T *QBasicAtomicPointer::fetchAndAddOrdered(qptrdiff valueToAdd) -{ return reinterpret_cast(InterlockedExchangeAdd(reinterpret_cast(const_cast(&_q_value)), valueToAdd * sizeof(T))); } - -#endif // Q_CC_GNU +//////////////////////////////////////////////////////////////////////////////////////////////////// inline bool QBasicAtomicInt::testAndSetRelaxed(int expectedValue, int newValue) { @@ -516,6 +404,8 @@ inline int QBasicAtomicInt::fetchAndAddRelease(int valueToAdd) return fetchAndAddOrdered(valueToAdd); } +//////////////////////////////////////////////////////////////////////////////////////////////////// + template Q_INLINE_TEMPLATE bool QBasicAtomicPointer::testAndSetRelaxed(T *expectedValue, T *newValue) { @@ -570,8 +460,30 @@ Q_INLINE_TEMPLATE T *QBasicAtomicPointer::fetchAndAddRelease(qptrdiff valueTo return fetchAndAddOrdered(valueToAdd); } +//////////////////////////////////////////////////////////////////////////////////////////////////// +// Cleanup + +#undef QT_INTERLOCKED_CONCAT_I +#undef QT_INTERLOCKED_CONCAT +#undef QT_INTERLOCKED_FUNCTION +#undef QT_INTERLOCKED_PREFIX + +#undef QT_INTERLOCKED_NO_VOLATILE +#undef QT_INTERLOCKED_REMOVE_VOLATILE + +#undef QT_INTERLOCKED_INCREMENT +#undef QT_INTERLOCKED_DECREMENT +#undef QT_INTERLOCKED_COMPARE_EXCHANGE +#undef QT_INTERLOCKED_EXCHANGE +#undef QT_INTERLOCKED_EXCHANGE_ADD +#undef QT_INTERLOCKED_COMPARE_EXCHANGE_POINTER +#undef QT_INTERLOCKED_EXCHANGE_POINTER +#undef QT_INTERLOCKED_EXCHANGE_ADD_POINTER + QT_END_NAMESPACE QT_END_HEADER +#endif // Q_CC_MSVC + #endif // QATOMIC_WINDOWS_H diff --git a/src/corelib/thread/qbasicatomic.h b/src/corelib/thread/qbasicatomic.h index e96b4d2..629fb3d 100644 --- a/src/corelib/thread/qbasicatomic.h +++ b/src/corelib/thread/qbasicatomic.h @@ -56,7 +56,13 @@ public: #ifdef QT_ARCH_PARISC int _q_lock[4]; #endif +#if defined(QT_ARCH_WINDOWS) || defined(QT_ARCH_WINDOWSCE) + union { // needed for Q_BASIC_ATOMIC_INITIALIZER + volatile long _q_value; + }; +#else volatile int _q_value; +#endif // Non-atomic API inline bool operator==(int value) const @@ -128,7 +134,14 @@ public: #ifdef QT_ARCH_PARISC int _q_lock[4]; #endif +#if defined(QT_ARCH_WINDOWS) || defined(QT_ARCH_WINDOWSCE) + union { + T * volatile _q_value; + long volatile _q_value_integral; + }; +#else T * volatile _q_value; +#endif // Non-atomic API inline bool operator==(T *value) const @@ -194,6 +207,8 @@ public: #ifdef QT_ARCH_PARISC # define Q_BASIC_ATOMIC_INITIALIZER(a) {{-1,-1,-1,-1},(a)} +#elif defined(QT_ARCH_WINDOWS) || defined(QT_ARCH_WINDOWSCE) +# define Q_BASIC_ATOMIC_INITIALIZER(a) { {(a)} } #else # define Q_BASIC_ATOMIC_INITIALIZER(a) { (a) } #endif diff --git a/tests/auto/qatomicint/tst_qatomicint.cpp b/tests/auto/qatomicint/tst_qatomicint.cpp index c3ea31d..5fde633 100644 --- a/tests/auto/qatomicint/tst_qatomicint.cpp +++ b/tests/auto/qatomicint/tst_qatomicint.cpp @@ -59,6 +59,8 @@ public: ~tst_QAtomicInt(); private slots: + void warningFree(); + // QAtomicInt members void constructor_data(); void constructor(); @@ -101,6 +103,9 @@ private slots: void testAndSet_loop(); void fetchAndAdd_loop(); void fetchAndAdd_threadedLoop(); + +private: + static void warningFreeHelper(); }; tst_QAtomicInt::tst_QAtomicInt() @@ -109,6 +114,45 @@ tst_QAtomicInt::tst_QAtomicInt() tst_QAtomicInt::~tst_QAtomicInt() { } +void tst_QAtomicInt::warningFreeHelper() +{ + Q_ASSERT(false); + // The code below is bogus, and shouldn't be run. We're looking for warnings, only. + + QBasicAtomicInt i = Q_BASIC_ATOMIC_INITIALIZER(0); + + int expectedValue = 0; + int newValue = 0; + int valueToAdd = 0; + + i.ref(); + i.deref(); + + i.testAndSetRelaxed(expectedValue, newValue); + i.testAndSetAcquire(expectedValue, newValue); + i.testAndSetRelease(expectedValue, newValue); + i.testAndSetOrdered(expectedValue, newValue); + + i.fetchAndStoreRelaxed(newValue); + i.fetchAndStoreAcquire(newValue); + i.fetchAndStoreRelease(newValue); + i.fetchAndStoreOrdered(newValue); + + i.fetchAndAddRelaxed(valueToAdd); + i.fetchAndAddAcquire(valueToAdd); + i.fetchAndAddRelease(valueToAdd); + i.fetchAndAddOrdered(valueToAdd); +} + +void tst_QAtomicInt::warningFree() +{ + // This is a compile time check for warnings. + // No need for actual work here. + + void (*foo)() = &warningFreeHelper; + (void)foo; +} + void tst_QAtomicInt::constructor_data() { QTest::addColumn("value"); diff --git a/tests/auto/qatomicpointer/tst_qatomicpointer.cpp b/tests/auto/qatomicpointer/tst_qatomicpointer.cpp index b9636a0..c1e0efd 100644 --- a/tests/auto/qatomicpointer/tst_qatomicpointer.cpp +++ b/tests/auto/qatomicpointer/tst_qatomicpointer.cpp @@ -58,6 +58,8 @@ public: ~tst_QAtomicPointer(); private slots: + void warningFree(); + void constructor(); void copy_constructor(); void equality_operator(); @@ -78,6 +80,9 @@ private slots: void isFetchAndAddWaitFree(); void fetchAndAdd_data(); void fetchAndAdd(); + +private: + static void warningFreeHelper(); }; tst_QAtomicPointer::tst_QAtomicPointer() @@ -86,6 +91,49 @@ tst_QAtomicPointer::tst_QAtomicPointer() tst_QAtomicPointer::~tst_QAtomicPointer() { } +struct WFHC +{ + void bar() {} +}; + +void tst_QAtomicPointer::warningFreeHelper() +{ + Q_ASSERT(false); + // The code below is bogus, and shouldn't be run. We're looking for warnings, only. + + QBasicAtomicPointer p = Q_BASIC_ATOMIC_INITIALIZER(0); + + p->bar(); + + WFHC *expectedValue = 0; + WFHC *newValue = 0; + qptrdiff valueToAdd = 0; + + p.testAndSetRelaxed(expectedValue, newValue); + p.testAndSetAcquire(expectedValue, newValue); + p.testAndSetRelease(expectedValue, newValue); + p.testAndSetOrdered(expectedValue, newValue); + + p.fetchAndStoreRelaxed(newValue); + p.fetchAndStoreAcquire(newValue); + p.fetchAndStoreRelease(newValue); + p.fetchAndStoreOrdered(newValue); + + p.fetchAndAddRelaxed(valueToAdd); + p.fetchAndAddAcquire(valueToAdd); + p.fetchAndAddRelease(valueToAdd); + p.fetchAndAddOrdered(valueToAdd); +} + +void tst_QAtomicPointer::warningFree() +{ + // This is a compile time check for warnings. + // No need for actual work here. + + void (*foo)() = &warningFreeHelper; + (void)foo; +} + void tst_QAtomicPointer::constructor() { void *one = this; -- cgit v0.12 From 758f4735bcae034ac25730e53bb371df3b7d6e8a Mon Sep 17 00:00:00 2001 From: Jens Bache-Wiig Date: Mon, 31 Aug 2009 18:15:13 +0200 Subject: Make QMargins a proper class Since we need QMargins for other things then the CSS helper functions in drawutil, we have to make it more generic. It is already useful for QWidget::contentsMargins for example. This ensures we have some flexibility on how to use and modify it in the future. Reviewed-by: mbm --- src/corelib/tools/qmargins.cpp | 169 +++++++++++++++++++++++++++++++++++ src/corelib/tools/qmargins.h | 152 +++++++++++++++++++++++++++++++ src/corelib/tools/tools.pri | 128 +++++++++++++------------- src/gui/kernel/qwidget.cpp | 36 +++++++- src/gui/kernel/qwidget.h | 4 + src/gui/painting/qdrawutil.cpp | 137 ++++++++++++---------------- src/gui/painting/qdrawutil.h | 20 +---- tests/auto/qmargins/qmargins.pro | 3 + tests/auto/qmargins/tst_qmargins.cpp | 109 ++++++++++++++++++++++ 9 files changed, 596 insertions(+), 162 deletions(-) create mode 100644 src/corelib/tools/qmargins.cpp create mode 100644 src/corelib/tools/qmargins.h create mode 100644 tests/auto/qmargins/qmargins.pro create mode 100644 tests/auto/qmargins/tst_qmargins.cpp diff --git a/src/corelib/tools/qmargins.cpp b/src/corelib/tools/qmargins.cpp new file mode 100644 index 0000000..710023e --- /dev/null +++ b/src/corelib/tools/qmargins.cpp @@ -0,0 +1,169 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qmargins.h" +#include "qdatastream.h" +#include "qdebug.h" + +QT_BEGIN_NAMESPACE + +/*! + \class QMargins + \ingroup painting + + \brief The QMargins + + QMargin defines a set of four margins; left, top, right and bottom, + that describe the size of the borders surrounding a rectangle. + + The isNull() function returns true only if all margins are set to zero. + + QMargin objects can be streamed as well as compared. + +*/ + + +/***************************************************************************** + QMargins member functions + *****************************************************************************/ + +/*! + \fn QMargins::QMargins() + + Constructs a margins object with all margins set to 0. + + \sa isValid() +*/ + +/*! + \fn QMargins::QMargins(int left, int top, int right, int bottom) + + Constructs margins with the given \a left, \a top, \a right, \a bottom + + \sa setWidth(), setHeight() +*/ + +/*! + \fn bool QMargins::isNull() const + + Returns true if all margins are is 0; otherwise returns + false. + + \sa isValid(), isEmpty() +*/ + + +/*! + \fn int QMargins::left() const + + Returns the left margin. + + \sa setLeft() +*/ + +/*! + \fn int QMargins::top() const + + Returns the top margin. + + \sa setTop() +*/ + +/*! + \fn int QMargins::right() const + + Returns the right margin. +*/ + +/*! + \fn int QMargins::bottom() const + + Returns the bottom margin. +*/ + + +/*! + \fn void QMargins::setLeft(int left) + + Sets the left margin to \a left. +*/ + +/*! + \fn void QMargins::setTop(int Top) + + Sets the Top margin to \a Top. +*/ + +/*! + \fn void QMargins::setRight(int right) + + Sets the right margin to \a right. +*/ + +/*! + \fn void QMargins::setBottom(int bottom) + + Sets the bottom margin to \a bottom. +*/ + +/*! + \fn bool operator==(const QMargins &m1, const QMargins &m2) + \relates QMargins + + Returns true if \a m1 and \a m2 are equal; otherwise returns false. +*/ + +/*! + \fn bool operator!=(const QMargins &m1, const QMargins &m2) + \relates QMargins + + Returns true if \a m1 and \a m2 are different; otherwise returns false. +*/ + +#ifndef QT_NO_DEBUG_STREAM +QDebug operator<<(QDebug dbg, const QMargins &m) { + dbg.nospace() << "QMargins(" << m.left() << ", " + << m.top() << ", " << m.right() << ", " << m.bottom() << ')'; + return dbg.space(); +} +#endif + +QT_END_NAMESPACE diff --git a/src/corelib/tools/qmargins.h b/src/corelib/tools/qmargins.h new file mode 100644 index 0000000..de5ce0d --- /dev/null +++ b/src/corelib/tools/qmargins.h @@ -0,0 +1,152 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QMARGINS_H +#define QMARGINS_H + +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Core) + +class Q_CORE_EXPORT QMargins +{ +public: + QMargins(); + QMargins(int left, int top, int right, int bottom); + + bool isNull() const; + + int left() const; + int top() const; + int right() const; + int bottom() const; + + void setLeft(int left); + void setTop(int top); + void setRight(int right); + void setBottom(int bottom); + + int &rleft(); + int &rtop(); + int &rright(); + int &rbottom(); + +private: + int m_left; + int m_top; + int m_right; + int m_bottom; + + friend inline bool operator==(const QMargins &, const QMargins &); + friend inline bool operator!=(const QMargins &, const QMargins &); +}; + +Q_DECLARE_TYPEINFO(QMargins, Q_MOVABLE_TYPE); + +/***************************************************************************** + QMargins inline functions + *****************************************************************************/ + +inline QMargins::QMargins() +{ m_top = m_bottom = m_left = m_right = 0; } + +inline QMargins::QMargins(int left, int top, int right, int bottom) +{ m_left = left; m_top = top; m_right = right; m_bottom = bottom; } + +inline bool QMargins::isNull() const +{ return m_left==0 && m_top==0 && m_right==0 && m_bottom==0; } + +inline int QMargins::left() const +{ return m_left; } + +inline int QMargins::top() const +{ return m_top; } + +inline int QMargins::right() const +{ return m_right; } + +inline int QMargins::bottom() const +{ return m_bottom; } + + +inline void QMargins::setLeft(int left) +{ m_left = left; } + +inline void QMargins::setTop(int top) +{ m_top = top; } + +inline void QMargins::setRight(int right) +{ m_right = right; } + +inline void QMargins::setBottom(int bottom) +{ m_bottom = bottom; } + +inline bool operator==(const QMargins &m1, const QMargins &m2) +{ + return + m1.m_left == m2.m_left && + m1.m_top == m2.m_top && + m1.m_right == m2.m_right && + m1.m_bottom == m2.m_bottom; +} + +inline bool operator!=(const QMargins &m1, const QMargins &m2) +{ + return + m1.m_left != m2.m_left || + m1.m_top != m2.m_top || + m1.m_right != m2.m_right || + m1.m_bottom != m2.m_bottom; +} + +#ifndef QT_NO_DEBUG_STREAM +Q_CORE_EXPORT QDebug operator<<(QDebug, const QMargins &); +#endif + +QT_END_NAMESPACE + +QT_END_HEADER + +#endif // QMARGINS_H diff --git a/src/corelib/tools/tools.pri b/src/corelib/tools/tools.pri index 464c60f..007b763 100644 --- a/src/corelib/tools/tools.pri +++ b/src/corelib/tools/tools.pri @@ -1,77 +1,79 @@ # Qt tools module HEADERS += \ - tools/qalgorithms.h \ - tools/qbitarray.h \ - tools/qbytearray.h \ - tools/qbytearraymatcher.h \ + tools/qalgorithms.h \ + tools/qbitarray.h \ + tools/qbytearray.h \ + tools/qbytearraymatcher.h \ tools/qbytedata_p.h \ - tools/qcache.h \ - tools/qchar.h \ - tools/qcontainerfwd.h \ - tools/qcryptographichash.h \ - tools/qdatetime.h \ - tools/qdatetime_p.h \ + tools/qcache.h \ + tools/qchar.h \ + tools/qcontainerfwd.h \ + tools/qcryptographichash.h \ + tools/qdatetime.h \ + tools/qdatetime_p.h \ tools/qeasingcurve.h \ - tools/qhash.h \ + tools/qhash.h \ tools/qline.h \ - tools/qlinkedlist.h \ - tools/qlist.h \ - tools/qlocale.h \ - tools/qlocale_p.h \ - tools/qlocale_data_p.h \ - tools/qmap.h \ + tools/qlinkedlist.h \ + tools/qlist.h \ + tools/qlocale.h \ + tools/qlocale_p.h \ + tools/qlocale_data_p.h \ + tools/qmap.h \ + tools/qmargins.h \ tools/qcontiguouscache.h \ tools/qpodlist_p.h \ tools/qpoint.h \ - tools/qqueue.h \ + tools/qqueue.h \ tools/qrect.h \ - tools/qregexp.h \ - tools/qringbuffer_p.h \ - tools/qshareddata.h \ + tools/qregexp.h \ + tools/qringbuffer_p.h \ + tools/qshareddata.h \ tools/qsharedpointer.h \ tools/qsharedpointer_impl.h \ - tools/qset.h \ + tools/qset.h \ tools/qsize.h \ - tools/qstack.h \ - tools/qstring.h \ - tools/qstringbuilder.h \ - tools/qstringlist.h \ - tools/qstringmatcher.h \ - tools/qtextboundaryfinder.h \ - tools/qtimeline.h \ - tools/qunicodetables_p.h \ - tools/qvarlengtharray.h \ - tools/qvector.h \ + tools/qstack.h \ + tools/qstring.h \ + tools/qstringbuilder.h \ + tools/qstringlist.h \ + tools/qstringmatcher.h \ + tools/qtextboundaryfinder.h \ + tools/qtimeline.h \ + tools/qunicodetables_p.h \ + tools/qvarlengtharray.h \ + tools/qvector.h \ tools/qscopedpointer.h SOURCES += \ - tools/qbitarray.cpp \ - tools/qbytearray.cpp \ - tools/qbytearraymatcher.cpp \ - tools/qcryptographichash.cpp \ - tools/qdatetime.cpp \ + tools/qbitarray.cpp \ + tools/qbytearray.cpp \ + tools/qbytearraymatcher.cpp \ + tools/qcryptographichash.cpp \ + tools/qdatetime.cpp \ tools/qeasingcurve.cpp \ - tools/qhash.cpp \ + tools/qhash.cpp \ tools/qline.cpp \ - tools/qlinkedlist.cpp \ - tools/qlist.cpp \ - tools/qlocale.cpp \ + tools/qlinkedlist.cpp \ + tools/qlist.cpp \ + tools/qlocale.cpp \ tools/qpoint.cpp \ - tools/qmap.cpp \ - tools/qcontiguouscache.cpp \ + tools/qmap.cpp \ + tools/qmargins.cpp \ + tools/qcontiguouscache.cpp \ tools/qrect.cpp \ - tools/qregexp.cpp \ - tools/qshareddata.cpp \ - tools/qsharedpointer.cpp \ + tools/qregexp.cpp \ + tools/qshareddata.cpp \ + tools/qsharedpointer.cpp \ tools/qsize.cpp \ - tools/qstring.cpp \ - tools/qstringbuilder.cpp \ - tools/qstringlist.cpp \ - tools/qtextboundaryfinder.cpp \ - tools/qtimeline.cpp \ - tools/qvector.cpp \ + tools/qstring.cpp \ + tools/qstringbuilder.cpp \ + tools/qstringlist.cpp \ + tools/qtextboundaryfinder.cpp \ + tools/qtimeline.cpp \ + tools/qvector.cpp \ tools/qvsnprintf.cpp symbian:SOURCES+=tools/qlocale_symbian.cpp @@ -81,17 +83,17 @@ contains(QT_CONFIG, zlib) { wince*: DEFINES += NO_ERRNO_H INCLUDEPATH += ../3rdparty/zlib SOURCES+= \ - ../3rdparty/zlib/adler32.c \ - ../3rdparty/zlib/compress.c \ - ../3rdparty/zlib/crc32.c \ - ../3rdparty/zlib/deflate.c \ - ../3rdparty/zlib/gzio.c \ - ../3rdparty/zlib/inffast.c \ - ../3rdparty/zlib/inflate.c \ - ../3rdparty/zlib/inftrees.c \ - ../3rdparty/zlib/trees.c \ - ../3rdparty/zlib/uncompr.c \ - ../3rdparty/zlib/zutil.c + ../3rdparty/zlib/adler32.c \ + ../3rdparty/zlib/compress.c \ + ../3rdparty/zlib/crc32.c \ + ../3rdparty/zlib/deflate.c \ + ../3rdparty/zlib/gzio.c \ + ../3rdparty/zlib/inffast.c \ + ../3rdparty/zlib/inflate.c \ + ../3rdparty/zlib/inftrees.c \ + ../3rdparty/zlib/trees.c \ + ../3rdparty/zlib/uncompr.c \ + ../3rdparty/zlib/zutil.c } else:!contains(QT_CONFIG, no-zlib) { unix:LIBS_PRIVATE += -lz # win32:LIBS += libz.lib diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index ff644b8..37ffa8fb 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -6748,7 +6748,27 @@ void QWidget::setContentsMargins(int left, int top, int right, int bottom) QApplication::sendEvent(this, &e); } -/*! Returns the widget's contents margins for \a left, \a top, \a +/*! + \overload + \since 4.6 + + Sets the margins around the contents of the widget to have the + sizes determined by \a margins. The margins are + used by the layout system, and may be used by subclasses to + specify the area to draw in (e.g. excluding the frame). + + Changing the margins will trigger a resizeEvent(). + + \sa contentsRect(), getContentsMargins() +*/ +void QWidget::setContentsMargins(const QMargins &margins) +{ + setContentsMargins(margins.left(), margins.top(), + margins.right(), margins.bottom()); +} + +/*! + Returns the widget's contents margins for \a left, \a top, \a right, and \a bottom. \sa setContentsMargins(), contentsRect() @@ -6767,6 +6787,20 @@ void QWidget::getContentsMargins(int *left, int *top, int *right, int *bottom) c } /*! + \since 4.6 + + Returns the widget's contents margins. + + \sa getContentsMargins(), setContentsMargins(), contentsRect() + */ +QMargins QWidget::contentsMargins() const +{ + Q_D(const QWidget); + return QMargins(d->leftmargin, d->topmargin, d->rightmargin, d->bottommargin); +} + + +/*! Returns the area inside the widget's margins. \sa setContentsMargins(), getContentsMargins() diff --git a/src/gui/kernel/qwidget.h b/src/gui/kernel/qwidget.h index 38650f0..f398dbd 100644 --- a/src/gui/kernel/qwidget.h +++ b/src/gui/kernel/qwidget.h @@ -44,6 +44,7 @@ #include #include +#include #include #include #include @@ -527,7 +528,10 @@ public: QRegion visibleRegion() const; void setContentsMargins(int left, int top, int right, int bottom); + void setContentsMargins(const QMargins &margins); void getContentsMargins(int *left, int *top, int *right, int *bottom) const; + QMargins contentsMargins() const; + QRect contentsRect() const; public: diff --git a/src/gui/painting/qdrawutil.cpp b/src/gui/painting/qdrawutil.cpp index 59a5063..2220206 100644 --- a/src/gui/painting/qdrawutil.cpp +++ b/src/gui/painting/qdrawutil.cpp @@ -1038,27 +1038,6 @@ void qDrawItem(QPainter *p, Qt::GUIStyle gs, #endif /*! - \class QMargins - \since 4.6 - - Holds the borders used to split a pixmap into nine segments in order to - draw it, similar to \l{http://www.w3.org/TR/css3-background/} - {CSS3 border-images}. - - \sa Qt::TileRule, QTileRules -*/ - -/*! \fn QMargins::QMargins(int margin) - Constructs a QMargins with the top, left, bottom, and - right margins set to \a margin. -*/ - -/*! \fn QMargins::QMargins(int topMargin, int leftMargin, int bottomMargin, int rightMargin) - Constructs a QMargins with the given \a topMargin, \a leftMargin, - \a bottomMargin, and \a rightMargin. - */ - -/*! \class QTileRules \since 4.6 @@ -1195,79 +1174,79 @@ void qDrawBorderPixmap(QPainter *painter, const QRect &targetRect, const QMargin // source center const int sourceTop = sourceRect.top(); const int sourceLeft = sourceRect.left(); - const int sourceCenterTop = sourceTop + sourceMargins.top; - const int sourceCenterLeft = sourceLeft + sourceMargins.left; - const int sourceCenterBottom = sourceRect.bottom() - sourceMargins.bottom + 1; - const int sourceCenterRight = sourceRect.right() - sourceMargins.right + 1; - const int sourceCenterWidth = sourceCenterRight - sourceMargins.left; - const int sourceCenterHeight = sourceCenterBottom - sourceMargins.top; + const int sourceCenterTop = sourceTop + sourceMargins.top(); + const int sourceCenterLeft = sourceLeft + sourceMargins.left(); + const int sourceCenterBottom = sourceRect.bottom() - sourceMargins.bottom() + 1; + const int sourceCenterRight = sourceRect.right() - sourceMargins.right() + 1; + const int sourceCenterWidth = sourceCenterRight - sourceMargins.left(); + const int sourceCenterHeight = sourceCenterBottom - sourceMargins.top(); // target center const int targetTop = targetRect.top(); const int targetLeft = targetRect.left(); - const int targetCenterTop = targetTop + targetMargins.top; - const int targetCenterLeft = targetLeft + targetMargins.left; - const int targetCenterBottom = targetRect.bottom() - targetMargins.bottom + 1; - const int targetCenterRight = targetRect.right() - targetMargins.right + 1; + const int targetCenterTop = targetTop + targetMargins.top(); + const int targetCenterLeft = targetLeft + targetMargins.left(); + const int targetCenterBottom = targetRect.bottom() - targetMargins.bottom() + 1; + const int targetCenterRight = targetRect.right() - targetMargins.right() + 1; const int targetCenterWidth = targetCenterRight - targetCenterLeft; const int targetCenterHeight = targetCenterBottom - targetCenterTop; // corners - if (targetMargins.top > 0 && targetMargins.left > 0 && sourceMargins.top > 0 && sourceMargins.left > 0) { // top left - const QRect targetTopLeftRect(targetLeft, targetTop, targetMargins.left, targetMargins.top); - const QRect sourceTopLeftRect(sourceLeft, sourceTop, sourceMargins.left, sourceMargins.top); + if (targetMargins.top() > 0 && targetMargins.left() > 0 && sourceMargins.top() > 0 && sourceMargins.left() > 0) { // top left + const QRect targetTopLeftRect(targetLeft, targetTop, targetMargins.left(), targetMargins.top()); + const QRect sourceTopLeftRect(sourceLeft, sourceTop, sourceMargins.left(), sourceMargins.top()); qDrawPixmap(painter, targetTopLeftRect, pixmap, sourceTopLeftRect); } - if (targetMargins.top > 0 && targetMargins.right > 0 && sourceMargins.top > 0 && sourceMargins.right > 0) { // top right - const QRect targetTopRightRect(targetCenterRight, targetTop, targetMargins.right, targetMargins.top); - const QRect sourceTopRightRect(sourceCenterRight, sourceTop, sourceMargins.right, sourceMargins.top); + if (targetMargins.top() > 0 && targetMargins.right() > 0 && sourceMargins.top() > 0 && sourceMargins.right() > 0) { // top right + const QRect targetTopRightRect(targetCenterRight, targetTop, targetMargins.right(), targetMargins.top()); + const QRect sourceTopRightRect(sourceCenterRight, sourceTop, sourceMargins.right(), sourceMargins.top()); qDrawPixmap(painter, targetTopRightRect, pixmap, sourceTopRightRect); } - if (targetMargins.bottom > 0 && targetMargins.left > 0 && sourceMargins.bottom > 0 && sourceMargins.left > 0) { // bottom left - const QRect targetBottomLeftRect(targetLeft, targetCenterBottom, targetMargins.left, targetMargins.bottom); - const QRect sourceBottomLeftRect(sourceLeft, sourceCenterBottom, sourceMargins.left, sourceMargins.bottom); + if (targetMargins.bottom() > 0 && targetMargins.left() > 0 && sourceMargins.bottom() > 0 && sourceMargins.left() > 0) { // bottom left + const QRect targetBottomLeftRect(targetLeft, targetCenterBottom, targetMargins.left(), targetMargins.bottom()); + const QRect sourceBottomLeftRect(sourceLeft, sourceCenterBottom, sourceMargins.left(), sourceMargins.bottom()); qDrawPixmap(painter, targetBottomLeftRect, pixmap, sourceBottomLeftRect); } - if (targetMargins.bottom > 0 && targetMargins.right > 0 && sourceMargins.bottom > 0 && sourceMargins.right > 0) { // bottom right - const QRect targetBottomRightRect(targetCenterRight, targetCenterBottom, targetMargins.right, targetMargins.bottom); - const QRect sourceBottomRightRect(sourceCenterRight, sourceCenterBottom, sourceMargins.right, sourceMargins.bottom); + if (targetMargins.bottom() > 0 && targetMargins.right() > 0 && sourceMargins.bottom() > 0 && sourceMargins.right() > 0) { // bottom right + const QRect targetBottomRightRect(targetCenterRight, targetCenterBottom, targetMargins.right(), targetMargins.bottom()); + const QRect sourceBottomRightRect(sourceCenterRight, sourceCenterBottom, sourceMargins.right(), sourceMargins.bottom()); qDrawPixmap(painter, targetBottomRightRect, pixmap, sourceBottomRightRect); } // horizontal edges switch (rules.horizontal) { case Qt::Stretch: - if (targetMargins.top > 0 && sourceMargins.top > 0) { // top - const QRect targetTopRect(targetCenterLeft, targetTop, targetCenterWidth, targetMargins.top); - const QRect sourceTopRect(sourceCenterLeft, sourceTop, sourceCenterWidth, sourceMargins.top); + if (targetMargins.top() > 0 && sourceMargins.top() > 0) { // top + const QRect targetTopRect(targetCenterLeft, targetTop, targetCenterWidth, targetMargins.top()); + const QRect sourceTopRect(sourceCenterLeft, sourceTop, sourceCenterWidth, sourceMargins.top()); qDrawPixmap(painter, targetTopRect, pixmap, sourceTopRect); } - if (targetMargins.bottom > 0 && sourceMargins.bottom > 0) { // bottom - const QRect targetBottomRect(targetCenterLeft, targetCenterBottom, targetCenterWidth, targetMargins.bottom); - const QRect sourceBottomRect(sourceCenterLeft, sourceCenterBottom, sourceCenterWidth, sourceMargins.bottom); + if (targetMargins.bottom() > 0 && sourceMargins.bottom() > 0) { // bottom + const QRect targetBottomRect(targetCenterLeft, targetCenterBottom, targetCenterWidth, targetMargins.bottom()); + const QRect sourceBottomRect(sourceCenterLeft, sourceCenterBottom, sourceCenterWidth, sourceMargins.bottom()); qDrawPixmap(painter, targetBottomRect, pixmap, sourceBottomRect); } break; case Qt::Repeat: - if (targetMargins.top > 0 && sourceMargins.top > 0) { // top - const QRect targetTopRect(targetCenterLeft, targetTop, targetCenterWidth, targetMargins.top); - const QRect sourceTopRect(sourceCenterLeft, sourceTop, sourceCenterWidth, sourceMargins.top); + if (targetMargins.top() > 0 && sourceMargins.top() > 0) { // top + const QRect targetTopRect(targetCenterLeft, targetTop, targetCenterWidth, targetMargins.top()); + const QRect sourceTopRect(sourceCenterLeft, sourceTop, sourceCenterWidth, sourceMargins.top()); qDrawHorizontallyRepeatedPixmap(painter, targetTopRect, pixmap, sourceTopRect); } - if (targetMargins.bottom > 0 && sourceMargins.bottom > 0) { // bottom - const QRect targetBottomRect(targetCenterLeft, targetCenterBottom, targetCenterWidth, targetMargins.bottom); - const QRect sourceBottomRect(sourceCenterLeft, sourceCenterBottom, sourceCenterWidth, sourceMargins.bottom); + if (targetMargins.bottom() > 0 && sourceMargins.bottom() > 0) { // bottom + const QRect targetBottomRect(targetCenterLeft, targetCenterBottom, targetCenterWidth, targetMargins.bottom()); + const QRect sourceBottomRect(sourceCenterLeft, sourceCenterBottom, sourceCenterWidth, sourceMargins.bottom()); qDrawHorizontallyRepeatedPixmap(painter, targetBottomRect, pixmap, sourceBottomRect); } break; case Qt::Round: - if (targetMargins.top > 0 && sourceMargins.top > 0) { // top - const QRect targetTopRect(targetCenterLeft, targetTop, targetCenterWidth, targetMargins.top); - const QRect sourceTopRect(sourceCenterLeft, sourceTop, sourceCenterWidth, sourceMargins.top); + if (targetMargins.top() > 0 && sourceMargins.top() > 0) { // top + const QRect targetTopRect(targetCenterLeft, targetTop, targetCenterWidth, targetMargins.top()); + const QRect sourceTopRect(sourceCenterLeft, sourceTop, sourceCenterWidth, sourceMargins.top()); qDrawHorizontallyRoundedPixmap(painter, targetTopRect, pixmap, sourceTopRect); } - if (targetMargins.bottom > 0 && sourceMargins.bottom > 0) { // bottom - const QRect targetBottomRect(targetCenterLeft, targetCenterBottom, targetCenterWidth, targetMargins.bottom); - const QRect sourceBottomRect(sourceCenterLeft, sourceCenterBottom, sourceCenterWidth, sourceMargins.bottom); + if (targetMargins.bottom() > 0 && sourceMargins.bottom() > 0) { // bottom + const QRect targetBottomRect(targetCenterLeft, targetCenterBottom, targetCenterWidth, targetMargins.bottom()); + const QRect sourceBottomRect(sourceCenterLeft, sourceCenterBottom, sourceCenterWidth, sourceMargins.bottom()); qDrawHorizontallyRoundedPixmap(painter, targetBottomRect, pixmap, sourceBottomRect); } break; @@ -1276,38 +1255,38 @@ void qDrawBorderPixmap(QPainter *painter, const QRect &targetRect, const QMargin // vertical edges switch (rules.vertical) { case Qt::Stretch: - if (targetMargins.left > 0 && sourceMargins.left > 0) { // left - const QRect targetLeftRect(targetLeft, targetCenterTop, targetMargins.left, targetCenterHeight); - const QRect sourceLeftRect(sourceLeft, sourceCenterTop, sourceMargins.left, sourceCenterHeight); + if (targetMargins.left() > 0 && sourceMargins.left() > 0) { // left + const QRect targetLeftRect(targetLeft, targetCenterTop, targetMargins.left(), targetCenterHeight); + const QRect sourceLeftRect(sourceLeft, sourceCenterTop, sourceMargins.left(), sourceCenterHeight); qDrawPixmap(painter, targetLeftRect, pixmap, sourceLeftRect); } - if (targetMargins.right > 0 && sourceMargins.right > 0) { // right - const QRect targetRightRect(targetCenterRight, targetCenterTop, targetMargins.right, targetCenterHeight); - const QRect sourceRightRect(sourceCenterRight, sourceCenterTop, sourceMargins.right, sourceCenterHeight); + if (targetMargins.right() > 0 && sourceMargins.right() > 0) { // right + const QRect targetRightRect(targetCenterRight, targetCenterTop, targetMargins.right(), targetCenterHeight); + const QRect sourceRightRect(sourceCenterRight, sourceCenterTop, sourceMargins.right(), sourceCenterHeight); qDrawPixmap(painter, targetRightRect, pixmap, sourceRightRect); } break; case Qt::Repeat: - if (targetMargins.left > 0 && sourceMargins.left > 0) { // left - const QRect targetLeftRect(targetLeft, targetCenterTop, targetMargins.left, targetCenterHeight); - const QRect sourceLeftRect(sourceLeft, sourceCenterTop, sourceMargins.left, sourceCenterHeight); + if (targetMargins.left() > 0 && sourceMargins.left() > 0) { // left + const QRect targetLeftRect(targetLeft, targetCenterTop, targetMargins.left(), targetCenterHeight); + const QRect sourceLeftRect(sourceLeft, sourceCenterTop, sourceMargins.left(), sourceCenterHeight); qDrawVerticallyRepeatedPixmap(painter, targetLeftRect, pixmap, sourceLeftRect); } - if (targetMargins.right > 0 && sourceMargins.right > 0) { // right - const QRect targetRightRect(targetCenterRight, targetCenterTop, targetMargins.right, targetCenterHeight); - const QRect sourceRightRect(sourceCenterRight, sourceCenterTop, sourceMargins.right, sourceCenterHeight); + if (targetMargins.right() > 0 && sourceMargins.right() > 0) { // right + const QRect targetRightRect(targetCenterRight, targetCenterTop, targetMargins.right(), targetCenterHeight); + const QRect sourceRightRect(sourceCenterRight, sourceCenterTop, sourceMargins.right(), sourceCenterHeight); qDrawVerticallyRepeatedPixmap(painter, targetRightRect, pixmap, sourceRightRect); } break; case Qt::Round: - if (targetMargins.left > 0 && sourceMargins.left > 0) { // left - const QRect targetLeftRect(targetLeft, targetCenterTop, targetMargins.left, targetCenterHeight); - const QRect sourceLeftRect(sourceLeft, sourceCenterTop, sourceMargins.left, sourceCenterHeight); + if (targetMargins.left() > 0 && sourceMargins.left() > 0) { // left + const QRect targetLeftRect(targetLeft, targetCenterTop, targetMargins.left(), targetCenterHeight); + const QRect sourceLeftRect(sourceLeft, sourceCenterTop, sourceMargins.left(), sourceCenterHeight); qDrawVerticallyRoundedPixmap(painter, targetLeftRect, pixmap, sourceLeftRect); } - if (targetMargins.right > 0 && sourceMargins.right > 0) { // right - const QRect targetRightRect(targetCenterRight, targetCenterTop, targetMargins.right, targetCenterHeight); - const QRect sourceRightRect(sourceCenterRight, sourceCenterTop, sourceMargins.right, sourceCenterHeight); + if (targetMargins.right() > 0 && sourceMargins.right() > 0) { // right + const QRect targetRightRect(targetCenterRight, targetCenterTop, targetMargins.right(), targetCenterHeight); + const QRect sourceRightRect(sourceCenterRight, sourceCenterTop, sourceMargins.right(), sourceCenterHeight); qDrawVerticallyRoundedPixmap(painter, targetRightRect, pixmap, sourceRightRect); } break; diff --git a/src/gui/painting/qdrawutil.h b/src/gui/painting/qdrawutil.h index 4135c19..38ef30e 100644 --- a/src/gui/painting/qdrawutil.h +++ b/src/gui/painting/qdrawutil.h @@ -44,8 +44,8 @@ #include #include // char*->QString conversion +#include #include - QT_BEGIN_HEADER QT_BEGIN_NAMESPACE @@ -133,24 +133,6 @@ Q_GUI_EXPORT QT3_SUPPORT void qDrawArrow(QPainter *p, Qt::ArrowType type, Qt::GU const QPalette &pal, bool enabled); #endif -struct QMargins -{ - inline QMargins(int margin = 0) - : top(margin), - left(margin), - bottom(margin), - right(margin) {} - inline QMargins(int topMargin, int leftMargin, int bottomMargin, int rightMargin) - : top(topMargin), - left(leftMargin), - bottom(bottomMargin), - right(rightMargin) {} - int top; - int left; - int bottom; - int right; -}; - struct QTileRules { inline QTileRules(Qt::TileRule horizontalRule, Qt::TileRule verticalRule = Qt::Stretch) diff --git a/tests/auto/qmargins/qmargins.pro b/tests/auto/qmargins/qmargins.pro new file mode 100644 index 0000000..5a6aa4f --- /dev/null +++ b/tests/auto/qmargins/qmargins.pro @@ -0,0 +1,3 @@ +load(qttest_p4) +SOURCES += tst_qmargins.cpp +QT = core diff --git a/tests/auto/qmargins/tst_qmargins.cpp b/tests/auto/qmargins/tst_qmargins.cpp new file mode 100644 index 0000000..070aa19 --- /dev/null +++ b/tests/auto/qmargins/tst_qmargins.cpp @@ -0,0 +1,109 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + + +#include +#include + +Q_DECLARE_METATYPE(QMargins) + +//TESTED_CLASS= +//TESTED_FILES= + +class tst_QMargins : public QObject +{ + Q_OBJECT + +public: + tst_QMargins(); + virtual ~tst_QMargins(); + + +public slots: + void init(); + void cleanup(); +private slots: + void getSetCheck(); +}; + +// Testing get/set functions +void tst_QMargins::getSetCheck() +{ + QMargins margins; + // int QMargins::width() + // void QMargins::setWidth(int) + margins.setLeft(0); + QCOMPARE(0, margins.left()); + margins.setTop(INT_MIN); + QCOMPARE(INT_MIN, margins.top()); + margins.setBottom(INT_MAX); + QCOMPARE(INT_MAX, margins.bottom()); + margins.setRight(INT_MAX); + QCOMPARE(INT_MAX, margins.right()); + + margins = QMargins(); + QVERIFY(margins.isNull()); + margins.setLeft(5); + margins.setRight(5); + QVERIFY(!margins.isNull()); + QCOMPARE(margins, QMargins(5, 0, 5, 0)); +} + +tst_QMargins::tst_QMargins() +{ +} + +tst_QMargins::~tst_QMargins() +{ +} + +void tst_QMargins::init() +{ +} + +void tst_QMargins::cleanup() +{ +} + + + +QTEST_APPLESS_MAIN(tst_QMargins) +#include "tst_qmargins.moc" -- cgit v0.12 From 25ae1b6fc4d277f337639bc90c3f7df893b867f3 Mon Sep 17 00:00:00 2001 From: Jens Bache-Wiig Date: Mon, 31 Aug 2009 18:21:05 +0200 Subject: Updated lisence headers for QMargins --- src/corelib/tools/qmargins.cpp | 26 +++++++++++++------------- src/corelib/tools/qmargins.h | 26 +++++++++++++------------- 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/src/corelib/tools/qmargins.cpp b/src/corelib/tools/qmargins.cpp index 710023e..df08da1 100644 --- a/src/corelib/tools/qmargins.cpp +++ b/src/corelib/tools/qmargins.cpp @@ -9,8 +9,8 @@ ** No Commercial Usage ** This file contains pre-release code and may not be distributed. ** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. +** contained in the Technology Preview License Agreement accompanying +** this package. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser @@ -21,20 +21,20 @@ ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.1, included in the file LGPL_EXCEPTION.txt in this ** package. ** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** ** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/corelib/tools/qmargins.h b/src/corelib/tools/qmargins.h index de5ce0d..be918cc 100644 --- a/src/corelib/tools/qmargins.h +++ b/src/corelib/tools/qmargins.h @@ -9,8 +9,8 @@ ** No Commercial Usage ** This file contains pre-release code and may not be distributed. ** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. +** contained in the Technology Preview License Agreement accompanying +** this package. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser @@ -21,20 +21,20 @@ ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.1, included in the file LGPL_EXCEPTION.txt in this ** package. ** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** ** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ -- cgit v0.12 From aecf60446a0b7f02c3728b0f653ab04f1f45d11c Mon Sep 17 00:00:00 2001 From: David Faure Date: Wed, 5 Aug 2009 18:05:53 +0200 Subject: Add QNetworkProxyFactory::setUseSystemConfigurationEnabled(true) Simply following the system configuration for the proxy used to require writing a QNetworkProxyFactory subclass. The static setter makes this easier, so apps can in one line say "I want to use the system proxy settings". Solution and method name suggested by Thiago. --- src/network/kernel/qnetworkproxy.cpp | 24 ++++++++++ src/network/kernel/qnetworkproxy.h | 1 + src/network/kernel/qnetworkproxy_p.h | 85 ++++++++++++++++++++++++++++++++++++ 3 files changed, 110 insertions(+) create mode 100644 src/network/kernel/qnetworkproxy_p.h diff --git a/src/network/kernel/qnetworkproxy.cpp b/src/network/kernel/qnetworkproxy.cpp index af8d6fb..908f01f 100644 --- a/src/network/kernel/qnetworkproxy.cpp +++ b/src/network/kernel/qnetworkproxy.cpp @@ -220,6 +220,7 @@ #ifndef QT_NO_NETWORKPROXY +#include "private/qnetworkproxy_p.h" #include "private/qsocks5socketengine_p.h" #include "private/qhttpsocketengine_p.h" #include "qauthenticator.h" @@ -1156,6 +1157,29 @@ QNetworkProxyFactory::~QNetworkProxyFactory() { } + +/*! + Enables the use of the platform-specific proxy settings, and only those. + See systemProxyForQuery() for more information. + + Internally, this method (when called with \a enable set to true) + sets an application-wide proxy factory. For this reason, this method + is mutually exclusive with setApplicationProxyFactory: calling + setApplicationProxyFactory overrides the use of the system-wide proxy, + and calling setUseSystemConfigurationEnabled overrides any + application proxy or proxy factory that was previously set. + + \since 4.6 +*/ +void QNetworkProxyFactory::setUseSystemConfigurationEnabled(bool enable) +{ + if (enable) { + setApplicationProxyFactory(new QSystemConfigurationProxyFactory); + } else { + setApplicationProxyFactory(0); + } +} + /*! Sets the application-wide proxy factory to be \a factory. This function will take ownership of that object and will delete it diff --git a/src/network/kernel/qnetworkproxy.h b/src/network/kernel/qnetworkproxy.h index d64ba09..01a88b8 100644 --- a/src/network/kernel/qnetworkproxy.h +++ b/src/network/kernel/qnetworkproxy.h @@ -171,6 +171,7 @@ public: virtual QList queryProxy(const QNetworkProxyQuery &query = QNetworkProxyQuery()) = 0; + static void setUseSystemConfigurationEnabled(bool enable); static void setApplicationProxyFactory(QNetworkProxyFactory *factory); static QList proxyForQuery(const QNetworkProxyQuery &query); static QList systemProxyForQuery(const QNetworkProxyQuery &query = QNetworkProxyQuery()); diff --git a/src/network/kernel/qnetworkproxy_p.h b/src/network/kernel/qnetworkproxy_p.h new file mode 100644 index 0000000..dce8c84 --- /dev/null +++ b/src/network/kernel/qnetworkproxy_p.h @@ -0,0 +1,85 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtNetwork module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QNETWORKPROXY_P_H +#define QNETWORKPROXY_P_H + + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of the QLibrary class. This header file may change from +// version to version without notice, or even be removed. +// +// We mean it. +// + +#ifndef QT_NO_NETWORKPROXY + +QT_BEGIN_NAMESPACE + +class QSystemConfigurationProxyFactory : public QNetworkProxyFactory +{ +public: + QSystemConfigurationProxyFactory() : QNetworkProxyFactory() {} + + virtual QList queryProxy(const QNetworkProxyQuery& query) + { + QList proxies = QNetworkProxyFactory::systemProxyForQuery(query); + + // Make sure NoProxy is in the list, so that QTcpServer can work: + // it searches for the first proxy that can has the ListeningCapability capability + // if none have (as is the case with HTTP proxies), it fails to bind. + // NoProxy allows it to fallback to the 'no proxy' case and bind. + proxies.append(QNetworkProxy::NoProxy); + + return proxies; + } +}; + +QT_END_NAMESPACE + +#endif // QT_NO_NETWORKINTERFACE + +#endif + -- cgit v0.12 From 2c20b446abfef16f3852aa90c791c9f51210869f Mon Sep 17 00:00:00 2001 From: David Faure Date: Wed, 5 Aug 2009 18:07:23 +0200 Subject: Use system-wide proxy settings --- examples/webkit/fancybrowser/mainwindow.cpp | 2 ++ examples/webkit/googlechat/main.cpp | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/examples/webkit/fancybrowser/mainwindow.cpp b/examples/webkit/fancybrowser/mainwindow.cpp index ecca36b..06b1e30 100644 --- a/examples/webkit/fancybrowser/mainwindow.cpp +++ b/examples/webkit/fancybrowser/mainwindow.cpp @@ -56,6 +56,8 @@ MainWindow::MainWindow() file.close(); //! [1] + QNetworkProxyFactory::setUseSystemConfigurationEnabled(true); + //! [2] view = new QWebView(this); view->load(QUrl("http://www.google.com/ncr")); diff --git a/examples/webkit/googlechat/main.cpp b/examples/webkit/googlechat/main.cpp index 31937ee..09d94ef 100644 --- a/examples/webkit/googlechat/main.cpp +++ b/examples/webkit/googlechat/main.cpp @@ -40,11 +40,15 @@ ****************************************************************************/ #include +#include #include "googlechat.h" int main(int argc, char * argv[]) { QApplication app(argc, argv); + + QNetworkProxyFactory::setUseSystemConfigurationEnabled(true); + GoogleChat *chat = new GoogleChat; chat->show(); return app.exec(); -- cgit v0.12 From a4600c82a4bcc53713bce1a50eaefc81f4f73ca4 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 31 Aug 2009 18:13:44 +0200 Subject: Update license header for new file from merge request --- src/network/kernel/qnetworkproxy_p.h | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/network/kernel/qnetworkproxy_p.h b/src/network/kernel/qnetworkproxy_p.h index dce8c84..facbfed 100644 --- a/src/network/kernel/qnetworkproxy_p.h +++ b/src/network/kernel/qnetworkproxy_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2009 David Faure ** Contact: Nokia Corporation (qt-info@nokia.com) ** ** This file is part of the QtNetwork module of the Qt Toolkit. @@ -9,8 +9,8 @@ ** No Commercial Usage ** This file contains pre-release code and may not be distributed. ** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. +** contained in the Technology Preview License Agreement accompanying +** this package. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser @@ -21,20 +21,20 @@ ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.1, included in the file LGPL_EXCEPTION.txt in this ** package. ** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** ** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ -- cgit v0.12 From 935c9b6ffe952e28914c3e51c377c07380e6e6c1 Mon Sep 17 00:00:00 2001 From: Riccardo Iaconelli Date: Mon, 31 Aug 2009 18:38:06 +0200 Subject: fix doc. id maps to QObject::objectName, not QGraphicsObject::setOpacity ;-) Signed-off-by: Riccardo Iaconelli Merge-request: 1371 Reviewed-by: Thiago Macieira --- src/gui/graphicsview/qgraphicsitem.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index 4f8755e..822c208 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -6992,7 +6992,7 @@ QGraphicsObject::QGraphicsObject(QGraphicsItemPrivate &dd, QGraphicsItem *parent \property QGraphicsObject::id \brief the id of of the item - \sa QGraphicsItem::opacity(), QGraphicsItem::setOpacity() + \sa QObject::objectName(), QObject::setObjectName() */ /*! -- cgit v0.12 From d322e54e377edf76b3ff4449659b7221349689d3 Mon Sep 17 00:00:00 2001 From: Bernhard Rosenkraenzer Date: Mon, 31 Aug 2009 18:43:35 +0200 Subject: Qt fails to build with libpng 1.4 betas Qt expects a trans_values member in png_info_struct; this member has been renamed to trans_color in libpng 1.4. Merge-request: 1317 Reviewed-by: Thiago Macieira --- src/gui/image/qpnghandler.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/gui/image/qpnghandler.cpp b/src/gui/image/qpnghandler.cpp index 3f3a55c..b9dcf48 100644 --- a/src/gui/image/qpnghandler.cpp +++ b/src/gui/image/qpnghandler.cpp @@ -205,7 +205,11 @@ void setup_qt(QImage& image, png_structp png_ptr, png_infop info_ptr, float scre image.setColor(i, qRgba(c,c,c,0xff)); } if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) { +#if PNG_LIBPNG_VER_MAJOR < 1 || (PNG_LIBPNG_VER_MAJOR == 1 && PNG_LIBPNG_VER_MINOR < 4) const int g = info_ptr->trans_values.gray; +#else + const int g = info_ptr->trans_color.gray; +#endif if (g < ncols) { image.setColor(g, 0); } -- cgit v0.12 From cb2913bea73e17c4628974fa5d1f652576c2b52c Mon Sep 17 00:00:00 2001 From: Bernhard Rosenkraenzer Date: Mon, 31 Aug 2009 18:43:39 +0200 Subject: Adapt to libpng 1.4.0beta74 API change From libpng changelog: version 1.4.0beta74 [August 8, 2009] Changed png_ptr and info_ptr member "trans" to "trans_alpha". Merge-request: 1317 Reviewed-by: Thiago Macieira --- src/gui/image/qpnghandler.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/gui/image/qpnghandler.cpp b/src/gui/image/qpnghandler.cpp index b9dcf48..c4733cf 100644 --- a/src/gui/image/qpnghandler.cpp +++ b/src/gui/image/qpnghandler.cpp @@ -238,7 +238,11 @@ void setup_qt(QImage& image, png_structp png_ptr, png_infop info_ptr, float scre info_ptr->palette[i].red, info_ptr->palette[i].green, info_ptr->palette[i].blue, +#if PNG_LIBPNG_VER_MAJOR < 1 || (PNG_LIBPNG_VER_MAJOR == 1 && PNG_LIBPNG_VER_MINOR < 4) info_ptr->trans[i] +#else + info_ptr->trans_alpha[i] +#endif ) ); i++; -- cgit v0.12 From 3b65bb32fda7e34373b64f416ea92a3fa6eb266c Mon Sep 17 00:00:00 2001 From: David Faure Date: Mon, 31 Aug 2009 19:11:07 +0200 Subject: Performance: don't call WinHttpGetProxyForUrl for a file URL (e.g. from webkit) That method can be slow, since it does a DHCP query followed by a DNS query (sometimes followed by a Netbios query, too)... no point in doing it for every file URL loaded in webkit. Merge-request: 1128 Reviewed-by: Thiago Macieira --- src/network/kernel/qnetworkproxy_win.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/network/kernel/qnetworkproxy_win.cpp b/src/network/kernel/qnetworkproxy_win.cpp index 34a702b..8080261 100644 --- a/src/network/kernel/qnetworkproxy_win.cpp +++ b/src/network/kernel/qnetworkproxy_win.cpp @@ -363,8 +363,13 @@ QList QNetworkProxyFactory::systemProxyForQuery(const QNetworkPro if (sp->isAutoConfig) { WINHTTP_PROXY_INFO proxyInfo; - // try to get the proxy config for the URL, if we have a URL + // try to get the proxy config for the URL QUrl url = query.url(); + // url could be empty, e.g. from QNetworkProxy::applicationProxy(), that's fine, + // we'll still ask for the proxy. + // But for a file url, we know we don't need one. + if (url.scheme() == QLatin1String("file") || url.scheme() == QLatin1String("qrc")) + return sp->defaultResult; if (query.queryType() != QNetworkProxyQuery::UrlRequest) { // change the scheme to https, maybe it'll work url.setScheme(QLatin1String("https")); -- cgit v0.12 From 7c06af4528d7aa7186b12546c261d5d2a0a3641d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Thu, 27 Aug 2009 18:56:47 +0200 Subject: Reset QTemporaryFile's state after failed open() on Windows This fixes a regression introduced in 4.5.2 where QTemporaryFile would no longer attempt to generate a random name after a failed open. Under certain situations, this led to a non-random file being left behind in QDir::tempPath when using the fallback implementation of QFile::copy. Avoid calling QFSFileEngine::setFileName() on a template, so as not to process it as file name. By consistently not calling setFileTemplate in the constructor, we also delay allocation of the fileEngine. Changes made to that function also keep it from unnecessarily allocating the fileEngine. Task-number: 260165 Reviewed-by: Thiago Macieira --- src/corelib/io/qtemporaryfile.cpp | 38 ++++++++--- tests/auto/qtemporaryfile/tst_qtemporaryfile.cpp | 82 ++++++++++++++++++++++++ 2 files changed, 112 insertions(+), 8 deletions(-) diff --git a/src/corelib/io/qtemporaryfile.cpp b/src/corelib/io/qtemporaryfile.cpp index bd039c8..47fa257 100644 --- a/src/corelib/io/qtemporaryfile.cpp +++ b/src/corelib/io/qtemporaryfile.cpp @@ -292,14 +292,20 @@ class QTemporaryFileEngine : public QFSFileEngine Q_DECLARE_PRIVATE(QFSFileEngine) public: QTemporaryFileEngine(const QString &file, bool fileIsTemplate = true) - : QFSFileEngine(file), filePathIsTemplate(fileIsTemplate) + : QFSFileEngine(), filePathIsTemplate(fileIsTemplate) { + Q_D(QFSFileEngine); + d->filePath = file; + + if (!filePathIsTemplate) + QFSFileEngine::setFileName(file); } ~QTemporaryFileEngine(); bool isReallyOpen(); void setFileName(const QString &file); + void setFileTemplate(const QString &fileTemplate); bool open(QIODevice::OpenMode flags); bool remove(); @@ -336,6 +342,13 @@ void QTemporaryFileEngine::setFileName(const QString &file) QFSFileEngine::setFileName(file); } +void QTemporaryFileEngine::setFileTemplate(const QString &fileTemplate) +{ + Q_D(QFSFileEngine); + if (filePathIsTemplate) + d->filePath = fileTemplate; +} + bool QTemporaryFileEngine::open(QIODevice::OpenMode openMode) { Q_D(QFSFileEngine); @@ -382,12 +395,19 @@ bool QTemporaryFileEngine::open(QIODevice::OpenMode openMode) return false; } + QString template_ = d->filePath; d->filePath = QString::fromLocal8Bit(filename); - filePathIsTemplate = false; d->nativeInitFileName(); - d->closeFileHandle = true; delete [] filename; - return QFSFileEngine::open(openMode); + + if (QFSFileEngine::open(openMode)) { + filePathIsTemplate = false; + return true; + } + + d->filePath = template_; + d->nativeFilePath.clear(); + return false; #endif } @@ -533,7 +553,8 @@ QTemporaryFile::QTemporaryFile() QTemporaryFile::QTemporaryFile(const QString &templateName) : QFile(*new QTemporaryFilePrivate, 0) { - setFileTemplate(templateName); + Q_D(QTemporaryFile); + d->templateName = templateName; } /*! @@ -567,7 +588,8 @@ QTemporaryFile::QTemporaryFile(QObject *parent) QTemporaryFile::QTemporaryFile(const QString &templateName, QObject *parent) : QFile(*new QTemporaryFilePrivate, parent) { - setFileTemplate(templateName); + Q_D(QTemporaryFile); + d->templateName = templateName; } #endif @@ -671,10 +693,10 @@ QString QTemporaryFile::fileTemplate() const */ void QTemporaryFile::setFileTemplate(const QString &name) { - Q_ASSERT(!isOpen()); Q_D(QTemporaryFile); - fileEngine()->setFileName(name); d->templateName = name; + if (d->fileEngine) + static_cast(d->fileEngine)->setFileTemplate(name); } /*! diff --git a/tests/auto/qtemporaryfile/tst_qtemporaryfile.cpp b/tests/auto/qtemporaryfile/tst_qtemporaryfile.cpp index 2541b48..73486e7 100644 --- a/tests/auto/qtemporaryfile/tst_qtemporaryfile.cpp +++ b/tests/auto/qtemporaryfile/tst_qtemporaryfile.cpp @@ -89,6 +89,8 @@ private slots: void renameFdLeak(); void reOpenThroughQFile(); void keepOpenMode(); + void resetTemplateAfterError(); + void setTemplateAfterOpen(); public: }; @@ -472,5 +474,85 @@ void tst_QTemporaryFile::keepOpenMode() } } +void tst_QTemporaryFile::resetTemplateAfterError() +{ + // calling setFileTemplate on a failed open + + QString tempPath = QDir::tempPath(); + + QString const fileTemplate("destination/qt_temp_file_test.XXXXXX"); + QString const fileTemplate2(tempPath + "/qt_temp_file_test.XXXXXX"); + + QVERIFY2( QDir(tempPath).exists() || QDir().mkpath(tempPath), "Test precondition" ); + QVERIFY2( !QFile::exists("destination"), "Test precondition" ); + QVERIFY2( !QFile::exists(fileTemplate2) || QFile::remove(fileTemplate2), "Test precondition" ); + + QFile file(fileTemplate2); + QByteArray fileContent("This file is intentionally NOT left empty."); + + QVERIFY( file.open(QIODevice::ReadWrite | QIODevice::Truncate) ); + QCOMPARE( file.write(fileContent), (qint64)fileContent.size() ); + QVERIFY( file.flush() ); + + QString fileName; + { + QTemporaryFile temp; + + QVERIFY( temp.fileName().isEmpty() ); + QVERIFY( !temp.fileTemplate().isEmpty() ); + + temp.setFileTemplate( fileTemplate ); + + QVERIFY( temp.fileName().isEmpty() ); + QCOMPARE( temp.fileTemplate(), fileTemplate ); + + QVERIFY( !temp.open() ); + + QVERIFY( temp.fileName().isEmpty() ); + QCOMPARE( temp.fileTemplate(), fileTemplate ); + + temp.setFileTemplate( fileTemplate2 ); + QVERIFY( temp.open() ); + + fileName = temp.fileName(); + QVERIFY( QFile::exists(fileName) ); + QVERIFY( !fileName.isEmpty() ); + QVERIFY2( fileName != fileTemplate2, + ("Generated name shouldn't be same as template: " + fileTemplate2).toLocal8Bit().constData() ); + } + + QVERIFY( !QFile::exists(fileName) ); + + file.seek(0); + QCOMPARE( QString(file.readAll()), QString(fileContent) ); + QVERIFY( file.remove() ); +} + +void tst_QTemporaryFile::setTemplateAfterOpen() +{ + QTemporaryFile temp; + + QVERIFY( temp.fileName().isEmpty() ); + QVERIFY( !temp.fileTemplate().isEmpty() ); + + QVERIFY( temp.open() ); + + QString const fileName = temp.fileName(); + QString const newTemplate("funny-path/funny-name-XXXXXX.tmp"); + + QVERIFY( !fileName.isEmpty() ); + QVERIFY( QFile::exists(fileName) ); + QVERIFY( !temp.fileTemplate().isEmpty() ); + QVERIFY( temp.fileTemplate() != newTemplate ); + + temp.close(); // QTemporaryFile::setFileTemplate will assert on isOpen() up to 4.5.2 + temp.setFileTemplate(newTemplate); + QCOMPARE( temp.fileTemplate(), newTemplate ); + + QVERIFY( temp.open() ); + QCOMPARE( temp.fileName(), fileName ); + QCOMPARE( temp.fileTemplate(), newTemplate ); +} + QTEST_MAIN(tst_QTemporaryFile) #include "tst_qtemporaryfile.moc" -- cgit v0.12 From 627ddefd4f2b27ff2f5127bf20356bb302e6ad6d Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Thu, 27 Aug 2009 14:50:23 -0700 Subject: Allow setting screen size with connect options Reviewed-by: Donald Carr --- src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp index 8be0355..9c509d5 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp @@ -1227,6 +1227,8 @@ bool QDirectFBScreen::connect(const QString &displaySpec) "Unable to get screen size!", result); return false; } + ::setIntOption(displayArgs, QLatin1String("width"), &w); + ::setIntOption(displayArgs, QLatin1String("height"), &h); dw = w; dh = h; -- cgit v0.12 From 20cc50a21eb5841b3a3e8546877e805f5a4df528 Mon Sep 17 00:00:00 2001 From: Albert Astals Cid Date: Mon, 31 Aug 2009 19:33:10 +0200 Subject: Fix #error line not to have a ' as it's not correct Merge-request: 753 Reviewed-by: Thiago Macieira --- src/3rdparty/webkit/WebCore/DerivedSources.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/3rdparty/webkit/WebCore/DerivedSources.cpp b/src/3rdparty/webkit/WebCore/DerivedSources.cpp index f698913..aaf8983 100644 --- a/src/3rdparty/webkit/WebCore/DerivedSources.cpp +++ b/src/3rdparty/webkit/WebCore/DerivedSources.cpp @@ -334,5 +334,5 @@ // want StaticConstructors.h to "pollute" all the source files we #include here // accidentally, so we'll throw an error whenever any file includes it. #ifdef StaticConstructors_h -#error Don't include any file in DerivedSources.cpp that includes StaticConstructors.h +#error Do not include any file in DerivedSources.cpp that includes StaticConstructors.h #endif -- cgit v0.12 From 74136269e834077daa623fe6e1f14adf1b64a7d0 Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Mon, 31 Aug 2009 09:41:08 -0700 Subject: Remove duplicated code in qdirectfbScreen.cpp Reviewed-by: Donald Carr --- .../gfxdrivers/directfb/qdirectfbscreen.cpp | 32 +--------------------- 1 file changed, 1 insertion(+), 31 deletions(-) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp index 9c509d5..8cc7d8a 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp @@ -1024,36 +1024,6 @@ static inline bool setIntOption(const QStringList &arguments, const QString &var return false; } -static inline int depth(QImage::Format format) -{ - switch (format) { - case QImage::Format_Mono: - case QImage::Format_MonoLSB: - return 1; - case QImage::Format_Indexed8: - return 8; - case QImage::Format_RGB32: - case QImage::Format_ARGB32: - case QImage::Format_ARGB32_Premultiplied: - return 32; - case QImage::Format_ARGB8565_Premultiplied: - case QImage::Format_RGB666: - case QImage::Format_ARGB6666_Premultiplied: - case QImage::Format_ARGB8555_Premultiplied: - case QImage::Format_RGB888: - return 24; - case QImage::Format_RGB555: - case QImage::Format_RGB444: - case QImage::Format_RGB16: - case QImage::Format_ARGB4444_Premultiplied: - return 16; - case QImage::Format_Invalid: - case QImage::NImageFormats: - break; - } - return -1; -} - bool QDirectFBScreen::connect(const QString &displaySpec) { DFBResult result = DFB_OK; @@ -1199,7 +1169,7 @@ bool QDirectFBScreen::connect(const QString &displaySpec) break; } setPixelFormat(pixelFormat); - QScreen::d = ::depth(pixelFormat); + QScreen::d = QDirectFBScreen::depth(pixelFormat); data = 0; lstep = 0; size = 0; -- cgit v0.12 From 42540863d4b31b619a22c68391637f091b1c30f4 Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Mon, 31 Aug 2009 09:42:36 -0700 Subject: Don't use QString(const char *) in QDirectFBScreen Reviewed-by: Donald Carr --- src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp index 8cc7d8a..fab18e4 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp @@ -1015,7 +1015,7 @@ static void printDirectFBInfo(IDirectFB *fb, IDirectFBSurface *primarySurface) static inline bool setIntOption(const QStringList &arguments, const QString &variable, int *value) { Q_ASSERT(value); - QRegExp rx(QString("%1=?(\\d+)").arg(variable)); + QRegExp rx(QString::fromLatin1("%1=?(\\d+)").arg(variable)); rx.setCaseSensitivity(Qt::CaseInsensitive); if (arguments.indexOf(rx) != -1) { *value = rx.cap(1).toInt(); @@ -1224,7 +1224,7 @@ bool QDirectFBScreen::connect(const QString &displaySpec) surface->Release(surface); #endif - QRegExp backgroundColorRegExp("bgcolor=?(.+)"); + QRegExp backgroundColorRegExp(QLatin1String("bgcolor=?(.+)")); backgroundColorRegExp.setCaseSensitivity(Qt::CaseInsensitive); if (displayArgs.indexOf(backgroundColorRegExp) != -1) { d_ptr->backgroundColor.setNamedColor(backgroundColorRegExp.cap(1)); -- cgit v0.12 From c35974f60cab2d74b399c92ece7ceb96c147ef8a Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Mon, 31 Aug 2009 10:10:28 -0700 Subject: Fix QT_BEGIN/END_NAMESPACE in DirectFB Reviewed-by: Donald Carr --- src/plugins/gfxdrivers/directfb/qdirectfbkeyboard.cpp | 4 ++++ src/plugins/gfxdrivers/directfb/qdirectfbkeyboard.h | 4 ++++ src/plugins/gfxdrivers/directfb/qdirectfbmouse.cpp | 5 +++++ src/plugins/gfxdrivers/directfb/qdirectfbmouse.h | 4 ++++ src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp | 4 ++++ src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.h | 4 ++++ src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp | 7 +++++++ src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.h | 4 ++++ src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp | 5 +++++ src/plugins/gfxdrivers/directfb/qdirectfbpixmap.h | 4 ++++ src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp | 9 +++++++-- src/plugins/gfxdrivers/directfb/qdirectfbscreen.h | 4 ++++ src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp | 5 +++++ src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.h | 4 ++++ 14 files changed, 65 insertions(+), 2 deletions(-) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbkeyboard.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbkeyboard.cpp index fe77fd1..44ce72b3 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbkeyboard.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbkeyboard.cpp @@ -53,6 +53,8 @@ #include #include +QT_BEGIN_NAMESPACE + class KeyMap : public QHash { public: @@ -429,6 +431,8 @@ KeyMap::KeyMap() insert(DIKS_TILDE , Qt::Key_AsciiTilde); } +QT_END_NAMESPACE + #include "qdirectfbkeyboard.moc" #endif // QT_NO_DIRECTFB diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbkeyboard.h b/src/plugins/gfxdrivers/directfb/qdirectfbkeyboard.h index 756892f..14618bb 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbkeyboard.h +++ b/src/plugins/gfxdrivers/directfb/qdirectfbkeyboard.h @@ -46,6 +46,8 @@ QT_BEGIN_HEADER +QT_BEGIN_NAMESPACE + QT_MODULE(Gui) #ifndef QT_NO_DIRECTFB @@ -62,6 +64,8 @@ private: QDirectFBKeyboardHandlerPrivate *d; }; +QT_END_NAMESPACE + #endif // QT_NO_DIRECTFB QT_END_HEADER diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbmouse.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbmouse.cpp index 1f2b363..8d30f93 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbmouse.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbmouse.cpp @@ -49,6 +49,8 @@ #include #include +QT_BEGIN_NAMESPACE + class QDirectFBMouseHandlerPrivate : public QObject { Q_OBJECT @@ -269,5 +271,8 @@ void QDirectFBMouseHandler::resume() d->setEnabled(true); } +QT_END_NAMESPACE + #include "qdirectfbmouse.moc" + diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbmouse.h b/src/plugins/gfxdrivers/directfb/qdirectfbmouse.h index 14026ee..37d0845 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbmouse.h +++ b/src/plugins/gfxdrivers/directfb/qdirectfbmouse.h @@ -46,6 +46,8 @@ QT_BEGIN_HEADER +QT_BEGIN_NAMESPACE + QT_MODULE(Gui) #ifndef QT_NO_DIRECTFB @@ -67,6 +69,8 @@ protected: #endif // QT_NO_DIRECTFB +QT_END_NAMESPACE + QT_END_HEADER #endif // QDIRECTFBMOUSE_H diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp index dec4bdd..e839b47 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp @@ -45,6 +45,8 @@ #include "qdirectfbpaintdevice.h" #include "qdirectfbpaintengine.h" +QT_BEGIN_NAMESPACE + QDirectFBPaintDevice::QDirectFBPaintDevice(QDirectFBScreen *scr) : QCustomRasterPaintDevice(0), dfbSurface(0), lockedImage(0), screen(scr), bpl(-1), lockFlgs(DFBSurfaceLockFlags(0)), mem(0), engine(0), @@ -169,5 +171,7 @@ QPaintEngine *QDirectFBPaintDevice::paintEngine() const return engine; } +QT_END_NAMESPACE + #endif diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.h b/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.h index ca958c8..5befeab 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.h +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.h @@ -48,6 +48,8 @@ QT_BEGIN_HEADER +QT_BEGIN_NAMESPACE + QT_MODULE(Gui) // Inherited by both window surface and pixmap @@ -94,6 +96,8 @@ private: Q_DISABLE_COPY(QDirectFBPaintDevice); }; +QT_END_NAMESPACE + QT_END_HEADER #endif //QDIRECTFBPAINTDEVICE_H diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp index 337e75a..384a76a 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp @@ -55,6 +55,8 @@ #include #include +QT_BEGIN_NAMESPACE + class SurfaceCache; class QDirectFBPaintEnginePrivate : public QRasterPaintEnginePrivate { @@ -145,7 +147,9 @@ private: #ifdef QT_DIRECTFB_IMAGECACHE +QT_BEGIN_INCLUDE_NAMESPACE #include +QT_END_INCLUDE_NAMESPACE struct CachedImage { IDirectFBSurface *surface; @@ -1246,4 +1250,7 @@ static void rasterFallbackWarn(const char *msg, const char *func, const device * } #endif // QT_DIRECTFB_WARN_ON_RASTERFALLBACKS + +QT_END_NAMESPACE + #endif // QT_NO_DIRECTFB diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.h b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.h index 51468ad..ff67d14 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.h +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.h @@ -47,6 +47,8 @@ QT_BEGIN_HEADER +QT_BEGIN_NAMESPACE + QT_MODULE(Gui) class QDirectFBPaintEnginePrivate; @@ -107,6 +109,8 @@ public: static void initImageCache(int size); }; +QT_END_NAMESPACE + QT_END_HEADER #endif // QPAINTENGINE_DIRECTFB_P_H diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp index 2e3d32d..e921d24 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp @@ -48,6 +48,8 @@ #include #include +QT_BEGIN_NAMESPACE + static int global_ser_no = 0; QDirectFBPixmapData::QDirectFBPixmapData(QDirectFBScreen *screen, PixelType pixelType) @@ -574,3 +576,6 @@ void QDirectFBPixmapData::invalidate() imageFormat = QImage::Format_Invalid; } +QT_END_NAMESPACE + + diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.h b/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.h index 8bf1e73..fd59a93 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.h +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.h @@ -49,6 +49,8 @@ QT_BEGIN_HEADER +QT_BEGIN_NAMESPACE + QT_MODULE(Gui) class QDirectFBPaintEngine; @@ -91,6 +93,8 @@ private: bool alpha; }; +QT_END_NAMESPACE + QT_END_HEADER #endif // QDIRECTFBPIXMAP_H diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp index fab18e4..069ec5a 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp @@ -54,6 +54,8 @@ #include #include +QT_BEGIN_NAMESPACE + class QDirectFBScreenPrivate : public QObject, public QWSGraphicsSystem { Q_OBJECT @@ -94,8 +96,6 @@ public: QDirectFBScreen *q; }; -#include "qdirectfbscreen.moc" - QDirectFBScreenPrivate::QDirectFBScreenPrivate(QDirectFBScreen *qptr) : QWSGraphicsSystem(qptr), dfb(0), flipFlags(DSFLIP_NONE), directFBFlags(QDirectFBScreen::NoFlags), alphaPixmapFormat(QImage::Format_Invalid), @@ -1562,3 +1562,8 @@ IDirectFBSurface *QDirectFBScreen::subSurfaceForWidget(const QWidget *widget, co return subSurface; } +QT_END_NAMESPACE + +#include "qdirectfbscreen.moc" + + diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h index df0eea4..3e27ed1 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h +++ b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h @@ -48,6 +48,8 @@ QT_BEGIN_HEADER +QT_BEGIN_NAMESPACE + QT_MODULE(Gui) #if !defined QT_NO_DIRECTFB_LAYER && !defined QT_DIRECTFB_LAYER @@ -269,6 +271,8 @@ inline bool QDirectFBScreen::hasAlphaChannel(IDirectFBSurface *surface) return QDirectFBScreen::hasAlphaChannel(format); } +QT_END_NAMESPACE + QT_END_HEADER #endif // QDIRECTFBSCREEN_H diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp index a05ad21..421fbc2 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp @@ -48,6 +48,8 @@ #include #include +QT_BEGIN_NAMESPACE + QDirectFBWindowSurface::QDirectFBWindowSurface(DFBSurfaceFlipFlags flip, QDirectFBScreen *scr) : QDirectFBPaintDevice(scr) #ifndef QT_NO_DIRECTFB_WM @@ -449,3 +451,6 @@ void QDirectFBWindowSurface::updateFormat() { imageFormat = dfbSurface ? QDirectFBScreen::getImageFormat(dfbSurface) : QImage::Format_Invalid; } + +QT_END_NAMESPACE + diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.h b/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.h index a2861e5..771b7b5 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.h +++ b/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.h @@ -56,6 +56,8 @@ QT_BEGIN_HEADER +QT_BEGIN_NAMESPACE + QT_MODULE(Gui) class QDirectFBWindowSurface : public QWSWindowSurface, public QDirectFBPaintDevice @@ -110,6 +112,8 @@ private: #endif }; +QT_END_NAMESPACE + QT_END_HEADER #endif // QDIRECFBWINDOWSURFACE_H -- cgit v0.12 From cef94ba96e4fd45506dff793accd8603765de7f4 Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Mon, 31 Aug 2009 10:29:51 -0700 Subject: Clean up directfb ifdefs Make sure all files are wrapped in QT_NO_QWS_DIRECTFB Reviewed-by: Donald Carr --- src/plugins/gfxdrivers/directfb/qdirectfbkeyboard.cpp | 8 +++----- src/plugins/gfxdrivers/directfb/qdirectfbkeyboard.h | 6 +++--- src/plugins/gfxdrivers/directfb/qdirectfbmouse.cpp | 4 +++- src/plugins/gfxdrivers/directfb/qdirectfbmouse.h | 8 +++----- src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp | 7 +++---- src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.h | 4 +++- src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp | 4 ++-- src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.h | 4 ++++ src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp | 5 +++++ src/plugins/gfxdrivers/directfb/qdirectfbpixmap.h | 4 ++++ src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp | 4 +++- src/plugins/gfxdrivers/directfb/qdirectfbscreen.h | 4 ++++ src/plugins/gfxdrivers/directfb/qdirectfbscreenplugin.cpp | 3 +++ src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp | 5 +++++ src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.h | 5 ++++- 15 files changed, 52 insertions(+), 23 deletions(-) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbkeyboard.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbkeyboard.cpp index 44ce72b3..2bf1614 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbkeyboard.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbkeyboard.cpp @@ -41,8 +41,6 @@ #include "qdirectfbkeyboard.h" -#ifndef QT_NO_DIRECTFB - #include "qdirectfbscreen.h" #include #include @@ -53,6 +51,8 @@ #include #include +#ifndef QT_NO_QWS_DIRECTFB + QT_BEGIN_NAMESPACE class KeyMap : public QHash @@ -432,7 +432,5 @@ KeyMap::KeyMap() } QT_END_NAMESPACE - #include "qdirectfbkeyboard.moc" - -#endif // QT_NO_DIRECTFB +#endif // QT_NO_QWS_DIRECTFB diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbkeyboard.h b/src/plugins/gfxdrivers/directfb/qdirectfbkeyboard.h index 14618bb..826de3b 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbkeyboard.h +++ b/src/plugins/gfxdrivers/directfb/qdirectfbkeyboard.h @@ -44,14 +44,14 @@ #include +#ifndef QT_NO_QWS_DIRECTFB + QT_BEGIN_HEADER QT_BEGIN_NAMESPACE QT_MODULE(Gui) -#ifndef QT_NO_DIRECTFB - class QDirectFBKeyboardHandlerPrivate; class QDirectFBKeyboardHandler : public QWSKeyboardHandler @@ -66,7 +66,7 @@ private: QT_END_NAMESPACE -#endif // QT_NO_DIRECTFB +#endif // QT_NO_QWS_DIRECTFB QT_END_HEADER diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbmouse.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbmouse.cpp index 8d30f93..074904f 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbmouse.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbmouse.cpp @@ -49,6 +49,8 @@ #include #include +#ifndef QT_NO_QWS_DIRECTFB + QT_BEGIN_NAMESPACE class QDirectFBMouseHandlerPrivate : public QObject @@ -272,7 +274,7 @@ void QDirectFBMouseHandler::resume() } QT_END_NAMESPACE - #include "qdirectfbmouse.moc" +#endif // QT_NO_QWS_DIRECTFB diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbmouse.h b/src/plugins/gfxdrivers/directfb/qdirectfbmouse.h index 37d0845..fcb995e 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbmouse.h +++ b/src/plugins/gfxdrivers/directfb/qdirectfbmouse.h @@ -44,14 +44,14 @@ #include +#ifndef QT_NO_QWS_DIRECTFB + QT_BEGIN_HEADER QT_BEGIN_NAMESPACE QT_MODULE(Gui) -#ifndef QT_NO_DIRECTFB - class QDirectFBMouseHandlerPrivate; class QDirectFBMouseHandler : public QWSMouseHandler @@ -67,10 +67,8 @@ protected: QDirectFBMouseHandlerPrivate *d; }; -#endif // QT_NO_DIRECTFB - QT_END_NAMESPACE QT_END_HEADER - +#endif // QT_NO_QWS_DIRECTFB #endif // QDIRECTFBMOUSE_H diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp index e839b47..106de0d 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp @@ -39,12 +39,12 @@ ** ****************************************************************************/ -#ifndef QT_NO_DIRECTFB - #include "qdirectfbscreen.h" #include "qdirectfbpaintdevice.h" #include "qdirectfbpaintengine.h" +#ifndef QT_NO_QWS_DIRECTFB + QT_BEGIN_NAMESPACE QDirectFBPaintDevice::QDirectFBPaintDevice(QDirectFBScreen *scr) @@ -173,5 +173,4 @@ QPaintEngine *QDirectFBPaintDevice::paintEngine() const QT_END_NAMESPACE -#endif - +#endif // QT_NO_QWS_DIRECTFB diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.h b/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.h index 5befeab..aed1cb5 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.h +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.h @@ -43,9 +43,10 @@ #define QDIRECTFBPAINTDEVICE_H #include -#include #include "qdirectfbscreen.h" +#ifndef QT_NO_QWS_DIRECTFB + QT_BEGIN_HEADER QT_BEGIN_NAMESPACE @@ -100,4 +101,5 @@ QT_END_NAMESPACE QT_END_HEADER +#endif // QT_NO_QWS_DIRECTFB #endif //QDIRECTFBPAINTDEVICE_H diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp index 384a76a..9a9553e 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp @@ -41,7 +41,7 @@ #include "qdirectfbpaintengine.h" -#ifndef QT_NO_DIRECTFB +#ifndef QT_NO_QWS_DIRECTFB #include "qdirectfbwindowsurface.h" #include "qdirectfbscreen.h" @@ -1253,4 +1253,4 @@ static void rasterFallbackWarn(const char *msg, const char *func, const device * QT_END_NAMESPACE -#endif // QT_NO_DIRECTFB +#endif // QT_NO_QWS_DIRECTFB diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.h b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.h index ff67d14..b4f0b5d 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.h +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.h @@ -45,6 +45,8 @@ #include #include +#ifndef QT_NO_QWS_DIRECTFB + QT_BEGIN_HEADER QT_BEGIN_NAMESPACE @@ -113,4 +115,6 @@ QT_END_NAMESPACE QT_END_HEADER +#endif // QT_NO_QWS_DIRECTFB + #endif // QPAINTENGINE_DIRECTFB_P_H diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp index e921d24..ee63842 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp @@ -48,6 +48,8 @@ #include #include +#ifndef QT_NO_QWS_DIRECTFB + QT_BEGIN_NAMESPACE static int global_ser_no = 0; @@ -578,4 +580,7 @@ void QDirectFBPixmapData::invalidate() QT_END_NAMESPACE +#endif // QT_NO_QWS_DIRECTFB + + diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.h b/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.h index fd59a93..77364fd 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.h +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.h @@ -42,6 +42,8 @@ #ifndef QDIRECTFBPIXMAP_H #define QDIRECTFBPIXMAP_H +#ifndef QT_NO_QWS_DIRECTFB + #include #include #include "qdirectfbpaintdevice.h" @@ -97,4 +99,6 @@ QT_END_NAMESPACE QT_END_HEADER +#endif // QT_NO_QWS_DIRECTFB + #endif // QDIRECTFBPIXMAP_H diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp index 069ec5a..664c8a8 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp @@ -54,6 +54,8 @@ #include #include +#ifndef QT_NO_QWS_DIRECTFB + QT_BEGIN_NAMESPACE class QDirectFBScreenPrivate : public QObject, public QWSGraphicsSystem @@ -1565,5 +1567,5 @@ IDirectFBSurface *QDirectFBScreen::subSurfaceForWidget(const QWidget *widget, co QT_END_NAMESPACE #include "qdirectfbscreen.moc" - +#endif // QT_NO_QWS_DIRECTFB diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h index 3e27ed1..14fde86 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h +++ b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h @@ -42,6 +42,8 @@ #ifndef QDIRECTFBSCREEN_H #define QDIRECTFBSCREEN_H +#include +#ifndef QT_NO_QWS_DIRECTFB #include #include #include @@ -275,4 +277,6 @@ QT_END_NAMESPACE QT_END_HEADER +#endif // QT_NO_QWS_DIRECTFB #endif // QDIRECTFBSCREEN_H + diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbscreenplugin.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbscreenplugin.cpp index 4caee414..05fe70f 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbscreenplugin.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbscreenplugin.cpp @@ -43,6 +43,7 @@ #include #include +#ifndef QT_NO_QWS_DIRECTFB class DirectFBScreenDriverPlugin : public QScreenDriverPlugin { @@ -73,3 +74,5 @@ QScreen* DirectFBScreenDriverPlugin::create(const QString& driver, } Q_EXPORT_PLUGIN2(qdirectfbscreen, DirectFBScreenDriverPlugin) + +#endif diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp index 421fbc2..82c8a41 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp @@ -48,6 +48,8 @@ #include #include +#ifndef QT_NO_QWS_DIRECTFB + QT_BEGIN_NAMESPACE QDirectFBWindowSurface::QDirectFBWindowSurface(DFBSurfaceFlipFlags flip, QDirectFBScreen *scr) @@ -454,3 +456,6 @@ void QDirectFBWindowSurface::updateFormat() QT_END_NAMESPACE +#endif // QT_NO_QWS_DIRECTFB + + diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.h b/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.h index 771b7b5..bb81e1a 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.h +++ b/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.h @@ -46,9 +46,10 @@ #include "qdirectfbpaintdevice.h" #include "qdirectfbscreen.h" +#ifndef QT_NO_QWS_DIRECTFB + #include #include -#include #ifdef QT_DIRECTFB_TIMING #include @@ -116,4 +117,6 @@ QT_END_NAMESPACE QT_END_HEADER +#endif // QT_NO_QWS_DIRECTFB + #endif // QDIRECFBWINDOWSURFACE_H -- cgit v0.12 From 258b9c5d5b1d88a5c19ed1dcfb5fed446006de0d Mon Sep 17 00:00:00 2001 From: Benjamin Poulain Date: Mon, 24 Aug 2009 10:42:48 +0200 Subject: Initialize the line coordinates in the tablet example. For the first tablet events, polyLine contains null points. The first two line painted have an invalid origin. --- examples/widgets/tablet/tabletcanvas.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/examples/widgets/tablet/tabletcanvas.cpp b/examples/widgets/tablet/tabletcanvas.cpp index abb667c..612a635 100644 --- a/examples/widgets/tablet/tabletcanvas.cpp +++ b/examples/widgets/tablet/tabletcanvas.cpp @@ -98,8 +98,10 @@ void TabletCanvas::tabletEvent(QTabletEvent *event) switch (event->type()) { case QEvent::TabletPress: - if (!deviceDown) + if (!deviceDown) { deviceDown = true; + polyLine[0] = polyLine[1] = polyLine[2] = event->pos(); + } break; case QEvent::TabletRelease: if (deviceDown) -- cgit v0.12 From a2b2fbbbffa4fa04f47cd8b9e6265e2e61c5e5f3 Mon Sep 17 00:00:00 2001 From: Benjamin Poulain Date: Mon, 31 Aug 2009 19:19:04 +0200 Subject: Disable event compression when the tablet events are accepted Since Qt 4.5, all tablet events are compressed not to overload the widgets with the corresponding mouse event (a mouse event is generated if the tablet event is not accepted). This behavior reduce the precision when drawing on a widget that use the tablet events. All tablet events should be sent to the widget that are accepting the tablet event. With this patch, the tablet event are filtered only if the widget ignore the first tablet event. The mouse events are compressed. There is two special cases for the filtering: First, if a tablet event is for another widget than the one ignoring the tablet, this event should not be filtered. Second, if there is a mouse press event, the mouse move event should be sent to the widget that received the mouse press event. Helped-by: Pierre Rossi Reviewed-by: Thomas Zander Reviewed-by: Bradley T. Hughes --- src/gui/kernel/qapplication_x11.cpp | 111 ++++++------ .../qtabletevent/device_information/main.cpp | 50 ++++++ .../device_information/qtabletevent.pro | 13 ++ .../device_information/tabletwidget.cpp | 191 +++++++++++++++++++++ .../qtabletevent/device_information/tabletwidget.h | 73 ++++++++ .../event_compression/event_compression.pro | 7 + .../manual/qtabletevent/event_compression/main.cpp | 58 +++++++ .../event_compression/mousestatwidget.cpp | 99 +++++++++++ .../event_compression/mousestatwidget.h | 69 ++++++++ tests/manual/qtabletevent/main.cpp | 50 ------ tests/manual/qtabletevent/qtabletevent.pro | 13 -- tests/manual/qtabletevent/tabletwidget.cpp | 191 --------------------- tests/manual/qtabletevent/tabletwidget.h | 73 -------- 13 files changed, 618 insertions(+), 380 deletions(-) create mode 100644 tests/manual/qtabletevent/device_information/main.cpp create mode 100644 tests/manual/qtabletevent/device_information/qtabletevent.pro create mode 100644 tests/manual/qtabletevent/device_information/tabletwidget.cpp create mode 100644 tests/manual/qtabletevent/device_information/tabletwidget.h create mode 100644 tests/manual/qtabletevent/event_compression/event_compression.pro create mode 100644 tests/manual/qtabletevent/event_compression/main.cpp create mode 100644 tests/manual/qtabletevent/event_compression/mousestatwidget.cpp create mode 100644 tests/manual/qtabletevent/event_compression/mousestatwidget.h delete mode 100644 tests/manual/qtabletevent/main.cpp delete mode 100644 tests/manual/qtabletevent/qtabletevent.pro delete mode 100644 tests/manual/qtabletevent/tabletwidget.cpp delete mode 100644 tests/manual/qtabletevent/tabletwidget.h diff --git a/src/gui/kernel/qapplication_x11.cpp b/src/gui/kernel/qapplication_x11.cpp index 69dba40..0056b9e 100644 --- a/src/gui/kernel/qapplication_x11.cpp +++ b/src/gui/kernel/qapplication_x11.cpp @@ -4510,7 +4510,9 @@ void fetchWacomToolId(int &deviceType, qint64 &serialId) struct qt_tablet_motion_data { - Time timestamp; + bool filterByWidget; + const QWidget *widget; + const QWidget *etWidget; int tabletMotionType; bool error; // found a reason to stop searching }; @@ -4533,15 +4535,20 @@ static Bool qt_tabletMotion_scanner(Display *, XEvent *event, XPointer arg) qt_tablet_motion_data *data = (qt_tablet_motion_data *) arg; if (data->error) return false; - if (event->type == data->tabletMotionType) { - if (data->timestamp > 0) { - if ((reinterpret_cast(event))->time > data->timestamp) { - data->error = true; - return false; + const XDeviceMotionEvent *const motion = reinterpret_cast(event); + if (data->filterByWidget) { + const QPoint curr(motion->x, motion->y); + const QWidget *w = data->etWidget; + const QWidget *const child = w->childAt(curr); + if (child) { + w = child; } + if (w == data->widget) + return true; + } else { + return true; } - return true; } data->error = event->type != MotionNotify; // we stop compression when another event gets in between. @@ -4574,57 +4581,17 @@ bool QETWidget::translateXinputEvent(const XEvent *ev, QTabletDeviceData *tablet qreal rotation = 0; int deviceType = QTabletEvent::NoDevice; int pointerType = QTabletEvent::UnknownPointer; - XEvent mouseMotionEvent; - XEvent dummy; const XDeviceMotionEvent *motion = 0; XDeviceButtonEvent *button = 0; const XProximityNotifyEvent *proximity = 0; QEvent::Type t; Qt::KeyboardModifiers modifiers = 0; - bool reinsertMouseEvent = false; - XEvent mouseMotionEventSave; #if !defined (Q_OS_IRIX) XID device_id; #endif if (ev->type == tablet->xinput_motion) { motion = reinterpret_cast(ev); - - // Do event compression. Skip over tablet+mouse move events if there are newer ones. - qt_tablet_motion_data tabletMotionData; - tabletMotionData.tabletMotionType = tablet->xinput_motion; - while (true) { - // Find first mouse event since we expect them in pairs inside Qt - tabletMotionData.error =false; - tabletMotionData.timestamp = 0; - if (XCheckIfEvent(X11->display, &mouseMotionEvent, &qt_mouseMotion_scanner, (XPointer) &tabletMotionData)) { - mouseMotionEventSave = mouseMotionEvent; - reinsertMouseEvent = true; - } else { - break; - } - - // Now discard any duplicate tablet events. - tabletMotionData.error = false; - tabletMotionData.timestamp = mouseMotionEvent.xmotion.time; - while (XCheckIfEvent(X11->display, &dummy, &qt_tabletMotion_scanner, (XPointer) &tabletMotionData)) { - motion = reinterpret_cast(&dummy); - } - - // now check if there are more recent tablet motion events since we'll compress the current one with - // newer ones in that case - tabletMotionData.error = false; - tabletMotionData.timestamp = 0; - if (! XCheckIfEvent(X11->display, &dummy, &qt_tabletMotion_scanner, (XPointer) &tabletMotionData)) { - break; // done with compression - } - motion = reinterpret_cast(&dummy); - } - - if (reinsertMouseEvent) { - XPutBackEvent(X11->display, &mouseMotionEventSave); - } - t = QEvent::TabletMove; global = QPoint(motion->x_root, motion->y_root); curr = QPoint(motion->x, motion->y); @@ -4777,11 +4744,14 @@ bool QETWidget::translateXinputEvent(const XEvent *ev, QTabletDeviceData *tablet } #endif - QWidget *child = w->childAt(curr); - if (child) { - w = child; - curr = w->mapFromGlobal(global); + if (tablet->widgetToGetPress) { + w = tablet->widgetToGetPress; + } else { + QWidget *child = w->childAt(curr); + if (child) + w = child; } + curr = w->mapFromGlobal(global); if (t == QEvent::TabletPress) { tablet->widgetToGetPress = w; @@ -4795,10 +4765,45 @@ bool QETWidget::translateXinputEvent(const XEvent *ev, QTabletDeviceData *tablet deviceType, pointerType, qreal(pressure / qreal(tablet->maxPressure - tablet->minPressure)), xTilt, yTilt, tangentialPressure, rotation, z, modifiers, uid); - if (proximity) + if (proximity) { QApplication::sendSpontaneousEvent(qApp, &e); - else + } else { QApplication::sendSpontaneousEvent(w, &e); + const bool accepted = e.isAccepted(); + if (!accepted && ev->type == tablet->xinput_motion) { + // If the widget does not accept tablet events, we drop the next ones from the event queue + // for this widget so it is not overloaded with the numerous tablet events. + qt_tablet_motion_data tabletMotionData; + tabletMotionData.tabletMotionType = tablet->xinput_motion; + tabletMotionData.widget = w; + tabletMotionData.etWidget = this; + // if nothing is pressed, the events are filtered by position + tabletMotionData.filterByWidget = (tablet->widgetToGetPress == 0); + + bool reinsertMouseEvent = false; + XEvent mouseMotionEvent; + while (true) { + // Find first mouse event since we expect them in pairs inside Qt + tabletMotionData.error =false; + if (XCheckIfEvent(X11->display, &mouseMotionEvent, &qt_mouseMotion_scanner, (XPointer) &tabletMotionData)) { + reinsertMouseEvent = true; + } else { + break; + } + + // Now discard any duplicate tablet events. + tabletMotionData.error = false; + XEvent dummy; + while (XCheckIfEvent(X11->display, &dummy, &qt_tabletMotion_scanner, (XPointer) &tabletMotionData)) { + // just discard the event + } + } + + if (reinsertMouseEvent) { + XPutBackEvent(X11->display, &mouseMotionEvent); + } + } + } return true; } #endif diff --git a/tests/manual/qtabletevent/device_information/main.cpp b/tests/manual/qtabletevent/device_information/main.cpp new file mode 100644 index 0000000..0c2eda3 --- /dev/null +++ b/tests/manual/qtabletevent/device_information/main.cpp @@ -0,0 +1,50 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include "tabletwidget.h" + +int main(int argc, char **argv) { + QApplication app(argc, argv); + TabletWidget tabletWidget; + tabletWidget.showMaximized(); + return app.exec(); +} diff --git a/tests/manual/qtabletevent/device_information/qtabletevent.pro b/tests/manual/qtabletevent/device_information/qtabletevent.pro new file mode 100644 index 0000000..e0ed549 --- /dev/null +++ b/tests/manual/qtabletevent/device_information/qtabletevent.pro @@ -0,0 +1,13 @@ +###################################################################### +# Automatically generated by qmake (2.01a) Mon Aug 10 17:02:09 2009 +###################################################################### + +TEMPLATE = app +TARGET = +DEPENDPATH += . +INCLUDEPATH += . + +# Input +SOURCES += main.cpp\ + tabletwidget.cpp +HEADERS += tabletwidget.h diff --git a/tests/manual/qtabletevent/device_information/tabletwidget.cpp b/tests/manual/qtabletevent/device_information/tabletwidget.cpp new file mode 100644 index 0000000..15a3d80 --- /dev/null +++ b/tests/manual/qtabletevent/device_information/tabletwidget.cpp @@ -0,0 +1,191 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.1, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "tabletwidget.h" +#include +#include + +TabletWidget::TabletWidget() +{ + QPalette newPalette = palette(); + newPalette.setColor(QPalette::Window, Qt::white); + setPalette(newPalette); + qApp->installEventFilter(this); + resetAttributes(); +} + +bool TabletWidget::eventFilter(QObject *, QEvent *ev) +{ + switch (ev->type()) { + case QEvent::TabletEnterProximity: + case QEvent::TabletLeaveProximity: + case QEvent::TabletMove: + case QEvent::TabletPress: + case QEvent::TabletRelease: + { + QTabletEvent *event = static_cast(ev); + mType = event->type(); + mPos = event->pos(); + mGPos = event->globalPos(); + mHiResGlobalPos = event->hiResGlobalPos(); + mDev = event->device(); + mPointerType = event->pointerType(); + mUnique = event->uniqueId(); + mXT = event->xTilt(); + mYT = event->yTilt(); + mZ = event->z(); + mPress = event->pressure(); + mTangential = event->tangentialPressure(); + mRot = event->rotation(); + if (isVisible()) + update(); + break; + } + case QEvent::MouseMove: + { + resetAttributes(); + QMouseEvent *event = static_cast(ev); + mType = event->type(); + mPos = event->pos(); + mGPos = event->globalPos(); + } + default: + break; + } + return false; +} + +void TabletWidget::paintEvent(QPaintEvent *event) +{ + QPainter painter(this); + + QStringList eventInfo; + + QString typeString("Event type: "); + switch (mType) { + case QEvent::TabletEnterProximity: + typeString += "QEvent::TabletEnterProximity"; + break; + case QEvent::TabletLeaveProximity: + typeString += "QEvent::TabletLeaveProximity"; + break; + case QEvent::TabletMove: + typeString += "QEvent::TabletMove"; + break; + case QEvent::TabletPress: + typeString += "QEvent::TabletPress"; + break; + case QEvent::TabletRelease: + typeString += "QEvent::TabletRelease"; + break; + case QEvent::MouseMove: + typeString += "QEvent::MouseMove"; + break; + } + eventInfo << typeString; + + eventInfo << QString("Global position: %1 %2").arg(QString::number(mGPos.x()), QString::number(mGPos.y())); + eventInfo << QString("Local position: %1 %2").arg(QString::number(mPos.x()), QString::number(mPos.y())); + if (mType == QEvent::TabletEnterProximity || mType == QEvent::TabletLeaveProximity + || mType == QEvent::TabletMove || mType == QEvent::TabletPress + || mType == QEvent::TabletRelease) { + + eventInfo << QString("Hight res global position: %1 %2").arg(QString::number(mHiResGlobalPos.x()), QString::number(mHiResGlobalPos.y())); + + QString pointerType("Pointer type: "); + switch (mPointerType) { + case QTabletEvent::UnknownPointer: + pointerType += "QTabletEvent::UnknownPointer"; + break; + case QTabletEvent::Pen: + pointerType += "QTabletEvent::Pen"; + break; + case QTabletEvent::Cursor: + pointerType += "QTabletEvent::Cursor"; + break; + case QTabletEvent::Eraser: + pointerType += "QTabletEvent::Eraser"; + break; + } + eventInfo << pointerType; + + + QString deviceString = "Device type: "; + switch (mDev) { + case QTabletEvent::NoDevice: + deviceString += "QTabletEvent::NoDevice"; + break; + case QTabletEvent::Puck: + deviceString += "QTabletEvent::Puck"; + break; + case QTabletEvent::Stylus: + deviceString += "QTabletEvent::Stylus"; + break; + case QTabletEvent::Airbrush: + deviceString += "QTabletEvent::Airbrush"; + break; + case QTabletEvent::FourDMouse: + deviceString += "QTabletEvent::FourDMouse"; + break; + case QTabletEvent::RotationStylus: + deviceString += "QTabletEvent::RotationStylus"; + break; + } + eventInfo << deviceString; + + eventInfo << QString("Pressure: %1").arg(QString::number(mPress)); + eventInfo << QString("Tangential pressure: %1").arg(QString::number(mTangential)); + eventInfo << QString("Rotation: %1").arg(QString::number(mRot)); + eventInfo << QString("xTilt: %1").arg(QString::number(mXT)); + eventInfo << QString("yTilt: %1").arg(QString::number(mYT)); + eventInfo << QString("z: %1").arg(QString::number(mZ)); + + eventInfo << QString("Unique Id: %1").arg(QString::number(mUnique)); + } + + painter.drawText(rect(), eventInfo.join("\n")); +} + +void TabletWidget::tabletEvent(QTabletEvent *event) +{ + event->accept(); +} + diff --git a/tests/manual/qtabletevent/device_information/tabletwidget.h b/tests/manual/qtabletevent/device_information/tabletwidget.h new file mode 100644 index 0000000..b16e9ed --- /dev/null +++ b/tests/manual/qtabletevent/device_information/tabletwidget.h @@ -0,0 +1,73 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef TABLETWIDGET_H +#define TABLETWIDGET_H + +#include +#include + +// a widget showing the information of the last tablet event +class TabletWidget : public QWidget +{ +public: + TabletWidget(); +protected: + bool eventFilter(QObject *obj, QEvent *ev); + void tabletEvent(QTabletEvent *event); + void paintEvent(QPaintEvent *event); +private: + void resetAttributes() { + mType = mDev = mPointerType = mXT = mYT = mZ = 0; + mPress = mTangential = mRot = 0.0; + mPos = mGPos = QPoint(); + mHiResGlobalPos = QPointF(); + mUnique = 0; + } + int mType; + QPoint mPos, mGPos; + QPointF mHiResGlobalPos; + int mDev, mPointerType, mXT, mYT, mZ; + qreal mPress, mTangential, mRot; + qint64 mUnique; +}; + +#endif // TABLETWIDGET_H diff --git a/tests/manual/qtabletevent/event_compression/event_compression.pro b/tests/manual/qtabletevent/event_compression/event_compression.pro new file mode 100644 index 0000000..273fd6c --- /dev/null +++ b/tests/manual/qtabletevent/event_compression/event_compression.pro @@ -0,0 +1,7 @@ +TEMPLATE = app +QT += testlib + +# Input +SOURCES += main.cpp \ + mousestatwidget.cpp +HEADERS += mousestatwidget.h diff --git a/tests/manual/qtabletevent/event_compression/main.cpp b/tests/manual/qtabletevent/event_compression/main.cpp new file mode 100644 index 0000000..3b869e3 --- /dev/null +++ b/tests/manual/qtabletevent/event_compression/main.cpp @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "mousestatwidget.h" + +#include +#include +#include + +int main(int argc, char **argv){ + QApplication app(argc, argv); + + QWidget main; + QVBoxLayout *layout = new QVBoxLayout(&main); + layout->addWidget(new MouseStatWidget(true)); + layout->addWidget(new MouseStatWidget(false)); + main.resize(800, 600); + main.show(); + return app.exec(); +} diff --git a/tests/manual/qtabletevent/event_compression/mousestatwidget.cpp b/tests/manual/qtabletevent/event_compression/mousestatwidget.cpp new file mode 100644 index 0000000..024e14a --- /dev/null +++ b/tests/manual/qtabletevent/event_compression/mousestatwidget.cpp @@ -0,0 +1,99 @@ +#include "mousestatwidget.h" + +#include +#include +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.1, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include + +MouseStatWidget::MouseStatWidget(bool acceptTabletEvent):acceptTabletEvent(acceptTabletEvent), + receivedMouseEventCount(0), + receivedMouseEventCountToPaint(0), + receivedTabletEventCount(0), + receivedTabletEventCountToPaint(0) +{ + startTimer(1000); +} + + +void MouseStatWidget::tabletEvent(QTabletEvent *event) +{ + ++receivedTabletEventCount; + if (acceptTabletEvent) + event->accept(); + else + event->ignore(); + // make sure the event loop is slow + QTest::qSleep(15); +} + +void MouseStatWidget::mouseMoveEvent(QMouseEvent *) +{ + ++receivedMouseEventCount; +} + +void MouseStatWidget::timerEvent(QTimerEvent *) +{ + receivedMouseEventCountToPaint = receivedMouseEventCount; + receivedTabletEventCountToPaint = receivedTabletEventCount; + receivedMouseEventCount = 0; + receivedTabletEventCount = 0; + update(); +} + +void MouseStatWidget::paintEvent(QPaintEvent *) +{ + QPainter painter(this); + painter.setPen(Qt::black); + painter.drawRect(rect()); + QStringList text; + text << ((acceptTabletEvent) ? " - tablet events accepted - " : " - tablet events ignored - "); + text << QString("Number of tablet events received in the last second: %1").arg(QString::number(receivedTabletEventCountToPaint)); + text << QString("Number of mouse events received in the last second: %1").arg(QString::number(receivedMouseEventCountToPaint)); + + QTextOption textOption(Qt::AlignCenter); + textOption.setWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere); + painter.drawText(rect(), + text.join("\n"), + textOption); +} diff --git a/tests/manual/qtabletevent/event_compression/mousestatwidget.h b/tests/manual/qtabletevent/event_compression/mousestatwidget.h new file mode 100644 index 0000000..22c0dff --- /dev/null +++ b/tests/manual/qtabletevent/event_compression/mousestatwidget.h @@ -0,0 +1,69 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.1, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef MOUSESTATWIDGET_H +#define MOUSESTATWIDGET_H + +#include + +class QTabletEvent; +class QMouseEvent; +class QTimerEvent; +class QPaintEvent; + +class MouseStatWidget : public QWidget +{ +public: + MouseStatWidget(bool acceptTabletEvent = true); +protected: + void tabletEvent(QTabletEvent *); + void mouseMoveEvent(QMouseEvent *); + void timerEvent(QTimerEvent *); + void paintEvent(QPaintEvent *); +private: + const bool acceptTabletEvent; + int receivedMouseEventCount; + int receivedMouseEventCountToPaint; + int receivedTabletEventCount; + int receivedTabletEventCountToPaint; +}; + +#endif // MOUSESTATWIDGET_H diff --git a/tests/manual/qtabletevent/main.cpp b/tests/manual/qtabletevent/main.cpp deleted file mode 100644 index 44afcaf..0000000 --- a/tests/manual/qtabletevent/main.cpp +++ /dev/null @@ -1,50 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the test suite module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.1, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include "tabletwidget.h" - -int main(int argc, char **argv) { - QApplication app(argc, argv); - TabletWidget tabletWidget; - tabletWidget.showMaximized(); - return app.exec(); -} diff --git a/tests/manual/qtabletevent/qtabletevent.pro b/tests/manual/qtabletevent/qtabletevent.pro deleted file mode 100644 index e0ed549..0000000 --- a/tests/manual/qtabletevent/qtabletevent.pro +++ /dev/null @@ -1,13 +0,0 @@ -###################################################################### -# Automatically generated by qmake (2.01a) Mon Aug 10 17:02:09 2009 -###################################################################### - -TEMPLATE = app -TARGET = -DEPENDPATH += . -INCLUDEPATH += . - -# Input -SOURCES += main.cpp\ - tabletwidget.cpp -HEADERS += tabletwidget.h diff --git a/tests/manual/qtabletevent/tabletwidget.cpp b/tests/manual/qtabletevent/tabletwidget.cpp deleted file mode 100644 index 15a3d80..0000000 --- a/tests/manual/qtabletevent/tabletwidget.cpp +++ /dev/null @@ -1,191 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the test suite module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.1, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "tabletwidget.h" -#include -#include - -TabletWidget::TabletWidget() -{ - QPalette newPalette = palette(); - newPalette.setColor(QPalette::Window, Qt::white); - setPalette(newPalette); - qApp->installEventFilter(this); - resetAttributes(); -} - -bool TabletWidget::eventFilter(QObject *, QEvent *ev) -{ - switch (ev->type()) { - case QEvent::TabletEnterProximity: - case QEvent::TabletLeaveProximity: - case QEvent::TabletMove: - case QEvent::TabletPress: - case QEvent::TabletRelease: - { - QTabletEvent *event = static_cast(ev); - mType = event->type(); - mPos = event->pos(); - mGPos = event->globalPos(); - mHiResGlobalPos = event->hiResGlobalPos(); - mDev = event->device(); - mPointerType = event->pointerType(); - mUnique = event->uniqueId(); - mXT = event->xTilt(); - mYT = event->yTilt(); - mZ = event->z(); - mPress = event->pressure(); - mTangential = event->tangentialPressure(); - mRot = event->rotation(); - if (isVisible()) - update(); - break; - } - case QEvent::MouseMove: - { - resetAttributes(); - QMouseEvent *event = static_cast(ev); - mType = event->type(); - mPos = event->pos(); - mGPos = event->globalPos(); - } - default: - break; - } - return false; -} - -void TabletWidget::paintEvent(QPaintEvent *event) -{ - QPainter painter(this); - - QStringList eventInfo; - - QString typeString("Event type: "); - switch (mType) { - case QEvent::TabletEnterProximity: - typeString += "QEvent::TabletEnterProximity"; - break; - case QEvent::TabletLeaveProximity: - typeString += "QEvent::TabletLeaveProximity"; - break; - case QEvent::TabletMove: - typeString += "QEvent::TabletMove"; - break; - case QEvent::TabletPress: - typeString += "QEvent::TabletPress"; - break; - case QEvent::TabletRelease: - typeString += "QEvent::TabletRelease"; - break; - case QEvent::MouseMove: - typeString += "QEvent::MouseMove"; - break; - } - eventInfo << typeString; - - eventInfo << QString("Global position: %1 %2").arg(QString::number(mGPos.x()), QString::number(mGPos.y())); - eventInfo << QString("Local position: %1 %2").arg(QString::number(mPos.x()), QString::number(mPos.y())); - if (mType == QEvent::TabletEnterProximity || mType == QEvent::TabletLeaveProximity - || mType == QEvent::TabletMove || mType == QEvent::TabletPress - || mType == QEvent::TabletRelease) { - - eventInfo << QString("Hight res global position: %1 %2").arg(QString::number(mHiResGlobalPos.x()), QString::number(mHiResGlobalPos.y())); - - QString pointerType("Pointer type: "); - switch (mPointerType) { - case QTabletEvent::UnknownPointer: - pointerType += "QTabletEvent::UnknownPointer"; - break; - case QTabletEvent::Pen: - pointerType += "QTabletEvent::Pen"; - break; - case QTabletEvent::Cursor: - pointerType += "QTabletEvent::Cursor"; - break; - case QTabletEvent::Eraser: - pointerType += "QTabletEvent::Eraser"; - break; - } - eventInfo << pointerType; - - - QString deviceString = "Device type: "; - switch (mDev) { - case QTabletEvent::NoDevice: - deviceString += "QTabletEvent::NoDevice"; - break; - case QTabletEvent::Puck: - deviceString += "QTabletEvent::Puck"; - break; - case QTabletEvent::Stylus: - deviceString += "QTabletEvent::Stylus"; - break; - case QTabletEvent::Airbrush: - deviceString += "QTabletEvent::Airbrush"; - break; - case QTabletEvent::FourDMouse: - deviceString += "QTabletEvent::FourDMouse"; - break; - case QTabletEvent::RotationStylus: - deviceString += "QTabletEvent::RotationStylus"; - break; - } - eventInfo << deviceString; - - eventInfo << QString("Pressure: %1").arg(QString::number(mPress)); - eventInfo << QString("Tangential pressure: %1").arg(QString::number(mTangential)); - eventInfo << QString("Rotation: %1").arg(QString::number(mRot)); - eventInfo << QString("xTilt: %1").arg(QString::number(mXT)); - eventInfo << QString("yTilt: %1").arg(QString::number(mYT)); - eventInfo << QString("z: %1").arg(QString::number(mZ)); - - eventInfo << QString("Unique Id: %1").arg(QString::number(mUnique)); - } - - painter.drawText(rect(), eventInfo.join("\n")); -} - -void TabletWidget::tabletEvent(QTabletEvent *event) -{ - event->accept(); -} - diff --git a/tests/manual/qtabletevent/tabletwidget.h b/tests/manual/qtabletevent/tabletwidget.h deleted file mode 100644 index d3ccb32..0000000 --- a/tests/manual/qtabletevent/tabletwidget.h +++ /dev/null @@ -1,73 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.1, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef TABLETWIDGET_H -#define TABLETWIDGET_H - -#include -#include - -// a widget showing the information of the last tablet event -class TabletWidget : public QWidget -{ -public: - TabletWidget(); -protected: - bool eventFilter(QObject *obj, QEvent *ev); - void tabletEvent(QTabletEvent *event); - void paintEvent(QPaintEvent *event); -private: - void resetAttributes() { - mType = mDev = mPointerType = mXT = mYT = mZ = 0; - mPress = mTangential = mRot = 0.0; - mPos = mGPos = QPoint(); - mHiResGlobalPos = QPointF(); - mUnique = 0; - } - int mType; - QPoint mPos, mGPos; - QPointF mHiResGlobalPos; - int mDev, mPointerType, mXT, mYT, mZ; - qreal mPress, mTangential, mRot; - qint64 mUnique; -}; - -#endif // TABLETWIDGET_H -- cgit v0.12 From 9e652a18780aece1c5a8f12209747274a37bf91c Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Mon, 31 Aug 2009 12:21:03 -0700 Subject: Make cursor work in non-windowed mode Reviewed-by: Donald Carr --- .../gfxdrivers/directfb/qdirectfbpaintdevice.h | 2 +- .../gfxdrivers/directfb/qdirectfbscreen.cpp | 34 ++++++++++------------ src/plugins/gfxdrivers/directfb/qdirectfbscreen.h | 10 +++++++ .../gfxdrivers/directfb/qdirectfbwindowsurface.cpp | 21 +++++++------ .../gfxdrivers/directfb/qdirectfbwindowsurface.h | 4 ++- 5 files changed, 41 insertions(+), 30 deletions(-) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.h b/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.h index aed1cb5..f5de44b 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.h +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.h @@ -60,7 +60,7 @@ class QDirectFBPaintDevice : public QCustomRasterPaintDevice public: ~QDirectFBPaintDevice(); - IDirectFBSurface *directFBSurface() const; + virtual IDirectFBSurface *directFBSurface() const; void lockDirectFB(DFBSurfaceLockFlags lock); void unlockDirectFB(); diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp index 664c8a8..59fa191 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp @@ -496,14 +496,6 @@ void QDirectFBScreen::setSurfaceColorTable(IDirectFBSurface *surface, #endif // QT_NO_DIRECTFB_PALETTE -#ifndef QT_NO_QWS_CURSOR -#if defined QT_DIRECTFB_WM && defined QT_DIRECTFB_WINDOW_AS_CURSOR -#define QT_DIRECTFB_CURSOR -#elif defined QT_DIRECTFB_LAYER -#define QT_DIRECTFB_CURSOR -#endif -#endif - #if defined QT_DIRECTFB_CURSOR class Q_GUI_EXPORT QDirectFBScreenCursor : public QScreenCursor { @@ -1279,12 +1271,10 @@ bool QDirectFBScreen::initDevice() } #endif -#ifndef QT_NO_QWS_CURSOR -#if defined QT_NO_DIRECTFB_WM || defined QT_NO_DIRECTFB_LAYER - QScreenCursor::initSoftwareCursor(); -#else +#ifdef QT_DIRECTFB_CURSOR qt_screencursor = new QDirectFBScreenCursor; -#endif +#elif !defined QT_NO_QWS_CURSOR + QScreenCursor::initSoftwareCursor(); #endif return true; } @@ -1344,17 +1334,18 @@ QWSWindowSurface *QDirectFBScreen::createSurface(const QString &key) const // window surfaces. Normal, directFB surfaces are handled by DirectFB. void QDirectFBScreen::exposeRegion(QRegion r, int changing) { -#ifdef QT_NO_DIRECTFB_WM +#if defined QT_NO_DIRECTFB_WM const QList windows = QWSServer::instance()->clientWindows(); - if (changing < 0 || changing >= windows.size()) + if (changing < 0 || changing >= windows.size()) { return; - + } QWSWindow *win = windows.at(changing); QWSWindowSurface *s = win->windowSurface(); r &= region(); - if (r.isEmpty()) + if (r.isEmpty()) { return; + } const QRect brect = r.boundingRect(); @@ -1372,15 +1363,18 @@ void QDirectFBScreen::exposeRegion(QRegion r, int changing) ? static_cast(s) : 0; if (dfbWindowSurface) { IDirectFBSurface *surface = dfbWindowSurface->directFBSurface(); + Q_ASSERT(surface); const int n = insideWindow.numRects(); if (n == 1 || d_ptr->directFBFlags & BoundingRectFlip) { const QRect source = (insideWindow.boundingRect().intersected(windowGeometry)).translated(-windowGeometry.topLeft()); const DFBRectangle rect = { source.x(), source.y(), source.width(), source.height() }; + d_ptr->primarySurface->Blit(d_ptr->primarySurface, surface, &rect, windowGeometry.x() + source.x(), windowGeometry.y() + source.y()); + } else { const QVector rects = insideWindow.rects(); QVarLengthArray dfbRectangles(n); @@ -1403,6 +1397,7 @@ void QDirectFBScreen::exposeRegion(QRegion r, int changing) } } +#ifdef QT_NO_DIRECTFB_CURSOR if (QScreenCursor *cursor = QScreenCursor::instance()) { const QRect cursorRectangle = cursor->boundingRect(); if (cursor->isVisible() && !cursor->isAccelerated() && cursorRectangle.intersects(brect)) { @@ -1416,6 +1411,7 @@ void QDirectFBScreen::exposeRegion(QRegion r, int changing) #endif } } +#endif flipSurface(d_ptr->primarySurface, d_ptr->flipFlags, r, QPoint()); #else Q_UNUSED(r); @@ -1433,8 +1429,8 @@ void QDirectFBScreen::solidFill(const QColor &color, const QRegion ®ion) return; d_ptr->primarySurface->SetColor(d_ptr->primarySurface, - color.red(), color.green(), color.blue(), - color.alpha()); + color.red(), color.green(), color.blue(), + color.alpha()); const int n = region.numRects(); if (n > 1) { const QRect r = region.boundingRect(); diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h index 14fde86..e74adb1 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h +++ b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h @@ -87,6 +87,16 @@ QT_MODULE(Gui) #if !defined QT_NO_DIRECTFB_OPAQUE_DETECTION && !defined QT_DIRECTFB_OPAQUE_DETECTION #define QT_DIRECTFB_OPAQUE_DETECTION #endif +#ifndef QT_NO_QWS_CURSOR +#if defined QT_DIRECTFB_WM && defined QT_DIRECTFB_WINDOW_AS_CURSOR +#define QT_DIRECTFB_CURSOR +#elif defined QT_DIRECTFB_LAYER +#define QT_DIRECTFB_CURSOR +#endif +#endif +#ifndef QT_DIRECTFB_CURSOR +#define QT_NO_DIRECTFB_CURSOR +#endif #if defined QT_NO_DIRECTFB_LAYER && defined QT_DIRECTFB_WM #error QT_NO_DIRECTFB_LAYER requires QT_NO_DIRECTFB_WM #endif diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp index 82c8a41..73a6dd7 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp @@ -54,9 +54,9 @@ QT_BEGIN_NAMESPACE QDirectFBWindowSurface::QDirectFBWindowSurface(DFBSurfaceFlipFlags flip, QDirectFBScreen *scr) : QDirectFBPaintDevice(scr) + , sibling(0) #ifndef QT_NO_DIRECTFB_WM , dfbWindow(0) - , sibling(0) #endif , flipFlags(flip) , boundingRectFlip(scr->directFBFlags() & QDirectFBScreen::BoundingRectFlip) @@ -73,9 +73,9 @@ QDirectFBWindowSurface::QDirectFBWindowSurface(DFBSurfaceFlipFlags flip, QDirect QDirectFBWindowSurface::QDirectFBWindowSurface(DFBSurfaceFlipFlags flip, QDirectFBScreen *scr, QWidget *widget) : QWSWindowSurface(widget), QDirectFBPaintDevice(scr) + , sibling(0) #ifndef QT_NO_DIRECTFB_WM , dfbWindow(0) - , sibling(0) #endif , flipFlags(flip) , boundingRectFlip(scr->directFBFlags() & QDirectFBScreen::BoundingRectFlip) @@ -247,23 +247,16 @@ void QDirectFBWindowSurface::setGeometry(const QRect &rect) QByteArray QDirectFBWindowSurface::permanentState() const { -#ifdef QT_DIRECTFB_WM QByteArray state(sizeof(this), 0); *reinterpret_cast(state.data()) = this; return state; -#endif - return QByteArray(); } void QDirectFBWindowSurface::setPermanentState(const QByteArray &state) { -#ifdef QT_DIRECTFB_WM if (state.size() == sizeof(this)) { sibling = *reinterpret_cast(state.constData()); } -#else - Q_UNUSED(state); -#endif } static inline void scrollSurface(IDirectFBSurface *surface, const QRect &r, int dx, int dy) @@ -385,6 +378,7 @@ void QDirectFBWindowSurface::flush(QWidget *, const QRegion ®ion, } } +#ifdef QT_NO_DIRECTFB_CURSOR if (QScreenCursor *cursor = QScreenCursor::instance()) { const QRect cursorRectangle = cursor->boundingRect(); if (cursor->isVisible() && !cursor->isAccelerated() @@ -400,6 +394,7 @@ void QDirectFBWindowSurface::flush(QWidget *, const QRegion ®ion, #endif } } +#endif if (mode == Offscreen) { screen->flipSurface(primarySurface, flipFlags, region, offset + windowGeometry.topLeft()); } else @@ -428,6 +423,14 @@ void QDirectFBWindowSurface::endPaint(const QRegion &) unlockDirectFB(); } +IDirectFBSurface *QDirectFBWindowSurface::directFBSurface() const +{ + if (!dfbSurface && sibling && sibling->dfbSurface) + return sibling->dfbSurface; + return dfbSurface; +} + + IDirectFBSurface *QDirectFBWindowSurface::surfaceForWidget(const QWidget *widget, QRect *rect) const { Q_ASSERT(widget); diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.h b/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.h index bb81e1a..ca76613 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.h +++ b/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.h @@ -92,12 +92,14 @@ public: void endPaint(const QRegion &); IDirectFBSurface *surfaceForWidget(const QWidget *widget, QRect *rect) const; + IDirectFBSurface *directFBSurface() const; private: void updateFormat(); + QDirectFBWindowSurface *sibling; + #ifdef QT_DIRECTFB_WM void createWindow(); IDirectFBWindow *dfbWindow; - QDirectFBWindowSurface *sibling; #else enum Mode { Primary, -- cgit v0.12 From 709c4df621f637bc81127e7c1a8bd59d0f2f04e4 Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Mon, 31 Aug 2009 13:59:37 -0700 Subject: More DirectFB ifdef cleanup. Make sure the plugin builds but doesn't do anything when configured without -plugin-gfx-directfb Reviewed-by: Donald Carr --- src/plugins/gfxdrivers/directfb/qdirectfbkeyboard.cpp | 4 ++-- src/plugins/gfxdrivers/directfb/qdirectfbkeyboard.h | 1 + src/plugins/gfxdrivers/directfb/qdirectfbmouse.cpp | 4 ++-- src/plugins/gfxdrivers/directfb/qdirectfbmouse.h | 1 + src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp | 3 ++- src/plugins/gfxdrivers/directfb/qdirectfbpixmap.h | 2 ++ 6 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbkeyboard.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbkeyboard.cpp index 2bf1614..f207ebc 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbkeyboard.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbkeyboard.cpp @@ -41,6 +41,8 @@ #include "qdirectfbkeyboard.h" +#ifndef QT_NO_QWS_DIRECTFB + #include "qdirectfbscreen.h" #include #include @@ -51,8 +53,6 @@ #include #include -#ifndef QT_NO_QWS_DIRECTFB - QT_BEGIN_NAMESPACE class KeyMap : public QHash diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbkeyboard.h b/src/plugins/gfxdrivers/directfb/qdirectfbkeyboard.h index 826de3b..96d73ac 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbkeyboard.h +++ b/src/plugins/gfxdrivers/directfb/qdirectfbkeyboard.h @@ -42,6 +42,7 @@ #ifndef QDIRECTFBKEYBOARD_H #define QDIRECTFBKEYBOARD_H +#include #include #ifndef QT_NO_QWS_DIRECTFB diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbmouse.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbmouse.cpp index 074904f..2fb1520 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbmouse.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbmouse.cpp @@ -41,6 +41,8 @@ #include "qdirectfbmouse.h" +#ifndef QT_NO_QWS_DIRECTFB + #include "qdirectfbscreen.h" #include @@ -49,8 +51,6 @@ #include #include -#ifndef QT_NO_QWS_DIRECTFB - QT_BEGIN_NAMESPACE class QDirectFBMouseHandlerPrivate : public QObject diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbmouse.h b/src/plugins/gfxdrivers/directfb/qdirectfbmouse.h index fcb995e..5ef229c 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbmouse.h +++ b/src/plugins/gfxdrivers/directfb/qdirectfbmouse.h @@ -42,6 +42,7 @@ #ifndef QDIRECTFBMOUSE_H #define QDIRECTFBMOUSE_H +#include #include #ifndef QT_NO_QWS_DIRECTFB diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp index ee63842..0717020 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp @@ -41,6 +41,8 @@ #include "qdirectfbpixmap.h" +#ifndef QT_NO_QWS_DIRECTFB + #include "qdirectfbscreen.h" #include "qdirectfbpaintengine.h" @@ -48,7 +50,6 @@ #include #include -#ifndef QT_NO_QWS_DIRECTFB QT_BEGIN_NAMESPACE diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.h b/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.h index 77364fd..7b4ae47 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.h +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.h @@ -42,6 +42,8 @@ #ifndef QDIRECTFBPIXMAP_H #define QDIRECTFBPIXMAP_H +#include + #ifndef QT_NO_QWS_DIRECTFB #include -- cgit v0.12 From 4f72c6385b8d348611a907e6a8533de055188729 Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Tue, 1 Sep 2009 09:34:08 +1000 Subject: be51485f missed some instances of qt_get_extension_funcs Reviewed-by: trustme --- src/opengl/qglextensions.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/opengl/qglextensions.cpp b/src/opengl/qglextensions.cpp index e1ab6a4..a883c42 100644 --- a/src/opengl/qglextensions.cpp +++ b/src/opengl/qglextensions.cpp @@ -175,10 +175,10 @@ bool qt_resolve_glsl_extensions(QGLContext *ctx) #if defined(QT_OPENGL_ES_2) // The GLSL shader functions are always present in OpenGL/ES 2.0. // The only exceptions are glGetProgramBinaryOES and glProgramBinaryOES. - if (!QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glslResolved) { + if (!QGLContextPrivate::extensionFuncs(ctx).qt_glslResolved) { glGetProgramBinaryOES = (_glGetProgramBinaryOES) ctx->getProcAddress(QLatin1String("glGetProgramBinaryOES")); glProgramBinaryOES = (_glProgramBinaryOES) ctx->getProcAddress(QLatin1String("glProgramBinaryOES")); - QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glslResolved = true; + QGLContextPrivate::extensionFuncs(ctx).qt_glslResolved = true; } return true; #else -- cgit v0.12 From 8ff041dab354609b730849320f4f31659089b37e Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Tue, 1 Sep 2009 09:55:11 +1000 Subject: OpenGL/ES 2.0 compilation problem since QGLContextGroup changes Reviewed-by: trustme --- src/opengl/qglshaderprogram.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/opengl/qglshaderprogram.cpp b/src/opengl/qglshaderprogram.cpp index 61d8b10..c4d9322 100644 --- a/src/opengl/qglshaderprogram.cpp +++ b/src/opengl/qglshaderprogram.cpp @@ -1094,6 +1094,12 @@ QByteArray QGLShaderProgram::programBinary(int *format) const if (!isLinked()) return QByteArray(); + QGLContextGroup *ctx = d->ctx; +#ifndef QT_NO_DEBUG + if (!qt_check_sharing_with_current_context(ctx)) + qWarning("QGLShaderProgram::programBinary: Program is not associated with current context."); +#endif + // Get the length of the binary data, bailing out if there is none. GLint length = 0; glGetProgramiv(d->program, GL_PROGRAM_BINARY_LENGTH_OES, &length); @@ -1124,6 +1130,12 @@ QByteArray QGLShaderProgram::programBinary(int *format) const bool QGLShaderProgram::setProgramBinary(int format, const QByteArray& binary) { #if defined(QT_OPENGL_ES_2) + QGLContextGroup *ctx = d->ctx; +#ifndef QT_NO_DEBUG + if (!qt_check_sharing_with_current_context(ctx)) + qWarning("QGLShaderProgram::setProgramBinary: Program is not associated with current context."); +#endif + // Load the binary and check that it was linked correctly. glProgramBinaryOES(d->program, (GLenum)format, binary.constData(), binary.size()); -- cgit v0.12 From d1bb06923e825ac7079863d15d0d946d4c5aa19c Mon Sep 17 00:00:00 2001 From: Peter Yard Date: Mon, 31 Aug 2009 13:17:16 +1000 Subject: Added description of visualIndex condition to docs for logicalIndex() Fix for task: 214373 --- src/gui/itemviews/qheaderview.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/gui/itemviews/qheaderview.cpp b/src/gui/itemviews/qheaderview.cpp index a1c3e4e..4dbd6dc 100644 --- a/src/gui/itemviews/qheaderview.cpp +++ b/src/gui/itemviews/qheaderview.cpp @@ -1047,7 +1047,9 @@ int QHeaderView::visualIndex(int logicalIndex) const /*! Returns the logicalIndex for the section at the given \a visualIndex - position, or -1 otherwise. + position, or -1 if visualIndex < 0 or visualIndex >= QHeaderView::count(). + + Note that the visualIndex is not affected by hidden sections. \sa visualIndex(), sectionPosition() */ -- cgit v0.12 From 397fb3ece0fb556bc158cf1e826145196d2e6e95 Mon Sep 17 00:00:00 2001 From: Peter Yard Date: Tue, 1 Sep 2009 10:02:56 +1000 Subject: Doc for QSslError constructor parameters fixed each cons. --- src/network/ssl/qsslerror.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/network/ssl/qsslerror.cpp b/src/network/ssl/qsslerror.cpp index 69d2ccd..d47c91d 100644 --- a/src/network/ssl/qsslerror.cpp +++ b/src/network/ssl/qsslerror.cpp @@ -105,10 +105,8 @@ public: }; /*! - Constructs a QSslError object. The two optional arguments specify the \a - error that occurred, and which \a certificate the error relates to. + Constructs a QSslError object with no error and default certificate. - \sa QSslCertificate */ // RVCT compiler in debug build does not like about default values in const- @@ -120,6 +118,11 @@ QSslError::QSslError() d->certificate = QSslCertificate(); } +/*! + Constructs a QSslError object. The argument specifies the \a + error that occurred. + +*/ QSslError::QSslError(SslError error) : d(new QSslErrorPrivate) { @@ -127,6 +130,12 @@ QSslError::QSslError(SslError error) d->certificate = QSslCertificate(); } +/*! + Constructs a QSslError object. The two arguments specify the \a + error that occurred, and which \a certificate the error relates to. + + \sa QSslCertificate +*/ QSslError::QSslError(SslError error, const QSslCertificate &certificate) : d(new QSslErrorPrivate) { -- cgit v0.12 From 7a5d0d0b9f8b9203aa3921b2eb9fd7c77095c685 Mon Sep 17 00:00:00 2001 From: Keith Isdale Date: Mon, 31 Aug 2009 17:18:10 +1000 Subject: Update the qmake autotest: re MSVC test failure findMocs and findDeps When MSVC is used the default DESTDIR makes use a release/debug suffix. For these tests DESTDIR needs to be "."/ Minor code cleanup was done whilst correcting these effected .pro files Reviewed-by: Lincoln Ramsay --- tests/auto/qmake/testdata/findDeps/findDeps.pro | 7 ++----- tests/auto/qmake/testdata/findMocs/findMocs.pro | 7 ++----- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/tests/auto/qmake/testdata/findDeps/findDeps.pro b/tests/auto/qmake/testdata/findDeps/findDeps.pro index e0a2b86..43577b5 100644 --- a/tests/auto/qmake/testdata/findDeps/findDeps.pro +++ b/tests/auto/qmake/testdata/findDeps/findDeps.pro @@ -1,11 +1,8 @@ -###################################################################### -# Automatically generated by qmake (2.01a) Thu Mar 12 11:08:20 2009 -###################################################################### - TEMPLATE = app -TARGET = +TARGET = findDeps DEPENDPATH += . INCLUDEPATH += . +DESTDIR = ./ # Input HEADERS += object1.h \ diff --git a/tests/auto/qmake/testdata/findMocs/findMocs.pro b/tests/auto/qmake/testdata/findMocs/findMocs.pro index daa3c7f..1469b4c 100644 --- a/tests/auto/qmake/testdata/findMocs/findMocs.pro +++ b/tests/auto/qmake/testdata/findMocs/findMocs.pro @@ -1,11 +1,8 @@ -###################################################################### -# Automatically generated by qmake (2.01a) Wed Mar 11 16:11:09 2009 -###################################################################### - TEMPLATE = app -TARGET = +TARGET = findMocs DEPENDPATH += . INCLUDEPATH += . +DESTDIR = ./ # Input HEADERS += object1.h object2.h object3.h object4.h object5.h object6.h object7.h -- cgit v0.12 From d80748df828b92f376ca779ab83776f3c9f53ce1 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Tue, 1 Sep 2009 11:21:30 +1000 Subject: Update QML doc style. --- tools/qdoc3/test/classic.css | 38 +++++++++----------------------------- 1 file changed, 9 insertions(+), 29 deletions(-) diff --git a/tools/qdoc3/test/classic.css b/tools/qdoc3/test/classic.css index f97bdbe..c0bc3d47 100644 --- a/tools/qdoc3/test/classic.css +++ b/tools/qdoc3/test/classic.css @@ -251,45 +251,25 @@ span.string,span.char .qmlname { white-space: nowrap; - font-weight: bold; - font-size: 125%; } .qmltype { - font-weight: bold; - font-size: 125%; -} - -.qmlproto, .qmldoc { - // border-top: 1px solid #84b0c7; + text-align: center; + font-size: 160%; } .qmlproto { - padding: 0; - //background-color: #e4e4e4;//#d5e1e8; - //font-weight: bold; - //-webkit-border-top-left-radius: 8px; - //-webkit-border-top-right-radius: 8px; - //-moz-border-radius-topleft: 8px; - //-moz-border-radius-topright: 8px; + background-color: #eee; + border-width: 1px; + border-style: solid; + border-color: #ddd; + font-weight: bold; + padding: 6px 0px 6px 10px; + margin: 42px 0px 0px 0px; } .qmldoc { - border-top: 1px solid #e4e4e4; - //padding: 2px 5px; - //background-color: #eef3f5; - //border-top-width: 0; - //-webkit-border-bottom-left-radius: 8px; - //-webkit-border-bottom-right-radius: 8px; - //-moz-border-radius-bottomleft: 8px; - //-moz-border-radius-bottomright: 8px; -} - -.qmldoc p, .qmldoc dl, .qmldoc ul { - //margin: 6px 0; } *.qmlitem p { - //margin-top: 0px; - //margin-bottom: 0px; } -- cgit v0.12 From 28635d8aeefbd0aa807f333769a0ab9fea9324b0 Mon Sep 17 00:00:00 2001 From: Bill King Date: Tue, 1 Sep 2009 13:08:02 +1000 Subject: Fixes determination of end of odbc string on deficient driver Adds some cleanups (using QVarLengthArray), and reverting to the initial and correct calculation (when the driver doesn't deem fit to return SQL_NO_DATA). --- src/sql/drivers/odbc/qsql_odbc.cpp | 12 ++++---- tests/auto/qsqldatabase/tst_qsqldatabase.cpp | 41 ++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 6 deletions(-) diff --git a/src/sql/drivers/odbc/qsql_odbc.cpp b/src/sql/drivers/odbc/qsql_odbc.cpp index 742d596..2692c96 100644 --- a/src/sql/drivers/odbc/qsql_odbc.cpp +++ b/src/sql/drivers/odbc/qsql_odbc.cpp @@ -323,12 +323,12 @@ static QString qGetStringData(SQLHANDLE hStmt, int column, int colSize, bool uni colSize *= 2; // a tiny bit faster, since it saves a SQLGetData() call } } - char* buf = new char[colSize]; + QVarLengthArray buf(colSize); while (true) { r = SQLGetData(hStmt, column+1, unicode ? SQL_C_WCHAR : SQL_C_CHAR, - (SQLPOINTER)buf, + (SQLPOINTER)buf.data(), colSize, &lengthIndicator); if (r == SQL_SUCCESS || r == SQL_SUCCESS_WITH_INFO) { @@ -343,11 +343,12 @@ static QString qGetStringData(SQLHANDLE hStmt, int column, int colSize, bool uni // colSize-1: remove 0 termination when there is more data to fetch int rSize = (r == SQL_SUCCESS_WITH_INFO) ? (unicode ? colSize-2 : colSize-1) : lengthIndicator; if (unicode) { - fieldVal += QString((QChar*) buf, rSize / 2); + fieldVal += QString((const QChar*) buf.constData(), rSize / 2); } else { - fieldVal += QString::fromAscii(buf, rSize); + fieldVal += QString::fromAscii(buf.constData(), rSize); } - if (lengthIndicator - fieldVal.size() <= 0) { + memset(buf.data(), 0, colSize); + if (lengthIndicator < colSize) { // workaround for Drivermanagers that don't return SQL_NO_DATA break; } @@ -359,7 +360,6 @@ static QString qGetStringData(SQLHANDLE hStmt, int column, int colSize, bool uni break; } } - delete[] buf; return fieldVal; } diff --git a/tests/auto/qsqldatabase/tst_qsqldatabase.cpp b/tests/auto/qsqldatabase/tst_qsqldatabase.cpp index a6b887a..e9a0670 100644 --- a/tests/auto/qsqldatabase/tst_qsqldatabase.cpp +++ b/tests/auto/qsqldatabase/tst_qsqldatabase.cpp @@ -180,6 +180,8 @@ private slots: void odbc_uintfield(); void odbc_bindBoolean_data() { generic_data("QODBC"); } void odbc_bindBoolean(); + void odbc_testqGetString_data() { generic_data("QODBC"); } + void odbc_testqGetString(); void oci_serverDetach_data() { generic_data("QOCI"); } void oci_serverDetach(); // For task 154518 @@ -347,6 +349,7 @@ void tst_QSqlDatabase::dropTestTables(QSqlDatabase db) << qTableName("numericfields") << qTableName("qtest_ibaseblobs") << qTableName("qtestBindBool") + << qTableName("testqGetString") << qTableName("qtest_sqlguid") << qTableName("uint_table") << qTableName("uint_test") @@ -2024,6 +2027,44 @@ void tst_QSqlDatabase::odbc_bindBoolean() QCOMPARE(q.value(1).toBool(), false); } +void tst_QSqlDatabase::odbc_testqGetString() +{ + QFETCH(QString, dbName); + QSqlDatabase db = QSqlDatabase::database(dbName); + CHECK_DATABASE(db); + + QSqlQuery q(db); + QVERIFY_SQL(q, exec("CREATE TABLE " + qTableName("testqGetString") + "(id int, vcvalue varchar(65538))")); + + QString largeString; + largeString.fill('A', 65536); + + // Bind and insert + QVERIFY_SQL(q, prepare("INSERT INTO " + qTableName("testqGetString") + " VALUES(?, ?)")); + q.bindValue(0, 1); + q.bindValue(1, largeString); + QVERIFY_SQL(q, exec()); + q.bindValue(0, 2); + q.bindValue(1, largeString+QLatin1Char('B')); + QVERIFY_SQL(q, exec()); + q.bindValue(0, 3); + q.bindValue(1, largeString+QLatin1Char('B')+QLatin1Char('C')); + QVERIFY_SQL(q, exec()); + + // Retrive + QVERIFY_SQL(q, exec("SELECT id, vcvalue FROM " + qTableName("testqGetString") + " ORDER BY id")); + QVERIFY_SQL(q, next()); + QCOMPARE(q.value(0).toInt(), 1); + QCOMPARE(q.value(1).toString().length(), 65536); + QVERIFY_SQL(q, next()); + QCOMPARE(q.value(0).toInt(), 2); + QCOMPARE(q.value(1).toString().length(), 65537); + QVERIFY_SQL(q, next()); + QCOMPARE(q.value(0).toInt(), 3); + QCOMPARE(q.value(1).toString().length(), 65538); +} + + void tst_QSqlDatabase::mysql_multiselect() { QFETCH(QString, dbName); -- cgit v0.12 From ec581ee164cbdab1a321d44f0795a79d62faf569 Mon Sep 17 00:00:00 2001 From: Jason McDonald Date: Tue, 1 Sep 2009 13:27:21 +1000 Subject: Update license headers. Reviewed-by: Trust Me --- tests/auto/qmargins/tst_qmargins.cpp | 27 ++++++++++----------- .../qtabletevent/device_information/main.cpp | 28 +++++++++++----------- .../qtabletevent/device_information/tabletwidget.h | 26 ++++++++++---------- .../manual/qtabletevent/event_compression/main.cpp | 28 +++++++++++----------- 4 files changed, 54 insertions(+), 55 deletions(-) diff --git a/tests/auto/qmargins/tst_qmargins.cpp b/tests/auto/qmargins/tst_qmargins.cpp index 070aa19..6ee2495 100644 --- a/tests/auto/qmargins/tst_qmargins.cpp +++ b/tests/auto/qmargins/tst_qmargins.cpp @@ -9,8 +9,8 @@ ** No Commercial Usage ** This file contains pre-release code and may not be distributed. ** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. +** contained in the Technology Preview License Agreement accompanying +** this package. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser @@ -21,25 +21,24 @@ ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.1, included in the file LGPL_EXCEPTION.txt in this ** package. ** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** ** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ - #include #include diff --git a/tests/manual/qtabletevent/device_information/main.cpp b/tests/manual/qtabletevent/device_information/main.cpp index 0c2eda3..69867bc 100644 --- a/tests/manual/qtabletevent/device_information/main.cpp +++ b/tests/manual/qtabletevent/device_information/main.cpp @@ -3,14 +3,14 @@ ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the test suite module of the Qt Toolkit. +** This file is part of the test suite of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage ** This file contains pre-release code and may not be distributed. ** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. +** contained in the Technology Preview License Agreement accompanying +** this package. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser @@ -21,20 +21,20 @@ ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.1, included in the file LGPL_EXCEPTION.txt in this ** package. ** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** ** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/manual/qtabletevent/device_information/tabletwidget.h b/tests/manual/qtabletevent/device_information/tabletwidget.h index b16e9ed..d3ccb32 100644 --- a/tests/manual/qtabletevent/device_information/tabletwidget.h +++ b/tests/manual/qtabletevent/device_information/tabletwidget.h @@ -9,8 +9,8 @@ ** No Commercial Usage ** This file contains pre-release code and may not be distributed. ** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. +** contained in the Technology Preview License Agreement accompanying +** this package. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser @@ -21,20 +21,20 @@ ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.1, included in the file LGPL_EXCEPTION.txt in this ** package. ** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** ** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/manual/qtabletevent/event_compression/main.cpp b/tests/manual/qtabletevent/event_compression/main.cpp index 3b869e3..26611d3 100644 --- a/tests/manual/qtabletevent/event_compression/main.cpp +++ b/tests/manual/qtabletevent/event_compression/main.cpp @@ -3,14 +3,14 @@ ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the test suite module of the Qt Toolkit. +** This file is part of the test suite of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage ** This file contains pre-release code and may not be distributed. ** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. +** contained in the Technology Preview License Agreement accompanying +** this package. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser @@ -21,20 +21,20 @@ ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.1, included in the file LGPL_EXCEPTION.txt in this ** package. ** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** ** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ -- cgit v0.12 From b2d9dc8c487a8b87347a7d45a6c4f9dc827ddbfe Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Tue, 1 Sep 2009 13:57:30 +1000 Subject: Add #define's for highp/mediump after #version/#extension headers GLSL shaders require that #version and #extension must appear before any other code. The #define's we insert for highp/mediump/etc must therefore be moved down to just after them. Reviewed-by: Gunnar Sletta --- src/opengl/qglshaderprogram.cpp | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/opengl/qglshaderprogram.cpp b/src/opengl/qglshaderprogram.cpp index c4d9322..56b55d0 100644 --- a/src/opengl/qglshaderprogram.cpp +++ b/src/opengl/qglshaderprogram.cpp @@ -501,6 +501,25 @@ bool QGLShader::compile(const char *source) return d->compile(this); } else if (d->shader) { QVarLengthArray src; + int headerLen = 0; + while (source && source[headerLen] == '#') { + // Skip #version and #extension directives at the start of + // the shader code. We need to insert the qualifierDefines + // and redefineHighp just after them. + if (qstrncmp(source + headerLen, "#version", 8) != 0 && + qstrncmp(source + headerLen, "#extension", 10) != 0) { + break; + } + while (source[headerLen] != '\0' && source[headerLen] != '\n') + ++headerLen; + if (source[headerLen] == '\n') + ++headerLen; + } + QByteArray header; + if (headerLen > 0) { + header = QByteArray(source, headerLen); + src.append(header.constData()); + } #ifdef QGL_DEFINE_QUALIFIERS src.append(qualifierDefines); #endif @@ -509,7 +528,7 @@ bool QGLShader::compile(const char *source) d->shaderType == PartialFragmentShader) src.append(redefineHighp); #endif - src.append(source); + src.append(source + headerLen); QGLContextGroup *ctx = d->ctx; glShaderSource(d->shader, src.size(), src.data(), 0); return d->compile(this); -- cgit v0.12 From 632c430a70e2aa50d57c80e35e15391f0b859749 Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Tue, 1 Sep 2009 09:58:30 +0200 Subject: doc: Fixed several qdoc errors. Also removed four function declarations from QMargins that had no definitions. --- src/corelib/tools/qmargins.cpp | 8 +++----- src/corelib/tools/qmargins.h | 5 ----- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/src/corelib/tools/qmargins.cpp b/src/corelib/tools/qmargins.cpp index df08da1..747ea5e 100644 --- a/src/corelib/tools/qmargins.cpp +++ b/src/corelib/tools/qmargins.cpp @@ -49,7 +49,7 @@ QT_BEGIN_NAMESPACE \class QMargins \ingroup painting - \brief The QMargins + \brief The QMargins class defines the four margins of a rectangle. QMargin defines a set of four margins; left, top, right and bottom, that describe the size of the borders surrounding a rectangle. @@ -70,7 +70,7 @@ QT_BEGIN_NAMESPACE Constructs a margins object with all margins set to 0. - \sa isValid() + \sa isNull() */ /*! @@ -78,7 +78,7 @@ QT_BEGIN_NAMESPACE Constructs margins with the given \a left, \a top, \a right, \a bottom - \sa setWidth(), setHeight() + \sa setLeft(), setRight(), setTop(), setBottom() */ /*! @@ -86,8 +86,6 @@ QT_BEGIN_NAMESPACE Returns true if all margins are is 0; otherwise returns false. - - \sa isValid(), isEmpty() */ diff --git a/src/corelib/tools/qmargins.h b/src/corelib/tools/qmargins.h index be918cc..2691c62 100644 --- a/src/corelib/tools/qmargins.h +++ b/src/corelib/tools/qmargins.h @@ -68,11 +68,6 @@ public: void setRight(int right); void setBottom(int bottom); - int &rleft(); - int &rtop(); - int &rright(); - int &rbottom(); - private: int m_left; int m_top; -- cgit v0.12 From 76d18f5f06f55c7f908ceb9fba4cac41c0c852f8 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Mon, 31 Aug 2009 20:27:13 +0200 Subject: QMetaObject::normalizeType: fix out-of-bound access. As reported in merge request 1375 Also use QVarLenghtArray instead of manually allocated char* Reviewed-by: Thierry --- src/corelib/kernel/qmetaobject.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/corelib/kernel/qmetaobject.cpp b/src/corelib/kernel/qmetaobject.cpp index 30f1cc8..c311465 100644 --- a/src/corelib/kernel/qmetaobject.cpp +++ b/src/corelib/kernel/qmetaobject.cpp @@ -943,7 +943,7 @@ QByteArray QMetaObject::normalizedType(const char *type) if (!type || !*type) return result; - QVarLengthArray stackbuf((int)strlen(type)); + QVarLengthArray stackbuf(int(strlen(type)) + 1); qRemoveWhitespace(type, stackbuf.data()); int templdepth = 0; qNormalizeType(stackbuf.data(), templdepth, result); @@ -968,10 +968,9 @@ QByteArray QMetaObject::normalizedSignature(const char *method) if (!method || !*method) return result; int len = int(strlen(method)); - char stackbuf[64]; - char *buf = (len >= 64 ? new char[len+1] : stackbuf); - qRemoveWhitespace(method, buf); - char *d = buf; + QVarLengthArray stackbuf(len + 1); + char *d = stackbuf.data(); + qRemoveWhitespace(method, d); result.reserve(len); @@ -987,8 +986,6 @@ QByteArray QMetaObject::normalizedSignature(const char *method) result += *d++; } - if (buf != stackbuf) - delete [] buf; return result; } -- cgit v0.12 From 16edcd5ff94ecc731146e3703aaf25cd6bb3fb67 Mon Sep 17 00:00:00 2001 From: Raul Metsma Date: Tue, 1 Sep 2009 10:14:07 +0200 Subject: Implement QSslCertificate::version() and QSslCertificate::serialNumber() Task-number: 251830 Merge-request: 1383 Reviewed-by: Peter Hartmann --- src/network/ssl/qsslcertificate.cpp | 8 ++++++++ src/network/ssl/qsslsocket_openssl_symbols.cpp | 2 ++ src/network/ssl/qsslsocket_openssl_symbols_p.h | 1 + 3 files changed, 11 insertions(+) diff --git a/src/network/ssl/qsslcertificate.cpp b/src/network/ssl/qsslcertificate.cpp index 666770d..5db6d0a 100644 --- a/src/network/ssl/qsslcertificate.cpp +++ b/src/network/ssl/qsslcertificate.cpp @@ -250,6 +250,10 @@ void QSslCertificate::clear() */ QByteArray QSslCertificate::version() const { + if (d->versionString.isEmpty() && d->x509) + d->versionString = + QByteArray::number( qlonglong(q_ASN1_INTEGER_get( d->x509->cert_info->version )) ); + return d->versionString; } @@ -258,6 +262,10 @@ QByteArray QSslCertificate::version() const */ QByteArray QSslCertificate::serialNumber() const { + if (d->serialNumberString.isEmpty() && d->x509) + d->serialNumberString = + QByteArray::number( qlonglong(q_ASN1_INTEGER_get( d->x509->cert_info->serialNumber )) ); + return d->serialNumberString; } diff --git a/src/network/ssl/qsslsocket_openssl_symbols.cpp b/src/network/ssl/qsslsocket_openssl_symbols.cpp index 5b04a57..d3dcd51 100644 --- a/src/network/ssl/qsslsocket_openssl_symbols.cpp +++ b/src/network/ssl/qsslsocket_openssl_symbols.cpp @@ -94,6 +94,7 @@ QT_BEGIN_NAMESPACE #ifdef SSLEAY_MACROS DEFINEFUNC3(void *, ASN1_dup, i2d_of_void *a, a, d2i_of_void *b, b, char *c, c, return 0, return) #endif +DEFINEFUNC(long, ASN1_INTEGER_get, ASN1_INTEGER *a, a, return 0, return) DEFINEFUNC(unsigned char *, ASN1_STRING_data, ASN1_STRING *a, a, return 0, return) DEFINEFUNC(int, ASN1_STRING_length, ASN1_STRING *a, a, return 0, return) DEFINEFUNC4(long, BIO_ctrl, BIO *a, a, int b, b, long c, c, void *d, d, return -1, return) @@ -608,6 +609,7 @@ bool q_resolveOpenSslSymbols() #ifdef SSLEAY_MACROS RESOLVEFUNC(ASN1_dup) #endif + RESOLVEFUNC(ASN1_INTEGER_get) RESOLVEFUNC(ASN1_STRING_data) RESOLVEFUNC(ASN1_STRING_length) RESOLVEFUNC(BIO_ctrl) diff --git a/src/network/ssl/qsslsocket_openssl_symbols_p.h b/src/network/ssl/qsslsocket_openssl_symbols_p.h index f9c92e5..30762ca 100644 --- a/src/network/ssl/qsslsocket_openssl_symbols_p.h +++ b/src/network/ssl/qsslsocket_openssl_symbols_p.h @@ -201,6 +201,7 @@ QT_BEGIN_NAMESPACE #endif // !defined QT_LINKED_OPENSSL bool q_resolveOpenSslSymbols(); +long q_ASN1_INTEGER_get(ASN1_INTEGER *a); unsigned char * q_ASN1_STRING_data(ASN1_STRING *a); int q_ASN1_STRING_length(ASN1_STRING *a); long q_BIO_ctrl(BIO *a, int b, long c, void *d); -- cgit v0.12 From 8f1596ae9b64870c54958611552c71b0b390038f Mon Sep 17 00:00:00 2001 From: Raul Metsma Date: Tue, 1 Sep 2009 10:14:08 +0200 Subject: QSslCertificate: Add + 1 to serialNumber Merge-request: 1383 Reviewed-by: Peter Hartmann --- src/network/ssl/qsslcertificate.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/network/ssl/qsslcertificate.cpp b/src/network/ssl/qsslcertificate.cpp index 5db6d0a..c128da9 100644 --- a/src/network/ssl/qsslcertificate.cpp +++ b/src/network/ssl/qsslcertificate.cpp @@ -252,7 +252,7 @@ QByteArray QSslCertificate::version() const { if (d->versionString.isEmpty() && d->x509) d->versionString = - QByteArray::number( qlonglong(q_ASN1_INTEGER_get( d->x509->cert_info->version )) ); + QByteArray::number(qlonglong(q_ASN1_INTEGER_get(d->x509->cert_info->version))); return d->versionString; } @@ -264,7 +264,7 @@ QByteArray QSslCertificate::serialNumber() const { if (d->serialNumberString.isEmpty() && d->x509) d->serialNumberString = - QByteArray::number( qlonglong(q_ASN1_INTEGER_get( d->x509->cert_info->serialNumber )) ); + QByteArray::number(qlonglong(q_ASN1_INTEGER_get(d->x509->cert_info->serialNumber)) + 1); return d->serialNumberString; } -- cgit v0.12 From 0e03e0d96c65250cf4b982b4dd2be55f948e65c9 Mon Sep 17 00:00:00 2001 From: Benjamin C Meyer Date: Tue, 1 Sep 2009 09:51:53 +0200 Subject: Initialize QNetworkAccessBackend's private variables to 0 in the constructor and when creating a CacheBackend set the manager pointer. Merge-request: 1124 Reviewed-by: Thiago Macieira --- src/network/access/qnetworkaccessbackend.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/network/access/qnetworkaccessbackend.cpp b/src/network/access/qnetworkaccessbackend.cpp index ad9ec06..615ce7c 100644 --- a/src/network/access/qnetworkaccessbackend.cpp +++ b/src/network/access/qnetworkaccessbackend.cpp @@ -90,8 +90,11 @@ QNetworkAccessBackend *QNetworkAccessManagerPrivate::findBackend(QNetworkAccessM QNetworkRequest::PreferNetwork).toInt()); if (mode == QNetworkRequest::AlwaysCache && (op == QNetworkAccessManager::GetOperation - || op == QNetworkAccessManager::HeadOperation)) - return new QNetworkAccessCacheBackend; + || op == QNetworkAccessManager::HeadOperation)) { + QNetworkAccessBackend *backend = new QNetworkAccessCacheBackend; + backend->manager = this; + return backend; + } if (!factoryDataShutdown) { QMutexLocker locker(&factoryData()->mutex); @@ -110,6 +113,8 @@ QNetworkAccessBackend *QNetworkAccessManagerPrivate::findBackend(QNetworkAccessM } QNetworkAccessBackend::QNetworkAccessBackend() + : manager(0) + , reply(0) { } -- cgit v0.12 From 63e2f5d2c95ece21fd32d0690022b89c38fee865 Mon Sep 17 00:00:00 2001 From: Benjamin C Meyer Date: Tue, 1 Sep 2009 09:51:54 +0200 Subject: Use the QDesktopServices::CacheLocation to determine the location to store the temporary cache rather than QDesktopServices::DataLocation Merge-request: 1124 Reviewed-by: Thiago Macieira --- tests/auto/qabstractnetworkcache/tst_qabstractnetworkcache.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/auto/qabstractnetworkcache/tst_qabstractnetworkcache.cpp b/tests/auto/qabstractnetworkcache/tst_qabstractnetworkcache.cpp index 92610db..e338075 100644 --- a/tests/auto/qabstractnetworkcache/tst_qabstractnetworkcache.cpp +++ b/tests/auto/qabstractnetworkcache/tst_qabstractnetworkcache.cpp @@ -81,8 +81,8 @@ public: : QNetworkDiskCache(parent) , gotData(false) { - QString location = QDesktopServices::storageLocation(QDesktopServices::DataLocation) - + QLatin1String("/cache/"); + QString location = QDesktopServices::storageLocation(QDesktopServices::CacheLocation) + + QLatin1String("/qnetworkdiskcache/"); setCacheDirectory(location); clear(); } -- cgit v0.12 From 925912ebf552417306a5bd20fd986afda6a582be Mon Sep 17 00:00:00 2001 From: Benjamin C Meyer Date: Tue, 1 Sep 2009 09:51:56 +0200 Subject: QNetworkAccessManager can delete the QAbstractNetworkCache pointer at any point. Rather then keep a separate pointer to the cache in the reply use the pointer kept by the manager so the reply never tries to access a cache pointer that has already been deleted. Autotest: included Merge-request: 1124 Reviewed-by: Thiago Macieira --- src/network/access/qnetworkaccessbackend.cpp | 4 ++- src/network/access/qnetworkaccessmanager.cpp | 3 -- src/network/access/qnetworkreplyimpl.cpp | 35 ++++++++++++---------- src/network/access/qnetworkreplyimpl_p.h | 3 +- .../tst_qabstractnetworkcache.cpp | 16 ++++++++++ 5 files changed, 40 insertions(+), 21 deletions(-) diff --git a/src/network/access/qnetworkaccessbackend.cpp b/src/network/access/qnetworkaccessbackend.cpp index 615ce7c..947313c 100644 --- a/src/network/access/qnetworkaccessbackend.cpp +++ b/src/network/access/qnetworkaccessbackend.cpp @@ -176,7 +176,9 @@ QList QNetworkAccessBackend::proxyList() const QAbstractNetworkCache *QNetworkAccessBackend::networkCache() const { - return reply->networkCache; // should be the same as manager->networkCache + if (!manager) + return 0; + return manager->networkCache; } void QNetworkAccessBackend::setCachingEnabled(bool enable) diff --git a/src/network/access/qnetworkaccessmanager.cpp b/src/network/access/qnetworkaccessmanager.cpp index aafe44b..5a8756b 100644 --- a/src/network/access/qnetworkaccessmanager.cpp +++ b/src/network/access/qnetworkaccessmanager.cpp @@ -692,9 +692,6 @@ QNetworkReply *QNetworkAccessManager::createRequest(QNetworkAccessManager::Opera // third step: setup the reply priv->setup(op, request, outgoingData); - if (request.attribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferNetwork).toInt() != - QNetworkRequest::AlwaysNetwork) - priv->setNetworkCache(d->networkCache); #ifndef QT_NO_NETWORKPROXY QList proxyList = d->queryProxy(QNetworkProxyQuery(request.url())); priv->proxyList = proxyList; diff --git a/src/network/access/qnetworkreplyimpl.cpp b/src/network/access/qnetworkreplyimpl.cpp index c37c66d..c805d59 100644 --- a/src/network/access/qnetworkreplyimpl.cpp +++ b/src/network/access/qnetworkreplyimpl.cpp @@ -53,7 +53,7 @@ QT_BEGIN_NAMESPACE inline QNetworkReplyImplPrivate::QNetworkReplyImplPrivate() : backend(0), outgoingData(0), - copyDevice(0), networkCache(0), + copyDevice(0), cacheEnabled(false), cacheSaveDevice(0), notificationHandlingPaused(false), bytesDownloaded(0), lastBytesDownloaded(-1), bytesUploaded(-1), @@ -203,11 +203,6 @@ void QNetworkReplyImplPrivate::setup(QNetworkAccessManager::Operation op, const QMetaObject::invokeMethod(q, "_q_startOperation", Qt::QueuedConnection); } -void QNetworkReplyImplPrivate::setNetworkCache(QAbstractNetworkCache *nc) -{ - networkCache = nc; -} - void QNetworkReplyImplPrivate::backendNotify(InternalNotifications notification) { Q_Q(QNetworkReplyImpl); @@ -277,17 +272,27 @@ void QNetworkReplyImplPrivate::resumeNotificationHandling() QCoreApplication::postEvent(q, new QEvent(QEvent::NetworkReplyUpdated)); } +QAbstractNetworkCache *QNetworkReplyImplPrivate::networkCache() const +{ + if (!backend) + return 0; + return backend->networkCache(); +} + void QNetworkReplyImplPrivate::createCache() { // check if we can save and if we're allowed to - if (!networkCache || !request.attribute(QNetworkRequest::CacheSaveControlAttribute, true).toBool()) + if (!networkCache() + || request.attribute(QNetworkRequest::CacheLoadControlAttribute, + QNetworkRequest::PreferNetwork).toInt() + == QNetworkRequest::AlwaysNetwork) return; cacheEnabled = true; } bool QNetworkReplyImplPrivate::isCachingEnabled() const { - return (cacheEnabled && networkCache != 0); + return (cacheEnabled && networkCache() != 0); } void QNetworkReplyImplPrivate::setCachingEnabled(bool enable) @@ -311,7 +316,7 @@ void QNetworkReplyImplPrivate::setCachingEnabled(bool enable) qDebug("QNetworkReplyImpl: setCachingEnabled(true) called after setCachingEnabled(false) -- " "backend %s probably needs to be fixed", backend->metaObject()->className()); - networkCache->remove(url); + networkCache()->remove(url); cacheSaveDevice = 0; cacheEnabled = false; } @@ -320,9 +325,9 @@ void QNetworkReplyImplPrivate::setCachingEnabled(bool enable) void QNetworkReplyImplPrivate::completeCacheSave() { if (cacheEnabled && errorCode != QNetworkReplyImpl::NoError) { - networkCache->remove(url); + networkCache()->remove(url); } else if (cacheEnabled && cacheSaveDevice) { - networkCache->insert(cacheSaveDevice); + networkCache()->insert(cacheSaveDevice); } cacheSaveDevice = 0; cacheEnabled = false; @@ -385,15 +390,15 @@ void QNetworkReplyImplPrivate::feed(const QByteArray &data) metaData.setAttributes(attributes); } - cacheSaveDevice = networkCache->prepare(metaData); + cacheSaveDevice = networkCache()->prepare(metaData); if (!cacheSaveDevice || (cacheSaveDevice && !cacheSaveDevice->isOpen())) { if (cacheSaveDevice && !cacheSaveDevice->isOpen()) qCritical("QNetworkReplyImpl: network cache returned a device that is not open -- " "class %s probably needs to be fixed", - networkCache->metaObject()->className()); + networkCache()->metaObject()->className()); - networkCache->remove(url); + networkCache()->remove(url); cacheSaveDevice = 0; cacheEnabled = false; } @@ -524,7 +529,7 @@ QNetworkReplyImpl::~QNetworkReplyImpl() { Q_D(QNetworkReplyImpl); if (d->isCachingEnabled()) - d->networkCache->remove(url()); + d->networkCache()->remove(url()); } void QNetworkReplyImpl::abort() diff --git a/src/network/access/qnetworkreplyimpl_p.h b/src/network/access/qnetworkreplyimpl_p.h index 0accaab..f723b7f 100644 --- a/src/network/access/qnetworkreplyimpl_p.h +++ b/src/network/access/qnetworkreplyimpl_p.h @@ -128,7 +128,6 @@ public: void setup(QNetworkAccessManager::Operation op, const QNetworkRequest &request, QIODevice *outgoingData); - void setNetworkCache(QAbstractNetworkCache *networkCache); void pauseNotificationHandling(); void resumeNotificationHandling(); @@ -153,7 +152,7 @@ public: QNetworkAccessBackend *backend; QIODevice *outgoingData; QIODevice *copyDevice; - QAbstractNetworkCache *networkCache; + QAbstractNetworkCache *networkCache() const; bool cacheEnabled; QIODevice *cacheSaveDevice; diff --git a/tests/auto/qabstractnetworkcache/tst_qabstractnetworkcache.cpp b/tests/auto/qabstractnetworkcache/tst_qabstractnetworkcache.cpp index e338075..ee49210 100644 --- a/tests/auto/qabstractnetworkcache/tst_qabstractnetworkcache.cpp +++ b/tests/auto/qabstractnetworkcache/tst_qabstractnetworkcache.cpp @@ -69,6 +69,8 @@ private slots: void cacheControl_data(); void cacheControl(); + void deleteCache(); + private: void check(); }; @@ -269,6 +271,20 @@ void tst_QAbstractNetworkCache::check() QCOMPARE(diskCache->gotData, fetchFromCache); } +void tst_QAbstractNetworkCache::deleteCache() +{ + QNetworkAccessManager manager; + NetworkDiskCache *diskCache = new NetworkDiskCache(&manager); + manager.setCache(diskCache); + + QString url = "httpcachetest_cachecontrol.cgi?max-age=1000"; + QNetworkRequest request(QUrl(TESTFILE + url)); + QNetworkReply *reply = manager.get(request); + QSignalSpy downloaded1(reply, SIGNAL(finished())); + manager.setCache(0); + QTRY_COMPARE(downloaded1.count(), 1); +} + QTEST_MAIN(tst_QAbstractNetworkCache) #include "tst_qabstractnetworkcache.moc" -- cgit v0.12 From 651f63172e4f68f8e084c16415499fdbda08bf39 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 1 Sep 2009 09:53:10 +0200 Subject: Re-add check for saving to cache, which was removed by accident. Discussed with Ben Meyer. --- src/network/access/qnetworkreplyimpl.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/network/access/qnetworkreplyimpl.cpp b/src/network/access/qnetworkreplyimpl.cpp index c805d59..71e007f 100644 --- a/src/network/access/qnetworkreplyimpl.cpp +++ b/src/network/access/qnetworkreplyimpl.cpp @@ -283,6 +283,7 @@ void QNetworkReplyImplPrivate::createCache() { // check if we can save and if we're allowed to if (!networkCache() + || !request.attribute(QNetworkRequest::CacheSaveControlAttribute, true).toBool() || request.attribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferNetwork).toInt() == QNetworkRequest::AlwaysNetwork) -- cgit v0.12 From 67d5b1b800df55c61241c7fa33feeeea41a31513 Mon Sep 17 00:00:00 2001 From: Peter Hartmann Date: Tue, 1 Sep 2009 10:30:11 +0200 Subject: QSslCertificate: fix previous patch, add autotest and documentation The +1 must be added to the version, not the serial number. Reviewed-by: trustme --- src/network/ssl/qsslcertificate.cpp | 6 +++--- tests/auto/qsslcertificate/tst_qsslcertificate.cpp | 6 +++++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/network/ssl/qsslcertificate.cpp b/src/network/ssl/qsslcertificate.cpp index c128da9..3793b1e 100644 --- a/src/network/ssl/qsslcertificate.cpp +++ b/src/network/ssl/qsslcertificate.cpp @@ -252,19 +252,19 @@ QByteArray QSslCertificate::version() const { if (d->versionString.isEmpty() && d->x509) d->versionString = - QByteArray::number(qlonglong(q_ASN1_INTEGER_get(d->x509->cert_info->version))); + QByteArray::number(qlonglong(q_ASN1_INTEGER_get(d->x509->cert_info->version)) + 1); return d->versionString; } /*! - Returns the certificate's serial number string. + Returns the certificate's serial number string in decimal format. */ QByteArray QSslCertificate::serialNumber() const { if (d->serialNumberString.isEmpty() && d->x509) d->serialNumberString = - QByteArray::number(qlonglong(q_ASN1_INTEGER_get(d->x509->cert_info->serialNumber)) + 1); + QByteArray::number(qlonglong(q_ASN1_INTEGER_get(d->x509->cert_info->serialNumber))); return d->serialNumberString; } diff --git a/tests/auto/qsslcertificate/tst_qsslcertificate.cpp b/tests/auto/qsslcertificate/tst_qsslcertificate.cpp index add48c4..4dfb6b9 100644 --- a/tests/auto/qsslcertificate/tst_qsslcertificate.cpp +++ b/tests/auto/qsslcertificate/tst_qsslcertificate.cpp @@ -267,6 +267,8 @@ void tst_QSslCertificate::compareCertificates( QCOMPARE(cert1.alternateSubjectNames(), cert2.alternateSubjectNames()); QCOMPARE(cert1.effectiveDate(), cert2.effectiveDate()); QCOMPARE(cert1.expiryDate(), cert2.expiryDate()); + QCOMPARE(cert1.version(), cert2.version()); + QCOMPARE(cert1.serialNumber(), cert2.serialNumber()); // ### add more functions here ... } @@ -677,7 +679,9 @@ void tst_QSslCertificate::certInfo() QCOMPARE(cert.subjectInfo("C"), QString("NO")); QCOMPARE(cert.subjectInfo("ST"), QString()); - QCOMPARE(cert.version(), QByteArray()); + QCOMPARE(cert.version(), QByteArray::number(1)); + QCOMPARE(cert.serialNumber(), QByteArray::number(17)); + QCOMPARE(cert.toPem().constData(), (const char*)pem); QCOMPARE(cert.toDer(), QByteArray::fromHex(der)); -- cgit v0.12 From f39ead322f7b2e485cc6767b609eb5bc8a10b0ea Mon Sep 17 00:00:00 2001 From: Bernhard Rosenkraenzer Date: Tue, 1 Sep 2009 10:40:49 +0200 Subject: qlist.h uses memcpy() without including or Attempting to make use of the inlined QList::node_copy without including or with gcc 4.4 results in (e.g.) /usr/lib64/qt4/include/QtCore/qlist.h: In member function "void QList::node_copy(QList::Node*, QList::Node*, QList::Node*) [with T = net::Port]": /usr/lib64/qt4/include/QtCore/qlist.h:600: instantiated from "void QList::detach_helper() [with T = net::Port]" /usr/lib64/qt4/include/QtCore/qlist.h:121: instantiated from "void QList::detach() [with T = net::Port]" /usr/lib64/qt4/include/QtCore/qlist.h:462: instantiated from "void QList::append(const T&) [with T = net::Port]" /usr/src/ark/BUILD/kdenetwork/kget/transfer-plugins/bittorrent/libbtcore/net/portlist.cpp:54: instantiated from here /usr/lib64/qt4/include/QtCore/qlist.h:388: error: "memcpy" was not declared in this scope Task-number: reported, but not yet assigned a number Merge-request: 1388 Reviewed-by: Thiago Macieira --- src/corelib/tools/qlist.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/corelib/tools/qlist.h b/src/corelib/tools/qlist.h index ba8ae56..c2bdbee 100644 --- a/src/corelib/tools/qlist.h +++ b/src/corelib/tools/qlist.h @@ -52,6 +52,7 @@ #endif #include +#include QT_BEGIN_HEADER -- cgit v0.12 From a985aaccfcaf2e24b7094875f2e6f51d80c45997 Mon Sep 17 00:00:00 2001 From: Prasanth Ullattil Date: Tue, 1 Sep 2009 10:31:37 +0200 Subject: Reduce the flickering caused by QAxClientSite::EnableModeless Lock the updates during this call from the activex control. Task-number: 257593 Reviewed-by: Trust Me --- src/activeqt/container/qaxwidget.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/activeqt/container/qaxwidget.cpp b/src/activeqt/container/qaxwidget.cpp index 621c836..22e7a82 100644 --- a/src/activeqt/container/qaxwidget.cpp +++ b/src/activeqt/container/qaxwidget.cpp @@ -1437,6 +1437,7 @@ extern Q_GUI_EXPORT bool qt_win_ignoreNextMouseReleaseEvent; HRESULT WINAPI QAxClientSite::EnableModeless(BOOL fEnable) { + LockWindowUpdate(host->window()->winId()); EnableWindow(host->window()->winId(), fEnable); if (!fEnable) { @@ -1447,6 +1448,7 @@ HRESULT WINAPI QAxClientSite::EnableModeless(BOOL fEnable) QApplicationPrivate::leaveModal(host); } qt_win_ignoreNextMouseReleaseEvent = false; + LockWindowUpdate(0); return S_OK; } -- cgit v0.12 From efe61b3b44c0c391d4c11bd061e531f03bf8fb4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Tue, 1 Sep 2009 09:55:13 +0200 Subject: Fixed poor utilization of depth buffer range in GL 2 paint engine. Before this patch we were only able to do 20 or so IntersectClips before failing, this patch instead adapts to the fixed point nature of typical depth buffer implementations and lets us do ~2^15 IntersectClip operations before failing, which should be a reasonable limit for any real-world application. Using the following mapping of old floating point depths to integer depths: -1.0 -> 0, -0.5 -> 1, 0.0 -> 2, 0.25 -> 3, 0.5 -> 4, 0.625 -> 5, etc.. Reviewed-by: Tom --- .../gl2paintengineex/qpaintengineex_opengl2.cpp | 51 +++++++++++----------- .../gl2paintengineex/qpaintengineex_opengl2_p.h | 19 ++++++-- 2 files changed, 41 insertions(+), 29 deletions(-) diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp index a976a02..0c01263 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp @@ -380,7 +380,7 @@ void QGL2PaintEngineExPrivate::useSimpleShader() } if (simpleShaderDepthUniformDirty) { - shaderManager->simpleProgram()->setUniformValue("depth", (GLfloat)q->state()->currentDepth); + shaderManager->simpleProgram()->setUniformValue("depth", normalizedDeviceDepth(q->state()->currentDepth)); simpleShaderDepthUniformDirty = false; } } @@ -731,7 +731,6 @@ void QGL2PaintEngineExPrivate::resetGLState() glActiveTexture(GL_TEXTURE0); glDisable(GL_DEPTH_TEST); glDisable(GL_SCISSOR_TEST); - glDepthFunc(GL_LESS); glDepthMask(true); glClearDepth(1); } @@ -959,7 +958,7 @@ bool QGL2PaintEngineExPrivate::prepareForDraw(bool srcPixelsAreOpaque) } if (depthUniformDirty) { - shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::Depth), (GLfloat)q->state()->currentDepth); + shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::Depth), normalizedDeviceDepth(q->state()->currentDepth)); depthUniformDirty = false; } @@ -1351,7 +1350,7 @@ bool QGL2PaintEngineEx::begin(QPaintDevice *pdev) if (!d->inRenderText) { glDisable(GL_DEPTH_TEST); glDisable(GL_SCISSOR_TEST); - glDepthFunc(GL_LEQUAL); + glDepthFunc(GL_LESS); glDepthMask(false); } @@ -1441,7 +1440,7 @@ void QGL2PaintEngineEx::ensureActive() if (d->needsSync) { glViewport(0, 0, d->width, d->height); glDepthMask(false); - glDepthFunc(GL_LEQUAL); + glDepthFunc(GL_LESS); setState(state()); d->needsSync = false; } @@ -1492,7 +1491,7 @@ void QGL2PaintEngineEx::clipEnabledChanged() d->regenerateDepthClip(); } else { if (d->use_system_clip) { - state()->currentDepth = -0.5f; + state()->currentDepth = 0; } else { state()->depthTestEnabled = false; } @@ -1501,7 +1500,7 @@ void QGL2PaintEngineEx::clipEnabledChanged() } } -void QGL2PaintEngineExPrivate::writeClip(const QVectorPath &path, float depth) +void QGL2PaintEngineExPrivate::writeClip(const QVectorPath &path, uint depth) { transferMode(BrushDrawingMode); @@ -1510,7 +1509,7 @@ void QGL2PaintEngineExPrivate::writeClip(const QVectorPath &path, float depth) if (q->state()->needsDepthBufferClear) { glDepthMask(true); - glClearDepth(0.5); + glClearDepth(rawDepth(2)); glClear(GL_DEPTH_BUFFER_BIT); q->state()->needsDepthBufferClear = false; glDepthMask(false); @@ -1532,7 +1531,7 @@ void QGL2PaintEngineExPrivate::writeClip(const QVectorPath &path, float depth) glColorMask(false, false, false, false); glDepthMask(true); - shaderManager->simpleProgram()->setUniformValue("depth", depth); + shaderManager->simpleProgram()->setUniformValue("depth", normalizedDeviceDepth(depth)); simpleShaderDepthUniformDirty = true; glEnable(GL_DEPTH_TEST); @@ -1596,12 +1595,12 @@ void QGL2PaintEngineEx::clip(const QVectorPath &path, Qt::ClipOperation op) glDepthFunc(GL_ALWAYS); - state()->maxDepth = 0.5f; + state()->maxDepth = 4; d->writeClip(qtVectorPathForPath(path), state()->maxDepth); - state()->currentDepth = 0.25f; + state()->currentDepth = 3; state()->depthTestEnabled = true; - glDepthFunc(GL_LEQUAL); + glDepthFunc(GL_LESS); glEnable(GL_DEPTH_TEST); } @@ -1610,7 +1609,7 @@ void QGL2PaintEngineEx::clip(const QVectorPath &path, Qt::ClipOperation op) if (d->use_system_clip) { glEnable(GL_DEPTH_TEST); state()->depthTestEnabled = true; - state()->currentDepth = -0.5; + state()->currentDepth = 0; } else { glDisable(GL_DEPTH_TEST); state()->depthTestEnabled = false; @@ -1618,18 +1617,18 @@ void QGL2PaintEngineEx::clip(const QVectorPath &path, Qt::ClipOperation op) state()->canRestoreClip = false; break; case Qt::IntersectClip: - state()->maxDepth = (1.0f + state()->maxDepth) * 0.5; + ++state()->maxDepth; d->writeClip(path, state()->maxDepth); - state()->currentDepth = 1.5 * state()->maxDepth - 0.5f; + state()->currentDepth = state()->maxDepth - 1; state()->depthTestEnabled = true; break; case Qt::ReplaceClip: d->systemStateChanged(); state()->rectangleClip = QRect(); - state()->maxDepth = 0.5f; + state()->maxDepth = 4; glDepthFunc(GL_ALWAYS); d->writeClip(path, state()->maxDepth); - state()->currentDepth = 0.25f; + state()->currentDepth = 3; state()->canRestoreClip = false; state()->depthTestEnabled = true; break; @@ -1641,7 +1640,7 @@ void QGL2PaintEngineEx::clip(const QVectorPath &path, Qt::ClipOperation op) break; } - glDepthFunc(GL_LEQUAL); + glDepthFunc(GL_LESS); if (state()->depthTestEnabled) { glEnable(GL_DEPTH_TEST); d->simpleShaderDepthUniformDirty = true; @@ -1672,8 +1671,8 @@ void QGL2PaintEngineExPrivate::systemStateChanged() glDisable(GL_SCISSOR_TEST); - q->state()->currentDepth = -0.5f; - q->state()->maxDepth = 0.5f; + q->state()->currentDepth = 1; + q->state()->maxDepth = 4; q->state()->rectangleClip = QRect(0, 0, width, height); @@ -1708,8 +1707,8 @@ void QGL2PaintEngineExPrivate::systemStateChanged() path.addRegion(systemClip); glDepthFunc(GL_ALWAYS); - writeClip(qtVectorPathForPath(path), 0.0f); - glDepthFunc(GL_LEQUAL); + writeClip(qtVectorPathForPath(path), 2); + glDepthFunc(GL_LESS); glEnable(GL_DEPTH_TEST); q->state()->depthTestEnabled = true; @@ -1718,7 +1717,7 @@ void QGL2PaintEngineExPrivate::systemStateChanged() q->transformChanged(); } - q->state()->currentDepth = -0.5f; + q->state()->currentDepth = 1; simpleShaderDepthUniformDirty = true; depthUniformDirty = true; } @@ -1757,7 +1756,7 @@ void QGL2PaintEngineEx::setState(QPainterState *new_state) if (old_state && old_state != s && old_state->canRestoreClip) { d->updateDepthScissorTest(); glDepthMask(false); - glDepthFunc(GL_LEQUAL); + glDepthFunc(GL_LESS); s->maxDepth = old_state->maxDepth; } else { d->regenerateDepthClip(); @@ -1802,8 +1801,8 @@ QOpenGL2PaintEngineState::QOpenGL2PaintEngineState() needsDepthBufferClear = true; depthTestEnabled = false; scissorTestEnabled = false; - currentDepth = -0.5f; - maxDepth = 0.5f; + currentDepth = 1; + maxDepth = 4; canRestoreClip = true; hasRectangleClip = false; } diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h index 58fcde1..552e390 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h @@ -82,8 +82,8 @@ public: bool depthTestEnabled; bool scissorTestEnabled; - qreal currentDepth; - qreal maxDepth; + uint maxDepth; + uint currentDepth; bool canRestoreClip; QRect rectangleClip; @@ -230,13 +230,26 @@ public: QGLEngineShaderManager* shaderManager; - void writeClip(const QVectorPath &path, float depth); + void writeClip(const QVectorPath &path, uint depth); void updateDepthScissorTest(); void setScissor(const QRect &rect); void regenerateDepthClip(); void systemStateChanged(); uint use_system_clip : 1; + static inline GLfloat rawDepth(uint depth) + { + // assume at least 16 bits in the depth buffer, and + // use 2^15 depth levels to be safe with regard to + // rounding issues etc + return depth * (1.0f / GLfloat((1 << 15) - 1)); + } + + static inline GLfloat normalizedDeviceDepth(uint depth) + { + return 2.0f * rawDepth(depth) - 1.0f; + } + uint location(QGLEngineShaderManager::Uniform uniform) { return shaderManager->getUniformLocation(uniform); -- cgit v0.12 From b2e91ecd641b9c891ea823cfc647f729af6228e8 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 1 Sep 2009 07:58:11 +0200 Subject: Make the existence of the LICENSE.GPL3 file optional The repository no longer carries this license. The final releases will still have it. In any case, the LGPLv2.1 is compatible with the GPLv3. Required-By: Nokia Legal Reviewed-by: Marius Storm-Olsen --- LICENSE.GPL3 | 696 --------------------------------------- configure | 15 +- tools/configure/configureapp.cpp | 9 +- 3 files changed, 17 insertions(+), 703 deletions(-) delete mode 100644 LICENSE.GPL3 diff --git a/LICENSE.GPL3 b/LICENSE.GPL3 deleted file mode 100644 index 265c4ea..0000000 --- a/LICENSE.GPL3 +++ /dev/null @@ -1,696 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - - The Qt GUI Toolkit is Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). - Contact: Nokia Corporation (qt-info@nokia.com) - - You may use, distribute and copy the Qt GUI Toolkit under the terms of - GNU General Public License version 3, which is displayed below. - -------------------------------------------------------------------------- - - GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The GNU General Public License is a free, copyleft license for -software and other kinds of works. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -the GNU General Public License is intended to guarantee your freedom to -share and change all versions of a program--to make sure it remains free -software for all its users. We, the Free Software Foundation, use the -GNU General Public License for most of our software; it applies also to -any other work released this way by its authors. You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -them if you wish), that you receive source code or can get it if you -want it, that you can change the software or use pieces of it in new -free programs, and that you know you can do these things. - - To protect your rights, we need to prevent others from denying you -these rights or asking you to surrender the rights. Therefore, you have -certain responsibilities if you distribute copies of the software, or if -you modify it: responsibilities to respect the freedom of others. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must pass on to the recipients the same -freedoms that you received. You must make sure that they, too, receive -or can get the source code. And you must show them these terms so they -know their rights. - - Developers that use the GNU GPL protect your rights with two steps: -(1) assert copyright on the software, and (2) offer you this License -giving you legal permission to copy, distribute and/or modify it. - - For the developers' and authors' protection, the GPL clearly explains -that there is no warranty for this free software. For both users' and -authors' sake, the GPL requires that modified versions be marked as -changed, so that their problems will not be attributed erroneously to -authors of previous versions. - - Some devices are designed to deny users access to install or run -modified versions of the software inside them, although the manufacturer -can do so. This is fundamentally incompatible with the aim of -protecting users' freedom to change the software. The systematic -pattern of such abuse occurs in the area of products for individuals to -use, which is precisely where it is most unacceptable. Therefore, we -have designed this version of the GPL to prohibit the practice for those -products. If such problems arise substantially in other domains, we -stand ready to extend this provision to those domains in future versions -of the GPL, as needed to protect the freedom of users. - - Finally, every program is threatened constantly by software patents. -States should not allow patents to restrict development and use of -software on general-purpose computers, but in those that do, we wish to -avoid the special danger that patents applied to a free program could -make it effectively proprietary. To prevent this, the GPL assures that -patents cannot be used to render the program non-free. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS - - 0. Definitions. - - "This License" refers to version 3 of the GNU General Public License. - - "Copyright" also means copyright-like laws that apply to other kinds of -works, such as semiconductor masks. - - "The Program" refers to any copyrightable work licensed under this -License. Each licensee is addressed as "you". "Licensees" and -"recipients" may be individuals or organizations. - - To "modify" a work means to copy from or adapt all or part of the work -in a fashion requiring copyright permission, other than the making of an -exact copy. The resulting work is called a "modified version" of the -earlier work or a work "based on" the earlier work. - - A "covered work" means either the unmodified Program or a work based -on the Program. - - To "propagate" a work means to do anything with it that, without -permission, would make you directly or secondarily liable for -infringement under applicable copyright law, except executing it on a -computer or modifying a private copy. Propagation includes copying, -distribution (with or without modification), making available to the -public, and in some countries other activities as well. - - To "convey" a work means any kind of propagation that enables other -parties to make or receive copies. Mere interaction with a user through -a computer network, with no transfer of a copy, is not conveying. - - An interactive user interface displays "Appropriate Legal Notices" -to the extent that it includes a convenient and prominently visible -feature that (1) displays an appropriate copyright notice, and (2) -tells the user that there is no warranty for the work (except to the -extent that warranties are provided), that licensees may convey the -work under this License, and how to view a copy of this License. If -the interface presents a list of user commands or options, such as a -menu, a prominent item in the list meets this criterion. - - 1. Source Code. - - The "source code" for a work means the preferred form of the work -for making modifications to it. "Object code" means any non-source -form of a work. - - A "Standard Interface" means an interface that either is an official -standard defined by a recognized standards body, or, in the case of -interfaces specified for a particular programming language, one that -is widely used among developers working in that language. - - The "System Libraries" of an executable work include anything, other -than the work as a whole, that (a) is included in the normal form of -packaging a Major Component, but which is not part of that Major -Component, and (b) serves only to enable use of the work with that -Major Component, or to implement a Standard Interface for which an -implementation is available to the public in source code form. A -"Major Component", in this context, means a major essential component -(kernel, window system, and so on) of the specific operating system -(if any) on which the executable work runs, or a compiler used to -produce the work, or an object code interpreter used to run it. - - The "Corresponding Source" for a work in object code form means all -the source code needed to generate, install, and (for an executable -work) run the object code and to modify the work, including scripts to -control those activities. However, it does not include the work's -System Libraries, or general-purpose tools or generally available free -programs which are used unmodified in performing those activities but -which are not part of the work. For example, Corresponding Source -includes interface definition files associated with source files for -the work, and the source code for shared libraries and dynamically -linked subprograms that the work is specifically designed to require, -such as by intimate data communication or control flow between those -subprograms and other parts of the work. - - The Corresponding Source need not include anything that users -can regenerate automatically from other parts of the Corresponding -Source. - - The Corresponding Source for a work in source code form is that -same work. - - 2. Basic Permissions. - - All rights granted under this License are granted for the term of -copyright on the Program, and are irrevocable provided the stated -conditions are met. This License explicitly affirms your unlimited -permission to run the unmodified Program. The output from running a -covered work is covered by this License only if the output, given its -content, constitutes a covered work. This License acknowledges your -rights of fair use or other equivalent, as provided by copyright law. - - You may make, run and propagate covered works that you do not -convey, without conditions so long as your license otherwise remains -in force. You may convey covered works to others for the sole purpose -of having them make modifications exclusively for you, or provide you -with facilities for running those works, provided that you comply with -the terms of this License in conveying all material for which you do -not control copyright. Those thus making or running the covered works -for you must do so exclusively on your behalf, under your direction -and control, on terms that prohibit them from making any copies of -your copyrighted material outside their relationship with you. - - Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 -makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - - No covered work shall be deemed part of an effective technological -measure under any applicable law fulfilling obligations under article -11 of the WIPO copyright treaty adopted on 20 December 1996, or -similar laws prohibiting or restricting circumvention of such -measures. - - When you convey a covered work, you waive any legal power to forbid -circumvention of technological measures to the extent such circumvention -is effected by exercising rights under this License with respect to -the covered work, and you disclaim any intention to limit operation or -modification of the work as a means of enforcing, against the work's -users, your or third parties' legal rights to forbid circumvention of -technological measures. - - 4. Conveying Verbatim Copies. - - You may convey verbatim copies of the Program's source code as you -receive it, in any medium, provided that you conspicuously and -appropriately publish on each copy an appropriate copyright notice; -keep intact all notices stating that this License and any -non-permissive terms added in accord with section 7 apply to the code; -keep intact all notices of the absence of any warranty; and give all -recipients a copy of this License along with the Program. - - You may charge any price or no price for each copy that you convey, -and you may offer support or warranty protection for a fee. - - 5. Conveying Modified Source Versions. - - You may convey a work based on the Program, or the modifications to -produce it from the Program, in the form of source code under the -terms of section 4, provided that you also meet all of these conditions: - - a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - - b) The work must carry prominent notices stating that it is - released under this License and any conditions added under section - 7. This requirement modifies the requirement in section 4 to - "keep intact all notices". - - c) You must license the entire work, as a whole, under this - License to anyone who comes into possession of a copy. This - License will therefore apply, along with any applicable section 7 - additional terms, to the whole of the work, and all its parts, - regardless of how they are packaged. This License gives no - permission to license the work in any other way, but it does not - invalidate such permission if you have separately received it. - - d) If the work has interactive user interfaces, each must display - Appropriate Legal Notices; however, if the Program has interactive - interfaces that do not display Appropriate Legal Notices, your - work need not make them do so. - - A compilation of a covered work with other separate and independent -works, which are not by their nature extensions of the covered work, -and which are not combined with it such as to form a larger program, -in or on a volume of a storage or distribution medium, is called an -"aggregate" if the compilation and its resulting copyright are not -used to limit the access or legal rights of the compilation's users -beyond what the individual works permit. Inclusion of a covered work -in an aggregate does not cause this License to apply to the other -parts of the aggregate. - - 6. Conveying Non-Source Forms. - - You may convey a covered work in object code form under the terms -of sections 4 and 5, provided that you also convey the -machine-readable Corresponding Source under the terms of this License, -in one of these ways: - - a) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by the - Corresponding Source fixed on a durable physical medium - customarily used for software interchange. - - b) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by a - written offer, valid for at least three years and valid for as - long as you offer spare parts or customer support for that product - model, to give anyone who possesses the object code either (1) a - copy of the Corresponding Source for all the software in the - product that is covered by this License, on a durable physical - medium customarily used for software interchange, for a price no - more than your reasonable cost of physically performing this - conveying of source, or (2) access to copy the - Corresponding Source from a network server at no charge. - - c) Convey individual copies of the object code with a copy of the - written offer to provide the Corresponding Source. This - alternative is allowed only occasionally and noncommercially, and - only if you received the object code with such an offer, in accord - with subsection 6b. - - d) Convey the object code by offering access from a designated - place (gratis or for a charge), and offer equivalent access to the - Corresponding Source in the same way through the same place at no - further charge. You need not require recipients to copy the - Corresponding Source along with the object code. If the place to - copy the object code is a network server, the Corresponding Source - may be on a different server (operated by you or a third party) - that supports equivalent copying facilities, provided you maintain - clear directions next to the object code saying where to find the - Corresponding Source. Regardless of what server hosts the - Corresponding Source, you remain obligated to ensure that it is - available for as long as needed to satisfy these requirements. - - e) Convey the object code using peer-to-peer transmission, provided - you inform other peers where the object code and Corresponding - Source of the work are being offered to the general public at no - charge under subsection 6d. - - A separable portion of the object code, whose source code is excluded -from the Corresponding Source as a System Library, need not be -included in conveying the object code work. - - A "User Product" is either (1) a "consumer product", which means any -tangible personal property which is normally used for personal, family, -or household purposes, or (2) anything designed or sold for incorporation -into a dwelling. In determining whether a product is a consumer product, -doubtful cases shall be resolved in favor of coverage. For a particular -product received by a particular user, "normally used" refers to a -typical or common use of that class of product, regardless of the status -of the particular user or of the way in which the particular user -actually uses, or expects or is expected to use, the product. A product -is a consumer product regardless of whether the product has substantial -commercial, industrial or non-consumer uses, unless such uses represent -the only significant mode of use of the product. - - "Installation Information" for a User Product means any methods, -procedures, authorization keys, or other information required to install -and execute modified versions of a covered work in that User Product from -a modified version of its Corresponding Source. The information must -suffice to ensure that the continued functioning of the modified object -code is in no case prevented or interfered with solely because -modification has been made. - - If you convey an object code work under this section in, or with, or -specifically for use in, a User Product, and the conveying occurs as -part of a transaction in which the right of possession and use of the -User Product is transferred to the recipient in perpetuity or for a -fixed term (regardless of how the transaction is characterized), the -Corresponding Source conveyed under this section must be accompanied -by the Installation Information. But this requirement does not apply -if neither you nor any third party retains the ability to install -modified object code on the User Product (for example, the work has -been installed in ROM). - - The requirement to provide Installation Information does not include a -requirement to continue to provide support service, warranty, or updates -for a work that has been modified or installed by the recipient, or for -the User Product in which it has been modified or installed. Access to a -network may be denied when the modification itself materially and -adversely affects the operation of the network or violates the rules and -protocols for communication across the network. - - Corresponding Source conveyed, and Installation Information provided, -in accord with this section must be in a format that is publicly -documented (and with an implementation available to the public in -source code form), and must require no special password or key for -unpacking, reading or copying. - - 7. Additional Terms. - - "Additional permissions" are terms that supplement the terms of this -License by making exceptions from one or more of its conditions. -Additional permissions that are applicable to the entire Program shall -be treated as though they were included in this License, to the extent -that they are valid under applicable law. If additional permissions -apply only to part of the Program, that part may be used separately -under those permissions, but the entire Program remains governed by -this License without regard to the additional permissions. - - When you convey a copy of a covered work, you may at your option -remove any additional permissions from that copy, or from any part of -it. (Additional permissions may be written to require their own -removal in certain cases when you modify the work.) You may place -additional permissions on material, added by you to a covered work, -for which you have or can give appropriate copyright permission. - - Notwithstanding any other provision of this License, for material you -add to a covered work, you may (if authorized by the copyright holders of -that material) supplement the terms of this License with terms: - - a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - - b) Requiring preservation of specified reasonable legal notices or - author attributions in that material or in the Appropriate Legal - Notices displayed by works containing it; or - - c) Prohibiting misrepresentation of the origin of that material, or - requiring that modified versions of such material be marked in - reasonable ways as different from the original version; or - - d) Limiting the use for publicity purposes of names of licensors or - authors of the material; or - - e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - - f) Requiring indemnification of licensors and authors of that - material by anyone who conveys the material (or modified versions of - it) with contractual assumptions of liability to the recipient, for - any liability that these contractual assumptions directly impose on - those licensors and authors. - - All other non-permissive additional terms are considered "further -restrictions" within the meaning of section 10. If the Program as you -received it, or any part of it, contains a notice stating that it is -governed by this License along with a term that is a further -restriction, you may remove that term. If a license document contains -a further restriction but permits relicensing or conveying under this -License, you may add to a covered work material governed by the terms -of that license document, provided that the further restriction does -not survive such relicensing or conveying. - - If you add terms to a covered work in accord with this section, you -must place, in the relevant source files, a statement of the -additional terms that apply to those files, or a notice indicating -where to find the applicable terms. - - Additional terms, permissive or non-permissive, may be stated in the -form of a separately written license, or stated as exceptions; -the above requirements apply either way. - - 8. Termination. - - You may not propagate or modify a covered work except as expressly -provided under this License. Any attempt otherwise to propagate or -modify it is void, and will automatically terminate your rights under -this License (including any patent licenses granted under the third -paragraph of section 11). - - However, if you cease all violation of this License, then your -license from a particular copyright holder is reinstated (a) -provisionally, unless and until the copyright holder explicitly and -finally terminates your license, and (b) permanently, if the copyright -holder fails to notify you of the violation by some reasonable means -prior to 60 days after the cessation. - - Moreover, your license from a particular copyright holder is -reinstated permanently if the copyright holder notifies you of the -violation by some reasonable means, this is the first time you have -received notice of violation of this License (for any work) from that -copyright holder, and you cure the violation prior to 30 days after -your receipt of the notice. - - Termination of your rights under this section does not terminate the -licenses of parties who have received copies or rights from you under -this License. If your rights have been terminated and not permanently -reinstated, you do not qualify to receive new licenses for the same -material under section 10. - - 9. Acceptance Not Required for Having Copies. - - You are not required to accept this License in order to receive or -run a copy of the Program. Ancillary propagation of a covered work -occurring solely as a consequence of using peer-to-peer transmission -to receive a copy likewise does not require acceptance. However, -nothing other than this License grants you permission to propagate or -modify any covered work. These actions infringe copyright if you do -not accept this License. Therefore, by modifying or propagating a -covered work, you indicate your acceptance of this License to do so. - - 10. Automatic Licensing of Downstream Recipients. - - Each time you convey a covered work, the recipient automatically -receives a license from the original licensors, to run, modify and -propagate that work, subject to this License. You are not responsible -for enforcing compliance by third parties with this License. - - An "entity transaction" is a transaction transferring control of an -organization, or substantially all assets of one, or subdividing an -organization, or merging organizations. If propagation of a covered -work results from an entity transaction, each party to that -transaction who receives a copy of the work also receives whatever -licenses to the work the party's predecessor in interest had or could -give under the previous paragraph, plus a right to possession of the -Corresponding Source of the work from the predecessor in interest, if -the predecessor has it or can get it with reasonable efforts. - - You may not impose any further restrictions on the exercise of the -rights granted or affirmed under this License. For example, you may -not impose a license fee, royalty, or other charge for exercise of -rights granted under this License, and you may not initiate litigation -(including a cross-claim or counterclaim in a lawsuit) alleging that -any patent claim is infringed by making, using, selling, offering for -sale, or importing the Program or any portion of it. - - 11. Patents. - - A "contributor" is a copyright holder who authorizes use under this -License of the Program or a work on which the Program is based. The -work thus licensed is called the contributor's "contributor version". - - A contributor's "essential patent claims" are all patent claims -owned or controlled by the contributor, whether already acquired or -hereafter acquired, that would be infringed by some manner, permitted -by this License, of making, using, or selling its contributor version, -but do not include claims that would be infringed only as a -consequence of further modification of the contributor version. For -purposes of this definition, "control" includes the right to grant -patent sublicenses in a manner consistent with the requirements of -this License. - - Each contributor grants you a non-exclusive, worldwide, royalty-free -patent license under the contributor's essential patent claims, to -make, use, sell, offer for sale, import and otherwise run, modify and -propagate the contents of its contributor version. - - In the following three paragraphs, a "patent license" is any express -agreement or commitment, however denominated, not to enforce a patent -(such as an express permission to practice a patent or covenant not to -sue for patent infringement). To "grant" such a patent license to a -party means to make such an agreement or commitment not to enforce a -patent against the party. - - If you convey a covered work, knowingly relying on a patent license, -and the Corresponding Source of the work is not available for anyone -to copy, free of charge and under the terms of this License, through a -publicly available network server or other readily accessible means, -then you must either (1) cause the Corresponding Source to be so -available, or (2) arrange to deprive yourself of the benefit of the -patent license for this particular work, or (3) arrange, in a manner -consistent with the requirements of this License, to extend the patent -license to downstream recipients. "Knowingly relying" means you have -actual knowledge that, but for the patent license, your conveying the -covered work in a country, or your recipient's use of the covered work -in a country, would infringe one or more identifiable patents in that -country that you have reason to believe are valid. - - If, pursuant to or in connection with a single transaction or -arrangement, you convey, or propagate by procuring conveyance of, a -covered work, and grant a patent license to some of the parties -receiving the covered work authorizing them to use, propagate, modify -or convey a specific copy of the covered work, then the patent license -you grant is automatically extended to all recipients of the covered -work and works based on it. - - A patent license is "discriminatory" if it does not include within -the scope of its coverage, prohibits the exercise of, or is -conditioned on the non-exercise of one or more of the rights that are -specifically granted under this License. You may not convey a covered -work if you are a party to an arrangement with a third party that is -in the business of distributing software, under which you make payment -to the third party based on the extent of your activity of conveying -the work, and under which the third party grants, to any of the -parties who would receive the covered work from you, a discriminatory -patent license (a) in connection with copies of the covered work -conveyed by you (or copies made from those copies), or (b) primarily -for and in connection with specific products or compilations that -contain the covered work, unless you entered into that arrangement, -or that patent license was granted, prior to 28 March 2007. - - Nothing in this License shall be construed as excluding or limiting -any implied license or other defenses to infringement that may -otherwise be available to you under applicable patent law. - - 12. No Surrender of Others' Freedom. - - If conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot convey a -covered work so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you may -not convey it at all. For example, if you agree to terms that obligate you -to collect a royalty for further conveying from those to whom you convey -the Program, the only way you could satisfy both those terms and this -License would be to refrain entirely from conveying the Program. - - 13. Use with the GNU Affero General Public License. - - Notwithstanding any other provision of this License, you have -permission to link or combine any covered work with a work licensed -under version 3 of the GNU Affero General Public License into a single -combined work, and to convey the resulting work. The terms of this -License will continue to apply to the part which is the covered work, -but the special requirements of the GNU Affero General Public License, -section 13, concerning interaction through a network will apply to the -combination as such. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - - Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU General -Public License "or any later version" applies to it, you have the -option of following the terms and conditions either of that numbered -version or of any later version published by the Free Software -Foundation. If the Program does not specify a version number of the -GNU General Public License, you may choose any version ever published -by the Free Software Foundation. - - If the Program specifies that a proxy can decide which future -versions of the GNU General Public License can be used, that proxy's -public statement of acceptance of a version permanently authorizes you -to choose that version for the Program. - - Later license versions may give you additional or different -permissions. However, no additional obligations are imposed on any -author or copyright holder as a result of your choosing to follow a -later version. - - 15. Disclaimer of Warranty. - - THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY -APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT -HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY -OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM -IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF -ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. Limitation of Liability. - - IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS -THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY -GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE -USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF -DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD -PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), -EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF -SUCH DAMAGES. - - 17. Interpretation of Sections 15 and 16. - - If the disclaimer of warranty and limitation of liability provided -above cannot be given local legal effect according to their terms, -reviewing courts shall apply local law that most closely approximates -an absolute waiver of all civil liability in connection with the -Program, unless a warranty or assumption of liability accompanies a -copy of the Program in return for a fee. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -state the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - -Also add information on how to contact you by electronic and paper mail. - - If the program does terminal interaction, make it output a short -notice like this when it starts in an interactive mode: - - Copyright (C) - This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, your program's commands -might be different; for a GUI interface, you would use an "about box". - - You should also get your employer (if you work as a programmer) or school, -if any, to sign a "copyright disclaimer" for the program, if necessary. -For more information on this, and how to apply and follow the GNU GPL, see -. - - The GNU General Public License does not permit incorporating your program -into proprietary programs. If your program is a subroutine library, you -may consider it more useful to permit linking proprietary applications with -the library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. But first, please read -. - -------------------------------------------------------------------------- - -In addition, as a special exception, Nokia gives permission to link the -code of its release of Qt with the OpenSSL project's "OpenSSL" library (or -modified versions of it that use the same license as the "OpenSSL" -library), and distribute the linked executables. You must comply with the -GNU General Public License versions 2.0 or 3.0 in all respects for all of -the code used other than the "OpenSSL" code. If you modify this file, you -may extend this exception to your version of the file, but you are not -obligated to do so. If you do not wish to do so, delete this exception -statement from your version of this file. diff --git a/configure b/configure index 7af8487..6832ad3 100755 --- a/configure +++ b/configure @@ -3710,16 +3710,21 @@ if [ "$Edition" = "NokiaInternalBuild" ]; then elif [ "$Edition" = "OpenSource" ]; then while true; do echo "You are licensed to use this software under the terms of" - echo "the GNU General Public License (GPL) versions 3." - echo "You are also licensed to use this software under the terms of" echo "the Lesser GNU General Public License (LGPL) versions 2.1." + if [ -e "$relpath/LICENSE.GPL3" ]; then + echo "You are also licensed to use this software under the terms of" + echo "the GNU General Public License (GPL) versions 3." + affix="either" + else + affix="the" + fi echo - affix="either" if [ "$OPT_CONFIRM_LICENSE" = "yes" ]; then - echo "You have already accepted the terms of the $LicenseType license." + echo "You have already accepted the terms of the $LicenseType license." acceptance=yes else - echo "Type '3' to view the GNU General Public License version 3." + test -e "$relpath/LICENSE.GPL3" && \ + echo "Type '3' to view the GNU General Public License version 3." echo "Type 'L' to view the Lesser GNU General Public License version 2.1." echo "Type 'yes' to accept this license offer." echo "Type 'no' to decline this license offer." diff --git a/tools/configure/configureapp.cpp b/tools/configure/configureapp.cpp index 7ccd35b..193f8aa 100644 --- a/tools/configure/configureapp.cpp +++ b/tools/configure/configureapp.cpp @@ -3415,10 +3415,14 @@ bool Configure::showLicense(QString orgLicenseFile) return true; } + bool haveGpl3 = false; QString licenseFile = orgLicenseFile; QString theLicense; if (dictionary["EDITION"] == "OpenSource" || dictionary["EDITION"] == "Snapshot") { - theLicense = "GNU General Public License (GPL) version 3 \nor the GNU Lesser General Public License (LGPL) version 2.1"; + haveGpl3 = QFile::exists(orgLicenseFile + "/LICENSE.GPL3"); + theLicense = "GNU Lesser General Public License (LGPL) version 2.1"; + if (haveGpl3) + theLicense += "\nor the GNU General Public License (GPL) version 3"; } else { // the first line of the license file tells us which license it is QFile file(licenseFile); @@ -3435,7 +3439,8 @@ bool Configure::showLicense(QString orgLicenseFile) << "the " << theLicense << "." << endl << endl; if (dictionary["EDITION"] == "OpenSource" || dictionary["EDITION"] == "Snapshot") { - cout << "Type '3' to view the GNU General Public License version 3 (GPLv3)." << endl; + if (haveGpl3) + cout << "Type '3' to view the GNU General Public License version 3 (GPLv3)." << endl; cout << "Type 'L' to view the Lesser GNU General Public License version 2.1 (LGPLv2.1)." << endl; } else { cout << "Type '?' to view the " << theLicense << "." << endl; -- cgit v0.12 From fa7bed077d882d32e208c6f3879bac6355bb3726 Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Mon, 31 Aug 2009 14:36:37 +0200 Subject: QNAM HTTP Code: Pipelining used queue from wrong side Do it as it was done in dequeueAndSendRequest. Reviewed-by: TrustMe --- src/network/access/qhttpnetworkconnection.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/network/access/qhttpnetworkconnection.cpp b/src/network/access/qhttpnetworkconnection.cpp index e68aa3a..da9ec09 100644 --- a/src/network/access/qhttpnetworkconnection.cpp +++ b/src/network/access/qhttpnetworkconnection.cpp @@ -519,7 +519,7 @@ bool QHttpNetworkConnectionPrivate::fillPipeline(QList &queue, if (queue.isEmpty()) return true; - for (int i = 0; i < queue.length(); i++) { + for (int i = queue.count() - 1; i >= 0; --i) { HttpMessagePair messagePair = queue.at(i); const QHttpNetworkRequest &request = messagePair.first; -- cgit v0.12 From ab45aa26a040bdf84dc923792f5f384dd51f906d Mon Sep 17 00:00:00 2001 From: Andreas Aardal Hanssen Date: Tue, 1 Sep 2009 11:35:22 +0200 Subject: Make test more reliable - wait after show. This test failed randomly in the past, and more often on a KDE4 desktop with a slow graphics card. --- tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp index 2acb76d..aa1f2b8 100644 --- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp @@ -5420,6 +5420,7 @@ void tst_QGraphicsItem::contextMenuEventPropagation() qt_x11_wait_for_window_manager(&view); #endif view.resize(200, 200); + QTest::qWait(250); QContextMenuEvent event(QContextMenuEvent::Mouse, QPoint(10, 10), view.viewport()->mapToGlobal(QPoint(10, 10))); -- cgit v0.12 From 72d7a8e5d7cc5cf498078648f01a20869245d75e Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Tue, 1 Sep 2009 11:47:18 +0200 Subject: Fix compilation of QAbstractItemModel test --- tests/auto/qabstractitemmodel/dynamictreemodel.cpp | 9 +++------ tests/auto/qabstractitemmodel/dynamictreemodel.h | 9 +++------ tests/auto/qabstractitemmodel/qabstractitemmodel.pro | 2 +- tests/auto/qabstractitemmodel/tst_qabstractitemmodel.cpp | 2 +- 4 files changed, 8 insertions(+), 14 deletions(-) diff --git a/tests/auto/qabstractitemmodel/dynamictreemodel.cpp b/tests/auto/qabstractitemmodel/dynamictreemodel.cpp index 6425dcd..dd0615d 100644 --- a/tests/auto/qabstractitemmodel/dynamictreemodel.cpp +++ b/tests/auto/qabstractitemmodel/dynamictreemodel.cpp @@ -41,13 +41,10 @@ #include "dynamictreemodel.h" -#include -#include -#include +#include +#include +#include -#include - -#include DynamicTreeModel::DynamicTreeModel(QObject *parent) : QAbstractItemModel(parent), diff --git a/tests/auto/qabstractitemmodel/dynamictreemodel.h b/tests/auto/qabstractitemmodel/dynamictreemodel.h index d84bf68..a769c38 100644 --- a/tests/auto/qabstractitemmodel/dynamictreemodel.h +++ b/tests/auto/qabstractitemmodel/dynamictreemodel.h @@ -42,14 +42,11 @@ #ifndef DYNAMICTREEMODEL_H #define DYNAMICTREEMODEL_H -#include +#include -#include -#include +#include +#include -#include - -#include template class QList; diff --git a/tests/auto/qabstractitemmodel/qabstractitemmodel.pro b/tests/auto/qabstractitemmodel/qabstractitemmodel.pro index 84ed5a2..a31868b 100644 --- a/tests/auto/qabstractitemmodel/qabstractitemmodel.pro +++ b/tests/auto/qabstractitemmodel/qabstractitemmodel.pro @@ -2,5 +2,5 @@ load(qttest_p4) SOURCES += tst_qabstractitemmodel.cpp dynamictreemodel.cpp HEADERS += dynamictreemodel.h -QT = core + diff --git a/tests/auto/qabstractitemmodel/tst_qabstractitemmodel.cpp b/tests/auto/qabstractitemmodel/tst_qabstractitemmodel.cpp index da65e7d..58832c7 100644 --- a/tests/auto/qabstractitemmodel/tst_qabstractitemmodel.cpp +++ b/tests/auto/qabstractitemmodel/tst_qabstractitemmodel.cpp @@ -43,7 +43,7 @@ #include #include -#include +#include //TESTED_CLASS=QAbstractListModel QAbstractTableModel //TESTED_FILES= -- cgit v0.12 From bfa9b7e5cb1cd91aa0efad14bd91f14144e1acb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorbj=C3=B8rn=20Lindeijer?= Date: Mon, 31 Aug 2009 14:07:42 +0200 Subject: doc: Also mention HSL --- src/gui/painting/qcolor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/painting/qcolor.cpp b/src/gui/painting/qcolor.cpp index 422d5a3..173c870 100644 --- a/src/gui/painting/qcolor.cpp +++ b/src/gui/painting/qcolor.cpp @@ -298,7 +298,7 @@ QT_BEGIN_NAMESPACE /*! \enum QColor::Spec - The type of color specified, either RGB, HSV or CMYK. + The type of color specified, either RGB, HSV, CMYK or HSL. \value Rgb \value Hsv -- cgit v0.12 From 22ac5bb9aac73b0c7d319f2cdc42dd5bcd59f2b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorbj=C3=B8rn=20Lindeijer?= Date: Mon, 31 Aug 2009 16:02:23 +0200 Subject: Microoptimizations in QCleanLooksStyle Shaved 4K off the size of a release build of libQtGui. Reviewed-by: Jens Bache-Wiig --- src/gui/styles/qcleanlooksstyle.cpp | 364 ++++++++++++++++++++++-------------- 1 file changed, 224 insertions(+), 140 deletions(-) diff --git a/src/gui/styles/qcleanlooksstyle.cpp b/src/gui/styles/qcleanlooksstyle.cpp index 6d957ca..20f1d26 100644 --- a/src/gui/styles/qcleanlooksstyle.cpp +++ b/src/gui/styles/qcleanlooksstyle.cpp @@ -561,14 +561,20 @@ static void qt_cleanlooks_draw_mdibutton(QPainter *painter, const QStyleOptionTi QColor mdiButtonBorderColor(active ? option->palette.highlight().color().darker(180): dark.darker(110)); painter->setPen(QPen(mdiButtonBorderColor, 1)); - painter->drawLine(tmp.left() + 2, tmp.top(), tmp.right() - 2, tmp.top()); - painter->drawLine(tmp.left() + 2, tmp.bottom(), tmp.right() - 2, tmp.bottom()); - painter->drawLine(tmp.left(), tmp.top() + 2, tmp.left(), tmp.bottom() - 2); - painter->drawLine(tmp.right(), tmp.top() + 2, tmp.right(), tmp.bottom() - 2); - painter->drawPoint(tmp.left() + 1, tmp.top() + 1); - painter->drawPoint(tmp.right() - 1, tmp.top() + 1); - painter->drawPoint(tmp.left() + 1, tmp.bottom() - 1); - painter->drawPoint(tmp.right() - 1, tmp.bottom() - 1); + const QLine lines[4] = { + QLine(tmp.left() + 2, tmp.top(), tmp.right() - 2, tmp.top()), + QLine(tmp.left() + 2, tmp.bottom(), tmp.right() - 2, tmp.bottom()), + QLine(tmp.left(), tmp.top() + 2, tmp.left(), tmp.bottom() - 2), + QLine(tmp.right(), tmp.top() + 2, tmp.right(), tmp.bottom() - 2) + }; + painter->drawLines(lines, 4); + const QPoint points[4] = { + QPoint(tmp.left() + 1, tmp.top() + 1), + QPoint(tmp.right() - 1, tmp.top() + 1), + QPoint(tmp.left() + 1, tmp.bottom() - 1), + QPoint(tmp.right() - 1, tmp.bottom() - 1) + }; + painter->drawPoints(points, 4); painter->setPen(titleBarHighlight); painter->drawLine(tmp.left() + 2, tmp.top() + 1, tmp.right() - 2, tmp.top() + 1); @@ -900,14 +906,17 @@ void QCleanlooksStyle::drawPrimitive(PrimitiveElement elem, QRect r = rect.adjusted(0, 1, 0, -1); painter->setPen(buttonShadowAlpha); painter->drawLine(QPoint(r.left() + 2, r.top() - 1), QPoint(r.right() - 2, r.top() - 1)); - painter->drawPoint(r.right() - 1, r.top()); - painter->drawPoint(r.right(), r.top() + 1); - painter->drawPoint(r.right() - 1, r.bottom()); - painter->drawPoint(r.right(), r.bottom() - 1); - painter->drawPoint(r.left() + 1, r.top() ); - painter->drawPoint(r.left(), r.top() + 1); - painter->drawPoint(r.left() + 1, r.bottom() ); - painter->drawPoint(r.left(), r.bottom() - 1); + const QPoint points[8] = { + QPoint(r.right() - 1, r.top()), + QPoint(r.right(), r.top() + 1), + QPoint(r.right() - 1, r.bottom()), + QPoint(r.right(), r.bottom() - 1), + QPoint(r.left() + 1, r.top() ), + QPoint(r.left(), r.top() + 1), + QPoint(r.left() + 1, r.bottom() ), + QPoint(r.left(), r.bottom() - 1) + }; + painter->drawPoints(points, 8); painter->setPen(QPen(option->palette.background().color(), 1)); painter->drawLine(QPoint(r.left() + 2, r.top() + 1), QPoint(r.right() - 2, r.top() + 1)); @@ -939,10 +948,13 @@ void QCleanlooksStyle::drawPrimitive(PrimitiveElement elem, painter->drawLine(QPoint(r.left(), r.top() + 2), QPoint(r.left(), r.bottom() - 2)); painter->drawLine(QPoint(r.right(), r.top() + 2), QPoint(r.right(), r.bottom() - 2)); painter->drawLine(QPoint(r.left() + 2, r.bottom()), QPoint(r.right() - 2, r.bottom())); - painter->drawPoint(QPoint(r.right() - 1, r.bottom() - 1)); - painter->drawPoint(QPoint(r.right() - 1, r.top() + 1)); - painter->drawPoint(QPoint(r.left() + 1, r.bottom() - 1)); - painter->drawPoint(QPoint(r.left() + 1, r.top() + 1)); + const QPoint points2[4] = { + QPoint(r.right() - 1, r.bottom() - 1), + QPoint(r.right() - 1, r.top() + 1), + QPoint(r.left() + 1, r.bottom() - 1), + QPoint(r.left() + 1, r.top() + 1) + }; + painter->drawPoints(points2, 4); painter->drawLine(QPoint(r.left() + 2, r.top()), QPoint(r.right() - 2, r.top())); painter->setPen(oldPen); } @@ -1040,10 +1052,13 @@ void QCleanlooksStyle::drawPrimitive(PrimitiveElement elem, painter->setBrush(QBrush(dark.darker(120), Qt::Dense4Pattern)); painter->setBrushOrigin(rect.topLeft()); painter->setPen(Qt::NoPen); - painter->drawRect(rect.left(), rect.top(), rect.width(), 1); // Top - painter->drawRect(rect.left(), rect.bottom(), rect.width(), 1); // Bottom - painter->drawRect(rect.left(), rect.top(), 1, rect.height()); // Left - painter->drawRect(rect.right(), rect.top(), 1, rect.height()); // Right + const QRect rects[4] = { + QRect(rect.left(), rect.top(), rect.width(), 1), // Top + QRect(rect.left(), rect.bottom(), rect.width(), 1), // Bottom + QRect(rect.left(), rect.top(), 1, rect.height()), // Left + QRect(rect.right(), rect.top(), 1, rect.height()) // Right + }; + painter->drawRects(rects, 4); painter->restore(); } break; @@ -1065,18 +1080,24 @@ void QCleanlooksStyle::drawPrimitive(PrimitiveElement elem, if (isDefault) { r = option->rect.adjusted(0, 1, 0, -1); painter->setPen(QPen(Qt::black, 0)); - painter->drawLine(QPoint(r.left() + 2, r.top()), - QPoint(r.right() - 2, r.top())); - painter->drawLine(QPoint(r.left(), r.top() + 2), - QPoint(r.left(), r.bottom() - 2)); - painter->drawLine(QPoint(r.right(), r.top() + 2), - QPoint(r.right(), r.bottom() - 2)); - painter->drawLine(QPoint(r.left() + 2, r.bottom()), - QPoint(r.right() - 2, r.bottom())); - painter->drawPoint(QPoint(r.right() - 1, r.bottom() - 1)); - painter->drawPoint(QPoint(r.right() - 1, r.top() + 1)); - painter->drawPoint(QPoint(r.left() + 1, r.bottom() - 1)); - painter->drawPoint(QPoint(r.left() + 1, r.top() + 1)); + const QLine lines[4] = { + QLine(QPoint(r.left() + 2, r.top()), + QPoint(r.right() - 2, r.top())), + QLine(QPoint(r.left(), r.top() + 2), + QPoint(r.left(), r.bottom() - 2)), + QLine(QPoint(r.right(), r.top() + 2), + QPoint(r.right(), r.bottom() - 2)), + QLine(QPoint(r.left() + 2, r.bottom()), + QPoint(r.right() - 2, r.bottom())) + }; + painter->drawLines(lines, 4); + const QPoint points[4] = { + QPoint(r.right() - 1, r.bottom() - 1), + QPoint(r.right() - 1, r.top() + 1), + QPoint(r.left() + 1, r.bottom() - 1), + QPoint(r.left() + 1, r.top() + 1) + }; + painter->drawPoints(points, 4); painter->setPen(oldPen); } return; @@ -1140,10 +1161,13 @@ void QCleanlooksStyle::drawPrimitive(PrimitiveElement elem, QPoint(r.right(), r.bottom() - 2)); p->drawLine(QPoint(r.left() + 2, r.bottom()), QPoint(r.right() - 2, r.bottom())); - p->drawPoint(QPoint(r.right() - 1, r.bottom() - 1)); - p->drawPoint(QPoint(r.right() - 1, r.top() + 1)); - p->drawPoint(QPoint(r.left() + 1, r.bottom() - 1)); - p->drawPoint(QPoint(r.left() + 1, r.top() + 1)); + const QPoint points[4] = { + QPoint(r.right() - 1, r.bottom() - 1), + QPoint(r.right() - 1, r.top() + 1), + QPoint(r.left() + 1, r.bottom() - 1), + QPoint(r.left() + 1, r.top() + 1) + }; + p->drawPoints(points, 4); if (!isDefault && !hasFocus && isEnabled) p->setPen(QPen(darkOutline.darker(110), 0)); @@ -1163,14 +1187,17 @@ void QCleanlooksStyle::drawPrimitive(PrimitiveElement elem, topShadow.setAlpha(60); p->setPen(topShadow); - p->drawPoint(QPoint(r.right(), r.top() + 1)); - p->drawPoint(QPoint(r.right() - 1, r.top() )); - p->drawPoint(QPoint(r.right(), r.bottom() - 1)); - p->drawPoint(QPoint(r.right() - 1, r.bottom() )); - p->drawPoint(QPoint(r.left() + 1, r.bottom())); - p->drawPoint(QPoint(r.left(), r.bottom() - 1)); - p->drawPoint(QPoint(r.left() + 1, r.top())); - p->drawPoint(QPoint(r.left(), r.top() + 1)); + const QPoint points2[8] = { + QPoint(r.right(), r.top() + 1), + QPoint(r.right() - 1, r.top() ), + QPoint(r.right(), r.bottom() - 1), + QPoint(r.right() - 1, r.bottom() ), + QPoint(r.left() + 1, r.bottom()), + QPoint(r.left(), r.bottom() - 1), + QPoint(r.left() + 1, r.top()), + QPoint(r.left(), r.top() + 1) + }; + p->drawPoints(points2, 8); topShadow.setAlpha(30); p->setPen(topShadow); @@ -1183,18 +1210,24 @@ void QCleanlooksStyle::drawPrimitive(PrimitiveElement elem, if (isDefault) { r.adjust(-1, -1, 1, 1); p->setPen(buttonShadowAlpha.darker(120)); - p->drawLine(r.topLeft() + QPoint(3, 0), r.topRight() - QPoint(3, 0)); - p->drawLine(r.bottomLeft() + QPoint(3, 0), r.bottomRight() - QPoint(3, 0)); - p->drawLine(r.topLeft() + QPoint(0, 3), r.bottomLeft() - QPoint(0, 3)); - p->drawLine(r.topRight() + QPoint(0, 3), r.bottomRight() - QPoint(0, 3)); - p->drawPoint(r.topRight() + QPoint(-2, 1)); - p->drawPoint(r.topRight() + QPoint(-1, 2)); - p->drawPoint(r.bottomRight() + QPoint(-1, -2)); - p->drawPoint(r.bottomRight() + QPoint(-2, -1)); - p->drawPoint(r.topLeft() + QPoint(1, 2)); - p->drawPoint(r.topLeft() + QPoint(2, 1)); - p->drawPoint(r.bottomLeft() + QPoint(1, -2)); - p->drawPoint(r.bottomLeft() + QPoint(2, -1)); + const QLine lines[4] = { + QLine(r.topLeft() + QPoint(3, 0), r.topRight() - QPoint(3, 0)), + QLine(r.bottomLeft() + QPoint(3, 0), r.bottomRight() - QPoint(3, 0)), + QLine(r.topLeft() + QPoint(0, 3), r.bottomLeft() - QPoint(0, 3)), + QLine(r.topRight() + QPoint(0, 3), r.bottomRight() - QPoint(0, 3)) + }; + p->drawLines(lines, 4); + const QPoint points3[8] = { + r.topRight() + QPoint(-2, 1), + r.topRight() + QPoint(-1, 2), + r.bottomRight() + QPoint(-1, -2), + r.bottomRight() + QPoint(-2, -1), + r.topLeft() + QPoint(1, 2), + r.topLeft() + QPoint(2, 1), + r.bottomLeft() + QPoint(1, -2), + r.bottomLeft() + QPoint(2, -1) + }; + p->drawPoints(points3, 8); } painter->setPen(oldPen); painter->setBrush(oldBrush); @@ -1307,12 +1340,15 @@ void QCleanlooksStyle::drawPrimitive(PrimitiveElement elem, painter->drawLine(innerBottomLine); painter->setPen(alphaCornerColor); - painter->drawPoint(leftBottomInnerCorner1); - painter->drawPoint(leftBottomInnerCorner2); - painter->drawPoint(rightBottomInnerCorner1); - painter->drawPoint(rightBottomInnerCorner2); - painter->drawPoint(leftTopInnerCorner1); - painter->drawPoint(leftTopInnerCorner2); + const QPoint points[6] = { + leftBottomInnerCorner1, + leftBottomInnerCorner2, + rightBottomInnerCorner1, + rightBottomInnerCorner2, + leftTopInnerCorner1, + leftTopInnerCorner2 + }; + painter->drawPoints(points, 6); } #endif // QT_NO_TABWIDGET painter->restore(); @@ -1670,19 +1706,25 @@ void QCleanlooksStyle::drawControl(ControlElement element, const QStyleOption *o painter->fillRect(rect, option->palette.base()); QColor borderColor = dark.lighter(110); painter->setPen(QPen(borderColor, 0)); - painter->drawLine(QPoint(rect.left() + 1, rect.top()), QPoint(rect.right() - 1, rect.top())); - painter->drawLine(QPoint(rect.left() + 1, rect.bottom()), QPoint(rect.right() - 1, rect.bottom())); - painter->drawLine(QPoint(rect.left(), rect.top() + 1), QPoint(rect.left(), rect.bottom() - 1)); - painter->drawLine(QPoint(rect.right(), rect.top() + 1), QPoint(rect.right(), rect.bottom() - 1)); + const QLine lines[4] = { + QLine(QPoint(rect.left() + 1, rect.top()), QPoint(rect.right() - 1, rect.top())), + QLine(QPoint(rect.left() + 1, rect.bottom()), QPoint(rect.right() - 1, rect.bottom())), + QLine(QPoint(rect.left(), rect.top() + 1), QPoint(rect.left(), rect.bottom() - 1)), + QLine(QPoint(rect.right(), rect.top() + 1), QPoint(rect.right(), rect.bottom() - 1)) + }; + painter->drawLines(lines, 4); QColor alphaCorner = mergedColors(borderColor, option->palette.background().color()); QColor innerShadow = mergedColors(borderColor, option->palette.base().color()); //corner smoothing painter->setPen(alphaCorner); - painter->drawPoint(rect.topRight()); - painter->drawPoint(rect.topLeft()); - painter->drawPoint(rect.bottomRight()); - painter->drawPoint(rect.bottomLeft()); + const QPoint points[4] = { + rect.topRight(), + rect.topLeft(), + rect.bottomRight(), + rect.bottomLeft() + }; + painter->drawPoints(points, 4); //inner shadow painter->setPen(innerShadow); @@ -1807,10 +1849,13 @@ void QCleanlooksStyle::drawControl(ControlElement element, const QStyleOption *o option->palette.highlight()); painter->setPen(QPen(highlightOutline, 0)); - painter->drawLine(QPoint(r.left(), r.top() + 1), QPoint(r.left(), r.bottom())); - painter->drawLine(QPoint(r.right(), r.top() + 1), QPoint(r.right(), r.bottom())); - painter->drawLine(QPoint(r.left() + 1, r.bottom()), QPoint(r.right() - 1, r.bottom())); - painter->drawLine(QPoint(r.left() + 1, r.top()), QPoint(r.right() - 1, r.top())); + const QLine lines[4] = { + QLine(QPoint(r.left(), r.top() + 1), QPoint(r.left(), r.bottom())), + QLine(QPoint(r.right(), r.top() + 1), QPoint(r.right(), r.bottom())), + QLine(QPoint(r.left() + 1, r.bottom()), QPoint(r.right() - 1, r.bottom())), + QLine(QPoint(r.left() + 1, r.top()), QPoint(r.right() - 1, r.top())) + }; + painter->drawLines(lines, 4); //draw text QPalette::ColorRole textRole = dis ? QPalette::Text : QPalette::HighlightedText; @@ -1864,10 +1909,13 @@ void QCleanlooksStyle::drawControl(ControlElement element, const QStyleOption *o highlight); r = r.adjusted(-1, 0, 1, 0); painter->setPen(QPen(highlightOutline, 0)); - painter->drawLine(QPoint(r.left(), r.top() + 1), QPoint(r.left(), r.bottom() - 1)); - painter->drawLine(QPoint(r.right(), r.top() + 1), QPoint(r.right(), r.bottom() - 1)); - painter->drawLine(QPoint(r.left() + 1, r.bottom()), QPoint(r.right() - 1, r.bottom())); - painter->drawLine(QPoint(r.left() + 1, r.top()), QPoint(r.right() - 1, r.top())); + const QLine lines[4] = { + QLine(QPoint(r.left(), r.top() + 1), QPoint(r.left(), r.bottom() - 1)), + QLine(QPoint(r.right(), r.top() + 1), QPoint(r.right(), r.bottom() - 1)), + QLine(QPoint(r.left() + 1, r.bottom()), QPoint(r.right() - 1, r.bottom())), + QLine(QPoint(r.left() + 1, r.top()), QPoint(r.right() - 1, r.top())) + }; + painter->drawLines(lines, 4); } else { painter->fillRect(option->rect, menuBackground); } @@ -2447,14 +2495,17 @@ void QCleanlooksStyle::drawComplexControl(ComplexControl control, const QStyleOp cachePainter.setPen(topShadow); // antialias corners - cachePainter.drawPoint(QPoint(r.right(), r.top() + 1)); - cachePainter.drawPoint(QPoint(r.right() - 1, r.top() )); - cachePainter.drawPoint(QPoint(r.right(), r.bottom() - 1)); - cachePainter.drawPoint(QPoint(r.right() - 1, r.bottom() )); - cachePainter.drawPoint(QPoint(r.left() + 1, r.bottom())); - cachePainter.drawPoint(QPoint(r.left(), r.bottom() - 1)); - cachePainter.drawPoint(QPoint(r.left() + 1, r.top())); - cachePainter.drawPoint(QPoint(r.left(), r.top() + 1)); + const QPoint points[8] = { + QPoint(r.right(), r.top() + 1), + QPoint(r.right() - 1, r.top() ), + QPoint(r.right(), r.bottom() - 1), + QPoint(r.right() - 1, r.bottom() ), + QPoint(r.left() + 1, r.bottom()), + QPoint(r.left(), r.bottom() - 1), + QPoint(r.left() + 1, r.top()), + QPoint(r.left(), r.top() + 1) + }; + cachePainter.drawPoints(points, 8); // draw frame topShadow.setAlpha(30); @@ -2482,10 +2533,13 @@ void QCleanlooksStyle::drawComplexControl(ComplexControl control, const QStyleOp cachePainter.setPen(QPen(darkOutline, 1)); // top and bottom lines - cachePainter.drawLine(QPoint(r.left() + 2, r.bottom()), QPoint(r.right()- 2, r.bottom())); - cachePainter.drawLine(QPoint(r.left() + 2, r.top()), QPoint(r.right() - 2, r.top())); - cachePainter.drawLine(QPoint(r.right(), r.top() + 2), QPoint(r.right(), r.bottom() - 2)); - cachePainter.drawLine(QPoint(r.left(), r.top() + 2), QPoint(r.left(), r.bottom() - 2)); + const QLine lines[4] = { + QLine(QPoint(r.left() + 2, r.bottom()), QPoint(r.right()- 2, r.bottom())), + QLine(QPoint(r.left() + 2, r.top()), QPoint(r.right() - 2, r.top())), + QLine(QPoint(r.right(), r.top() + 2), QPoint(r.right(), r.bottom() - 2)), + QLine(QPoint(r.left(), r.top() + 2), QPoint(r.left(), r.bottom() - 2)) + }; + cachePainter.drawLines(lines, 4); } // gradients @@ -2519,10 +2573,13 @@ void QCleanlooksStyle::drawComplexControl(ComplexControl control, const QStyleOp if (spinBox->frame) { // rounded corners - cachePainter.drawPoint(QPoint(r.left() + 1, r.bottom() - 1)); - cachePainter.drawPoint(QPoint(r.left() + 1, r.top() + 1)); - cachePainter.drawPoint(QPoint(r.right() - 1, r.bottom() - 1)); - cachePainter.drawPoint(QPoint(r.right() - 1, r.top() + 1)); + const QPoint points[4] = { + QPoint(r.left() + 1, r.bottom() - 1), + QPoint(r.left() + 1, r.top() + 1), + QPoint(r.right() - 1, r.bottom() - 1), + QPoint(r.right() - 1, r.top() + 1) + }; + cachePainter.drawPoints(points, 4); if (option->state & State_HasFocus) { QColor darkoutline = option->palette.highlight().color().darker(150); @@ -2531,10 +2588,13 @@ void QCleanlooksStyle::drawComplexControl(ComplexControl control, const QStyleOp if (spinBox->direction == Qt::LeftToRight) { cachePainter.drawRect(rect.adjusted(1, 2, -3 -downRect.width(), -3)); cachePainter.setPen(QPen(darkoutline, 0)); - cachePainter.drawLine(QPoint(r.left() + 2, r.bottom()), QPoint(r.right()- downRect.width() - 1, r.bottom())); - cachePainter.drawLine(QPoint(r.left() + 2, r.top()), QPoint(r.right() - downRect.width() - 1, r.top())); - cachePainter.drawLine(QPoint(r.right() - downRect.width() - 1, r.top() + 1), QPoint(r.right()- downRect.width() - 1, r.bottom() - 1)); - cachePainter.drawLine(QPoint(r.left(), r.top() + 2), QPoint(r.left(), r.bottom() - 2)); + const QLine lines[4] = { + QLine(QPoint(r.left() + 2, r.bottom()), QPoint(r.right()- downRect.width() - 1, r.bottom())), + QLine(QPoint(r.left() + 2, r.top()), QPoint(r.right() - downRect.width() - 1, r.top())), + QLine(QPoint(r.right() - downRect.width() - 1, r.top() + 1), QPoint(r.right()- downRect.width() - 1, r.bottom() - 1)), + QLine(QPoint(r.left(), r.top() + 2), QPoint(r.left(), r.bottom() - 2)) + }; + cachePainter.drawLines(lines, 4); cachePainter.drawPoint(QPoint(r.left() + 1, r.bottom() - 1)); cachePainter.drawPoint(QPoint(r.left() + 1, r.top() + 1)); cachePainter.drawLine(QPoint(r.left(), r.top() + 2), QPoint(r.left(), r.bottom() - 2)); @@ -2679,18 +2739,24 @@ void QCleanlooksStyle::drawComplexControl(ComplexControl control, const QStyleOp // top outline painter->drawLine(fullRect.left() + 5, fullRect.top(), fullRect.right() - 5, fullRect.top()); painter->drawLine(fullRect.left(), fullRect.top() + 4, fullRect.left(), fullRect.bottom()); - painter->drawPoint(fullRect.left() + 4, fullRect.top() + 1); - painter->drawPoint(fullRect.left() + 3, fullRect.top() + 1); - painter->drawPoint(fullRect.left() + 2, fullRect.top() + 2); - painter->drawPoint(fullRect.left() + 1, fullRect.top() + 3); - painter->drawPoint(fullRect.left() + 1, fullRect.top() + 4); + const QPoint points[5] = { + QPoint(fullRect.left() + 4, fullRect.top() + 1), + QPoint(fullRect.left() + 3, fullRect.top() + 1), + QPoint(fullRect.left() + 2, fullRect.top() + 2), + QPoint(fullRect.left() + 1, fullRect.top() + 3), + QPoint(fullRect.left() + 1, fullRect.top() + 4) + }; + painter->drawPoints(points, 5); painter->drawLine(fullRect.right(), fullRect.top() + 4, fullRect.right(), fullRect.bottom()); - painter->drawPoint(fullRect.right() - 3, fullRect.top() + 1); - painter->drawPoint(fullRect.right() - 4, fullRect.top() + 1); - painter->drawPoint(fullRect.right() - 2, fullRect.top() + 2); - painter->drawPoint(fullRect.right() - 1, fullRect.top() + 3); - painter->drawPoint(fullRect.right() - 1, fullRect.top() + 4); + const QPoint points2[5] = { + QPoint(fullRect.right() - 3, fullRect.top() + 1), + QPoint(fullRect.right() - 4, fullRect.top() + 1), + QPoint(fullRect.right() - 2, fullRect.top() + 2), + QPoint(fullRect.right() - 1, fullRect.top() + 3), + QPoint(fullRect.right() - 1, fullRect.top() + 4) + }; + painter->drawPoints(points2, 5); // draw bottomline painter->drawLine(fullRect.right(), fullRect.bottom(), fullRect.left(), fullRect.bottom()); @@ -2749,10 +2815,13 @@ void QCleanlooksStyle::drawComplexControl(ComplexControl control, const QStyleOp painter->drawLine(maxButtonIconRect.left() + 1, maxButtonIconRect.top() + 1, maxButtonIconRect.right() - 1, maxButtonIconRect.top() + 1); painter->setPen(textAlphaColor); - painter->drawPoint(maxButtonIconRect.topLeft()); - painter->drawPoint(maxButtonIconRect.topRight()); - painter->drawPoint(maxButtonIconRect.bottomLeft()); - painter->drawPoint(maxButtonIconRect.bottomRight()); + const QPoint points[4] = { + maxButtonIconRect.topLeft(), + maxButtonIconRect.topRight(), + maxButtonIconRect.bottomLeft(), + maxButtonIconRect.bottomRight() + }; + painter->drawPoints(points, 4); } } @@ -2765,18 +2834,24 @@ void QCleanlooksStyle::drawComplexControl(ComplexControl control, const QStyleOp qt_cleanlooks_draw_mdibutton(painter, titleBar, closeButtonRect, hover, sunken); QRect closeIconRect = closeButtonRect.adjusted(buttonMargin, buttonMargin, -buttonMargin, -buttonMargin); painter->setPen(textAlphaColor); - painter->drawLine(closeIconRect.left() + 1, closeIconRect.top(), - closeIconRect.right(), closeIconRect.bottom() - 1); - painter->drawLine(closeIconRect.left(), closeIconRect.top() + 1, - closeIconRect.right() - 1, closeIconRect.bottom()); - painter->drawLine(closeIconRect.right() - 1, closeIconRect.top(), - closeIconRect.left(), closeIconRect.bottom() - 1); - painter->drawLine(closeIconRect.right(), closeIconRect.top() + 1, - closeIconRect.left() + 1, closeIconRect.bottom()); - painter->drawPoint(closeIconRect.topLeft()); - painter->drawPoint(closeIconRect.topRight()); - painter->drawPoint(closeIconRect.bottomLeft()); - painter->drawPoint(closeIconRect.bottomRight()); + const QLine lines[4] = { + QLine(closeIconRect.left() + 1, closeIconRect.top(), + closeIconRect.right(), closeIconRect.bottom() - 1), + QLine(closeIconRect.left(), closeIconRect.top() + 1, + closeIconRect.right() - 1, closeIconRect.bottom()), + QLine(closeIconRect.right() - 1, closeIconRect.top(), + closeIconRect.left(), closeIconRect.bottom() - 1), + QLine(closeIconRect.right(), closeIconRect.top() + 1, + closeIconRect.left() + 1, closeIconRect.bottom()) + }; + painter->drawLines(lines, 4); + const QPoint points[4] = { + closeIconRect.topLeft(), + closeIconRect.topRight(), + closeIconRect.bottomLeft(), + closeIconRect.bottomRight() + }; + painter->drawPoints(points, 4); painter->setPen(textColor); painter->drawLine(closeIconRect.left() + 1, closeIconRect.top() + 1, @@ -2806,10 +2881,13 @@ void QCleanlooksStyle::drawComplexControl(ComplexControl control, const QStyleOp painter->drawLine(frontWindowRect.left() + 1, frontWindowRect.top() + 1, frontWindowRect.right() - 1, frontWindowRect.top() + 1); painter->setPen(textAlphaColor); - painter->drawPoint(frontWindowRect.topLeft()); - painter->drawPoint(frontWindowRect.topRight()); - painter->drawPoint(frontWindowRect.bottomLeft()); - painter->drawPoint(frontWindowRect.bottomRight()); + const QPoint points[4] = { + frontWindowRect.topLeft(), + frontWindowRect.topRight(), + frontWindowRect.bottomLeft(), + frontWindowRect.bottomRight() + }; + painter->drawPoints(points, 4); QRect backWindowRect = normalButtonIconRect.adjusted(3, 0, 0, -3); QRegion clipRegion = backWindowRect; @@ -2821,10 +2899,13 @@ void QCleanlooksStyle::drawComplexControl(ComplexControl control, const QStyleOp painter->drawLine(backWindowRect.left() + 1, backWindowRect.top() + 1, backWindowRect.right() - 1, backWindowRect.top() + 1); painter->setPen(textAlphaColor); - painter->drawPoint(backWindowRect.topLeft()); - painter->drawPoint(backWindowRect.topRight()); - painter->drawPoint(backWindowRect.bottomLeft()); - painter->drawPoint(backWindowRect.bottomRight()); + const QPoint points2[4] = { + backWindowRect.topLeft(), + backWindowRect.topRight(), + backWindowRect.bottomLeft(), + backWindowRect.bottomRight() + }; + painter->drawPoints(points2, 4); painter->restore(); } } @@ -3498,10 +3579,13 @@ void QCleanlooksStyle::drawComplexControl(ComplexControl control, const QStyleOp handlePainter.save(); handlePainter.setRenderHint(QPainter::Antialiasing); handlePainter.translate(0.5, 0.5); - handlePainter.drawLine(QPoint(r.left(), r.bottom() - 2), QPoint(r.left() + 2, r.bottom())); - handlePainter.drawLine(QPoint(r.left(), r.top() + 2), QPoint(r.left() + 2, r.top())); - handlePainter.drawLine(QPoint(r.right(), r.bottom() - 2), QPoint(r.right() - 2, r.bottom())); - handlePainter.drawLine(QPoint(r.right(), r.top() + 2), QPoint(r.right() - 2, r.top())); + const QLine lines[4] = { + QLine(QPoint(r.left(), r.bottom() - 2), QPoint(r.left() + 2, r.bottom())), + QLine(QPoint(r.left(), r.top() + 2), QPoint(r.left() + 2, r.top())), + QLine(QPoint(r.right(), r.bottom() - 2), QPoint(r.right() - 2, r.bottom())), + QLine(QPoint(r.right(), r.top() + 2), QPoint(r.right() - 2, r.top())) + }; + handlePainter.drawLines(lines, 4); handlePainter.restore();; handlePainter.setPen(QPen(outline.darker(130), 1)); handlePainter.drawLine(QPoint(r.left() + 3, r.top()), QPoint(r.right() - 3, r.top())); -- cgit v0.12 From 150c14bc50d28d2e6c768ff00654f527cb226812 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorbj=C3=B8rn=20Lindeijer?= Date: Tue, 1 Sep 2009 10:37:56 +0200 Subject: Fixed QPainterPath::toFillPolygons autotest Now it verifies that there are two non-intersecting polygons. Reviewed-by: Gunnar Sletta --- tests/auto/qpainterpath/tst_qpainterpath.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/auto/qpainterpath/tst_qpainterpath.cpp b/tests/auto/qpainterpath/tst_qpainterpath.cpp index 26c1f9b..9c4cbc4 100644 --- a/tests/auto/qpainterpath/tst_qpainterpath.cpp +++ b/tests/auto/qpainterpath/tst_qpainterpath.cpp @@ -1145,8 +1145,9 @@ void tst_QPainterPath::testToFillPolygons() path.lineTo(QPointF(70, 100)); path.lineTo(QPointF(40, 100)); - QPolygonF polygon = path.toFillPolygons(QMatrix()).first(); - QCOMPARE(polygon.count(QPointF(70, 50)), 2); + const QList polygons = path.toFillPolygons(); + QCOMPARE(polygons.size(), 2); + QCOMPARE(polygons.first().count(QPointF(70, 50)), 0); } void tst_QPainterPath::connectPathDuplicatePoint() -- cgit v0.12 From 9aa88cf3d15bf7ed6d3faf03ebe9fd574e1667ec Mon Sep 17 00:00:00 2001 From: Prasanth Ullattil Date: Tue, 1 Sep 2009 11:55:30 +0200 Subject: Fix compile error for WinCE Do not use LockWindowUpdate() in Win CE Reviewed-by: Trust Me --- src/activeqt/container/qaxwidget.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/activeqt/container/qaxwidget.cpp b/src/activeqt/container/qaxwidget.cpp index 22e7a82..94f85a5 100644 --- a/src/activeqt/container/qaxwidget.cpp +++ b/src/activeqt/container/qaxwidget.cpp @@ -1437,7 +1437,9 @@ extern Q_GUI_EXPORT bool qt_win_ignoreNextMouseReleaseEvent; HRESULT WINAPI QAxClientSite::EnableModeless(BOOL fEnable) { +#if !defined(Q_OS_WINCE) LockWindowUpdate(host->window()->winId()); +#endif EnableWindow(host->window()->winId(), fEnable); if (!fEnable) { @@ -1448,8 +1450,9 @@ HRESULT WINAPI QAxClientSite::EnableModeless(BOOL fEnable) QApplicationPrivate::leaveModal(host); } qt_win_ignoreNextMouseReleaseEvent = false; +#if !defined(Q_OS_WINCE) LockWindowUpdate(0); - +#endif return S_OK; } -- cgit v0.12 From c78d75db9467af9f5638073f74bed437c24c3584 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Tue, 1 Sep 2009 09:59:17 +0200 Subject: QMargins doesn't need to be exported as it is fully inline Reviewed-by: ogoffart --- src/corelib/tools/qmargins.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/tools/qmargins.h b/src/corelib/tools/qmargins.h index 2691c62..549c634 100644 --- a/src/corelib/tools/qmargins.h +++ b/src/corelib/tools/qmargins.h @@ -50,7 +50,7 @@ QT_BEGIN_NAMESPACE QT_MODULE(Core) -class Q_CORE_EXPORT QMargins +class QMargins { public: QMargins(); -- cgit v0.12 From c15e07884a29be26f1110e4d54a56da0001e3c53 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Tue, 1 Sep 2009 10:06:38 +0200 Subject: dynamic_cast in the demo was failing to build without rtti Reviewed-by: Kim Motoyoshi Kalland --- demos/boxes/qtbox.cpp | 14 ++++++++++---- demos/boxes/qtbox.h | 6 ++++-- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/demos/boxes/qtbox.cpp b/demos/boxes/qtbox.cpp index 015bc95..54882fb 100644 --- a/demos/boxes/qtbox.cpp +++ b/demos/boxes/qtbox.cpp @@ -122,7 +122,7 @@ void ItemBase::duplicateSelectedItems(QGraphicsScene *scene) selected = scene->selectedItems(); foreach (QGraphicsItem *item, selected) { - ItemBase *itemBase = dynamic_cast(item); + ItemBase *itemBase = qgraphicsitem_cast(item); if (itemBase) scene->addItem(itemBase->createNew(itemBase->m_size, itemBase->pos().x() + itemBase->m_size, itemBase->pos().y())); } @@ -137,7 +137,7 @@ void ItemBase::deleteSelectedItems(QGraphicsScene *scene) selected = scene->selectedItems(); foreach (QGraphicsItem *item, selected) { - ItemBase *itemBase = dynamic_cast(item); + ItemBase *itemBase = qgraphicsitem_cast(item); if (itemBase) delete itemBase; } @@ -152,7 +152,7 @@ void ItemBase::growSelectedItems(QGraphicsScene *scene) selected = scene->selectedItems(); foreach (QGraphicsItem *item, selected) { - ItemBase *itemBase = dynamic_cast(item); + ItemBase *itemBase = qgraphicsitem_cast(item); if (itemBase) { itemBase->prepareGeometryChange(); itemBase->m_size *= 2; @@ -171,7 +171,7 @@ void ItemBase::shrinkSelectedItems(QGraphicsScene *scene) selected = scene->selectedItems(); foreach (QGraphicsItem *item, selected) { - ItemBase *itemBase = dynamic_cast(item); + ItemBase *itemBase = qgraphicsitem_cast(item); if (itemBase) { itemBase->prepareGeometryChange(); itemBase->m_size /= 2; @@ -257,6 +257,12 @@ void ItemBase::wheelEvent(QGraphicsSceneWheelEvent *event) m_size = MIN_ITEM_SIZE; } +int ItemBase::type() const +{ + return Type; +} + + bool ItemBase::isInResizeArea(const QPointF &pos) { return (-pos.y() < pos.x() - m_size + 9); diff --git a/demos/boxes/qtbox.h b/demos/boxes/qtbox.h index 6f39b0d..9465911 100644 --- a/demos/boxes/qtbox.h +++ b/demos/boxes/qtbox.h @@ -47,10 +47,11 @@ #include #include "glbuffers.h" -class ItemBase : public QObject, public QGraphicsItem +class ItemBase : public QGraphicsItem { - Q_OBJECT public: + enum { Type = UserType + 1 }; + ItemBase(int size, int x, int y); virtual ~ItemBase(); virtual QRectF boundingRect() const; @@ -64,6 +65,7 @@ protected: virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); virtual void keyPressEvent(QKeyEvent *event); virtual void wheelEvent(QGraphicsSceneWheelEvent *event); + virtual int type() const; bool isInResizeArea(const QPointF &pos); static void duplicateSelectedItems(QGraphicsScene *scene); -- cgit v0.12 From c78c520bde91c08cedc6f7cc5c943998155f078e Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Tue, 1 Sep 2009 12:11:03 +0200 Subject: Fixed warnings (just 2 Q_Q() that are not used any more --- src/corelib/kernel/qabstractitemmodel.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/corelib/kernel/qabstractitemmodel.cpp b/src/corelib/kernel/qabstractitemmodel.cpp index 0a6c628..ec8fb76 100644 --- a/src/corelib/kernel/qabstractitemmodel.cpp +++ b/src/corelib/kernel/qabstractitemmodel.cpp @@ -601,7 +601,6 @@ void QAbstractItemModelPrivate::rowsInserted(const QModelIndex &parent, void QAbstractItemModelPrivate::itemsAboutToBeMoved(const QModelIndex &srcParent, int srcFirst, int srcLast, const QModelIndex &destinationParent, int destinationChild, Qt::Orientation orientation) { - Q_Q(QAbstractItemModel); QVector persistent_moved_explicitly; QVector persistent_moved_in_source; QVector persistent_moved_in_destination; @@ -2469,7 +2468,6 @@ void QAbstractItemModel::endRemoveRows() */ bool QAbstractItemModelPrivate::allowMove(const QModelIndex &srcParent, int start, int end, const QModelIndex &destinationParent, int destinationStart, Qt::Orientation orientation) { - Q_Q(QAbstractItemModel); // Don't move the range within itself. if ( ( destinationParent == srcParent ) && ( destinationStart >= start ) -- cgit v0.12 From fa97a0f683bf288356f6fed8c77a03fb6c363624 Mon Sep 17 00:00:00 2001 From: Jason McDonald Date: Tue, 1 Sep 2009 20:41:23 +1000 Subject: Fix misformatted license headers. Reviewed-by: Trust Me --- examples/qws/dbscreen/dbscreen.cpp | 21 +++++++++------------ examples/qws/dbscreen/dbscreen.h | 21 +++++++++------------ examples/qws/dbscreen/dbscreendriverplugin.cpp | 23 ++++++++++------------- qmake/generators/unix/unixmake.cpp | 19 ++++++++----------- src/gui/kernel/qt_mac.cpp | 19 ++++++++----------- 5 files changed, 44 insertions(+), 59 deletions(-) diff --git a/examples/qws/dbscreen/dbscreen.cpp b/examples/qws/dbscreen/dbscreen.cpp index 81df21d..3d3b15b 100644 --- a/examples/qws/dbscreen/dbscreen.cpp +++ b/examples/qws/dbscreen/dbscreen.cpp @@ -1,11 +1,11 @@ - /**************************************************************************** - ** - ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Nokia Corporation (qt-info@nokia.com) - ** - ** This file is part of the examples of the Qt Toolkit. - ** - ** $QT_BEGIN_LICENSE:LGPL$ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage ** This file contains pre-release code and may not be distributed. ** You may use this file in accordance with the terms and conditions @@ -36,11 +36,8 @@ ** ** ** $QT_END_LICENSE$ - ** - ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE - ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. - ** - ****************************************************************************/ +** +****************************************************************************/ #include "dbscreen.h" #include diff --git a/examples/qws/dbscreen/dbscreen.h b/examples/qws/dbscreen/dbscreen.h index a3c392e..b177cfc 100644 --- a/examples/qws/dbscreen/dbscreen.h +++ b/examples/qws/dbscreen/dbscreen.h @@ -1,11 +1,11 @@ - /**************************************************************************** - ** - ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Nokia Corporation (qt-info@nokia.com) - ** - ** This file is part of the examples of the Qt Toolkit. - ** - ** $QT_BEGIN_LICENSE:LGPL$ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage ** This file contains pre-release code and may not be distributed. ** You may use this file in accordance with the terms and conditions @@ -36,11 +36,8 @@ ** ** ** $QT_END_LICENSE$ - ** - ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE - ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. - ** - ****************************************************************************/ +** +****************************************************************************/ #ifndef DBSCREEN_H #define DBSCREEN_H diff --git a/examples/qws/dbscreen/dbscreendriverplugin.cpp b/examples/qws/dbscreen/dbscreendriverplugin.cpp index c1cc03c..bc2434b 100644 --- a/examples/qws/dbscreen/dbscreendriverplugin.cpp +++ b/examples/qws/dbscreen/dbscreendriverplugin.cpp @@ -1,11 +1,11 @@ - /**************************************************************************** - ** - ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Nokia Corporation (qt-info@nokia.com) - ** - ** This file is part of the examples of the Qt Toolkit. - ** - ** $QT_BEGIN_LICENSE:LGPL$ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage ** This file contains pre-release code and may not be distributed. ** You may use this file in accordance with the terms and conditions @@ -36,12 +36,9 @@ ** ** ** $QT_END_LICENSE$ - ** - ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE - ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. - ** - ****************************************************************************/ - +** +****************************************************************************/ + #include #include "dbscreen.h" diff --git a/qmake/generators/unix/unixmake.cpp b/qmake/generators/unix/unixmake.cpp index 2e6397b..4d8883c 100644 --- a/qmake/generators/unix/unixmake.cpp +++ b/qmake/generators/unix/unixmake.cpp @@ -1,11 +1,11 @@ /**************************************************************************** - ** - ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Nokia Corporation (qt-info@nokia.com) - ** - ** This file is part of the qmake application of the Qt Toolkit. - ** - ** $QT_BEGIN_LICENSE:LGPL$ +** +** This file is part of the qmake application of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage ** This file contains pre-release code and may not be distributed. ** You may use this file in accordance with the terms and conditions @@ -36,11 +36,8 @@ ** ** ** $QT_END_LICENSE$ - ** - ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE - ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. - ** - ****************************************************************************/ +** +****************************************************************************/ #include "unixmake.h" #include "option.h" diff --git a/src/gui/kernel/qt_mac.cpp b/src/gui/kernel/qt_mac.cpp index 6b2bbcb..2b9d073 100644 --- a/src/gui/kernel/qt_mac.cpp +++ b/src/gui/kernel/qt_mac.cpp @@ -1,11 +1,11 @@ /**************************************************************************** - ** - ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Nokia Corporation (qt-info@nokia.com) - ** - ** This file is part of the QtGui module of the Qt Toolkit. - ** - ** $QT_BEGIN_LICENSE:LGPL$ +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage ** This file contains pre-release code and may not be distributed. ** You may use this file in accordance with the terms and conditions @@ -36,11 +36,8 @@ ** ** ** $QT_END_LICENSE$ - ** - ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE - ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. - ** - ****************************************************************************/ +** +****************************************************************************/ #include #include -- cgit v0.12 From 2a9ffbeda34c04bede04c1aac24eab13fc490fe9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Nilsen?= Date: Tue, 1 Sep 2009 09:03:43 +0200 Subject: Make sure graphics effects updates properly when changing their properties. Reviewed-by: Leo --- src/gui/effects/qgraphicseffect.cpp | 23 +++++++++++++++++++++++ src/gui/effects/qgraphicseffect.h | 2 +- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/gui/effects/qgraphicseffect.cpp b/src/gui/effects/qgraphicseffect.cpp index ccbf7fc..1e0ea53 100644 --- a/src/gui/effects/qgraphicseffect.cpp +++ b/src/gui/effects/qgraphicseffect.cpp @@ -349,6 +349,22 @@ void QGraphicsEffect::setEnabled(bool enable) */ /*! + Schedules a redraw of the source. Call this function whenever the source + needs to be redrawn. + + This convenience function is equivalent to calling + QGraphicsEffectSource::update(). + + \sa updateBoundingRect(), QGraphicsEffectSource::update() +*/ +void QGraphicsEffect::update() +{ + Q_D(QGraphicsEffect); + if (d->source) + d->source->update(); +} + +/*! Returns a pointer to the source, which provides extra context information that can be useful for the effect. @@ -366,6 +382,8 @@ QGraphicsEffectSource *QGraphicsEffect::source() const function whenever you change any parameters that will cause the virtual boundingRectFor() function to return a different value. + This function will call update() if this is necessary. + \sa boundingRectFor(), boundingRect() */ void QGraphicsEffect::updateBoundingRect() @@ -523,6 +541,7 @@ void QGraphicsColorizeEffect::setColor(const QColor &color) return; d->filter->setColor(color); + update(); emit colorChanged(color); } @@ -610,6 +629,7 @@ void QGraphicsPixelizeEffect::setPixelSize(int size) return; d->pixelSize = size; + update(); emit pixelSizeChanged(size); } @@ -903,6 +923,7 @@ void QGraphicsDropShadowEffect::setColor(const QColor &color) return; d->filter->setColor(color); + update(); emit colorChanged(color); } @@ -1012,6 +1033,7 @@ void QGraphicsOpacityEffect::setOpacity(qreal opacity) d->isFullyOpaque = 0; else d->isFullyOpaque = qFuzzyIsNull(d->opacity - 1); + update(); emit opacityChanged(opacity); } @@ -1050,6 +1072,7 @@ void QGraphicsOpacityEffect::setOpacityMask(const QBrush &mask) d->opacityMask = mask; d->hasOpacityMask = (mask.style() != Qt::NoBrush); + update(); emit opacityMaskChanged(mask); } diff --git a/src/gui/effects/qgraphicseffect.h b/src/gui/effects/qgraphicseffect.h index 8e5384c..ad941a5 100644 --- a/src/gui/effects/qgraphicseffect.h +++ b/src/gui/effects/qgraphicseffect.h @@ -118,7 +118,7 @@ public: public Q_SLOTS: void setEnabled(bool enable); - // ### add update() slot + void update(); Q_SIGNALS: void enabledChanged(bool enabled); -- cgit v0.12 From cc6e8f466111dc04395041cdabb73a831ae802c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Nilsen?= Date: Tue, 1 Sep 2009 10:39:49 +0200 Subject: QGraphicsDropShadowEffect convenience; setXOffset() and setYOffset(). Reviewed-by: Andreas --- src/gui/effects/qgraphicseffect.cpp | 20 +++++++++++++++++++- src/gui/effects/qgraphicseffect.h | 18 ++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/src/gui/effects/qgraphicseffect.cpp b/src/gui/effects/qgraphicseffect.cpp index 1e0ea53..2be6a49 100644 --- a/src/gui/effects/qgraphicseffect.cpp +++ b/src/gui/effects/qgraphicseffect.cpp @@ -840,7 +840,7 @@ QGraphicsDropShadowEffect::~QGraphicsDropShadowEffect() By default, the offset is 8 pixels towards the lower right. - \sa blurRadius(), color() + \sa xOffset(), yOffset(), blurRadius(), color() */ QPointF QGraphicsDropShadowEffect::offset() const { @@ -860,6 +860,24 @@ void QGraphicsDropShadowEffect::setOffset(const QPointF &offset) } /*! + \property QGraphicsDropShadowEffect::xOffset + \brief the horizontal shadow offset in pixels. + + By default, the horizontal shadow offset is 8 pixels. + + \sa yOffset(), offset() +*/ + +/*! + \property QGraphicsDropShadowEffect::yOffset + \brief the vertical shadow offset in pixels. + + By default, the vertical shadow offset is 8 pixels. + + \sa xOffset(), offset() +*/ + +/*! \fn void QGraphicsDropShadowEffect::offsetChanged(const QPointF &offset) This signal is emitted whenever the effect's shadow offset changes. diff --git a/src/gui/effects/qgraphicseffect.h b/src/gui/effects/qgraphicseffect.h index ad941a5..aee7834 100644 --- a/src/gui/effects/qgraphicseffect.h +++ b/src/gui/effects/qgraphicseffect.h @@ -237,6 +237,8 @@ class Q_GUI_EXPORT QGraphicsDropShadowEffect: public QGraphicsEffect { Q_OBJECT Q_PROPERTY(QPointF offset READ offset WRITE setOffset NOTIFY offsetChanged) + Q_PROPERTY(qreal xOffset READ xOffset WRITE setXOffset NOTIFY offsetChanged) + Q_PROPERTY(qreal yOffset READ yOffset WRITE setYOffset NOTIFY offsetChanged) Q_PROPERTY(int blurRadius READ blurRadius WRITE setBlurRadius NOTIFY blurRadiusChanged) Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged) public: @@ -245,15 +247,31 @@ public: QRectF boundingRectFor(const QRectF &rect) const; QPointF offset() const; + + inline qreal xOffset() const + { return offset().x(); } + + inline qreal yOffset() const + { return offset().y(); } + int blurRadius() const; QColor color() const; public Q_SLOTS: void setOffset(const QPointF &ofs); + inline void setOffset(qreal dx, qreal dy) { setOffset(QPointF(dx, dy)); } + inline void setOffset(qreal d) { setOffset(QPointF(d, d)); } + + inline void setXOffset(qreal dx) + { setOffset(QPointF(dx, yOffset())); } + + inline void setYOffset(qreal dy) + { setOffset(QPointF(xOffset(), dy)); } + void setBlurRadius(int blurRadius); void setColor(const QColor &color); -- cgit v0.12 From d3cf11841763ab222ae0ca62468e83a695116514 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Arve=20S=C3=A6ther?= Date: Tue, 1 Sep 2009 11:50:14 +0200 Subject: Add a benchmark for QGraphicsAnchorLayout. --- .../qgraphicsanchorlayout.pro | 6 + .../tst_qgraphicsanchorlayout.cpp | 197 +++++++++++++++++++++ 2 files changed, 203 insertions(+) create mode 100644 tests/benchmarks/qgraphicsanchorlayout/qgraphicsanchorlayout.pro create mode 100644 tests/benchmarks/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp diff --git a/tests/benchmarks/qgraphicsanchorlayout/qgraphicsanchorlayout.pro b/tests/benchmarks/qgraphicsanchorlayout/qgraphicsanchorlayout.pro new file mode 100644 index 0000000..0d563b9 --- /dev/null +++ b/tests/benchmarks/qgraphicsanchorlayout/qgraphicsanchorlayout.pro @@ -0,0 +1,6 @@ +load(qttest_p4) +TEMPLATE = app +TARGET = tst_qgraphicsanchorlayout + +SOURCES += tst_qgraphicsanchorlayout.cpp + diff --git a/tests/benchmarks/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp b/tests/benchmarks/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp new file mode 100644 index 0000000..e419bae --- /dev/null +++ b/tests/benchmarks/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp @@ -0,0 +1,197 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtOpenGL module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include + +class tst_QGraphicsAnchorLayout : public QObject +{ + Q_OBJECT +public: + tst_QGraphicsAnchorLayout() {} + ~tst_QGraphicsAnchorLayout() {} + +private slots: + void s60_hard_complex_data(); + void s60_hard_complex(); +}; + + +class RectWidget : public QGraphicsWidget +{ +public: + RectWidget(QGraphicsItem *parent = 0) : QGraphicsWidget(parent){} + + void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) + { + Q_UNUSED(option); + Q_UNUSED(widget); + painter->drawRoundRect(rect()); + painter->drawLine(rect().topLeft(), rect().bottomRight()); + painter->drawLine(rect().bottomLeft(), rect().topRight()); + } +}; + +static QGraphicsWidget *createItem(const QSizeF &minimum = QSizeF(100.0, 100.0), + const QSizeF &preferred = QSize(150.0, 100.0), + const QSizeF &maximum = QSizeF(200.0, 100.0), + const QString &name = QString()) +{ + QGraphicsWidget *w = new RectWidget; + w->setMinimumSize(minimum); + w->setPreferredSize(preferred); + w->setMaximumSize(maximum); + w->setData(0, name); + return w; +} + +static void setAnchor(QGraphicsAnchorLayout *l, + QGraphicsLayoutItem *firstItem, + Qt::AnchorPoint firstEdge, + QGraphicsLayoutItem *secondItem, + Qt::AnchorPoint secondEdge, + qreal spacing) +{ + l->addAnchor(firstItem, firstEdge, secondItem, secondEdge); + l->setAnchorSpacing(firstItem, firstEdge, secondItem, secondEdge, spacing); +} + +void tst_QGraphicsAnchorLayout::s60_hard_complex_data() +{ + QTest::addColumn("whichSizeHint"); + QTest::newRow("minimumSizeHint") + << int(Qt::MinimumSize); + QTest::newRow("preferredSizeHint") + << int(Qt::PreferredSize); + QTest::newRow("maximumSizeHint") + << int(Qt::MaximumSize); + // Add it as a reference to see how much overhead the body of effectiveSizeHint takes. + QTest::newRow("noSizeHint") + << -1; +} + +void tst_QGraphicsAnchorLayout::s60_hard_complex() +{ + QFETCH(int, whichSizeHint); + + // Test for "hard" complex case, taken from wiki + // https://cwiki.nokia.com/S60QTUI/AnchorLayoutComplexCases + QSizeF min(0, 10); + QSizeF pref(50, 10); + QSizeF max(100, 10); + + QGraphicsWidget *a = createItem(min, pref, max, "a"); + QGraphicsWidget *b = createItem(min, pref, max, "b"); + QGraphicsWidget *c = createItem(min, pref, max, "c"); + QGraphicsWidget *d = createItem(min, pref, max, "d"); + QGraphicsWidget *e = createItem(min, pref, max, "e"); + QGraphicsWidget *f = createItem(min, pref, max, "f"); + QGraphicsWidget *g = createItem(min, pref, max, "g"); + + QGraphicsAnchorLayout *l = new QGraphicsAnchorLayout; + l->setContentsMargins(0, 0, 0, 0); + + // + setAnchor(l, l, Qt::AnchorLeft, a, Qt::AnchorLeft, 10); + setAnchor(l, a, Qt::AnchorRight, b, Qt::AnchorLeft, 10); + setAnchor(l, b, Qt::AnchorRight, c, Qt::AnchorLeft, 10); + setAnchor(l, c, Qt::AnchorRight, d, Qt::AnchorLeft, 10); + setAnchor(l, d, Qt::AnchorRight, l, Qt::AnchorRight, 10); + + // + setAnchor(l, b, Qt::AnchorLeft, e, Qt::AnchorLeft, 10); + setAnchor(l, e, Qt::AnchorRight, d, Qt::AnchorLeft, 10); + + // + setAnchor(l, a, Qt::AnchorHorizontalCenter, g, Qt::AnchorLeft, 10); + setAnchor(l, g, Qt::AnchorRight, f, Qt::AnchorHorizontalCenter, 10); + setAnchor(l, c, Qt::AnchorLeft, f, Qt::AnchorLeft, 10); + setAnchor(l, f, Qt::AnchorRight, d, Qt::AnchorRight, 10); + + // + setAnchor(l, l, Qt::AnchorTop, e, Qt::AnchorTop, 0); + setAnchor(l, e, Qt::AnchorBottom, a, Qt::AnchorTop, 0); + setAnchor(l, e, Qt::AnchorBottom, b, Qt::AnchorTop, 0); + setAnchor(l, e, Qt::AnchorBottom, c, Qt::AnchorTop, 0); + setAnchor(l, e, Qt::AnchorBottom, d, Qt::AnchorTop, 0); + setAnchor(l, a, Qt::AnchorBottom, f, Qt::AnchorTop, 0); + setAnchor(l, a, Qt::AnchorBottom, b, Qt::AnchorBottom, 0); + setAnchor(l, a, Qt::AnchorBottom, c, Qt::AnchorBottom, 0); + setAnchor(l, a, Qt::AnchorBottom, d, Qt::AnchorBottom, 0); + setAnchor(l, f, Qt::AnchorBottom, g, Qt::AnchorTop, 0); + setAnchor(l, g, Qt::AnchorBottom, l, Qt::AnchorBottom, 0); + + // It won't query the size hint if it already has a size set. + // If only one of the sizes is unset it will query sizeHint only of for that hint type. + l->setMinimumSize(60,40); + l->setPreferredSize(220,40); + l->setMaximumSize(240,40); + + switch (whichSizeHint) { + case Qt::MinimumSize: + l->setMinimumSize(-1, -1); + break; + case Qt::PreferredSize: + l->setPreferredSize(-1, -1); + break; + case Qt::MaximumSize: + l->setMaximumSize(-1, -1); + break; + default: + break; + } + + QSizeF sizeHint; + // warm up instruction cache + l->invalidate(); + sizeHint = l->effectiveSizeHint((Qt::SizeHint)whichSizeHint); + // ...then measure... + QBENCHMARK { + l->invalidate(); + sizeHint = l->effectiveSizeHint((Qt::SizeHint)whichSizeHint); + } +} + +QTEST_MAIN(tst_QGraphicsAnchorLayout) + +#include "tst_qgraphicsanchorlayout.moc" -- cgit v0.12 From 4f19cd391aa32b12b9f749af06ebe6836cd0cbae Mon Sep 17 00:00:00 2001 From: Geir Vattekar Date: Tue, 1 Sep 2009 13:31:10 +0200 Subject: Doc: Said what happens when setFocus() is called on a widget in an inactive window. Task-number: 78707 Reviewed-by: Morten Engvoldsen --- src/gui/kernel/qwidget.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index 37ffa8fb..863c43e 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -5962,6 +5962,8 @@ bool QWidget::hasFocus() const isActiveWindow() active window\endlink. The \a reason argument will be passed into any focus event sent from this function, it is used to give an explanation of what caused the widget to get focus. + If the window is not active, the widget will be given the focus when + the window becomes active. First, a focus out event is sent to the focus widget (if any) to tell it that it is about to lose the focus. Then a focus in event -- cgit v0.12 From 7b6152ad6ac588350b8acf4353fb05628e86af2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Tue, 1 Sep 2009 13:53:52 +0200 Subject: Compilation fixes for Windows CE on ARM My earlier cleanup/refactoring of qatomic_windows.h broke things on this platform. Should be fixed now. Reviewed-by: Joerg Bornemann --- src/corelib/arch/qatomic_windows.h | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/src/corelib/arch/qatomic_windows.h b/src/corelib/arch/qatomic_windows.h index 50dedc1..a09e9fd 100644 --- a/src/corelib/arch/qatomic_windows.h +++ b/src/corelib/arch/qatomic_windows.h @@ -68,7 +68,7 @@ # if _WIN32_WCE < 0x600 && defined(_X86_) // For X86 Windows CE, include winbase.h to catch inline functions which -// overwrite the regular definitions inside of coredll.dll. +// override the regular definitions inside of coredll.dll. // Though one could use the original version of Increment/Decrement, others are // not exported at all. # include @@ -76,19 +76,21 @@ // It's safer to remove the volatile and let the compiler add it as needed. # define QT_INTERLOCKED_NO_VOLATILE -# else // _WIN32_WCE >= 0x600 || _X86_ +# else // _WIN32_WCE >= 0x600 || !_X86_ # define QT_INTERLOCKED_PROTOTYPE __cdecl # define QT_INTERLOCKED_DECLARE_PROTOTYPES -# if _WIN32_WCE >= 0x600 && defined(_X86_) -# define QT_INTERLOCKED_PREFIX _ -# define QT_INTERLOCKED_INTRINSIC +# if _WIN32_WCE >= 0x600 +# if defined(_X86_) +# define QT_INTERLOCKED_PREFIX _ +# define QT_INTERLOCKED_INTRINSIC +# endif # else # define QT_INTERLOCKED_NO_VOLATILE # endif -# endif // _WIN32_WCE >= 0x600 || _X86_ +# endif // _WIN32_WCE >= 0x600 || !_X86_ #endif // Q_OS_WINCE @@ -132,9 +134,9 @@ extern "C" { long QT_INTERLOCKED_PROTOTYPE QT_INTERLOCKED_FUNCTION( InterlockedExchangeAdd )(long QT_INTERLOCKED_VOLATILE *, long); # if !defined(__i386__) && !defined(_M_IX86) - long QT_INTERLOCKED_FUNCTION( InterlockedCompareExchangePointer )(void * QT_INTERLOCKED_VOLATILE *, void *, void *); - long QT_INTERLOCKED_FUNCTION( InterlockedExchangePointer )(void * QT_INTERLOCKED_VOLATILE *, void *); - __int64 QT_INTERLOCKED_FUNCTION( InterlockedExchangeAdd64 )(__int64 QT_INTERLOCKED_VOLATILE *, long); + void * QT_INTERLOCKED_FUNCTION( InterlockedCompareExchangePointer )(void * QT_INTERLOCKED_VOLATILE *, void *, void *); + void * QT_INTERLOCKED_FUNCTION( InterlockedExchangePointer )(void * QT_INTERLOCKED_VOLATILE *, void *); + __int64 QT_INTERLOCKED_FUNCTION( InterlockedExchangeAdd64 )(__int64 QT_INTERLOCKED_VOLATILE *, __int64); # endif } @@ -190,7 +192,7 @@ extern "C" { QT_INTERLOCKED_REMOVE_VOLATILE( value ), \ valueToAdd ) -#if defined(__i386__) || defined(_M_IX86) +#if defined(Q_OS_WINCE) || defined(__i386__) || defined(_M_IX86) # define QT_INTERLOCKED_COMPARE_EXCHANGE_POINTER(value, newValue, expectedValue) \ reinterpret_cast( \ @@ -209,7 +211,7 @@ extern "C" { QT_INTERLOCKED_REMOVE_VOLATILE( value ## _integral ), \ valueToAdd ) -#else // !defined(__i386__) && !defined(_M_IX86) +#else // !defined(Q_OS_WINCE) && !defined(__i386__) && !defined(_M_IX86) # define QT_INTERLOCKED_COMPARE_EXCHANGE_POINTER(value, newValue, expectedValue) \ QT_INTERLOCKED_FUNCTION(InterlockedCompareExchangePointer)( \ @@ -227,7 +229,7 @@ extern "C" { QT_INTERLOCKED_REMOVE_VOLATILE( value ## _integral ), \ valueToAdd ) -#endif // !defined(__i386__) && !defined(_M_IX86) +#endif // !defined(Q_OS_WINCE) && !defined(__i386__) && !defined(_M_IX86) //////////////////////////////////////////////////////////////////////////////////////////////////// -- cgit v0.12 From d0b4bd21d5fc04febdfdb41111435d79750e5ff6 Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Tue, 1 Sep 2009 14:14:18 +0200 Subject: Manual test for QNAM HTTP: Downloading a big file --- tests/manual/qhttpnetworkconnection/main.cpp | 81 ++++++++++++++++++++++ .../qhttpnetworkconnection.pro | 13 ++++ 2 files changed, 94 insertions(+) create mode 100644 tests/manual/qhttpnetworkconnection/main.cpp create mode 100644 tests/manual/qhttpnetworkconnection/qhttpnetworkconnection.pro diff --git a/tests/manual/qhttpnetworkconnection/main.cpp b/tests/manual/qhttpnetworkconnection/main.cpp new file mode 100644 index 0000000..b15a7ed --- /dev/null +++ b/tests/manual/qhttpnetworkconnection/main.cpp @@ -0,0 +1,81 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.1, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +// This file contains benchmarks for QNetworkReply functions. + +#include +#include +#include +#include +#include +#include +#include "../../auto/network-settings.h" + +class tst_qhttpnetworkconnection : public QObject +{ + Q_OBJECT +private slots: + void bigRemoteFile(); + +}; + +void tst_qhttpnetworkconnection::bigRemoteFile() +{ + QNetworkAccessManager manager; + qint64 size; + QTime t; + QNetworkRequest request(QUrl("http://nds1.nokia.com/files/support/global/phones/software/Nokia_Ovi_Suite_webinstaller.exe")); + QNetworkReply* reply = manager.get(request); + connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop()), Qt::QueuedConnection); + qDebug() << "Starting download"; + t.start(); + QTestEventLoop::instance().enterLoop(50); + QVERIFY(!QTestEventLoop::instance().timeout()); + size = reply->size(); + delete reply; + qDebug() << "Finished!" << endl; + qDebug() << "Time:" << t.elapsed() << "msec"; + qDebug() << "Bytes:" << size; + qDebug() << "Speed:" << (size / 1024) / (t.elapsed() / 1000) << "KB/sec"; +} + +QTEST_MAIN(tst_qhttpnetworkconnection) + +#include "main.moc" diff --git a/tests/manual/qhttpnetworkconnection/qhttpnetworkconnection.pro b/tests/manual/qhttpnetworkconnection/qhttpnetworkconnection.pro new file mode 100644 index 0000000..2471389 --- /dev/null +++ b/tests/manual/qhttpnetworkconnection/qhttpnetworkconnection.pro @@ -0,0 +1,13 @@ +load(qttest_p4) +TEMPLATE = app +TARGET = tst_qhttpnetworkconnection +DEPENDPATH += . +INCLUDEPATH += . + +QT -= gui +QT += network + +CONFIG += release + +# Input +SOURCES += main.cpp -- cgit v0.12 From ae2f5c66d16fab9f92f960435057d955e9a832ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Tue, 1 Sep 2009 14:09:29 +0200 Subject: Fixed QGLFramebufferObject::toImage() releasing the FBO if bound. Reviewed-by: Trond --- src/opengl/qglframebufferobject.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/opengl/qglframebufferobject.cpp b/src/opengl/qglframebufferobject.cpp index 9659654..859afc7 100644 --- a/src/opengl/qglframebufferobject.cpp +++ b/src/opengl/qglframebufferobject.cpp @@ -875,9 +875,12 @@ QImage QGLFramebufferObject::toImage() const if (!d->valid) return QImage(); - const_cast(this)->bind(); + bool wasBound = isBound(); + if (!wasBound) + const_cast(this)->bind(); QImage image = qt_gl_read_framebuffer(d->size, d->ctx->format().alpha(), true); - const_cast(this)->release(); + if (!wasBound) + const_cast(this)->release(); return image; } -- cgit v0.12 From e0e0ae322e654b0b152fc54d99201b18b620a0ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Tue, 1 Sep 2009 14:16:08 +0200 Subject: Fixed toImage() not working on a multisample QGLFramebufferObject. Need to blit into a regular QGLFramebufferObject first to force a multisample resolve. Reviewed-by: Trond --- src/opengl/qglframebufferobject.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/opengl/qglframebufferobject.cpp b/src/opengl/qglframebufferobject.cpp index 859afc7..8fd113a 100644 --- a/src/opengl/qglframebufferobject.cpp +++ b/src/opengl/qglframebufferobject.cpp @@ -875,6 +875,16 @@ QImage QGLFramebufferObject::toImage() const if (!d->valid) return QImage(); + // qt_gl_read_framebuffer doesn't work on a multisample FBO + if (format().samples() != 0) { + QGLFramebufferObject temp(size()); + + QRect rect(QPoint(0, 0), size()); + blitFramebuffer(&temp, rect, const_cast(this), rect); + + return temp.toImage(); + } + bool wasBound = isBound(); if (!wasBound) const_cast(this)->bind(); -- cgit v0.12 From a7178d96d7e9c50a4392ab9ee23b219d26028ed3 Mon Sep 17 00:00:00 2001 From: Pierre Rossi Date: Wed, 22 Jul 2009 12:55:25 +0200 Subject: Fixes the gif plugin's rendering for some animated gif files. In the case of optimized animated gifs, we don't want to discard the contents of the previous frame, this is handled if needed in the disposal process. Task-number: 247365 Reviewed-by: Samuel --- src/plugins/imageformats/gif/qgifhandler.cpp | 4 ++-- tests/auto/qimagereader/images/qt.gif | Bin 0 -> 26504 bytes tests/auto/qimagereader/images/qt1.gif | Bin 0 -> 7216 bytes tests/auto/qimagereader/images/qt2.gif | Bin 0 -> 5559 bytes tests/auto/qimagereader/images/qt3.gif | Bin 0 -> 4702 bytes tests/auto/qimagereader/images/qt4.gif | Bin 0 -> 4310 bytes tests/auto/qimagereader/images/qt5.gif | Bin 0 -> 4234 bytes tests/auto/qimagereader/images/qt6.gif | Bin 0 -> 4732 bytes tests/auto/qimagereader/images/qt7.gif | Bin 0 -> 5265 bytes tests/auto/qimagereader/images/qt8.gif | Bin 0 -> 6144 bytes tests/auto/qimagereader/qimagereader.qrc | 13 +++++++++++-- tests/auto/qimagereader/tst_qimagereader.cpp | 13 +++++++++++++ 12 files changed, 26 insertions(+), 4 deletions(-) create mode 100644 tests/auto/qimagereader/images/qt.gif create mode 100644 tests/auto/qimagereader/images/qt1.gif create mode 100644 tests/auto/qimagereader/images/qt2.gif create mode 100644 tests/auto/qimagereader/images/qt3.gif create mode 100644 tests/auto/qimagereader/images/qt4.gif create mode 100644 tests/auto/qimagereader/images/qt5.gif create mode 100644 tests/auto/qimagereader/images/qt6.gif create mode 100644 tests/auto/qimagereader/images/qt7.gif create mode 100644 tests/auto/qimagereader/images/qt8.gif diff --git a/src/plugins/imageformats/gif/qgifhandler.cpp b/src/plugins/imageformats/gif/qgifhandler.cpp index de985d8..0f6a349 100644 --- a/src/plugins/imageformats/gif/qgifhandler.cpp +++ b/src/plugins/imageformats/gif/qgifhandler.cpp @@ -234,7 +234,7 @@ int QGIFFormat::decode(QImage *image, const uchar *buffer, int length, #define LM(l, m) (((m)<<8)|l) digress = false; - int initial = length; + const int initial = length; while (!digress && length) { length--; unsigned char ch=*buffer++; @@ -333,7 +333,7 @@ int QGIFFormat::decode(QImage *image, const uchar *buffer, int length, sheight = newtop + newheight; QImage::Format format = trans_index >= 0 ? QImage::Format_ARGB32 : QImage::Format_RGB32; - if (image->isNull() || (image->size() != QSize(swidth, sheight)) || image->format() != format) { + if (image->isNull()) { (*image) = QImage(swidth, sheight, format); memset(image->bits(), 0, image->numBytes()); diff --git a/tests/auto/qimagereader/images/qt.gif b/tests/auto/qimagereader/images/qt.gif new file mode 100644 index 0000000..e0a5a80 Binary files /dev/null and b/tests/auto/qimagereader/images/qt.gif differ diff --git a/tests/auto/qimagereader/images/qt1.gif b/tests/auto/qimagereader/images/qt1.gif new file mode 100644 index 0000000..0ce910c Binary files /dev/null and b/tests/auto/qimagereader/images/qt1.gif differ diff --git a/tests/auto/qimagereader/images/qt2.gif b/tests/auto/qimagereader/images/qt2.gif new file mode 100644 index 0000000..993a315 Binary files /dev/null and b/tests/auto/qimagereader/images/qt2.gif differ diff --git a/tests/auto/qimagereader/images/qt3.gif b/tests/auto/qimagereader/images/qt3.gif new file mode 100644 index 0000000..7391678 Binary files /dev/null and b/tests/auto/qimagereader/images/qt3.gif differ diff --git a/tests/auto/qimagereader/images/qt4.gif b/tests/auto/qimagereader/images/qt4.gif new file mode 100644 index 0000000..41109a9 Binary files /dev/null and b/tests/auto/qimagereader/images/qt4.gif differ diff --git a/tests/auto/qimagereader/images/qt5.gif b/tests/auto/qimagereader/images/qt5.gif new file mode 100644 index 0000000..5a3fb54 Binary files /dev/null and b/tests/auto/qimagereader/images/qt5.gif differ diff --git a/tests/auto/qimagereader/images/qt6.gif b/tests/auto/qimagereader/images/qt6.gif new file mode 100644 index 0000000..f22e7c9 Binary files /dev/null and b/tests/auto/qimagereader/images/qt6.gif differ diff --git a/tests/auto/qimagereader/images/qt7.gif b/tests/auto/qimagereader/images/qt7.gif new file mode 100644 index 0000000..a315671 Binary files /dev/null and b/tests/auto/qimagereader/images/qt7.gif differ diff --git a/tests/auto/qimagereader/images/qt8.gif b/tests/auto/qimagereader/images/qt8.gif new file mode 100644 index 0000000..2a7d09e Binary files /dev/null and b/tests/auto/qimagereader/images/qt8.gif differ diff --git a/tests/auto/qimagereader/qimagereader.qrc b/tests/auto/qimagereader/qimagereader.qrc index c6b963b..11b9406 100644 --- a/tests/auto/qimagereader/qimagereader.qrc +++ b/tests/auto/qimagereader/qimagereader.qrc @@ -1,5 +1,5 @@ - - + + images/16bpp.bmp images/4bpp-rle.bmp images/YCbCr_cmyk.jpg @@ -48,5 +48,14 @@ images/tst7.png images/transparent.xpm images/trolltech.gif + images/qt.gif + images/qt1.gif + images/qt2.gif + images/qt3.gif + images/qt4.gif + images/qt5.gif + images/qt6.gif + images/qt7.gif + images/qt8.gif diff --git a/tests/auto/qimagereader/tst_qimagereader.cpp b/tests/auto/qimagereader/tst_qimagereader.cpp index 27c6925..a325a33 100644 --- a/tests/auto/qimagereader/tst_qimagereader.cpp +++ b/tests/auto/qimagereader/tst_qimagereader.cpp @@ -140,6 +140,7 @@ private slots: #if defined QTEST_HAVE_GIF void gifHandlerBugs(); + void animatedGif(); #endif void readCorruptImage_data(); @@ -710,6 +711,18 @@ void tst_QImageReader::gifHandlerBugs() QCOMPARE(im1.convertToFormat(QImage::Format_ARGB32), im2.convertToFormat(QImage::Format_ARGB32)); } } + +void tst_QImageReader::animatedGif() +{ + QImageReader io(prefix + "qt.gif"); + QImage image= io.read(); + int i=0; + while(!image.isNull()){ + QString frameName = QString(prefix + "qt%1.gif").arg(++i); + QCOMPARE(image, QImage(frameName)); + image=io.read(); + } +} #endif class Server : public QObject -- cgit v0.12 From 505458d4e2d094eba7cf34a71c6cd960c28a52e4 Mon Sep 17 00:00:00 2001 From: David Boddie Date: Tue, 1 Sep 2009 15:26:07 +0200 Subject: Doc: Fixed broken links to renamed functions. Reviewed-by: Trust Me --- src/gui/widgets/qcalendarwidget.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/gui/widgets/qcalendarwidget.cpp b/src/gui/widgets/qcalendarwidget.cpp index dfd8639..8ed57cd 100644 --- a/src/gui/widgets/qcalendarwidget.cpp +++ b/src/gui/widgets/qcalendarwidget.cpp @@ -1967,9 +1967,7 @@ void QCalendarWidgetPrivate::_q_editingFinished() The widget is initialized with the current month and year, but QCalendarWidget provides several public slots to change the year - and month that is shown. The currently displayed month and year - can be retrieved using the currentPageMonth() and currentPageYear() - functions, respectively. + and month that is shown. By default, today's date is selected, and the user can select a date using both mouse and keyboard. The currently selected date @@ -1982,6 +1980,9 @@ void QCalendarWidgetPrivate::_q_editingFinished() all. Note that a date also can be selected programmatically using the setSelectedDate() slot. + The currently displayed month and year can be retrieved using the + monthShown() and yearShown() functions, respectively. + A newly created calendar widget uses abbreviated day names, and both Saturdays and Sundays are marked in red. The calendar grid is not visible. The week numbers are displayed, and the first column @@ -2287,7 +2288,7 @@ int QCalendarWidget::monthShown() const selected date. The currently displayed month and year can be retrieved using the - currentPageMonth() and currentPageYear() functions respectively. + monthShown() and yearShown() functions respectively. \sa yearShown(), monthShown(), showPreviousMonth(), showNextMonth(), showPreviousYear(), showNextYear() -- cgit v0.12 From d117525a4ff8757208231fa77f171c7fd7a30ef9 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Tue, 1 Sep 2009 15:27:35 +0200 Subject: fix Windows CE compile failure in qatomic_windows.h Reviewed-by: joao --- src/corelib/arch/qatomic_windows.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/arch/qatomic_windows.h b/src/corelib/arch/qatomic_windows.h index a09e9fd..9b7ff5d 100644 --- a/src/corelib/arch/qatomic_windows.h +++ b/src/corelib/arch/qatomic_windows.h @@ -133,7 +133,7 @@ extern "C" { long QT_INTERLOCKED_PROTOTYPE QT_INTERLOCKED_FUNCTION( InterlockedExchange )(long QT_INTERLOCKED_VOLATILE *, long); long QT_INTERLOCKED_PROTOTYPE QT_INTERLOCKED_FUNCTION( InterlockedExchangeAdd )(long QT_INTERLOCKED_VOLATILE *, long); -# if !defined(__i386__) && !defined(_M_IX86) +# if !defined(Q_OS_WINCE) && !defined(__i386__) && !defined(_M_IX86) void * QT_INTERLOCKED_FUNCTION( InterlockedCompareExchangePointer )(void * QT_INTERLOCKED_VOLATILE *, void *, void *); void * QT_INTERLOCKED_FUNCTION( InterlockedExchangePointer )(void * QT_INTERLOCKED_VOLATILE *, void *); __int64 QT_INTERLOCKED_FUNCTION( InterlockedExchangeAdd64 )(__int64 QT_INTERLOCKED_VOLATILE *, __int64); -- cgit v0.12 From 8abc68d262c40c1f035a2d77779e76f038261a89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Nilsen?= Date: Tue, 1 Sep 2009 15:22:21 +0200 Subject: Make sure the BSP is updated when a graphics effect changes bounding rect. In the case of applying an effect to a QGraphicsItem, we have to notify the scene's BSP that the item's bounding rect has changed. We do this by calling prepareGeometryChange(). In the case of QWidget, it's sub-optimal that we update its parent, but there's no other way to solve it at the moment. --- src/gui/effects/qgraphicseffect.cpp | 4 ++-- src/gui/effects/qgraphicseffect_p.h | 1 + src/gui/graphicsview/qgraphicsitem_p.h | 3 +++ src/gui/kernel/qwidget_p.h | 10 ++++++++++ 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/gui/effects/qgraphicseffect.cpp b/src/gui/effects/qgraphicseffect.cpp index 2be6a49..6624cfb 100644 --- a/src/gui/effects/qgraphicseffect.cpp +++ b/src/gui/effects/qgraphicseffect.cpp @@ -335,7 +335,7 @@ void QGraphicsEffect::setEnabled(bool enable) d->isEnabled = enable; if (d->source) - d->source->update(); + d->source->d_func()->effectBoundingRectChanged(); emit enabledChanged(enable); } @@ -390,7 +390,7 @@ void QGraphicsEffect::updateBoundingRect() { Q_D(QGraphicsEffect); if (d->source) - d->source->update(); + d->source->d_func()->effectBoundingRectChanged(); } /*! diff --git a/src/gui/effects/qgraphicseffect_p.h b/src/gui/effects/qgraphicseffect_p.h index bfabfc0..24b605f 100644 --- a/src/gui/effects/qgraphicseffect_p.h +++ b/src/gui/effects/qgraphicseffect_p.h @@ -76,6 +76,7 @@ public: virtual void update() = 0; virtual bool isPixmap() const = 0; virtual QPixmap pixmap(Qt::CoordinateSystem system, QPoint *offset = 0) const = 0; + virtual void effectBoundingRectChanged() = 0; friend class QGraphicsScenePrivate; friend class QGraphicsItem; friend class QGraphicsItemPrivate; diff --git a/src/gui/graphicsview/qgraphicsitem_p.h b/src/gui/graphicsview/qgraphicsitem_p.h index 1090620..49361cf 100644 --- a/src/gui/graphicsview/qgraphicsitem_p.h +++ b/src/gui/graphicsview/qgraphicsitem_p.h @@ -572,6 +572,9 @@ public: inline void update() { item->update(); } + inline void effectBoundingRectChanged() + { item->prepareGeometryChange(); } + inline bool isPixmap() const { return (item->type() == QGraphicsPixmapItem::Type); diff --git a/src/gui/kernel/qwidget_p.h b/src/gui/kernel/qwidget_p.h index ff0c453..f69c3a7 100644 --- a/src/gui/kernel/qwidget_p.h +++ b/src/gui/kernel/qwidget_p.h @@ -727,6 +727,16 @@ public: inline bool isPixmap() const { return false; } + inline void effectBoundingRectChanged() + { + // ### This function should take a rect parameter; then we can avoid + // updating too much on the parent widget. + if (QWidget *parent = m_widget->parentWidget()) + parent->update(); + else + m_widget->update(); + } + inline const QStyleOption *styleOption() const { return 0; } -- cgit v0.12 From 6b779a021a9c3d334127a4c460ad7f780a97ddb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Nilsen?= Date: Tue, 1 Sep 2009 15:52:27 +0200 Subject: Fix rounding bug in QGraphicsOpacityEffect. The pixmap was painted at wrong offset. --- src/gui/effects/qgraphicseffect.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/gui/effects/qgraphicseffect.cpp b/src/gui/effects/qgraphicseffect.cpp index 6624cfb..f60e80e 100644 --- a/src/gui/effects/qgraphicseffect.cpp +++ b/src/gui/effects/qgraphicseffect.cpp @@ -1129,19 +1129,20 @@ void QGraphicsOpacityEffect::draw(QPainter *painter, QGraphicsEffectSource *sour const QPixmap pixmap = source->pixmap(Qt::LogicalCoordinates, &offset); painter->drawPixmap(offset, pixmap); } else { - QRectF srcBrect = source->boundingRect(); - QPixmap pixmap(srcBrect.size().toSize()); + QRect srcBrect = source->boundingRect().toAlignedRect(); + offset = srcBrect.topLeft(); + QPixmap pixmap(srcBrect.size()); pixmap.fill(Qt::transparent); QPainter pixmapPainter(&pixmap); pixmapPainter.setRenderHints(painter->renderHints()); - pixmapPainter.translate(-srcBrect.topLeft()); + pixmapPainter.translate(-offset); source->draw(&pixmapPainter); pixmapPainter.setCompositionMode(QPainter::CompositionMode_DestinationIn); pixmapPainter.fillRect(srcBrect, d->opacityMask); pixmapPainter.end(); - painter->drawPixmap(srcBrect.topLeft(), pixmap); + painter->drawPixmap(offset, pixmap); } } else { // Draw pixmap in device coordinates to avoid pixmap scaling; -- cgit v0.12 From 500de752ac6af943ced98cd685ed460457b3166d Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Tue, 1 Sep 2009 16:03:00 +0200 Subject: Coverity: Small fix for QIODevice --- src/corelib/io/qiodevice.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/corelib/io/qiodevice.cpp b/src/corelib/io/qiodevice.cpp index 75f8e54..ac9f532 100644 --- a/src/corelib/io/qiodevice.cpp +++ b/src/corelib/io/qiodevice.cpp @@ -122,7 +122,12 @@ void debugBinaryString(const char *data, qint64 maxlen) */ QIODevicePrivate::QIODevicePrivate() : openMode(QIODevice::NotOpen), buffer(QIODEVICE_BUFFERSIZE), - pos(0), devicePos(0), accessMode(Unset) + pos(0), devicePos(0) + , baseReadLineDataCalled(false) + , accessMode(Unset) +#ifdef QT_NO_QOBJECT + , q_ptr(0) +#endif { } -- cgit v0.12 From 5632ba903c1b31717b4fabdfc2a3c8b710b5cbf1 Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Tue, 1 Sep 2009 16:08:56 +0200 Subject: Socket code: Do not use magic buffer size value I have seen a performance increase of around 30% for big file transfers on Linux when having high bandwidth and higher latency. Reviewed-by: Thiago --- src/network/socket/qnativesocketengine.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/network/socket/qnativesocketengine.cpp b/src/network/socket/qnativesocketengine.cpp index 3e56995..3d9aa61 100644 --- a/src/network/socket/qnativesocketengine.cpp +++ b/src/network/socket/qnativesocketengine.cpp @@ -389,10 +389,19 @@ bool QNativeSocketEngine::initialize(QAbstractSocket::SocketType socketType, QAb qWarning("QNativeSocketEngine::initialize unable to inline out-of-band data"); } - // Set the send and receive buffer sizes to a magic size, found - // most optimal for our platforms. - setReceiveBufferSize(49152); - setSendBufferSize(49152); + // Before Qt 4.6, we always set the send and receive buffer size to 49152 as + // this was found to be an optimal value. However, modern OS + // all have some kind of auto tuning for this and we therefore don't set + // this explictly anymore. + // If it introduces any performance regressions for Qt 4.6.x (x > 0) then + // it will be put back in. + // + // You can use tests/manual/qhttpnetworkconnection to test HTTP download speed + // with this. + // + // pre-4.6: + // setReceiveBufferSize(49152); + // setSendBufferSize(49152); d->socketType = socketType; d->socketProtocol = protocol; -- cgit v0.12 From 9f59fb741183e1235b2a385b0e688e4a7f4b15c9 Mon Sep 17 00:00:00 2001 From: Alexis Menard Date: Tue, 1 Sep 2009 16:25:49 +0200 Subject: Make sub-attaq working without the popup which make it working on Mac. --- demos/sub-attaq/graphicsscene.cpp | 13 +++++--- demos/sub-attaq/graphicsscene.h | 2 ++ demos/sub-attaq/states.cpp | 25 ++++++++++++--- demos/sub-attaq/states.h | 2 ++ demos/sub-attaq/sub-attaq.pro | 18 +++++++---- demos/sub-attaq/textinformationitem.cpp | 54 ++++++++++++++++++++++++++++++++ demos/sub-attaq/textinformationitem.h | 55 +++++++++++++++++++++++++++++++++ 7 files changed, 153 insertions(+), 16 deletions(-) create mode 100644 demos/sub-attaq/textinformationitem.cpp create mode 100644 demos/sub-attaq/textinformationitem.h diff --git a/demos/sub-attaq/graphicsscene.cpp b/demos/sub-attaq/graphicsscene.cpp index b4fd0c9..79de011 100644 --- a/demos/sub-attaq/graphicsscene.cpp +++ b/demos/sub-attaq/graphicsscene.cpp @@ -51,6 +51,7 @@ #include "animationmanager.h" #include "qanimationstate.h" #include "progressitem.h" +#include "textinformationitem.h" //Qt #include @@ -112,6 +113,8 @@ GraphicsScene::GraphicsScene(int x, int y, int width, int height, Mode mode) //The item that display score and level progressItem = new ProgressItem(backgroundItem); + textInformationItem = new TextInformationItem(backgroundItem); + textInformationItem->hide(); //We create the boat boat = new Boat(); addItem(boat); @@ -244,15 +247,15 @@ void GraphicsScene::setupScene(const QList &actions) lettersFadingState->setAnimation(lettersGroupFading); //if new game then we fade out the welcome screen and start playing - lettersMovingState->addTransition(newAction, SIGNAL(triggered()),lettersFadingState); - lettersFadingState->addTransition(lettersFadingState, SIGNAL(animationFinished()),gameState); + lettersMovingState->addTransition(newAction, SIGNAL(triggered()), lettersFadingState); + lettersFadingState->addTransition(lettersFadingState, SIGNAL(animationFinished()), gameState); //New Game is triggered then player start playing - gameState->addTransition(newAction, SIGNAL(triggered()),gameState); + gameState->addTransition(newAction, SIGNAL(triggered()), gameState); //Wanna quit, then connect to CTRL+Q - gameState->addTransition(quitAction, SIGNAL(triggered()),final); - lettersMovingState->addTransition(quitAction, SIGNAL(triggered()),final); + gameState->addTransition(quitAction, SIGNAL(triggered()), final); + lettersMovingState->addTransition(quitAction, SIGNAL(triggered()), final); //Welcome screen is the initial state machine->setInitialState(lettersMovingState); diff --git a/demos/sub-attaq/graphicsscene.h b/demos/sub-attaq/graphicsscene.h index 073ad17..8fa62f7 100644 --- a/demos/sub-attaq/graphicsscene.h +++ b/demos/sub-attaq/graphicsscene.h @@ -54,6 +54,7 @@ class Torpedo; class Bomb; class PixmapItem; class ProgressItem; +class TextInformationItem; QT_BEGIN_NAMESPACE class QAction; QT_END_NAMESPACE @@ -108,6 +109,7 @@ private: Mode mode; PixmapItem *backgroundItem; ProgressItem *progressItem; + TextInformationItem *textInformationItem; QAction * newAction; QAction * quitAction; Boat *boat; diff --git a/demos/sub-attaq/states.cpp b/demos/sub-attaq/states.cpp index 75a2615..5c809cb 100644 --- a/demos/sub-attaq/states.cpp +++ b/demos/sub-attaq/states.cpp @@ -47,6 +47,7 @@ #include "torpedo.h" #include "animationmanager.h" #include "progressitem.h" +#include "textinformationitem.h" //Qt #include @@ -226,8 +227,15 @@ void LostState::onEntry(QEvent *) //We clear the scene scene->clearScene(); - //we have only one view - QMessageBox::information(scene->views().at(0),"You lose",message); + //We inform the player + scene->textInformationItem->setMessage(message); + scene->textInformationItem->show(); +} + +void LostState::onExit(QEvent *) +{ + //we hide the information + scene->textInformationItem->hide(); } /** Win State */ @@ -242,7 +250,7 @@ void WinState::onEntry(QEvent *) QString message; if (scene->levelsData.size() - 1 != game->currentLevel) { - message = QString("You win the level %1. Your score is %2.\nPress Space to continue after closing this dialog.").arg(game->currentLevel+1).arg(game->score); + message = QString("You win the level %1. Your score is %2.\nPress Space to continue.").arg(game->currentLevel+1).arg(game->score); //We increment the level number game->currentLevel++; } else { @@ -253,8 +261,15 @@ void WinState::onEntry(QEvent *) game->score = 0; } - //we have only one view - QMessageBox::information(scene->views().at(0),"You win",message); + //We inform the player + scene->textInformationItem->setMessage(message); + scene->textInformationItem->show(); +} + +void WinState::onExit(QEvent *) +{ + //we hide the information + scene->textInformationItem->hide(); } /** UpdateScore State */ diff --git a/demos/sub-attaq/states.h b/demos/sub-attaq/states.h index 7635c0c..3176571 100644 --- a/demos/sub-attaq/states.h +++ b/demos/sub-attaq/states.h @@ -113,6 +113,7 @@ public: protected: void onEntry(QEvent *); + void onExit(QEvent *); private : GraphicsScene *scene; PlayState *game; @@ -125,6 +126,7 @@ public: protected: void onEntry(QEvent *); + void onExit(QEvent *); private : GraphicsScene *scene; PlayState *game; diff --git a/demos/sub-attaq/sub-attaq.pro b/demos/sub-attaq/sub-attaq.pro index ad1327d..ba2b54b 100644 --- a/demos/sub-attaq/sub-attaq.pro +++ b/demos/sub-attaq/sub-attaq.pro @@ -1,5 +1,4 @@ contains(QT_CONFIG, opengl):QT += opengl - HEADERS += boat.h \ bomb.h \ mainwindow.h \ @@ -13,7 +12,8 @@ HEADERS += boat.h \ submarine_p.h \ custompropertyanimation.h \ qanimationstate.h \ - progressitem.h + progressitem.h \ + textinformationitem.h SOURCES += boat.cpp \ bomb.cpp \ main.cpp \ @@ -26,12 +26,18 @@ SOURCES += boat.cpp \ states.cpp \ custompropertyanimation.cpp \ qanimationstate.cpp \ - progressitem.cpp + progressitem.cpp \ + textinformationitem.cpp RESOURCES += subattaq.qrc # install target.path = $$[QT_INSTALL_DEMOS]/animation/sub-attaq -sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS sub-attaq.pro pics +sources.files = $$SOURCES \ + $$HEADERS \ + $$RESOURCES \ + $$FORMS \ + sub-attaq.pro \ + pics sources.path = $$[QT_INSTALL_DEMOS]/animation/sub-attaq -INSTALLS += target sources - +INSTALLS += target \ + sources diff --git a/demos/sub-attaq/textinformationitem.cpp b/demos/sub-attaq/textinformationitem.cpp new file mode 100644 index 0000000..759aa56 --- /dev/null +++ b/demos/sub-attaq/textinformationitem.cpp @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.1, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "textinformationitem.h" +#include "pixmapitem.h" + +TextInformationItem::TextInformationItem (QGraphicsItem * parent) + : QGraphicsTextItem(parent) +{ + setFont(QFont("Comic Sans MS", 25)); +} +#include +void TextInformationItem::setMessage(const QString& text) +{ + setHtml(text); + setPos(parentItem()->boundingRect().center().x() - boundingRect().size().width()/2 , parentItem()->boundingRect().center().y()); +} diff --git a/demos/sub-attaq/textinformationitem.h b/demos/sub-attaq/textinformationitem.h new file mode 100644 index 0000000..aa7f0be --- /dev/null +++ b/demos/sub-attaq/textinformationitem.h @@ -0,0 +1,55 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.1, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef TEXTINFORMATIONITEM_H +#define TEXTINFORMATIONITEM_H + +//Qt +#include + +class TextInformationItem : public QGraphicsTextItem +{ +public: + TextInformationItem(QGraphicsItem * parent = 0); + void setMessage(const QString& text); +}; + +#endif // TEXTINFORMATIONITEM_H -- cgit v0.12 From 3418320aa5cad4a982f6278be1fbe8ce66c1558f Mon Sep 17 00:00:00 2001 From: Leonardo Sobral Cunha Date: Tue, 1 Sep 2009 16:27:57 +0200 Subject: Fixes examples/animation/states, supposedly hidden element was appearing Reviewed-by: trustme --- examples/animation/states/main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/animation/states/main.cpp b/examples/animation/states/main.cpp index a78548c..9644049 100644 --- a/examples/animation/states/main.cpp +++ b/examples/animation/states/main.cpp @@ -179,8 +179,8 @@ int main(int argc, char *argv[]) // State 3 state3->assignProperty(button, "text", "Switch to state 1"); - state3->assignProperty(p1, "geometry", QRectF(5, 5, 64, 64)); - state3->assignProperty(p2, "geometry", QRectF(5, 5 + 64 + 5, 64, 64)); + state3->assignProperty(p1, "geometry", QRectF(0, 5, 64, 64)); + state3->assignProperty(p2, "geometry", QRectF(0, 5 + 64 + 5, 64, 64)); state3->assignProperty(p3, "geometry", QRectF(5, 5 + (64 + 5) + 64, 64, 64)); state3->assignProperty(p4, "geometry", QRectF(5 + 64 + 5, 5, 64, 64)); state3->assignProperty(p5, "geometry", QRectF(5 + 64 + 5, 5 + 64 + 5, 64, 64)); -- cgit v0.12 From 3dfde91fcbeaf304edd8d0d09e0732597055cd53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Nilsen?= Date: Tue, 1 Sep 2009 16:31:33 +0200 Subject: Cleanup examples/effects/lighting. There's no need to re-implement QGraphicsDropShadowEffect anymore. --- examples/effects/lighting/lighting.cpp | 22 +++++++-- examples/effects/lighting/lighting.h | 2 - examples/effects/lighting/lighting.pro | 4 +- examples/effects/lighting/shadoweffect.cpp | 76 ------------------------------ examples/effects/lighting/shadoweffect.h | 66 -------------------------- 5 files changed, 21 insertions(+), 149 deletions(-) delete mode 100644 examples/effects/lighting/shadoweffect.cpp delete mode 100644 examples/effects/lighting/shadoweffect.h diff --git a/examples/effects/lighting/lighting.cpp b/examples/effects/lighting/lighting.cpp index 2294b36..e309e2e 100644 --- a/examples/effects/lighting/lighting.cpp +++ b/examples/effects/lighting/lighting.cpp @@ -43,8 +43,6 @@ #include -#include "shadoweffect.h" - #ifndef M_PI #define M_PI 3.14159265358979323846 #endif @@ -98,7 +96,7 @@ void Lighting::setupScene() item->setPen(QPen(Qt::black)); item->setBrush(QBrush(Qt::white)); - item->setGraphicsEffect(new ShadowEffect(item, m_lightSource)); + item->setGraphicsEffect(new QGraphicsDropShadowEffect); item->setZValue(1); item->setPos(i * 80, j * 80); m_scene.addItem(item); @@ -114,6 +112,24 @@ void Lighting::animate() qreal xs = 200 * sin(angle) - 40 + 25; qreal ys = 200 * cos(angle) - 40 + 25; m_lightSource->setPos(xs, ys); + + for (int i = 0; i < m_items.size(); ++i) { + QGraphicsItem *item = m_items.at(i); + Q_ASSERT(item); + QGraphicsDropShadowEffect *effect = static_cast(item->graphicsEffect()); + Q_ASSERT(effect); + + QPointF delta(item->x() - xs, item->y() - ys); + effect->setOffset(delta.toPoint() / 30); + + qreal dx = delta.x(); + qreal dy = delta.y(); + qreal dd = sqrt(dx * dx + dy * dy); + QColor color = effect->color(); + color.setAlphaF(qBound(0.4, 1 - dd / 200.0, 0.7)); + effect->setColor(color); + } + m_scene.update(); } diff --git a/examples/effects/lighting/lighting.h b/examples/effects/lighting/lighting.h index 3e12fdf..eef5cae 100644 --- a/examples/effects/lighting/lighting.h +++ b/examples/effects/lighting/lighting.h @@ -45,8 +45,6 @@ #include #include -#include "shadoweffect.h" - class Lighting: public QGraphicsView { Q_OBJECT diff --git a/examples/effects/lighting/lighting.pro b/examples/effects/lighting/lighting.pro index ea9d5f6..432d1b5 100644 --- a/examples/effects/lighting/lighting.pro +++ b/examples/effects/lighting/lighting.pro @@ -1,5 +1,5 @@ -SOURCES += main.cpp lighting.cpp shadoweffect.cpp -HEADERS += lighting.h shadoweffect.h +SOURCES += main.cpp lighting.cpp +HEADERS += lighting.h # install target.path = $$[QT_INSTALL_EXAMPLES]/effects/lighting diff --git a/examples/effects/lighting/shadoweffect.cpp b/examples/effects/lighting/shadoweffect.cpp deleted file mode 100644 index 16e52fb..0000000 --- a/examples/effects/lighting/shadoweffect.cpp +++ /dev/null @@ -1,76 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.1, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "shadoweffect.h" - -#include - -ShadowEffect::ShadowEffect(QGraphicsItem *item, QGraphicsItem *source) - : QGraphicsDropShadowEffect() - , item(item), m_lightSource(source) -{ - setBlurRadius(8); - m_color = color(); -} - -void ShadowEffect::adjustForItem() -{ - QPointF delta = item->pos() - m_lightSource->pos(); - setOffset(delta.toPoint() / 30); - - qreal dx = delta.x(); - qreal dy = delta.y(); - qreal dd = sqrt(dx * dx + dy * dy); - m_color.setAlphaF(qBound(0.4, 1 - dd / 200.0, 0.7)); - setColor(m_color); -} - -QRectF ShadowEffect::boundingRectFor(const QRectF &rect) const -{ - const_cast(this)->adjustForItem(); - return QGraphicsDropShadowEffect::boundingRectFor(rect); -} - -void ShadowEffect::draw(QPainter *painter, QGraphicsEffectSource *source) -{ - adjustForItem(); - QGraphicsDropShadowEffect::draw(painter, source); -} diff --git a/examples/effects/lighting/shadoweffect.h b/examples/effects/lighting/shadoweffect.h deleted file mode 100644 index 64314e5..0000000 --- a/examples/effects/lighting/shadoweffect.h +++ /dev/null @@ -1,66 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.1, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef SHADOWEFFECT_H -#define SHADOWEFFECT_H - -#include -#include - -class ShadowEffect: public QGraphicsDropShadowEffect -{ -public: - ShadowEffect(QGraphicsItem *item, QGraphicsItem *source); - - QRectF boundingRectFor(const QRectF &rect) const; - - void draw(QPainter *painter, QGraphicsEffectSource *source); - -private: - void adjustForItem(); - -private: - QColor m_color; - QGraphicsItem *item; - QGraphicsItem *m_lightSource; -}; - -#endif // SHADOWEFFECT_H -- cgit v0.12 From efc616f2a1a83bd4ca50aea9d40a0df005ada063 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Tue, 1 Sep 2009 16:39:30 +0200 Subject: QTreeView: exapnding nodes just after replacing the model wouldn't work The problem is that deleting the previous model would triggera delayed reset. This reset could happen after the model has changed and nodes are expanded. We can now cancel a reset when reset is called from another place (like when we set a new model). Note: autotest included Task-number: 245654 Reviewed-by: ogoffart --- src/gui/itemviews/qabstractitemview.cpp | 8 +++++--- src/gui/itemviews/qabstractitemview_p.h | 10 ++++++++++ tests/auto/qtreeview/tst_qtreeview.cpp | 30 ++++++++++++++++++++++++++++++ 3 files changed, 45 insertions(+), 3 deletions(-) diff --git a/src/gui/itemviews/qabstractitemview.cpp b/src/gui/itemviews/qabstractitemview.cpp index 07c5454..ea98cb2 100644 --- a/src/gui/itemviews/qabstractitemview.cpp +++ b/src/gui/itemviews/qabstractitemview.cpp @@ -956,6 +956,7 @@ QModelIndex QAbstractItemView::currentIndex() const void QAbstractItemView::reset() { Q_D(QAbstractItemView); + d->delayedReset.stop(); //make sure we stop the timer QList::const_iterator it = d->editors.constBegin(); for (; it != d->editors.constEnd(); ++it) d->releaseEditor(it->editor); @@ -2208,7 +2209,9 @@ void QAbstractItemView::timerEvent(QTimerEvent *event) Q_D(QAbstractItemView); if (event->timerId() == d->fetchMoreTimer.timerId()) d->fetchMore(); - if (event->timerId() == d->autoScrollTimer.timerId()) + else if (event->timerId() == d->delayedReset.timerId()) + reset(); + else if (event->timerId() == d->autoScrollTimer.timerId()) doAutoScroll(); else if (event->timerId() == d->updateTimer.timerId()) d->updateDirtyRegion(); @@ -3132,9 +3135,8 @@ void QAbstractItemViewPrivate::_q_columnsInserted(const QModelIndex &, int, int) */ void QAbstractItemViewPrivate::_q_modelDestroyed() { - Q_Q(QAbstractItemView); model = QAbstractItemModelPrivate::staticEmptyModel(); - QMetaObject::invokeMethod(q, "reset", Qt::QueuedConnection); + doDelayedReset(); } /*! diff --git a/src/gui/itemviews/qabstractitemview_p.h b/src/gui/itemviews/qabstractitemview_p.h index 4517941..434d644 100644 --- a/src/gui/itemviews/qabstractitemview_p.h +++ b/src/gui/itemviews/qabstractitemview_p.h @@ -328,6 +328,15 @@ public: QStyleOptionViewItemV4 viewOptionsV4() const; + void doDelayedReset() + { + //we delay the reset of the timer because some views (QTableView) + //with headers can't handle the fact that the model has been destroyed + //all _q_modelDestroyed slots must have been called + if (!delayedReset.isActive()) + delayedReset.start(0, q_func()); + } + QAbstractItemModel *model; QPointer itemDelegate; QMap > rowDelegates; @@ -389,6 +398,7 @@ public: QBasicTimer updateTimer; QBasicTimer delayedEditing; QBasicTimer delayedAutoScroll; //used when an item is clicked + QBasicTimer delayedReset; QAbstractItemView::ScrollMode verticalScrollMode; QAbstractItemView::ScrollMode horizontalScrollMode; diff --git a/tests/auto/qtreeview/tst_qtreeview.cpp b/tests/auto/qtreeview/tst_qtreeview.cpp index ef43c3a..6709807 100644 --- a/tests/auto/qtreeview/tst_qtreeview.cpp +++ b/tests/auto/qtreeview/tst_qtreeview.cpp @@ -233,6 +233,7 @@ private slots: void task239271_addRowsWithFirstColumnHidden(); void task254234_proxySort(); void task248022_changeSelection(); + void task245654_changeModelAndExpandAll(); }; class QtTestModel: public QAbstractItemModel @@ -3463,6 +3464,35 @@ void tst_QTreeView::task248022_changeSelection() QCOMPARE(view.selectionModel()->selectedIndexes().count(), list.count()); } +void tst_QTreeView::task245654_changeModelAndExpandAll() +{ + QTreeView view; + QStandardItemModel *model = new QStandardItemModel; + QStandardItem *top = new QStandardItem("top"); + QStandardItem *sub = new QStandardItem("sub"); + top->appendRow(sub); + model->appendRow(top); + view.setModel(model); + view.expandAll(); + QApplication::processEvents(); + QVERIFY(view.isExpanded(top->index())); + + //now let's try to delete the model + //then repopulate and expand again + delete model; + model = new QStandardItemModel; + top = new QStandardItem("top"); + sub = new QStandardItem("sub"); + top->appendRow(sub); + model->appendRow(top); + view.setModel(model); + view.expandAll(); + QApplication::processEvents(); + QVERIFY(view.isExpanded(top->index())); + +} + + QTEST_MAIN(tst_QTreeView) #include "tst_qtreeview.moc" -- cgit v0.12 From 31e4c350981e10076ce4f2f1ecc7076983b9cefa Mon Sep 17 00:00:00 2001 From: Jedrzej Nowacki Date: Wed, 26 Aug 2009 15:51:15 +0200 Subject: Fix column number in QScriptEngineAgent Fix column number in QScriptEngineAgent with JIT enabled and in the same time with QT_BUILD_SCRIPT_LIB disabled Reviewed-by: Kent Hansen --- src/3rdparty/webkit/JavaScriptCore/jit/JITStubs.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/3rdparty/webkit/JavaScriptCore/jit/JITStubs.cpp b/src/3rdparty/webkit/JavaScriptCore/jit/JITStubs.cpp index 2563848..e2542a5 100644 --- a/src/3rdparty/webkit/JavaScriptCore/jit/JITStubs.cpp +++ b/src/3rdparty/webkit/JavaScriptCore/jit/JITStubs.cpp @@ -2713,11 +2713,7 @@ DEFINE_STUB_FUNCTION(void, op_debug) int debugHookID = stackFrame.args[0].int32(); int firstLine = stackFrame.args[1].int32(); int lastLine = stackFrame.args[2].int32(); -#ifdef QT_BUILD_SCRIPT_LIB int column = stackFrame.args[3].int32(); -#else - int column = -1; -#endif stackFrame.globalData->interpreter->debug(callFrame, static_cast(debugHookID), firstLine, lastLine, column); } -- cgit v0.12 From 2a521d8d26577bfe0487a48c0d723e14e67ee0b5 Mon Sep 17 00:00:00 2001 From: Jedrzej Nowacki Date: Tue, 1 Sep 2009 16:24:24 +0200 Subject: Create exceptionCatch events Call to JSC::Debugger::exceptionCatch when exception is catched were added for JIT enabled. Few XFAIL were moved. Reviewed-by: Kent Hansen --- src/3rdparty/webkit/JavaScriptCore/jit/JITOpcodes.cpp | 4 ++++ src/3rdparty/webkit/JavaScriptCore/jit/JITStubs.cpp | 11 +++++++++++ src/3rdparty/webkit/JavaScriptCore/jit/JITStubs.h | 3 +++ tests/auto/qscriptengineagent/tst_qscriptengineagent.cpp | 10 ++++------ 4 files changed, 22 insertions(+), 6 deletions(-) diff --git a/src/3rdparty/webkit/JavaScriptCore/jit/JITOpcodes.cpp b/src/3rdparty/webkit/JavaScriptCore/jit/JITOpcodes.cpp index 8371229..4a33e67 100644 --- a/src/3rdparty/webkit/JavaScriptCore/jit/JITOpcodes.cpp +++ b/src/3rdparty/webkit/JavaScriptCore/jit/JITOpcodes.cpp @@ -684,6 +684,10 @@ void JIT::emit_op_catch(Instruction* currentInstruction) killLastResultRegister(); // FIXME: Implicitly treat op_catch as a labeled statement, and remove this line of code. peek(callFrameRegister, OBJECT_OFFSETOF(struct JITStackFrame, callFrame) / sizeof (void*)); emitPutVirtualRegister(currentInstruction[1].u.operand); +#ifdef QT_BUILD_SCRIPT_LIB + JITStubCall stubCall(this, JITStubs::cti_op_debug_catch); + stubCall.call(); +#endif } void JIT::emit_op_jmp_scopes(Instruction* currentInstruction) diff --git a/src/3rdparty/webkit/JavaScriptCore/jit/JITStubs.cpp b/src/3rdparty/webkit/JavaScriptCore/jit/JITStubs.cpp index e2542a5..f0d3b84 100644 --- a/src/3rdparty/webkit/JavaScriptCore/jit/JITStubs.cpp +++ b/src/3rdparty/webkit/JavaScriptCore/jit/JITStubs.cpp @@ -2718,6 +2718,17 @@ DEFINE_STUB_FUNCTION(void, op_debug) stackFrame.globalData->interpreter->debug(callFrame, static_cast(debugHookID), firstLine, lastLine, column); } +#ifdef QT_BUILD_SCRIPT_LIB +DEFINE_STUB_FUNCTION(void, op_debug_catch) +{ + STUB_INIT_STACK_FRAME(stackFrame); + CallFrame* callFrame = stackFrame.callFrame; + if (JSC::Debugger* debugger = callFrame->lexicalGlobalObject()->debugger() ) { + debugger->exceptionCatch(DebuggerCallFrame(callFrame), callFrame->codeBlock()->ownerNode()->sourceID()); + } +} +#endif + DEFINE_STUB_FUNCTION(EncodedJSValue, vm_throw) { STUB_INIT_STACK_FRAME(stackFrame); diff --git a/src/3rdparty/webkit/JavaScriptCore/jit/JITStubs.h b/src/3rdparty/webkit/JavaScriptCore/jit/JITStubs.h index 0493189..60bf64a 100644 --- a/src/3rdparty/webkit/JavaScriptCore/jit/JITStubs.h +++ b/src/3rdparty/webkit/JavaScriptCore/jit/JITStubs.h @@ -221,6 +221,9 @@ namespace JITStubs { extern "C" { void JIT_STUB cti_op_create_arguments(STUB_ARGS_DECLARATION); void JIT_STUB cti_op_create_arguments_no_params(STUB_ARGS_DECLARATION); void JIT_STUB cti_op_debug(STUB_ARGS_DECLARATION); +#ifdef QT_BUILD_SCRIPT_LIB + void JIT_STUB cti_op_debug_catch(STUB_ARGS_DECLARATION); +#endif void JIT_STUB cti_op_end(STUB_ARGS_DECLARATION); void JIT_STUB cti_op_jmp_scopes(STUB_ARGS_DECLARATION); void JIT_STUB cti_op_pop_scope(STUB_ARGS_DECLARATION); diff --git a/tests/auto/qscriptengineagent/tst_qscriptengineagent.cpp b/tests/auto/qscriptengineagent/tst_qscriptengineagent.cpp index 68f0620..1f9476f 100644 --- a/tests/auto/qscriptengineagent/tst_qscriptengineagent.cpp +++ b/tests/auto/qscriptengineagent/tst_qscriptengineagent.cpp @@ -1593,8 +1593,6 @@ void tst_QScriptEngineAgent::exceptionThrowAndCatch() { spy->clear(); eng.evaluate("try { throw new Error('ciao'); } catch (e) { }"); - if (qt_script_isJITEnabled()) - QEXPECT_FAIL("", "Some events are missing when JIT is enabled", Abort); QCOMPARE(spy->count(), 2); QCOMPARE(spy->at(0).type, ScriptEngineEvent::ExceptionThrow); @@ -1606,6 +1604,8 @@ void tst_QScriptEngineAgent::exceptionThrowAndCatch() QCOMPARE(spy->at(1).type, ScriptEngineEvent::ExceptionCatch); QCOMPARE(spy->at(1).scriptId, spy->at(0).scriptId); + if (qt_script_isJITEnabled()) + QEXPECT_FAIL("", "Exception value is not passed in exceptionCatch event when JIT is enabled", Continue); QVERIFY(spy->at(1).value.strictlyEquals(spy->at(0).value)); } } @@ -1728,8 +1728,6 @@ void tst_QScriptEngineAgent::eventOrder_throwAndCatch() { spy->clear(); eng.evaluate("try { throw new Error('ciao') } catch (e) { void(e); }"); - if (qt_script_isJITEnabled()) - QEXPECT_FAIL("", "One event is missing when JIT is enabled", Abort); QCOMPARE(spy->count(), 12); // load QCOMPARE(spy->at(0).type, ScriptEngineEvent::ScriptLoad); @@ -1751,6 +1749,8 @@ void tst_QScriptEngineAgent::eventOrder_throwAndCatch() QVERIFY(spy->at(7).hasExceptionHandler); // catch QCOMPARE(spy->at(8).type, ScriptEngineEvent::ExceptionCatch); + if (qt_script_isJITEnabled()) + QEXPECT_FAIL("", "Exception value is not passed in exceptionCatch event when JIT is enabled", Continue); QVERIFY(spy->at(8).value.isError()); // void(e) QCOMPARE(spy->at(9).type, ScriptEngineEvent::PositionChange); @@ -1914,8 +1914,6 @@ void tst_QScriptEngineAgent::eventOrder_throwCatchFinally() { spy->clear(); eng.evaluate("try { throw 1; } catch(e) { i = e; } finally { i = 2; }"); - if (qt_script_isJITEnabled()) - QEXPECT_FAIL("", "One event is missing when JIT is enabled", Abort); QCOMPARE(spy->count(), 9); // load -- cgit v0.12 From 8e2213ea0bb3692783c03fe4da2df659c1859136 Mon Sep 17 00:00:00 2001 From: Tom Cooksey Date: Tue, 1 Sep 2009 09:43:09 +0200 Subject: An an autotest to check QPainter rendering to an FBO works The test also checks that when we ask for CombinedDepthStencil, that's what we get. Reviewed-by: Samuel --- tests/auto/qgl/tst_qgl.cpp | 63 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/tests/auto/qgl/tst_qgl.cpp b/tests/auto/qgl/tst_qgl.cpp index 073afc8..1629542 100644 --- a/tests/auto/qgl/tst_qgl.cpp +++ b/tests/auto/qgl/tst_qgl.cpp @@ -46,6 +46,7 @@ #include #include #include +#include #include #include @@ -71,6 +72,7 @@ private slots: void partialGLWidgetUpdates_data(); void partialGLWidgetUpdates(); void glWidgetRendering(); + void glFBORendering(); void glPBufferRendering(); void glWidgetReparent(); void colormap(); @@ -706,6 +708,67 @@ void tst_QGL::glWidgetRendering() QCOMPARE(fb, reference); } +// NOTE: This tests that CombinedDepthStencil attachment works by assuming the +// GL2 engine is being used and is implemented the same way as it was when +// this autotest was written. If this is not the case, there may be some +// false-positives: I.e. The test passes when either the depth or stencil +// buffer is actually missing. But that's probably ok anyway. +void tst_QGL::glFBORendering() +{ + if (!QGLFramebufferObject::hasOpenGLFramebufferObjects()) + QSKIP("QGLFramebufferObject not supported on this platform", SkipSingle); + + QGLWidget glw; + glw.makeCurrent(); + + // No multisample with combined depth/stencil attachment: + QGLFramebufferObjectFormat fboFormat(0, QGLFramebufferObject::CombinedDepthStencil); + + // Don't complicate things by using NPOT: + QGLFramebufferObject *fbo = new QGLFramebufferObject(256, 128, fboFormat); + + QPainter fboPainter; + bool painterBegun = fboPainter.begin(fbo); + QVERIFY(painterBegun); + + QPainterPath intersectingPath; + intersectingPath.moveTo(0, 0); + intersectingPath.lineTo(100, 0); + intersectingPath.lineTo(0, 100); + intersectingPath.lineTo(100, 100); + intersectingPath.closeSubpath(); + + QPainterPath trianglePath; + trianglePath.moveTo(50, 0); + trianglePath.lineTo(100, 100); + trianglePath.lineTo(0, 100); + trianglePath.closeSubpath(); + + fboPainter.fillRect(0, 0, fbo->width(), fbo->height(), Qt::red); // Background + fboPainter.translate(14, 14); + fboPainter.fillPath(intersectingPath, Qt::blue); // Test stencil buffer works + fboPainter.translate(128, 0); + fboPainter.setClipPath(trianglePath); // Test depth buffer works + fboPainter.setTransform(QTransform()); // reset xform + fboPainter.fillRect(0, 0, fbo->width(), fbo->height(), Qt::green); + fboPainter.end(); + + QImage fb = fbo->toImage().convertToFormat(QImage::Format_RGB32); + delete fbo; + + // As we're doing more than trivial painting, we can't just compare to + // an image rendered with raster. Instead, we sample at well-defined + // test-points: + QCOMPARE(fb.pixel(39, 64), QColor(Qt::red).rgb()); + QCOMPARE(fb.pixel(89, 64), QColor(Qt::red).rgb()); + QCOMPARE(fb.pixel(64, 39), QColor(Qt::blue).rgb()); + QCOMPARE(fb.pixel(64, 89), QColor(Qt::blue).rgb()); + + QCOMPARE(fb.pixel(167, 39), QColor(Qt::red).rgb()); + QCOMPARE(fb.pixel(217, 39), QColor(Qt::red).rgb()); + QCOMPARE(fb.pixel(192, 64), QColor(Qt::green).rgb()); +} + void tst_QGL::glWidgetReparent() { // Try it as a top-level first: -- cgit v0.12 From 4d403875d9d88d2acb0433511eb3f44e0dee4377 Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Tue, 1 Sep 2009 17:05:56 +0200 Subject: QtNetwork: More Coverity fixes --- src/network/access/qnetworkaccesscachebackend.cpp | 1 + src/network/socket/qhttpsocketengine.cpp | 1 + src/network/ssl/qsslsocket.cpp | 8 +++++++- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/network/access/qnetworkaccesscachebackend.cpp b/src/network/access/qnetworkaccesscachebackend.cpp index df66c9d..2be10db 100644 --- a/src/network/access/qnetworkaccesscachebackend.cpp +++ b/src/network/access/qnetworkaccesscachebackend.cpp @@ -52,6 +52,7 @@ QT_BEGIN_NAMESPACE QNetworkAccessCacheBackend::QNetworkAccessCacheBackend() : QNetworkAccessBackend() + , device(0) { } diff --git a/src/network/socket/qhttpsocketengine.cpp b/src/network/socket/qhttpsocketengine.cpp index bb0915a..9ef92e1 100644 --- a/src/network/socket/qhttpsocketengine.cpp +++ b/src/network/socket/qhttpsocketengine.cpp @@ -752,6 +752,7 @@ QHttpSocketEnginePrivate::QHttpSocketEnginePrivate() , readNotificationPending(false) , writeNotificationPending(false) , connectionNotificationPending(false) + , pendingResponseData(0) { socket = 0; state = QHttpSocketEngine::None; diff --git a/src/network/ssl/qsslsocket.cpp b/src/network/ssl/qsslsocket.cpp index 6858d40..0e0c347 100644 --- a/src/network/ssl/qsslsocket.cpp +++ b/src/network/ssl/qsslsocket.cpp @@ -1745,7 +1745,13 @@ qint64 QSslSocket::writeData(const char *data, qint64 len) \internal */ QSslSocketPrivate::QSslSocketPrivate() - : initialized(false), readyReadEmittedPointer(0), plainSocket(0) + : initialized(false) + , mode(QSslSocket::UnencryptedMode) + , autoStartHandshake(false) + , connectionEncrypted(false) + , ignoreAllSslErrors(false) + , readyReadEmittedPointer(0) + , plainSocket(0) { QSslConfigurationPrivate::deepCopyDefaultConfiguration(&configuration); } -- cgit v0.12 From f88f879954c31e45c2edb1f5a8050673a471c78e Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Tue, 1 Sep 2009 14:11:48 +0200 Subject: Define QT_NO_EXCEPTIONS if we detect that we are building without exceptions on gcc This is necessary to compile applications that are compiled without exception support (many KDE applications) Reviewed-by: Thiago --- src/corelib/global/qglobal.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index c34fc31..765665c 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -1364,6 +1364,9 @@ inline void qt_noop() {} #ifdef QT_BOOTSTRAPPED # define QT_NO_EXCEPTIONS #endif +#if defined(Q_CC_GNU) && !defined (__EXCEPTIONS) +# define QT_NO_EXCEPTIONS +#endif #ifdef QT_NO_EXCEPTIONS # define QT_TRY if (true) -- cgit v0.12 From cd027ea513ce57939964ee23b522eb1a7c4f9a6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Tue, 1 Sep 2009 17:02:16 +0200 Subject: Unambiguated QGLFramebufferObject constructor on Mac OS X. Reviewed-by: Trond --- src/opengl/qglframebufferobject.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/opengl/qglframebufferobject.cpp b/src/opengl/qglframebufferobject.cpp index 8fd113a..427aab3 100644 --- a/src/opengl/qglframebufferobject.cpp +++ b/src/opengl/qglframebufferobject.cpp @@ -877,7 +877,7 @@ QImage QGLFramebufferObject::toImage() const // qt_gl_read_framebuffer doesn't work on a multisample FBO if (format().samples() != 0) { - QGLFramebufferObject temp(size()); + QGLFramebufferObject temp(size(), QGLFramebufferObjectFormat()); QRect rect(QPoint(0, 0), size()); blitFramebuffer(&temp, rect, const_cast(this), rect); -- cgit v0.12 From 4a7912195beca671c562f5f1f9c60c2fc2585166 Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Tue, 1 Sep 2009 17:26:00 +0200 Subject: Tiny doc fix spotted by panter_dsd. Reviewed-by: trustme --- doc/src/snippets/code/src_corelib_io_qsettings.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/src/snippets/code/src_corelib_io_qsettings.cpp b/doc/src/snippets/code/src_corelib_io_qsettings.cpp index 12a204b..c380d19 100644 --- a/doc/src/snippets/code/src_corelib_io_qsettings.cpp +++ b/doc/src/snippets/code/src_corelib_io_qsettings.cpp @@ -309,7 +309,7 @@ int main(int argc, char *argv[]) const QSettings::Format XmlFormat = QSettings::registerFormat("xml", readXmlFile, writeXmlFile); - QSettings settings(XmlFormat, QSettings::UserSettings, "MySoft", + QSettings settings(XmlFormat, QSettings::UserScope, "MySoft", "Star Runner"); ... -- cgit v0.12 From 950ab0520f0be607aaa1ec7e46dc33ebfde84f03 Mon Sep 17 00:00:00 2001 From: Geir Vattekar Date: Tue, 1 Sep 2009 15:41:18 +0200 Subject: Doc: Fixed outdated docs in QStyle::styleHint(). Task-number: 256745 Reviewed-by: Trust Me --- src/gui/styles/qstyle.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/gui/styles/qstyle.cpp b/src/gui/styles/qstyle.cpp index d61d291..0500bff 100644 --- a/src/gui/styles/qstyle.cpp +++ b/src/gui/styles/qstyle.cpp @@ -1897,11 +1897,9 @@ void QStyle::drawItemPixmap(QPainter *painter, const QRect &rect, int alignment, Returns an integer representing the specified style \a hint for the given \a widget described by the provided style \a option. - Note that currently, the \a returnData and \a widget parameters - are not used; they are provided for future enhancement. In - addition, the \a option parameter is used only in case of the - SH_ComboBox_Popup, SH_ComboBox_LayoutDirection, and - SH_GroupBox_TextLabelColor style hints. + \c returnData is used when the querying widget needs more detailed data than + the integer that styleHint() returns. See the QStyleHintReturn class + description for details. */ /*! -- cgit v0.12 From e86ddf19ca20cb2128465b42fae4a9129abe25b3 Mon Sep 17 00:00:00 2001 From: Geir Vattekar Date: Tue, 1 Sep 2009 17:27:00 +0200 Subject: Doc: Fixed typos in QGraphicsItem and Diagram Scene Example Task-number: 257292 Reviewed-by: Trust Me --- doc/src/examples/diagramscene.qdoc | 7 ++++--- src/gui/graphicsview/qgraphicsitem.cpp | 27 +++++++++++++-------------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/doc/src/examples/diagramscene.qdoc b/doc/src/examples/diagramscene.qdoc index 9f5d785..2011aa9 100644 --- a/doc/src/examples/diagramscene.qdoc +++ b/doc/src/examples/diagramscene.qdoc @@ -704,7 +704,7 @@ We use \c itemChange() and \c focusOutEvent() to notify the \c DiagramScene when the text item loses focus and gets selected. - Vi reimplement the functions that handle mouse events to make it + We reimplement the functions that handle mouse events to make it possible to alter the mouse behavior of QGraphicsTextItem. \section1 DiagramTextItem Implementation @@ -729,7 +729,8 @@ \snippet examples/graphicsview/diagramscene/diagramtextitem.cpp 2 \c DiagramScene uses the signal emitted when the text item looses - remove the item if it is empty, i.e., it contains no text. + focus to remove the item if it is empty, i.e., it contains no + text. This is the implementation of \c mouseDoubleClickEvent(): @@ -838,7 +839,7 @@ \snippet examples/graphicsview/diagramscene/arrow.cpp 7 - If the line is selected we draw to dotted lines that are + If the line is selected, we draw two dotted lines that are parallel with the line of the arrow. We do not use the default implementation, which uses \l{QGraphicsItem::}{boundingRect()} because the QRect bounding rectangle is considerably larger than diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index 822c208..4c7765d 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -198,20 +198,19 @@ \o hoverEnterEvent(), hoverMoveEvent(), and hoverLeaveEvent() handles hover enter, move and leave events \o inputMethodEvent() handles input events, for accessibility support - \o keyPressEvent() and keyReleaseEvent handle key press and release events + \o keyPressEvent() and keyReleaseEvent() handle key press and release events \o mousePressEvent(), mouseMoveEvent(), mouseReleaseEvent(), and mouseDoubleClickEvent() handles mouse press, move, release, click and doubleclick events \endlist - You can filter events for any other item by installing event - filters. This functionaly is separate from from Qt's regular - event filters (see QObject::installEventFilter()), which only - work on subclasses of QObject. After installing your item as an - event filter for another item by calling - installSceneEventFilter(), the filtered events will be received - by the virtual function sceneEventFilter(). You can remove item - event filters by calling removeSceneEventFilter(). + You can filter events for any other item by installing event filters. This + functionality is separate from Qt's regular event filters (see + QObject::installEventFilter()), which only work on subclasses of QObject. After + installing your item as an event filter for another item by calling + installSceneEventFilter(), the filtered events will be received by the virtual + function sceneEventFilter(). You can remove item event filters by calling + removeSceneEventFilter(). \section1 Custom Data @@ -414,11 +413,11 @@ (same as transform()), and QGraphicsItem ignores the return value for this notification (i.e., a read-only notification). - \value ItemSelectedChange The item's selected state changes. If the item - is presently selected, it will become unselected, and vice verca. The - value argument is the new selected state (i.e., true or false). Do not - call setSelected() in itemChange() as this notification is delivered(); - instead, you can return the new selected state from itemChange(). + \value ItemSelectedChange The item's selected state changes. If the item is + presently selected, it will become unselected, and vice verca. The value + argument is the new selected state (i.e., true or false). Do not call + setSelected() in itemChange() as this notification is delivered; instead, you + can return the new selected state from itemChange(). \value ItemSelectedHasChanged The item's selected state has changed. The value argument is the new selected state (i.e., true or false). Do not -- cgit v0.12 From fe501b51b03c8c48c3efada83e8ae278c93ae5ab Mon Sep 17 00:00:00 2001 From: David Boddie Date: Tue, 1 Sep 2009 17:38:56 +0200 Subject: Doc: Fixed broken links to renamed functions. Reviewed-by: Trust Me --- src/gui/widgets/qcalendarwidget.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/gui/widgets/qcalendarwidget.cpp b/src/gui/widgets/qcalendarwidget.cpp index 14efb9f..9c8ca01 100644 --- a/src/gui/widgets/qcalendarwidget.cpp +++ b/src/gui/widgets/qcalendarwidget.cpp @@ -1968,9 +1968,7 @@ void QCalendarWidgetPrivate::_q_editingFinished() The widget is initialized with the current month and year, but QCalendarWidget provides several public slots to change the year - and month that is shown. The currently displayed month and year - can be retrieved using the currentPageMonth() and currentPageYear() - functions, respectively. + and month that is shown. By default, today's date is selected, and the user can select a date using both mouse and keyboard. The currently selected date @@ -1983,6 +1981,9 @@ void QCalendarWidgetPrivate::_q_editingFinished() all. Note that a date also can be selected programmatically using the setSelectedDate() slot. + The currently displayed month and year can be retrieved using the + monthShown() and yearShown() functions, respectively. + A newly created calendar widget uses abbreviated day names, and both Saturdays and Sundays are marked in red. The calendar grid is not visible. The week numbers are displayed, and the first column @@ -2292,7 +2293,7 @@ int QCalendarWidget::monthShown() const selected date. The currently displayed month and year can be retrieved using the - currentPageMonth() and currentPageYear() functions respectively. + monthShown() and yearShown() functions respectively. \sa yearShown(), monthShown(), showPreviousMonth(), showNextMonth(), showPreviousYear(), showNextYear() -- cgit v0.12 From 8fab695b7987856da4ebb6b36410dd05aa48c13d Mon Sep 17 00:00:00 2001 From: Ariya Hidayat Date: Tue, 1 Sep 2009 13:22:04 +0200 Subject: Use QStringRef when parsing SVG transformation matrix. There is really no need to use QString for parsing the matrix, hence use QStringRef. In a complex SVG, this cuts significantly the time spent in parseTransform(). Reviewed-by: Kim --- src/svg/qsvghandler.cpp | 39 +++++++++++++++++++++++++++++++-------- 1 file changed, 31 insertions(+), 8 deletions(-) diff --git a/src/svg/qsvghandler.cpp b/src/svg/qsvghandler.cpp index 371b845..27de011 100644 --- a/src/svg/qsvghandler.cpp +++ b/src/svg/qsvghandler.cpp @@ -685,6 +685,28 @@ static QString idFromUrl(const QString &url) return id; } +static inline QStringRef trimRef(const QStringRef &str) +{ + if (str.isEmpty()) + return QStringRef(); + const QChar *s = str.string()->constData() + str.position(); + int end = str.length() - 1; + if (!s[0].isSpace() && !s[end].isSpace()) + return str; + + int start = 0; + while (start<=end && s[start].isSpace()) // skip white space from start + start++; + if (start <= end) { // only white space + while (s[end].isSpace()) // skip white space from end + end--; + } + int l = end - start + 1; + if (l <= 0) + return QStringRef(); + return QStringRef(str.string(), str.position() + start, l); +} + /** * returns true when successfuly set the color. false signifies * that the color should be inherited @@ -903,12 +925,16 @@ static void parseBrush(QSvgNode *node, -static QMatrix parseTransformationMatrix(const QString &value) +static QMatrix parseTransformationMatrix(const QStringRef &value) { + if (value.isEmpty()) + return QMatrix(); + QMatrix matrix; const QChar *str = value.constData(); + const QChar *end = str + value.length(); - while (*str != QLatin1Char(0)) { + while (str < end) { if (str->isSpace() || *str == QLatin1Char(',')) { ++str; continue; @@ -973,7 +999,7 @@ static QMatrix parseTransformationMatrix(const QString &value) } - while (str->isSpace()) + while (str < end && str->isSpace()) ++str; if (*str != QLatin1Char('(')) goto error; @@ -1212,10 +1238,7 @@ static void parseTransform(QSvgNode *node, { if (attributes.transform.isEmpty()) return; - QString value = attributes.transform.toString().trimmed(); - if (value.isEmpty()) - return; - QMatrix matrix = parseTransformationMatrix(value); + QMatrix matrix = parseTransformationMatrix(trimRef(attributes.transform)); if (!matrix.isIdentity()) { node->appendStyleProperty(new QSvgTransformStyle(QTransform(matrix)), someId(attributes)); @@ -2583,7 +2606,7 @@ static void parseBaseGradient(QSvgNode *node, QSvgHandler *handler) { QString link = attributes.value(QLatin1String("xlink:href")).toString(); - QString trans = attributes.value(QLatin1String("gradientTransform")).toString(); + QStringRef trans = attributes.value(QLatin1String("gradientTransform")); QString spread = attributes.value(QLatin1String("spreadMethod")).toString(); QString units = attributes.value(QLatin1String("gradientUnits")).toString(); -- cgit v0.12 From 928ee7059f42f7e5157dd25295bd6b9eea686f29 Mon Sep 17 00:00:00 2001 From: Ariya Hidayat Date: Tue, 1 Sep 2009 16:54:09 +0200 Subject: Speed-up parsing of SVG path data. Instead of using operations that shuffle the array of numbers, just use pointer to iterate the numbers. This reduced the amount of memory operations during the parsing. In addition, parse the numbers to QVarLengthArray instead of QVector. This works well because usually a path element is typically followed by a short list of numbers. Loading tiger.svg (tests/benchmarks/qsvgrenderer) is now 8% faster, mostly due to the time spent in parsePathDataFast is reduced from 26.1 millions instructions to just 20.5 millions (27% speed-up). Reviewed-by: Kim --- src/svg/qsvghandler.cpp | 244 +++++++++++++++++++++++++----------------------- 1 file changed, 127 insertions(+), 117 deletions(-) diff --git a/src/svg/qsvghandler.cpp b/src/svg/qsvghandler.cpp index 27de011..9683efd 100644 --- a/src/svg/qsvghandler.cpp +++ b/src/svg/qsvghandler.cpp @@ -1414,24 +1414,29 @@ static bool parsePathDataFast(const QStringRef &dataStr, QPainterPath &path) QChar pathElem = *str; ++str; QChar endc = *end; - *const_cast(end) = 0; // parseNumbersList requires 0-termination that QStringRef cannot guarantee - QVector arg = parseNumbersList(str); + *const_cast(end) = 0; // parseNumbersArray requires 0-termination that QStringRef cannot guarantee + QVarLengthArray arg; + parseNumbersArray(str, arg); *const_cast(end) = endc; if (pathElem == QLatin1Char('z') || pathElem == QLatin1Char('Z')) arg.append(0);//dummy - while (!arg.isEmpty()) { + const qreal *num = arg.constData(); + int count = arg.count(); + while (count > 0) { qreal offsetX = x; // correction offsets qreal offsetY = y; // for relative commands switch (pathElem.unicode()) { case 'm': { - if (arg.count() < 2) { - arg.pop_front(); + if (count < 2) { + num++; + count--; break; } - x = x0 = arg[0] + offsetX; - y = y0 = arg[1] + offsetY; + x = x0 = num[0] + offsetX; + y = y0 = num[1] + offsetY; + num += 2; + count -= 2; path.moveTo(x0, y0); - arg.pop_front(); arg.pop_front(); // As per 1.2 spec 8.3.2 The "moveto" commands // If a 'moveto' is followed by multiple pairs of coordinates without explicit commands, @@ -1440,15 +1445,16 @@ static bool parsePathDataFast(const QStringRef &dataStr, QPainterPath &path) } break; case 'M': { - if (arg.count() < 2) { - arg.pop_front(); + if (count < 2) { + num++; + count--; break; } - x = x0 = arg[0]; - y = y0 = arg[1]; - + x = x0 = num[0]; + y = y0 = num[1]; + num += 2; + count -= 2; path.moveTo(x0, y0); - arg.pop_front(); arg.pop_front(); // As per 1.2 spec 8.3.2 The "moveto" commands // If a 'moveto' is followed by multiple pairs of coordinates without explicit commands, @@ -1460,96 +1466,104 @@ static bool parsePathDataFast(const QStringRef &dataStr, QPainterPath &path) case 'Z': { x = x0; y = y0; + count--; // skip dummy + num++; path.closeSubpath(); - arg.pop_front();//pop dummy } break; case 'l': { - if (arg.count() < 2) { - arg.pop_front(); + if (count < 2) { + num++; + count--; break; } - x = arg.front() + offsetX; - arg.pop_front(); - y = arg.front() + offsetY; - arg.pop_front(); + x = x0 = num[0] + offsetX; + y = y0 = num[1] + offsetY; + num += 2; + count -= 2; path.lineTo(x, y); } break; case 'L': { - if (arg.count() < 2) { - arg.pop_front(); + if (count < 2) { + num++; + count--; break; } - x = arg.front(); arg.pop_front(); - y = arg.front(); arg.pop_front(); + x = x0 = num[0]; + y = y0 = num[1]; + num += 2; + count -= 2; path.lineTo(x, y); } break; case 'h': { - x = arg.front() + offsetX; arg.pop_front(); + x = num[0] + offsetX; + num++; + count--; path.lineTo(x, y); } break; case 'H': { - x = arg[0]; + x = num[0]; + num++; + count--; path.lineTo(x, y); - arg.pop_front(); } break; case 'v': { - y = arg[0] + offsetY; + y = num[0] + offsetY; + num++; + count--; path.lineTo(x, y); - arg.pop_front(); } break; case 'V': { - y = arg[0]; + y = num[0]; + num++; + count--; path.lineTo(x, y); - arg.pop_front(); } break; case 'c': { - if (arg.count() < 6) { - while (arg.count()) - arg.pop_front(); + if (count < 6) { + num += count; + count = 0; break; } - QPointF c1(arg[0]+offsetX, arg[1]+offsetY); - QPointF c2(arg[2]+offsetX, arg[3]+offsetY); - QPointF e(arg[4]+offsetX, arg[5]+offsetY); + QPointF c1(num[0] + offsetX, num[1] + offsetY); + QPointF c2(num[2] + offsetX, num[3] + offsetY); + QPointF e(num[4] + offsetX, num[5] + offsetY); + num += 6; + count -= 6; path.cubicTo(c1, c2, e); ctrlPt = c2; x = e.x(); y = e.y(); - arg.pop_front(); arg.pop_front(); - arg.pop_front(); arg.pop_front(); - arg.pop_front(); arg.pop_front(); break; } case 'C': { - if (arg.count() < 6) { - while (arg.count()) - arg.pop_front(); + if (count < 6) { + num += count; + count = 0; break; } - QPointF c1(arg[0], arg[1]); - QPointF c2(arg[2], arg[3]); - QPointF e(arg[4], arg[5]); + QPointF c1(num[0], num[1]); + QPointF c2(num[2], num[3]); + QPointF e(num[4], num[5]); + num += 6; + count -= 6; path.cubicTo(c1, c2, e); ctrlPt = c2; x = e.x(); y = e.y(); - arg.pop_front(); arg.pop_front(); - arg.pop_front(); arg.pop_front(); - arg.pop_front(); arg.pop_front(); break; } case 's': { - if (arg.count() < 4) { - while (arg.count()) - arg.pop_front(); + if (count < 4) { + num += count; + count = 0; break; } QPointF c1; @@ -1558,20 +1572,20 @@ static bool parsePathDataFast(const QStringRef &dataStr, QPainterPath &path) c1 = QPointF(2*x-ctrlPt.x(), 2*y-ctrlPt.y()); else c1 = QPointF(x, y); - QPointF c2(arg[0]+offsetX, arg[1]+offsetY); - QPointF e(arg[2]+offsetX, arg[3]+offsetY); + QPointF c2(num[0] + offsetX, num[1] + offsetY); + QPointF e(num[2] + offsetX, num[3] + offsetY); + num += 4; + count -= 4; path.cubicTo(c1, c2, e); ctrlPt = c2; x = e.x(); y = e.y(); - arg.pop_front(); arg.pop_front(); - arg.pop_front(); arg.pop_front(); break; } case 'S': { - if (arg.count() < 4) { - while (arg.count()) - arg.pop_front(); + if (count < 4) { + num += count; + count = 0; break; } QPointF c1; @@ -1580,55 +1594,57 @@ static bool parsePathDataFast(const QStringRef &dataStr, QPainterPath &path) c1 = QPointF(2*x-ctrlPt.x(), 2*y-ctrlPt.y()); else c1 = QPointF(x, y); - QPointF c2(arg[0], arg[1]); - QPointF e(arg[2], arg[3]); + QPointF c2(num[0], num[1]); + QPointF e(num[2], num[3]); + num += 4; + count -= 4; path.cubicTo(c1, c2, e); ctrlPt = c2; x = e.x(); y = e.y(); - arg.pop_front(); arg.pop_front(); - arg.pop_front(); arg.pop_front(); break; } case 'q': { - if (arg.count() < 4) { - while (arg.count()) - arg.pop_front(); + if (count < 4) { + num += count; + count = 0; break; } - QPointF c(arg[0]+offsetX, arg[1]+offsetY); - QPointF e(arg[2]+offsetX, arg[3]+offsetY); + QPointF c(num[0] + offsetX, num[1] + offsetY); + QPointF e(num[2] + offsetX, num[3] + offsetY); + num += 4; + count -= 4; path.quadTo(c, e); ctrlPt = c; x = e.x(); y = e.y(); - arg.pop_front(); arg.pop_front(); - arg.pop_front(); arg.pop_front(); break; } case 'Q': { - if (arg.count() < 4) { - while (arg.count()) - arg.pop_front(); + if (count < 4) { + num += count; + count = 0; break; } - QPointF c(arg[0], arg[1]); - QPointF e(arg[2], arg[3]); + QPointF c(num[0], num[1]); + QPointF e(num[2], num[3]); + num += 4; + count -= 4; path.quadTo(c, e); ctrlPt = c; x = e.x(); y = e.y(); - arg.pop_front(); arg.pop_front(); - arg.pop_front(); arg.pop_front(); break; } case 't': { - if (arg.count() < 2) { - while (arg.count()) - arg.pop_front(); + if (count < 2) { + num += count; + count = 0; break; } - QPointF e(arg[0]+offsetX, arg[1]+offsetY); + QPointF e(num[0] + offsetX, num[1] + offsetY); + num += 2; + count -= 2; QPointF c; if (lastMode == 'q' || lastMode == 'Q' || lastMode == 't' || lastMode == 'T') @@ -1639,16 +1655,17 @@ static bool parsePathDataFast(const QStringRef &dataStr, QPainterPath &path) ctrlPt = c; x = e.x(); y = e.y(); - arg.pop_front(); arg.pop_front(); break; } case 'T': { - if (arg.count() < 2) { - while (arg.count()) - arg.pop_front(); + if (count < 2) { + num += count; + count = 0; break; } - QPointF e(arg[0], arg[1]); + QPointF e(num[0], num[1]); + num += 2; + count -= 2; QPointF c; if (lastMode == 'q' || lastMode == 'Q' || lastMode == 't' || lastMode == 'T') @@ -1659,22 +1676,22 @@ static bool parsePathDataFast(const QStringRef &dataStr, QPainterPath &path) ctrlPt = c; x = e.x(); y = e.y(); - arg.pop_front(); arg.pop_front(); break; } case 'a': { - if (arg.count() < 7) { - while (arg.count()) - arg.pop_front(); + if (count < 7) { + num += count; + count = 0; break; } - qreal rx = arg[0]; - qreal ry = arg[1]; - qreal xAxisRotation = arg[2]; - qreal largeArcFlag = arg[3]; - qreal sweepFlag = arg[4]; - qreal ex = arg[5] + offsetX; - qreal ey = arg[6] + offsetY; + qreal rx = (*num++); + qreal ry = (*num++); + qreal xAxisRotation = (*num++); + qreal largeArcFlag = (*num++); + qreal sweepFlag = (*num++); + qreal ex = (*num++) + offsetX; + qreal ey = (*num++) + offsetY; + count -= 7; qreal curx = x; qreal cury = y; pathArc(path, rx, ry, xAxisRotation, int(largeArcFlag), @@ -1682,36 +1699,29 @@ static bool parsePathDataFast(const QStringRef &dataStr, QPainterPath &path) x = ex; y = ey; - - arg.pop_front(); arg.pop_front(); - arg.pop_front(); arg.pop_front(); - arg.pop_front(); arg.pop_front(); - arg.pop_front(); } break; case 'A': { - if (arg.count() < 7) { - while (arg.count()) - arg.pop_front(); + if (count < 7) { + num += count; + count = 0; break; } - qreal rx = arg[0]; - qreal ry = arg[1]; - qreal xAxisRotation = arg[2]; - qreal largeArcFlag = arg[3]; - qreal sweepFlag = arg[4]; - qreal ex = arg[5]; - qreal ey = arg[6]; + qreal rx = (*num++); + qreal ry = (*num++); + qreal xAxisRotation = (*num++); + qreal largeArcFlag = (*num++); + qreal sweepFlag = (*num++); + qreal ex = (*num++); + qreal ey = (*num++); + count -= 7; qreal curx = x; qreal cury = y; pathArc(path, rx, ry, xAxisRotation, int(largeArcFlag), int(sweepFlag), ex, ey, curx, cury); + x = ex; y = ey; - arg.pop_front(); arg.pop_front(); - arg.pop_front(); arg.pop_front(); - arg.pop_front(); arg.pop_front(); - arg.pop_front(); } break; default: -- cgit v0.12 From ec4f9047913c07897496e2362e859072c24e8d9f Mon Sep 17 00:00:00 2001 From: Geir Vattekar Date: Tue, 1 Sep 2009 17:48:11 +0200 Subject: Doc: Stylesheet min/max-width/height are relative to the box content. Task-number: 235550 Reviewed-by: Olivier Goffart --- doc/src/widgets-and-layouts/stylesheet.qdoc | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/doc/src/widgets-and-layouts/stylesheet.qdoc b/doc/src/widgets-and-layouts/stylesheet.qdoc index 6355850..354050d 100644 --- a/doc/src/widgets-and-layouts/stylesheet.qdoc +++ b/doc/src/widgets-and-layouts/stylesheet.qdoc @@ -2067,6 +2067,9 @@ QMenuBar, QPushButton, QRadioButton, QSizeGrip, QSpinBox, QSplitter, QStatusBar, QTextEdit, and QToolTip. + The value is relative to the contents rect in the \l{The + Box Model}{box model}. + Example: \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 63 @@ -2084,6 +2087,9 @@ QMenuBar, QPushButton, QRadioButton, QSizeGrip, QSpinBox, QSplitter, QStatusBar, QTextEdit, and QToolTip. + The value is relative to the contents rect in the \l{The + Box Model}{box model}. + Example: \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 64 @@ -2121,6 +2127,9 @@ If this property is not specified, the minimum height is derived based on the widget's contents and the style. + The value is relative to the contents rect in the \l{The + Box Model}{box model}. + Example: \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 66 @@ -2141,6 +2150,9 @@ If this property is not specified, the minimum width is derived based on the widget's contents and the style. + The value is relative to the contents rect in the \l{The + Box Model}{box model}. + Example: \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 67 -- cgit v0.12 From 8ed29668c48dd2a4560ad7a4b0908f3809cbc0df Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Tue, 1 Sep 2009 17:09:47 +0200 Subject: QNAM HTTP Code: Removed unnecessary legacy loop Thank you Coverity! Thank you Biochemist! Reviewed-by: joao --- src/network/access/qhttpnetworkconnection.cpp | 39 +++++++++++---------------- 1 file changed, 16 insertions(+), 23 deletions(-) diff --git a/src/network/access/qhttpnetworkconnection.cpp b/src/network/access/qhttpnetworkconnection.cpp index da9ec09..bd6fa57 100644 --- a/src/network/access/qhttpnetworkconnection.cpp +++ b/src/network/access/qhttpnetworkconnection.cpp @@ -425,32 +425,25 @@ void QHttpNetworkConnectionPrivate::dequeueAndSendRequest(QAbstractSocket *socke int i = indexOf(socket); if (!highPriorityQueue.isEmpty()) { - for (int j = highPriorityQueue.count() - 1; j >= 0; --j) { - HttpMessagePair &messagePair = highPriorityQueue[j]; - if (!messagePair.second->d_func()->requestIsPrepared) - prepareRequest(messagePair); - - channels[i].request = messagePair.first; - channels[i].reply = messagePair.second; - // remove before sendRequest! else we might pipeline the same request again - highPriorityQueue.removeAt(j); - channels[i].sendRequest(); - return; - } + // remove from queue before sendRequest! else we might pipeline the same request again + HttpMessagePair messagePair = highPriorityQueue.takeLast(); + if (!messagePair.second->d_func()->requestIsPrepared) + prepareRequest(messagePair); + channels[i].request = messagePair.first; + channels[i].reply = messagePair.second; + channels[i].sendRequest(); + return; } if (!lowPriorityQueue.isEmpty()) { - for (int j = lowPriorityQueue.count() - 1; j >= 0; --j) { - HttpMessagePair &messagePair = lowPriorityQueue[j]; - if (!messagePair.second->d_func()->requestIsPrepared) - prepareRequest(messagePair); - channels[i].request = messagePair.first; - channels[i].reply = messagePair.second; - // remove before sendRequest! else we might pipeline the same request again - lowPriorityQueue.removeAt(j); - channels[i].sendRequest(); - return; - } + // remove from queue before sendRequest! else we might pipeline the same request again + HttpMessagePair messagePair = lowPriorityQueue.takeLast(); + if (!messagePair.second->d_func()->requestIsPrepared) + prepareRequest(messagePair); + channels[i].request = messagePair.first; + channels[i].reply = messagePair.second; + channels[i].sendRequest(); + return; } } -- cgit v0.12 From fc4c4071d6e5704e84a5cca4ae22548bedb7b19d Mon Sep 17 00:00:00 2001 From: Jedrzej Nowacki Date: Tue, 1 Sep 2009 17:52:45 +0200 Subject: QScriptEngineAgent autotest bug fix Default value for script id in tests should be <-1, because -1 mean that there is no script and all numbers >0 are valid. Two test cases were marked as expected to fail. Reviewed-by: TrustMe --- tests/auto/qscriptengineagent/tst_qscriptengineagent.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/auto/qscriptengineagent/tst_qscriptengineagent.cpp b/tests/auto/qscriptengineagent/tst_qscriptengineagent.cpp index 1f9476f..8fe6839 100644 --- a/tests/auto/qscriptengineagent/tst_qscriptengineagent.cpp +++ b/tests/auto/qscriptengineagent/tst_qscriptengineagent.cpp @@ -155,7 +155,7 @@ struct ScriptEngineEvent lineNumber(lineNumber) { } - ScriptEngineEvent(Type type, qint64 scriptId = -1) + ScriptEngineEvent(Type type, qint64 scriptId = -777) : type(type), scriptId(scriptId) { } @@ -2098,6 +2098,7 @@ void tst_QScriptEngineAgent::syntaxError() i = 2; QCOMPARE(spy->at(i).type, ScriptEngineEvent::ContextPush); + QEXPECT_FAIL("","The test is broken, contextPush event do not provide scriptId", Continue); QVERIFY(spy->at(i).scriptId == -1); i = 3; QCOMPARE(spy->at(i).type, ScriptEngineEvent::FunctionEntry); @@ -2107,6 +2108,7 @@ void tst_QScriptEngineAgent::syntaxError() QVERIFY(spy->at(i).scriptId == -1); i = 5; QCOMPARE(spy->at(i).type, ScriptEngineEvent::ContextPop); + QEXPECT_FAIL("","The test is broken, contextPop event do not provide scriptId", Continue); QVERIFY(spy->at(i).scriptId == -1); i = 6; QCOMPARE(spy->at(i).type, ScriptEngineEvent::ExceptionThrow); -- cgit v0.12 From 400d72d5c4b1556ddcc188d82a24d5439f728bbe Mon Sep 17 00:00:00 2001 From: Tom Cooksey Date: Tue, 1 Sep 2009 18:50:41 +0200 Subject: Don't seg-fault when printing error message in shader manager It's very likely that some of the shader objects in required program will be null, as not all are manditory. Check to see if they exist before de-referencing them and asking for their log string. Reviewed-by: Trustme --- .../gl2paintengineex/qglengineshadermanager.cpp | 36 +++++++++++++++------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/src/opengl/gl2paintengineex/qglengineshadermanager.cpp b/src/opengl/gl2paintengineex/qglengineshadermanager.cpp index 891c027..d48a7b6 100644 --- a/src/opengl/gl2paintengineex/qglengineshadermanager.cpp +++ b/src/opengl/gl2paintengineex/qglengineshadermanager.cpp @@ -570,20 +570,34 @@ bool QGLEngineShaderManager::useCorrectShaderProg() requiredProgram.program->link(); if (!requiredProgram.program->isLinked()) { + QLatin1String none("none"); + QLatin1String br("\n"); QString error; - qWarning() << "Shader program failed to link," + error = QLatin1String("Shader program failed to link,") #if defined(QT_DEBUG) - << '\n' - << " Shaders Used:" << '\n' - << " mainVertexShader = " << requiredProgram.mainVertexShader->objectName() << '\n' - << " positionVertexShader = " << requiredProgram.positionVertexShader->objectName() << '\n' - << " mainFragShader = " << requiredProgram.mainFragShader->objectName() << '\n' - << " srcPixelFragShader = " << requiredProgram.srcPixelFragShader->objectName() << '\n' - << " maskFragShader = " << requiredProgram.maskFragShader->objectName() << '\n' - << " compositionFragShader = "<< requiredProgram.compositionFragShader->objectName() << '\n' + + br + + QLatin1String(" Shaders Used:\n") + + QLatin1String(" mainVertexShader = ") + + (requiredProgram.mainVertexShader ? + requiredProgram.mainVertexShader->objectName() : none) + br + + QLatin1String(" positionVertexShader = ") + + (requiredProgram.positionVertexShader ? + requiredProgram.positionVertexShader->objectName() : none) + br + + QLatin1String(" mainFragShader = ") + + (requiredProgram.mainFragShader ? + requiredProgram.mainFragShader->objectName() : none) + br + + QLatin1String(" srcPixelFragShader = ") + + (requiredProgram.srcPixelFragShader ? + requiredProgram.srcPixelFragShader->objectName() : none) + br + + QLatin1String(" maskFragShader = ") + + (requiredProgram.maskFragShader ? + requiredProgram.maskFragShader->objectName() : none) + br + + QLatin1String(" compositionFragShader = ") + + (requiredProgram.compositionFragShader ? + requiredProgram.compositionFragShader->objectName() : none) + br #endif - << " Error Log:" << '\n' - << " " << requiredProgram.program->log(); + + QLatin1String(" Error Log:\n") + + QLatin1String(" ") + requiredProgram.program->log(); qWarning() << error; delete requiredProgram.program; } else { -- cgit v0.12 From d21fc5446c7583e153c1d566aefd7186f9c445cd Mon Sep 17 00:00:00 2001 From: Tom Cooksey Date: Tue, 1 Sep 2009 18:55:05 +0200 Subject: Autotest which checks you can paint to an fbo in a gl widget's p.e. The test mimics examples/opengl/framebufferobjects in that it begins a QPainter on a QGLWidget in it's paint event, then begins a second QPainter on a QGLFramebufferObject, leaving 2 painters active at the same time. When the FBO's painter is ended, GL rendering should be re-targetted at the QGLWidget automatically. --- tests/auto/qgl/tst_qgl.cpp | 55 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/tests/auto/qgl/tst_qgl.cpp b/tests/auto/qgl/tst_qgl.cpp index 1629542..f979174 100644 --- a/tests/auto/qgl/tst_qgl.cpp +++ b/tests/auto/qgl/tst_qgl.cpp @@ -73,6 +73,7 @@ private slots: void partialGLWidgetUpdates(); void glWidgetRendering(); void glFBORendering(); + void glFBOUseInGLWidget(); void glPBufferRendering(); void glWidgetReparent(); void colormap(); @@ -769,6 +770,60 @@ void tst_QGL::glFBORendering() QCOMPARE(fb.pixel(192, 64), QColor(Qt::green).rgb()); } +class FBOUseInGLWidget : public QGLWidget +{ +public: + bool widgetPainterBeginOk; + bool fboPainterBeginOk; + QImage fboImage; +protected: + void paintEvent(QPaintEvent*) + { + QPainter widgetPainter; + widgetPainterBeginOk = widgetPainter.begin(this); + QGLFramebufferObjectFormat fboFormat(0, QGLFramebufferObject::CombinedDepthStencil); + QGLFramebufferObject *fbo = new QGLFramebufferObject(128, 128, fboFormat); + + QPainter fboPainter; + fboPainterBeginOk = fboPainter.begin(fbo); + fboPainter.fillRect(0, 0, 128, 128, Qt::red); + fboPainter.end(); + fboImage = fbo->toImage(); + + widgetPainter.fillRect(rect(), Qt::blue); + + delete fbo; + } + +}; + +void tst_QGL::glFBOUseInGLWidget() +{ + if (!QGLFramebufferObject::hasOpenGLFramebufferObjects()) + QSKIP("QGLFramebufferObject not supported on this platform", SkipSingle); + + FBOUseInGLWidget w; + w.resize(128, 128); + w.show(); + +#ifdef Q_WS_X11 + qt_x11_wait_for_window_manager(&w); +#endif + QTest::qWait(200); + + QVERIFY(w.widgetPainterBeginOk); + QVERIFY(w.fboPainterBeginOk); + + QImage widgetFB = w.grabFrameBuffer(false); + QImage widgetReference(widgetFB.size(), widgetFB.format()); + widgetReference.fill(0xff0000ff); + QCOMPARE(widgetFB, widgetReference); + + QImage fboReference(w.fboImage.size(), w.fboImage.format()); + fboReference.fill(0xffff0000); + QCOMPARE(w.fboImage, fboReference); +} + void tst_QGL::glWidgetReparent() { // Try it as a top-level first: -- cgit v0.12 From 491bf41b96fdc48aa166ae7702e00f3e6eb1825c Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 1 Sep 2009 19:16:11 +0200 Subject: Fix Solaris build: test isn't test. configure: test: argument expected Reviewed-by: TrustMe --- configure | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/configure b/configure index 6832ad3..c519ab1 100755 --- a/configure +++ b/configure @@ -3723,8 +3723,9 @@ elif [ "$Edition" = "OpenSource" ]; then echo "You have already accepted the terms of the $LicenseType license." acceptance=yes else - test -e "$relpath/LICENSE.GPL3" && \ + if [ -e "$relpath/LICENSE.GPL3" ]; then echo "Type '3' to view the GNU General Public License version 3." + fi echo "Type 'L' to view the Lesser GNU General Public License version 2.1." echo "Type 'yes' to accept this license offer." echo "Type 'no' to decline this license offer." -- cgit v0.12 From 16bbf23d75f0754b0b1a458cb77de560b280755d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Tue, 1 Sep 2009 18:54:03 +0200 Subject: Don't check for null if never happens, but test it if it may... Making coverity happy. Reviewed-by: Olivier Goffart --- src/corelib/kernel/qobject.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index 4d9d3b2..c0c97b8 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -3364,10 +3364,10 @@ void QMetaObject::activate(QObject *sender, const QMetaObject *m, int local_sign && (currentThreadData != sender->d_func()->threadData || receiver->d_func()->threadData != sender->d_func()->threadData)) || (c->connectionType == Qt::QueuedConnection)) { - queued_activate(sender, signal_absolute_index, c, argv); + queued_activate(sender, signal_absolute_index, c, argv ? argv : empty_argv); continue; } else if (c->connectionType == Qt::BlockingQueuedConnection) { - blocking_activate(sender, signal_absolute_index, c, argv); + blocking_activate(sender, signal_absolute_index, c, argv ? argv : empty_argv); continue; } @@ -3442,7 +3442,7 @@ void QMetaObject::activate(QObject *sender, const QMetaObject *m, int local_sign void QMetaObject::activate(QObject *sender, int signal_index, void **argv) { const QMetaObject *mo = sender->metaObject(); - while (mo && mo->methodOffset() > signal_index) + while (mo->methodOffset() > signal_index) mo = mo->superClass(); activate(sender, mo, signal_index - mo->methodOffset(), argv); } @@ -3706,7 +3706,7 @@ void QObject::dumpObjectInfo() const QMetaObject *mo = metaObject(); int signalOffset, methodOffset; computeOffsets(mo, &signalOffset, &methodOffset); - while (mo && signalOffset > signal_index) { + while (signalOffset > signal_index) { mo = mo->superClass(); offsetToNextMetaObject = signalOffset; computeOffsets(mo, &signalOffset, &methodOffset); -- cgit v0.12 From e2f53156a86457598f5fde00b6d8742061eb1f76 Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Thu, 27 Aug 2009 07:40:30 -0700 Subject: Add directfb to CFG_GFX_AVAILABLE This is a first step in making it possible to build DirectFB as part of QtGui. Reviewed-by: Thiago Macieira --- configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure b/configure index 3b0cf5b..87d1428 100755 --- a/configure +++ b/configure @@ -643,7 +643,7 @@ CFG_MULTIMEDIA=yes CFG_SVG=yes CFG_WEBKIT=auto # (yes|no|auto) -CFG_GFX_AVAILABLE="linuxfb transformed qvfb vnc multiscreen" +CFG_GFX_AVAILABLE="linuxfb transformed qvfb vnc multiscreen directfb" CFG_GFX_ON="linuxfb multiscreen" CFG_GFX_PLUGIN_AVAILABLE= CFG_GFX_PLUGIN= -- cgit v0.12 From 26ad573f487a370a01ba640813c189e948eb8fd0 Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Thu, 27 Aug 2009 07:47:35 -0700 Subject: Copy directfb.pro to src/gui/embedded/directfb.pri Reviewed-by: Thiago Macieira --- src/gui/embedded/directfb.pri | 38 ++++++++++++++++++++++++++++ src/plugins/gfxdrivers/directfb/directfb.pro | 38 +++------------------------- 2 files changed, 41 insertions(+), 35 deletions(-) create mode 100644 src/gui/embedded/directfb.pri diff --git a/src/gui/embedded/directfb.pri b/src/gui/embedded/directfb.pri new file mode 100644 index 0000000..e868252 --- /dev/null +++ b/src/gui/embedded/directfb.pri @@ -0,0 +1,38 @@ +# These defines might be necessary if your DirectFB driver doesn't +# support all of the DirectFB API. +# +#DEFINES += QT_DIRECTFB_WINDOW_AS_CURSOR +#DEFINES += QT_NO_DIRECTFB_IMAGEPROVIDER +#DEFINES += QT_DIRECTFB_IMAGEPROVIDER_KEEPALIVE +#DEFINES += QT_DIRECTFB_IMAGECACHE +#DEFINES += QT_NO_DIRECTFB_WM +#DEFINES += QT_NO_DIRECTFB_LAYER +#DEFINES += QT_NO_DIRECTFB_PALETTE +#DEFINES += QT_NO_DIRECTFB_PREALLOCATED +#DEFINES += QT_NO_DIRECTFB_MOUSE +#DEFINES += QT_NO_DIRECTFB_KEYBOARD +#DEFINES += QT_DIRECTFB_TIMING +#DEFINES += QT_NO_DIRECTFB_OPAQUE_DETECTION +#DIRECTFB_DRAWINGOPERATIONS=DRAW_RECTS|DRAW_LINES|DRAW_IMAGE|DRAW_PIXMAP|DRAW_TILED_PIXMAP|STROKE_PATH|DRAW_PATH|DRAW_POINTS|DRAW_ELLIPSE|DRAW_POLYGON|DRAW_TEXT|FILL_PATH|FILL_RECT|DRAW_COLORSPANS +#DEFINES += \"QT_DIRECTFB_WARN_ON_RASTERFALLBACKS=$$DIRECTFB_DRAWINGOPERATIONS\" +#DEFINES += \"QT_DIRECTFB_DISABLE_RASTERFALLBACKS=$$DIRECTFB_DRAWINGOPERATIONS\" + +HEADERS += $$QT_SOURCE_TREE/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h \ + $$QT_SOURCE_TREE/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.h \ + $$QT_SOURCE_TREE/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.h \ + $$QT_SOURCE_TREE/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.h \ + $$QT_SOURCE_TREE/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.h \ + $$QT_SOURCE_TREE/src/plugins/gfxdrivers/directfb/qdirectfbkeyboard.h \ + $$QT_SOURCE_TREE/src/plugins/gfxdrivers/directfb/qdirectfbmouse.h + +SOURCES += $$QT_SOURCE_TREE/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp \ + $$QT_SOURCE_TREE/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp \ + $$QT_SOURCE_TREE/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp \ + $$QT_SOURCE_TREE/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp \ + $$QT_SOURCE_TREE/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp \ + $$QT_SOURCE_TREE/src/plugins/gfxdrivers/directfb/qdirectfbkeyboard.cpp \ + $$QT_SOURCE_TREE/src/plugins/gfxdrivers/directfb/qdirectfbmouse.cpp + + +QMAKE_CXXFLAGS += $$QT_CFLAGS_DIRECTFB +LIBS += $$QT_LIBS_DIRECTFB diff --git a/src/plugins/gfxdrivers/directfb/directfb.pro b/src/plugins/gfxdrivers/directfb/directfb.pro index c5da3df..d397050 100644 --- a/src/plugins/gfxdrivers/directfb/directfb.pro +++ b/src/plugins/gfxdrivers/directfb/directfb.pro @@ -1,47 +1,15 @@ TARGET = qdirectfbscreen include(../../qpluginbase.pri) +include($$QT_SOURCE_TREE/src/gui/embedded/directfb.pri) QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/gfxdrivers -# These defines might be necessary if your DirectFB driver doesn't -# support all of the DirectFB API. -# -#DEFINES += QT_DIRECTFB_WINDOW_AS_CURSOR -#DEFINES += QT_NO_DIRECTFB_IMAGEPROVIDER -#DEFINES += QT_DIRECTFB_IMAGEPROVIDER_KEEPALIVE -#DEFINES += QT_DIRECTFB_IMAGECACHE -#DEFINES += QT_NO_DIRECTFB_WM -#DEFINES += QT_NO_DIRECTFB_LAYER -#DEFINES += QT_NO_DIRECTFB_PALETTE -#DEFINES += QT_NO_DIRECTFB_PREALLOCATED -#DEFINES += QT_NO_DIRECTFB_MOUSE -#DEFINES += QT_NO_DIRECTFB_KEYBOARD -#DEFINES += QT_DIRECTFB_TIMING -#DEFINES += QT_NO_DIRECTFB_OPAQUE_DETECTION -#DIRECTFB_DRAWINGOPERATIONS=DRAW_RECTS|DRAW_LINES|DRAW_IMAGE|DRAW_PIXMAP|DRAW_TILED_PIXMAP|STROKE_PATH|DRAW_PATH|DRAW_POINTS|DRAW_ELLIPSE|DRAW_POLYGON|DRAW_TEXT|FILL_PATH|FILL_RECT|DRAW_COLORSPANS -#DEFINES += \"QT_DIRECTFB_WARN_ON_RASTERFALLBACKS=$$DIRECTFB_DRAWINGOPERATIONS\" -#DEFINES += \"QT_DIRECTFB_DISABLE_RASTERFALLBACKS=$$DIRECTFB_DRAWINGOPERATIONS\" - target.path = $$[QT_INSTALL_PLUGINS]/gfxdrivers INSTALLS += target -HEADERS = qdirectfbscreen.h \ - qdirectfbwindowsurface.h \ - qdirectfbpaintengine.h \ - qdirectfbpaintdevice.h \ - qdirectfbpixmap.h \ - qdirectfbkeyboard.h \ - qdirectfbmouse.h - -SOURCES = qdirectfbscreen.cpp \ - qdirectfbscreenplugin.cpp \ - qdirectfbwindowsurface.cpp \ - qdirectfbpaintengine.cpp \ - qdirectfbpaintdevice.cpp \ - qdirectfbpixmap.cpp \ - qdirectfbkeyboard.cpp \ - qdirectfbmouse.cpp +SOURCES += qdirectfbscreenplugin.cpp QMAKE_CXXFLAGS += $$QT_CFLAGS_DIRECTFB LIBS += $$QT_LIBS_DIRECTFB DEFINES += $$QT_DEFINES_DIRECTFB +contains(gfx-plugins, directfb):DEFINES += QT_QWS_DIRECTFB -- cgit v0.12 From 5bbb30442772898a9af04a8986416e6d66cf1311 Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Thu, 27 Aug 2009 07:57:30 -0700 Subject: Add directfb.pri to embedded.pri Reviewed-by: Thiago Macieira --- src/gui/embedded/embedded.pri | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/gui/embedded/embedded.pri b/src/gui/embedded/embedded.pri index 255a504..eb13d8d 100644 --- a/src/gui/embedded/embedded.pri +++ b/src/gui/embedded/embedded.pri @@ -139,6 +139,10 @@ embedded { SOURCES += embedded/qscreentransformed_qws.cpp } + contains( gfx-drivers, directfb ) { + INCLUDEPATH += $$QT_SOURCE_TREE/src/plugins/gfxdrivers/directfb + include($$PWD/directfb.pri) + } # # Keyboard drivers # -- cgit v0.12 From d6c197aa263ba7e98d29376fee95ec10125b8cf2 Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Mon, 31 Aug 2009 13:30:45 -0700 Subject: Add DirectFB to QScreenDriverFactory Reviewed-by: Donald Carr --- src/gui/embedded/qscreendriverfactory_qws.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/gui/embedded/qscreendriverfactory_qws.cpp b/src/gui/embedded/qscreendriverfactory_qws.cpp index 21058af..99ee8f2 100644 --- a/src/gui/embedded/qscreendriverfactory_qws.cpp +++ b/src/gui/embedded/qscreendriverfactory_qws.cpp @@ -51,7 +51,9 @@ #include #include "private/qfactoryloader_p.h" #include "qscreendriverplugin_qws.h" - +#ifndef QT_NO_QWS_DIRECTFB +#include "qdirectfbscreen.h" +#endif #ifndef QT_NO_QWS_VNC #include "qscreenvnc_qws.h" #endif @@ -118,6 +120,10 @@ QScreen *QScreenDriverFactory::create(const QString& key, int displayId) if (driver == QLatin1String("linuxfb") || driver.isEmpty()) return new QLinuxFbScreen(displayId); #endif +#ifndef QT_NO_QWS_DIRECTFB + if (driver == QLatin1String("directfb") || driver.isEmpty()) + return new QDirectFBScreen(displayId); +#endif #ifndef QT_NO_QWS_TRANSFORMED if (driver == QLatin1String("transformed")) return new QTransformedScreen(displayId); @@ -130,7 +136,6 @@ QScreen *QScreenDriverFactory::create(const QString& key, int displayId) if (driver == QLatin1String("multi")) return new QMultiScreen(displayId); #endif - #if !defined(Q_OS_WIN32) || defined(QT_MAKEDLL) #ifndef QT_NO_LIBRARY -- cgit v0.12 From 913a21aae513714217be233c6cecfb39212a4be8 Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Mon, 31 Aug 2009 12:40:19 -0700 Subject: Make DirectFB compile with Qt in a namespace Reviewed-by: Donald Carr --- src/plugins/gfxdrivers/directfb/qdirectfbmouse.cpp | 4 +-- .../gfxdrivers/directfb/qdirectfbpaintengine.cpp | 33 +++++++++++----------- .../gfxdrivers/directfb/qdirectfbpixmap.cpp | 4 +-- .../gfxdrivers/directfb/qdirectfbscreen.cpp | 16 +++++------ .../gfxdrivers/directfb/qdirectfbwindowsurface.cpp | 24 +++++++--------- 5 files changed, 38 insertions(+), 43 deletions(-) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbmouse.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbmouse.cpp index 2fb1520..896f512 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbmouse.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbmouse.cpp @@ -121,8 +121,8 @@ QDirectFBMouseHandlerPrivate::QDirectFBMouseHandlerPrivate(QDirectFBMouseHandler return; } - int flags = ::fcntl(fd, F_GETFL, 0); - ::fcntl(fd, F_SETFL, flags | O_NONBLOCK); + int flags = fcntl(fd, F_GETFL, 0); + fcntl(fd, F_SETFL, flags | O_NONBLOCK); // DirectFB seems to assume that the mouse always starts centered prevPoint = QPoint(screen->deviceWidth() / 2, screen->deviceHeight() / 2); diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp index 9a9553e..984b5c6 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp @@ -109,7 +109,7 @@ public: #endif void prepareForBlit(bool alpha); -private: + IDirectFBSurface *surface; bool antialiased; @@ -129,7 +129,6 @@ private: QRect currentClip; QDirectFBPaintEngine *q; - friend class QDirectFBPaintEngine; }; class SurfaceCache @@ -412,11 +411,11 @@ void QDirectFBPaintEngine::drawRects(const QRect *rects, int rectCount) d->unlock(); if (brush != Qt::NoBrush) { d->setDFBColor(brush.color()); - CLIPPED_PAINT(::fillRects(rects, rectCount, state()->matrix, d->surface)); + CLIPPED_PAINT(QT_PREPEND_NAMESPACE(fillRects)(rects, rectCount, state()->matrix, d->surface)); } if (pen != Qt::NoPen) { d->setDFBColor(pen.color()); - CLIPPED_PAINT(::drawRects(rects, rectCount, state()->matrix, d->surface)); + CLIPPED_PAINT(QT_PREPEND_NAMESPACE(drawRects)(rects, rectCount, state()->matrix, d->surface)); } } @@ -441,11 +440,11 @@ void QDirectFBPaintEngine::drawRects(const QRectF *rects, int rectCount) d->unlock(); if (brush != Qt::NoBrush) { d->setDFBColor(brush.color()); - CLIPPED_PAINT(::fillRects(rects, rectCount, state()->matrix, d->surface)); + CLIPPED_PAINT(fillRects(rects, rectCount, state()->matrix, d->surface)); } if (pen != Qt::NoPen) { d->setDFBColor(pen.color()); - CLIPPED_PAINT(::drawRects(rects, rectCount, state()->matrix, d->surface)); + CLIPPED_PAINT(QT_PREPEND_NAMESPACE(drawRects)(rects, rectCount, state()->matrix, d->surface)); } } @@ -466,7 +465,7 @@ void QDirectFBPaintEngine::drawLines(const QLine *lines, int lineCount) if (pen != Qt::NoPen) { d->unlock(); d->setDFBColor(pen.color()); - CLIPPED_PAINT(::drawLines(lines, lineCount, state()->matrix, d->surface)); + CLIPPED_PAINT(QT_PREPEND_NAMESPACE(drawLines)(lines, lineCount, state()->matrix, d->surface)); } } @@ -487,7 +486,7 @@ void QDirectFBPaintEngine::drawLines(const QLineF *lines, int lineCount) if (pen != Qt::NoPen) { d->unlock(); d->setDFBColor(pen.color()); - CLIPPED_PAINT(::drawLines(lines, lineCount, state()->matrix, d->surface)); + CLIPPED_PAINT(QT_PREPEND_NAMESPACE(drawLines)(lines, lineCount, state()->matrix, d->surface)); } } @@ -1040,8 +1039,8 @@ void QDirectFBPaintEnginePrivate::drawTiledPixmap(const QRectF &dest, const QPix offset.ry() *= transform.m22(); const QSizeF mappedSize(pixmapSize.width() * transform.m11(), pixmapSize.height() * transform.m22()); - qreal y = ::fixCoord(destinationRect.y(), mappedSize.height(), offset.y()); - const qreal startX = ::fixCoord(destinationRect.x(), mappedSize.width(), offset.x()); + qreal y = fixCoord(destinationRect.y(), mappedSize.height(), offset.y()); + const qreal startX = fixCoord(destinationRect.x(), mappedSize.width(), offset.x()); while (y <= destinationRect.bottom()) { qreal x = startX; while (x <= destinationRect.right()) { @@ -1052,8 +1051,8 @@ void QDirectFBPaintEnginePrivate::drawTiledPixmap(const QRectF &dest, const QPix y += mappedSize.height(); } } else { - qreal y = ::fixCoord(destinationRect.y(), pixmapSize.height(), offset.y()); - const qreal startX = ::fixCoord(destinationRect.x(), pixmapSize.width(), offset.x()); + qreal y = fixCoord(destinationRect.y(), pixmapSize.height(), offset.y()); + const qreal startX = fixCoord(destinationRect.x(), pixmapSize.width(), offset.x()); int horizontal = qMax(1, destinationRect.width() / pixmapSize.width()) + 1; if (startX != destinationRect.x()) ++horizontal; @@ -1165,12 +1164,12 @@ template static inline void drawLines(const T *lines, int n, const QTransform &transform, IDirectFBSurface *surface) { if (n == 1) { - const QLine l = ::map(transform, lines[0]); + const QLine l = map(transform, lines[0]); surface->DrawLine(surface, l.x1(), l.y1(), l.x2(), l.y2()); } else { QVarLengthArray lineArray(n); for (int i=0; i static inline void fillRects(const T *rects, int n, const QTransform &transform, IDirectFBSurface *surface) { if (n == 1) { - const QRect r = ::mapRect(transform, rects[0]); + const QRect r = mapRect(transform, rects[0]); surface->FillRectangle(surface, r.x(), r.y(), r.width(), r.height()); } else { QVarLengthArray rectArray(n); for (int i=0; i static inline void drawRects(const T *rects, int n, const QTransform &transform, IDirectFBSurface *surface) { for (int i=0; iDrawRectangle(surface, r.x(), r.y(), r.width(), r.height()); } } diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp index 0717020..4da2f7c 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp @@ -167,7 +167,7 @@ static bool checkForAlphaPixels(const QImage &img) bool QDirectFBPixmapData::hasAlphaChannel(const QImage &img) { #ifndef QT_NO_DIRECTFB_OPAQUE_DETECTION - return ::checkForAlphaPixels(img); + return checkForAlphaPixels(img); #else return img.hasAlphaChannel(); #endif @@ -443,7 +443,7 @@ void QDirectFBPixmapData::fill(const QColor &color) alpha = (color.alpha() < 255); - if (alpha && ::isOpaqueFormat(imageFormat)) { + if (alpha && isOpaqueFormat(imageFormat)) { QSize size; dfbSurface->GetSize(dfbSurface, &size.rwidth(), &size.rheight()); screen->releaseDFBSurface(dfbSurface); diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp index 59fa191..c714989 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp @@ -999,9 +999,9 @@ static void printDirectFBInfo(IDirectFB *fb, IDirectFBSurface *primarySurface) dev.name, dev.vendor, dev.driver.name, dev.driver.major, dev.driver.minor, dev.driver.vendor, DFB_PIXELFORMAT_INDEX(pixelFormat), QDirectFBScreen::getImageFormat(primarySurface), dev.acceleration_mask, - ::flagDescriptions(dev.acceleration_mask, accelerationDescriptions).constData(), - dev.blitting_flags, ::flagDescriptions(dev.blitting_flags, blitDescriptions).constData(), - dev.drawing_flags, ::flagDescriptions(dev.drawing_flags, drawDescriptions).constData(), + flagDescriptions(dev.acceleration_mask, accelerationDescriptions).constData(), + dev.blitting_flags, flagDescriptions(dev.blitting_flags, blitDescriptions).constData(), + dev.drawing_flags, flagDescriptions(dev.drawing_flags, drawDescriptions).constData(), (dev.video_memory >> 10)); } #endif @@ -1067,7 +1067,7 @@ bool QDirectFBScreen::connect(const QString &displaySpec) #ifdef QT_DIRECTFB_IMAGECACHE int imageCacheSize = 4 * 1024 * 1024; // 4 MB - ::setIntOption(displayArgs, QLatin1String("imagecachesize"), &imageCacheSize); + setIntOption(displayArgs, QLatin1String("imagecachesize"), &imageCacheSize); QDirectFBPaintEngine::initImageCache(imageCacheSize); #endif @@ -1191,8 +1191,8 @@ bool QDirectFBScreen::connect(const QString &displaySpec) "Unable to get screen size!", result); return false; } - ::setIntOption(displayArgs, QLatin1String("width"), &w); - ::setIntOption(displayArgs, QLatin1String("height"), &h); + setIntOption(displayArgs, QLatin1String("width"), &w); + setIntOption(displayArgs, QLatin1String("height"), &h); dw = w; dh = h; @@ -1200,8 +1200,8 @@ bool QDirectFBScreen::connect(const QString &displaySpec) Q_ASSERT(dw != 0 && dh != 0); physWidth = physHeight = -1; - ::setIntOption(displayArgs, QLatin1String("mmWidth"), &physWidth); - ::setIntOption(displayArgs, QLatin1String("mmHeight"), &physHeight); + setIntOption(displayArgs, QLatin1String("mmWidth"), &physWidth); + setIntOption(displayArgs, QLatin1String("mmHeight"), &physHeight); const int dpi = 72; if (physWidth < 0) physWidth = qRound(dw * 25.4 / dpi); diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp index 73a6dd7..816bd83 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp @@ -102,6 +102,11 @@ QDirectFBWindowSurface::~QDirectFBWindowSurface() { } +bool QDirectFBWindowSurface::isValid() const +{ + return true; +} + #ifdef QT_DIRECTFB_WM void QDirectFBWindowSurface::raise() { @@ -111,14 +116,7 @@ void QDirectFBWindowSurface::raise() sibling->raise(); } } -#endif - -bool QDirectFBWindowSurface::isValid() const -{ - return true; -} -#ifndef QT_NO_DIRECTFB_WM void QDirectFBWindowSurface::createWindow() { IDirectFBDisplayLayer *layer = screen->dfbDisplayLayer(); @@ -148,10 +146,8 @@ void QDirectFBWindowSurface::createWindow() dfbWindow->GetSurface(dfbWindow, &dfbSurface); updateFormat(); } -#endif // QT_NO_DIRECTFB_WM -#ifndef QT_NO_DIRECTFB_WM -static DFBResult setGeometry(IDirectFBWindow *dfbWindow, const QRect &old, const QRect &rect) +static DFBResult setWindowGeometry(IDirectFBWindow *dfbWindow, const QRect &old, const QRect &rect) { DFBResult result = DFB_OK; const bool isMove = old.isEmpty() || rect.topLeft() != old.topLeft(); @@ -178,7 +174,7 @@ static DFBResult setGeometry(IDirectFBWindow *dfbWindow, const QRect &old, const #endif return result; } -#endif +#endif // QT_NO_DIRECTFB_WM void QDirectFBWindowSurface::setGeometry(const QRect &rect) { @@ -209,7 +205,7 @@ void QDirectFBWindowSurface::setGeometry(const QRect &rect) #ifdef QT_DIRECTFB_WM if (!dfbWindow) createWindow(); - ::setGeometry(dfbWindow, oldRect, rect); + setWindowGeometry(dfbWindow, oldRect, rect); #else if (mode == Primary) { if (dfbSurface && dfbSurface != primarySurface) @@ -271,12 +267,12 @@ bool QDirectFBWindowSurface::scroll(const QRegion ®ion, int dx, int dy) return false; dfbSurface->SetBlittingFlags(dfbSurface, DSBLIT_NOFX); if (region.numRects() == 1) { - ::scrollSurface(dfbSurface, region.boundingRect(), dx, dy); + scrollSurface(dfbSurface, region.boundingRect(), dx, dy); } else { const QVector rects = region.rects(); const int n = rects.size(); for (int i=0; i Date: Thu, 27 Aug 2009 20:37:40 -0700 Subject: Rewrite of DirectFB locking mechanism DirectFB allows you to have a locked subSurface that remains valid while you paint on the unlocked "parent" surface. The only limitation is that when accessing the locked memory you might have to call DirectFB->WaitIdle() in case pending GPU operations aren't finished. After this we keep the locked surface around at all times (from the first time it's requested) until the surface dies. Previous calls to lock() will just call WaitIdle if necessary and previous calls to unlock now just mark the surface as dirty and in need of a WaitIdle if someone needs to access its pixel data. Reviewed-by: Donald Carr --- src/gui/embedded/directfb.pri | 1 + .../gfxdrivers/directfb/qdirectfbpaintdevice.cpp | 99 +++++++++++++++------- .../gfxdrivers/directfb/qdirectfbpaintdevice.h | 16 ++-- .../gfxdrivers/directfb/qdirectfbpaintengine.cpp | 68 ++++++++------- .../gfxdrivers/directfb/qdirectfbpixmap.cpp | 31 ++++--- src/plugins/gfxdrivers/directfb/qdirectfbpixmap.h | 6 +- .../gfxdrivers/directfb/qdirectfbscreen.cpp | 39 ++++++++- src/plugins/gfxdrivers/directfb/qdirectfbscreen.h | 12 +++ .../gfxdrivers/directfb/qdirectfbwindowsurface.cpp | 5 +- 9 files changed, 185 insertions(+), 92 deletions(-) diff --git a/src/gui/embedded/directfb.pri b/src/gui/embedded/directfb.pri index e868252..7dae9d5 100644 --- a/src/gui/embedded/directfb.pri +++ b/src/gui/embedded/directfb.pri @@ -1,6 +1,7 @@ # These defines might be necessary if your DirectFB driver doesn't # support all of the DirectFB API. # +#DEFINES += QT_NO_DIRECTFB_SUBSURFACE #DEFINES += QT_DIRECTFB_WINDOW_AS_CURSOR #DEFINES += QT_NO_DIRECTFB_IMAGEPROVIDER #DEFINES += QT_DIRECTFB_IMAGEPROVIDER_KEEPALIVE diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp index 106de0d..2e56b9a 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp @@ -48,14 +48,29 @@ QT_BEGIN_NAMESPACE QDirectFBPaintDevice::QDirectFBPaintDevice(QDirectFBScreen *scr) - : QCustomRasterPaintDevice(0), dfbSurface(0), lockedImage(0), screen(scr), - bpl(-1), lockFlgs(DFBSurfaceLockFlags(0)), mem(0), engine(0), - imageFormat(QImage::Format_Invalid) -{} + : QCustomRasterPaintDevice(0), dfbSurface(0), screen(scr), + bpl(-1), lockFlgs(DFBSurfaceLockFlags(0)), mem(0), engine(0), imageFormat(QImage::Format_Invalid) +{ +#ifdef QT_DIRECTFB_SUBSURFACE + subSurface = 0; + syncPending = false; +#endif +} QDirectFBPaintDevice::~QDirectFBPaintDevice() { - delete lockedImage; + unlockSurface(); + if (QDirectFBScreen::instance()) { + unlockSurface(); +#ifdef QT_DIRECTFB_SUBSURFACE + if (subSurface) { + screen->releaseDFBSurface(subSurface); + } +#endif + if (dfbSurface) { + screen->releaseDFBSurface(dfbSurface); + } + } delete engine; } @@ -64,30 +79,57 @@ IDirectFBSurface *QDirectFBPaintDevice::directFBSurface() const return dfbSurface; } -void QDirectFBPaintDevice::lockDirectFB(DFBSurfaceLockFlags flags) +bool QDirectFBPaintDevice::lockSurface(DFBSurfaceLockFlags lockFlags) { - if (!(lockFlgs & flags)) { - if (lockFlgs) - unlockDirectFB(); - mem = QDirectFBScreen::lockSurface(dfbSurface, flags, &bpl); + if (lockFlgs && (lockFlags & ~lockFlgs)) + unlockSurface(); + if (!mem) { + Q_ASSERT(dfbSurface); +#ifdef QT_DIRECTFB_SUBSURFACE + if (!subSurface) { + DFBResult result; + subSurface = screen->getSubSurface(dfbSurface, QRect(), QDirectFBScreen::TrackSurface, &result); + if (result != DFB_OK || !subSurface) { + DirectFBError("Couldn't create sub surface", result); + return false; + } + } + IDirectFBSurface *surface = subSurface; +#else + IDirectFBSurface *surface = dfbSurface; +#endif + Q_ASSERT(surface); + mem = QDirectFBScreen::lockSurface(surface, lockFlags, &bpl); + lockFlgs = lockFlags; Q_ASSERT(mem); + Q_ASSERT(bpl > 0); const QSize s = size(); - lockedImage = new QImage(mem, s.width(), s.height(), bpl, - QDirectFBScreen::getImageFormat(dfbSurface)); - lockFlgs = flags; + lockedImage = QImage(mem, s.width(), s.height(), bpl, + QDirectFBScreen::getImageFormat(dfbSurface)); + return true; + } +#ifdef QT_DIRECTFB_SUBSURFACE + if (syncPending) { + syncPending = false; + screen->waitIdle(); } +#endif + return false; } -void QDirectFBPaintDevice::unlockDirectFB() +void QDirectFBPaintDevice::unlockSurface() { - if (!lockedImage || !QDirectFBScreen::instance()) - return; - - dfbSurface->Unlock(dfbSurface); - delete lockedImage; - lockedImage = 0; - mem = 0; - lockFlgs = DFBSurfaceLockFlags(0); + if (QDirectFBScreen::instance() && lockFlgs) { +#ifdef QT_DIRECTFB_SUBSURFACE + IDirectFBSurface *surface = subSurface; +#else + IDirectFBSurface *surface = dfbSurface; +#endif + if (surface) { + surface->Unlock(surface); + lockFlgs = static_cast(0); + } + } } void *QDirectFBPaintDevice::memory() const @@ -102,17 +144,10 @@ QImage::Format QDirectFBPaintDevice::format() const int QDirectFBPaintDevice::bytesPerLine() const { - if (bpl == -1) { - // Can only get the stride when we lock the surface - Q_ASSERT(!lockedImage); - QDirectFBPaintDevice* that = const_cast(this); - that->lockDirectFB(DSLF_READ|DSLF_WRITE); - Q_ASSERT(bpl != -1); - } + Q_ASSERT(!mem || bpl != -1); return bpl; } - QSize QDirectFBPaintDevice::size() const { int w, h; @@ -142,8 +177,8 @@ int QDirectFBPaintDevice::metric(QPaintDevice::PaintDeviceMetric metric) const case QPaintDevice::PdmDepth: return QDirectFBScreen::depth(imageFormat); case QPaintDevice::PdmNumColors: { - if (lockedImage) - return lockedImage->numColors(); + if (!lockedImage.isNull()) + return lockedImage.numColors(); DFBResult result; IDirectFBPalette *palette = 0; diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.h b/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.h index f5de44b..cdd2bea 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.h +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.h @@ -62,8 +62,8 @@ public: virtual IDirectFBSurface *directFBSurface() const; - void lockDirectFB(DFBSurfaceLockFlags lock); - void unlockDirectFB(); + bool lockSurface(DFBSurfaceLockFlags lockFlags); + void unlockSurface(); // Reimplemented from QCustomRasterPaintDevice: void *memory() const; @@ -73,7 +73,6 @@ public: int metric(QPaintDevice::PaintDeviceMetric metric) const; DFBSurfaceLockFlags lockFlags() const { return lockFlgs; } QPaintEngine *paintEngine() const; - protected: QDirectFBPaintDevice(QDirectFBScreen *scr); inline int dotsPerMeterX() const @@ -84,17 +83,20 @@ protected: { return (screen->deviceHeight() * 1000) / screen->physicalHeight(); } -protected: + IDirectFBSurface *dfbSurface; - QImage *lockedImage; +#ifdef QT_DIRECTFB_SUBSURFACE + IDirectFBSurface *subSurface; + friend class QDirectFBPaintEnginePrivate; + bool syncPending; +#endif + QImage lockedImage; QDirectFBScreen *screen; int bpl; DFBSurfaceLockFlags lockFlgs; uchar *mem; QDirectFBPaintEngine *engine; QImage::Format imageFormat; -private: - Q_DISABLE_COPY(QDirectFBPaintDevice); }; QT_END_NAMESPACE diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp index 984b5c6..5bad4de 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp @@ -93,6 +93,7 @@ public: inline void lock(); inline void unlock(); + static inline void unlock(QDirectFBPaintDevice *device); inline bool isSimpleBrush(const QBrush &brush) const; @@ -221,6 +222,7 @@ template static inline void drawRects(const T *rects, int n, const QTransform &transform, IDirectFBSurface *surface); #define CLIPPED_PAINT(operation) { \ + d->unlock(); \ DFBRegion clipRegion; \ switch (d->clipType) { \ case QDirectFBPaintEnginePrivate::NoClip: \ @@ -268,6 +270,7 @@ bool QDirectFBPaintEngine::begin(QPaintDevice *device) QPixmapData *data = static_cast(device)->pixmapData(); Q_ASSERT(data->classId() == QPixmapData::DirectFBClass); QDirectFBPixmapData *dfbPixmapData = static_cast(data); + QDirectFBPaintEnginePrivate::unlock(dfbPixmapData); d->dfbDevice = static_cast(dfbPixmapData); } @@ -408,7 +411,6 @@ void QDirectFBPaintEngine::drawRects(const QRect *rects, int rectCount) QRasterPaintEngine::drawRects(rects, rectCount); return; } - d->unlock(); if (brush != Qt::NoBrush) { d->setDFBColor(brush.color()); CLIPPED_PAINT(QT_PREPEND_NAMESPACE(fillRects)(rects, rectCount, state()->matrix, d->surface)); @@ -437,7 +439,6 @@ void QDirectFBPaintEngine::drawRects(const QRectF *rects, int rectCount) QRasterPaintEngine::drawRects(rects, rectCount); return; } - d->unlock(); if (brush != Qt::NoBrush) { d->setDFBColor(brush.color()); CLIPPED_PAINT(fillRects(rects, rectCount, state()->matrix, d->surface)); @@ -463,7 +464,6 @@ void QDirectFBPaintEngine::drawLines(const QLine *lines, int lineCount) const QPen &pen = state()->pen; if (pen != Qt::NoPen) { - d->unlock(); d->setDFBColor(pen.color()); CLIPPED_PAINT(QT_PREPEND_NAMESPACE(drawLines)(lines, lineCount, state()->matrix, d->surface)); } @@ -484,7 +484,6 @@ void QDirectFBPaintEngine::drawLines(const QLineF *lines, int lineCount) const QPen &pen = state()->pen; if (pen != Qt::NoPen) { - d->unlock(); d->setDFBColor(pen.color()); CLIPPED_PAINT(QT_PREPEND_NAMESPACE(drawLines)(lines, lineCount, state()->matrix, d->surface)); } @@ -532,7 +531,6 @@ void QDirectFBPaintEngine::drawImage(const QRectF &r, const QImage &image, return; } #if !defined QT_NO_DIRECTFB_PREALLOCATED || defined QT_DIRECTFB_IMAGECACHE - d->unlock(); bool release; IDirectFBSurface *imgSurface = d->getSurface(image, &release); d->prepareForBlit(QDirectFBScreen::hasAlphaChannel(imgSurface)); @@ -560,25 +558,25 @@ void QDirectFBPaintEngine::drawPixmap(const QRectF &r, const QPixmap &pixmap, RASTERFALLBACK(DRAW_PIXMAP, r, pixmap.size(), sr); d->lock(); QRasterPaintEngine::drawPixmap(r, pixmap, sr); - } else if (!(d->compositionModeStatus & QDirectFBPaintEnginePrivate::PorterDuff_SupportedBlits) - || (d->transformationType & QDirectFBPaintEnginePrivate::Matrix_BlitsUnsupported) - || d->clipType == QDirectFBPaintEnginePrivate::ComplexClip - || (state()->renderHints & QPainter::SmoothPixmapTransform - && state()->matrix.mapRect(r).size() != sr.size())) { - RASTERFALLBACK(DRAW_PIXMAP, r, pixmap.size(), sr); - const QImage *img = static_cast(pixmap.pixmapData())->buffer(DSLF_READ); - d->lock(); - QRasterPaintEngine::drawImage(r, *img, sr); } else { - d->unlock(); - d->prepareForBlit(pixmap.hasAlphaChannel()); QPixmapData *data = pixmap.pixmapData(); Q_ASSERT(data->classId() == QPixmapData::DirectFBClass); QDirectFBPixmapData *dfbData = static_cast(data); - dfbData->unlockDirectFB(); - IDirectFBSurface *s = dfbData->directFBSurface(); - - CLIPPED_PAINT(d->blit(r, s, sr)); + if (!(d->compositionModeStatus & QDirectFBPaintEnginePrivate::PorterDuff_SupportedBlits) + || (d->transformationType & QDirectFBPaintEnginePrivate::Matrix_BlitsUnsupported) + || d->clipType == QDirectFBPaintEnginePrivate::ComplexClip + || (state()->renderHints & QPainter::SmoothPixmapTransform + && state()->matrix.mapRect(r).size() != sr.size())) { + RASTERFALLBACK(DRAW_PIXMAP, r, pixmap.size(), sr); + const QImage *img = dfbData->buffer(); + d->lock(); + QRasterPaintEngine::drawImage(r, *img, sr); + } else { + QDirectFBPaintEnginePrivate::unlock(dfbData); + d->prepareForBlit(pixmap.hasAlphaChannel()); + IDirectFBSurface *s = dfbData->directFBSurface(); + CLIPPED_PAINT(d->blit(r, s, sr)); + } } } @@ -601,14 +599,16 @@ void QDirectFBPaintEngine::drawTiledPixmap(const QRectF &r, || d->clipType == QDirectFBPaintEnginePrivate::ComplexClip || (state()->renderHints & QPainter::SmoothPixmapTransform && state()->matrix.isScaling())) { RASTERFALLBACK(DRAW_TILED_PIXMAP, r, pixmap.size(), offset); - const QImage *img = static_cast(pixmap.pixmapData())->buffer(DSLF_READ); + QPixmapData *pixmapData = pixmap.pixmapData(); + Q_ASSERT(pixmapData->classId() == QPixmapData::DirectFBClass); + QDirectFBPixmapData *dfbData = static_cast(pixmapData); + const QImage *img = dfbData->buffer(); d->lock(); QRasterPixmapData *data = new QRasterPixmapData(QPixmapData::PixmapType); data->fromImage(*img, Qt::AutoColor); const QPixmap pix(data); QRasterPaintEngine::drawTiledPixmap(r, pix, offset); } else { - d->unlock(); CLIPPED_PAINT(d->drawTiledPixmap(r, pixmap, offset)); } } @@ -707,7 +707,6 @@ void QDirectFBPaintEngine::fillRect(const QRectF &rect, const QBrush &brush) const QColor color = brush.color(); if (!color.isValid()) return; - d->unlock(); d->setDFBColor(color); const QRect r = state()->matrix.mapRect(rect).toRect(); CLIPPED_PAINT(d->surface->FillRectangle(d->surface, r.x(), r.y(), r.width(), r.height())); @@ -724,7 +723,6 @@ void QDirectFBPaintEngine::fillRect(const QRectF &rect, const QBrush &brush) if (texture.pixmapData()->classId() != QPixmapData::DirectFBClass) break; - d->unlock(); CLIPPED_PAINT(d->drawTiledPixmap(rect, texture, rect.topLeft() - state()->brushOrigin)); return; } default: @@ -748,7 +746,6 @@ void QDirectFBPaintEngine::fillRect(const QRectF &rect, const QColor &color) d->lock(); QRasterPaintEngine::fillRect(rect, color); } else { - d->unlock(); d->setDFBColor(color); const QRect r = state()->matrix.mapRect(rect).toRect(); CLIPPED_PAINT(d->surface->FillRectangle(d->surface, r.x(), r.y(), r.width(), r.height())); @@ -810,8 +807,7 @@ void QDirectFBPaintEnginePrivate::lock() // lock so we need to call the base implementation of prepare so // it updates its rasterBuffer to point to the new buffer address. Q_ASSERT(dfbDevice); - if (dfbDevice->lockFlags() != (DSLF_WRITE|DSLF_READ)) { - dfbDevice->lockDirectFB(DSLF_READ|DSLF_WRITE); + if (dfbDevice->lockSurface(DSLF_READ|DSLF_WRITE)) { prepare(dfbDevice); } } @@ -819,7 +815,21 @@ void QDirectFBPaintEnginePrivate::lock() void QDirectFBPaintEnginePrivate::unlock() { Q_ASSERT(dfbDevice); - dfbDevice->unlockDirectFB(); +#ifdef QT_DIRECTFB_SUBSURFACE + dfbDevice->syncPending = true; +#else + QDirectFBPaintEnginePrivate::unlock(dfbDevice); +#endif +} + +void QDirectFBPaintEnginePrivate::unlock(QDirectFBPaintDevice *device) +{ +#ifdef QT_NO_DIRECTFB_SUBSURFACE + Q_ASSERT(device); + device->unlockSurface(); +#else + Q_UNUSED(device); +#endif } void QDirectFBPaintEnginePrivate::setTransform(const QTransform &transform) @@ -1030,7 +1040,7 @@ void QDirectFBPaintEnginePrivate::drawTiledPixmap(const QRectF &dest, const QPix QPixmapData *data = pixmap.pixmapData(); Q_ASSERT(data->classId() == QPixmapData::DirectFBClass); QDirectFBPixmapData *dfbData = static_cast(data); - dfbData->unlockDirectFB(); + QDirectFBPaintEnginePrivate::unlock(dfbData); const QSize pixmapSize = dfbData->size(); IDirectFBSurface *sourceSurface = dfbData->directFBSurface(); if (transform.isScaling()) { diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp index 4da2f7c..6550683 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp @@ -64,9 +64,6 @@ QDirectFBPixmapData::QDirectFBPixmapData(QDirectFBScreen *screen, PixelType pixe QDirectFBPixmapData::~QDirectFBPixmapData() { - unlockDirectFB(); - if (dfbSurface && QDirectFBScreen::instance()) - screen->releaseDFBSurface(dfbSurface); } void QDirectFBPixmapData::resize(int width, int height) @@ -375,9 +372,13 @@ void QDirectFBPixmapData::copy(const QPixmapData *data, const QRect &rect) QPixmapData::copy(data, rect); return; } - unlockDirectFB(); const QDirectFBPixmapData *otherData = static_cast(data); +#ifdef QT_NO_DIRECTFB_SUBSURFACE + if (otherData->lockFlags()) { + const_cast(otherData)->unlockSurface(); + } +#endif IDirectFBSurface *src = otherData->directFBSurface(); alpha = data->hasAlphaChannel(); imageFormat = (alpha @@ -405,6 +406,7 @@ void QDirectFBPixmapData::copy(const QPixmapData *data, const QRect &rect) h = rect.height(); d = otherData->d; is_null = (w <= 0 || h <= 0); + unlockSurface(); DFBResult result = dfbSurface->Blit(dfbSurface, src, &blitRect, 0, 0); #if (Q_DIRECTFB_VERSION >= 0x010000) dfbSurface->ReleaseSource(dfbSurface); @@ -465,18 +467,21 @@ QPixmap QDirectFBPixmapData::transformed(const QTransform &transform, Qt::TransformationMode mode) const { QDirectFBPixmapData *that = const_cast(this); +#ifdef QT_NO_DIRECTFB_SUBSURFACE + if (lockFlags()) + that->unlockSurface(); +#endif + if (!dfbSurface || transform.type() != QTransform::TxScale || mode != Qt::FastTransformation) { const QImage *image = that->buffer(); Q_ASSERT(image); const QImage transformed = image->transformed(transform, mode); - that->unlockDirectFB(); QDirectFBPixmapData *data = new QDirectFBPixmapData(screen, QPixmapData::PixmapType); data->fromImage(transformed, Qt::AutoColor); return QPixmap(data); } - that->unlockDirectFB(); const QSize size = transform.mapRect(QRect(0, 0, w, h)).size(); if (size.isEmpty()) @@ -556,14 +561,12 @@ QPaintEngine *QDirectFBPixmapData::paintEngine() const QImage *QDirectFBPixmapData::buffer() { - lockDirectFB(DSLF_READ|DSLF_WRITE); - return lockedImage; -} - -QImage * QDirectFBPixmapData::buffer(DFBSurfaceLockFlags lockFlags) -{ - lockDirectFB(lockFlags); - return lockedImage; + if (!lockFlgs) { + lockSurface(DSLF_READ|DSLF_WRITE); + } + Q_ASSERT(lockFlgs); + Q_ASSERT(!lockedImage.isNull()); + return &lockedImage; } void QDirectFBPixmapData::invalidate() diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.h b/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.h index 7b4ae47..5d3a2f6 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.h +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.h @@ -81,11 +81,9 @@ public: virtual QImage toImage() const; virtual QPaintEngine *paintEngine() const; virtual QImage *buffer(); - virtual int metric(QPaintDevice::PaintDeviceMetric m) const {return QDirectFBPaintDevice::metric(m);} - - QImage *buffer(DFBSurfaceLockFlags lockFlags); - // Pure virtual in QPixmapData, so re-implement here and delegate to QDirectFBPaintDevice + virtual int metric(QPaintDevice::PaintDeviceMetric m) const { return QDirectFBPaintDevice::metric(m); } + inline QImage::Format pixelFormat() const { return imageFormat; } static bool hasAlphaChannel(const QImage &img); inline bool hasAlphaChannel() const { return alpha; } diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp index c714989..599b2a9 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp @@ -319,14 +319,38 @@ IDirectFBSurface *QDirectFBScreen::createDFBSurface(DFBSurfaceDescription desc, if (options & TrackSurface) { d_ptr->allocatedSurfaces.insert(newSurface); - - //qDebug("Created a new DirectFB surface at %p. New count = %d", - // newSurface, d_ptr->allocatedSurfaces.count()); } return newSurface; } +#ifdef QT_DIRECTFB_SUBSURFACE +IDirectFBSurface *QDirectFBScreen::getSubSurface(IDirectFBSurface *surface, + const QRect &rect, + SurfaceCreationOptions options, + DFBResult *resultPtr) +{ + Q_ASSERT(!(options & NoPreallocated)); + Q_ASSERT(surface); + DFBResult res; + DFBResult &result = (resultPtr ? *resultPtr : res); + IDirectFBSurface *subSurface = 0; + if (rect.isNull()) { + result = surface->GetSubSurface(surface, 0, &subSurface); + } else { + const DFBRectangle subRect = { rect.x(), rect.y(), rect.width(), rect.height() }; + result = surface->GetSubSurface(surface, &subRect, &subSurface); + } + if (result != DFB_OK) { + DirectFBError("Can't get sub surface", result); + } else if (options & TrackSurface) { + d_ptr->allocatedSurfaces.insert(subSurface); + } + return subSurface; +} +#endif + + void QDirectFBScreen::releaseDFBSurface(IDirectFBSurface *surface) { Q_ASSERT(QDirectFBScreen::instance()); @@ -1527,6 +1551,11 @@ void QDirectFBScreen::setDirectFBImageProvider(IDirectFBImageProvider *provider) } #endif +void QDirectFBScreen::waitIdle() +{ + d_ptr->dfb->WaitIdle(d_ptr->dfb); +} + IDirectFBSurface * QDirectFBScreen::surfaceForWidget(const QWidget *widget, QRect *rect) const { Q_ASSERT(widget); @@ -1540,6 +1569,7 @@ IDirectFBSurface * QDirectFBScreen::surfaceForWidget(const QWidget *widget, QRec return 0; } +#ifdef QT_DIRECTFB_SUBSURFACE IDirectFBSurface *QDirectFBScreen::subSurfaceForWidget(const QWidget *widget, const QRect &area) const { Q_ASSERT(widget); @@ -1550,7 +1580,7 @@ IDirectFBSurface *QDirectFBScreen::subSurfaceForWidget(const QWidget *widget, co if (!area.isNull()) rect &= area.translated(widget->mapTo(widget->window(), QPoint(0, 0))); if (!rect.isNull()) { - const DFBRectangle subRect = {rect.x(), rect.y(), rect.width(), rect.height() }; + const DFBRectangle subRect = { rect.x(), rect.y(), rect.width(), rect.height() }; const DFBResult result = surface->GetSubSurface(surface, &subRect, &subSurface); if (result != DFB_OK) { DirectFBError("QDirectFBScreen::subSurface(): Can't get sub surface", result); @@ -1559,6 +1589,7 @@ IDirectFBSurface *QDirectFBScreen::subSurfaceForWidget(const QWidget *widget, co } return subSurface; } +#endif QT_END_NAMESPACE diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h index e74adb1..0ce7a53 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h +++ b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h @@ -54,6 +54,9 @@ QT_BEGIN_NAMESPACE QT_MODULE(Gui) +#if !defined QT_NO_DIRECTFB_SUBSURFACE && !defined QT_DIRECTFB_SUBSURFACE +#define QT_DIRECTFB_SUBSURFACE +#endif #if !defined QT_NO_DIRECTFB_LAYER && !defined QT_DIRECTFB_LAYER #define QT_DIRECTFB_LAYER #endif @@ -166,8 +169,11 @@ public: return static_cast(inst); } + void waitIdle(); IDirectFBSurface *surfaceForWidget(const QWidget *widget, QRect *rect) const; +#ifdef QT_DIRECTFB_SUBSURFACE IDirectFBSurface *subSurfaceForWidget(const QWidget *widget, const QRect &area = QRect()) const; +#endif IDirectFB *dfb(); #ifdef QT_NO_DIRECTFB_WM @@ -199,6 +205,12 @@ public: IDirectFBSurface *createDFBSurface(DFBSurfaceDescription desc, SurfaceCreationOptions options, DFBResult *result); +#ifdef QT_DIRECTFB_SUBSURFACE + IDirectFBSurface *getSubSurface(IDirectFBSurface *surface, + const QRect &rect, + SurfaceCreationOptions options, + DFBResult *result); +#endif void flipSurface(IDirectFBSurface *surface, DFBSurfaceFlipFlags flipFlags, const QRegion ®ion, const QPoint &offset); diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp index 816bd83..e288199 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp @@ -201,7 +201,6 @@ void QDirectFBWindowSurface::setGeometry(const QRect &rect) const QRect oldRect = geometry(); DFBResult result = DFB_OK; // If we're in a resize, the surface shouldn't be locked - Q_ASSERT((lockedImage == 0) || (rect.size() == geometry().size())); #ifdef QT_DIRECTFB_WM if (!dfbWindow) createWindow(); @@ -416,7 +415,9 @@ void QDirectFBWindowSurface::beginPaint(const QRegion &) void QDirectFBWindowSurface::endPaint(const QRegion &) { - unlockDirectFB(); +#ifdef QT_NO_DIRECTFB_SUBSURFACE + unlockSurface(); +#endif } IDirectFBSurface *QDirectFBWindowSurface::directFBSurface() const -- cgit v0.12 From 235aea42924013625fc4b7714fba16ef7b1aee60 Mon Sep 17 00:00:00 2001 From: Bill King Date: Wed, 2 Sep 2009 10:18:38 +1000 Subject: Fixes mysql not knowing the difference between tables and views. Task-number: 176267 Reviewed-by: Justin McPherson --- src/sql/drivers/mysql/qsql_mysql.cpp | 47 ++++++++++++++++++---------- tests/auto/qsqldatabase/tst_qsqldatabase.cpp | 8 ----- 2 files changed, 31 insertions(+), 24 deletions(-) diff --git a/src/sql/drivers/mysql/qsql_mysql.cpp b/src/sql/drivers/mysql/qsql_mysql.cpp index fa79460..b29e742 100644 --- a/src/sql/drivers/mysql/qsql_mysql.cpp +++ b/src/sql/drivers/mysql/qsql_mysql.cpp @@ -1310,23 +1310,38 @@ QSqlResult *QMYSQLDriver::createResult() const QStringList QMYSQLDriver::tables(QSql::TableType type) const { QStringList tl; - if (!isOpen()) - return tl; - if (!(type & QSql::Tables)) - return tl; - - MYSQL_RES* tableRes = mysql_list_tables(d->mysql, NULL); - MYSQL_ROW row; - int i = 0; - while (tableRes) { - mysql_data_seek(tableRes, i); - row = mysql_fetch_row(tableRes); - if (!row) - break; - tl.append(toUnicode(d->tc, row[0])); - i++; + if( mysql_get_server_version(d->mysql) < 50000) + { + if (!isOpen()) + return tl; + if (!(type & QSql::Tables)) + return tl; + + MYSQL_RES* tableRes = mysql_list_tables(d->mysql, NULL); + MYSQL_ROW row; + int i = 0; + while (tableRes) { + mysql_data_seek(tableRes, i); + row = mysql_fetch_row(tableRes); + if (!row) + break; + tl.append(toUnicode(d->tc, row[0])); + i++; + } + mysql_free_result(tableRes); + } else { + QSqlQuery q(createResult()); + if(type & QSql::Tables) { + q.exec(QLatin1String("select table_name from information_schema.tables where table_type = 'BASE TABLE'")); + while(q.next()) + tl.append(q.value(0).toString()); + } + if(type & QSql::Views) { + q.exec(QLatin1String("select table_name from information_schema.tables where table_type = 'VIEW'")); + while(q.next()) + tl.append(q.value(0).toString()); + } } - mysql_free_result(tableRes); return tl; } diff --git a/tests/auto/qsqldatabase/tst_qsqldatabase.cpp b/tests/auto/qsqldatabase/tst_qsqldatabase.cpp index e9a0670..a6d2c26 100644 --- a/tests/auto/qsqldatabase/tst_qsqldatabase.cpp +++ b/tests/auto/qsqldatabase/tst_qsqldatabase.cpp @@ -513,10 +513,6 @@ void tst_QSqlDatabase::tables() QVERIFY(tables.contains(qTableName("qtest"), Qt::CaseInsensitive)); QVERIFY(!tables.contains("sql_features", Qt::CaseInsensitive)); //check for postgres 7.4 internal tables if (views) { - if (db.driverName().startsWith("QMYSQL")) - // MySQL doesn't differentiate between tables and views when calling QSqlDatabase::tables() - // May be fixable by doing a select on informational_schema.tables instead of using the client library api - QEXPECT_FAIL("", "MySQL driver thinks that views are tables", Continue); QVERIFY(!tables.contains(qTableName("qtest_view"), Qt::CaseInsensitive)); } if (tempTables) @@ -524,10 +520,6 @@ void tst_QSqlDatabase::tables() tables = db.tables(QSql::Views); if (views) { - if (db.driverName().startsWith("QMYSQL")) - // MySQL doesn't give back anything when calling QSqlDatabase::tables() with QSql::Views - // May be fixable by doing a select on informational_schema.views instead of using the client library api - QEXPECT_FAIL("", "MySQL driver thinks that views are tables", Continue); if(!tables.contains(qTableName("qtest_view"), Qt::CaseInsensitive)) qDebug() << "failed to find" << qTableName("qtest_view") << "in" << tables; QVERIFY(tables.contains(qTableName("qtest_view"), Qt::CaseInsensitive)); -- cgit v0.12 From a668f029ddf7570cbf29e9e2f36733867cef62b1 Mon Sep 17 00:00:00 2001 From: Jason McDonald Date: Wed, 2 Sep 2009 13:21:44 +1000 Subject: Missing version number fixes Reviewed-by: Trust Me --- src/plugins/qpluginbase.pri | 2 +- tests/auto/mediaobject/dummy/dummy.pro | 2 +- tools/assistant/tools/assistant/doc/assistant.qdocconf | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/plugins/qpluginbase.pri b/src/plugins/qpluginbase.pri index 10563c1..a3abc98 100644 --- a/src/plugins/qpluginbase.pri +++ b/src/plugins/qpluginbase.pri @@ -1,6 +1,6 @@ TEMPLATE = lib isEmpty(QT_MAJOR_VERSION) { - VERSION=4.5.3 + VERSION=4.6.0 } else { VERSION=$${QT_MAJOR_VERSION}.$${QT_MINOR_VERSION}.$${QT_PATCH_VERSION} } diff --git a/tests/auto/mediaobject/dummy/dummy.pro b/tests/auto/mediaobject/dummy/dummy.pro index b4f6109..9febde7 100644 --- a/tests/auto/mediaobject/dummy/dummy.pro +++ b/tests/auto/mediaobject/dummy/dummy.pro @@ -1,7 +1,7 @@ TEMPLATE = lib isEmpty(QT_MAJOR_VERSION) { - VERSION=4.5.2 + VERSION=4.6.0 } else { VERSION=$${QT_MAJOR_VERSION}.$${QT_MINOR_VERSION}.$${QT_PATCH_VERSION} } diff --git a/tools/assistant/tools/assistant/doc/assistant.qdocconf b/tools/assistant/tools/assistant/doc/assistant.qdocconf index 9566e90..161d34f 100644 --- a/tools/assistant/tools/assistant/doc/assistant.qdocconf +++ b/tools/assistant/tools/assistant/doc/assistant.qdocconf @@ -12,5 +12,5 @@ HTML.footer = "


\n" \ "\n" \ "\n" \ "\n" \ - "\n" \ + "\n" \ "
Copyright © 2009 Nokia Corporation and/or its subsidiary(-ies)Trademarks
Qt 4.5.3
Qt 4.6.0
" -- cgit v0.12 From 441fcb027ddbe4a34c67af8cfbda14b9edafbcfd Mon Sep 17 00:00:00 2001 From: Jason McDonald Date: Wed, 2 Sep 2009 13:46:57 +1000 Subject: Fix license header. Reviewed-by: Trust Me --- .../tst_qgraphicsanchorlayout.cpp | 28 +++++++++++----------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/tests/benchmarks/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp b/tests/benchmarks/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp index e419bae..986ceb6 100644 --- a/tests/benchmarks/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp +++ b/tests/benchmarks/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp @@ -3,14 +3,14 @@ ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the QtOpenGL module of the Qt Toolkit. +** This file is part of the documentation of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage ** This file contains pre-release code and may not be distributed. ** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. +** contained in the Technology Preview License Agreement accompanying +** this package. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser @@ -21,20 +21,20 @@ ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.1, included in the file LGPL_EXCEPTION.txt in this ** package. ** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** ** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ -- cgit v0.12 From fb530ac0a12b90527b9792b31e08043518dd8bd7 Mon Sep 17 00:00:00 2001 From: Justin McPherson Date: Wed, 2 Sep 2009 15:39:39 +1000 Subject: Copy ctor and assignment operator for QAudioFormatPrivate (QSharedData derived class). Reviewed-by: bill king --- src/multimedia/audio/qaudioformat.cpp | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/multimedia/audio/qaudioformat.cpp b/src/multimedia/audio/qaudioformat.cpp index 71bbf83..6ae230f 100644 --- a/src/multimedia/audio/qaudioformat.cpp +++ b/src/multimedia/audio/qaudioformat.cpp @@ -57,10 +57,32 @@ public: sampleType = QAudioFormat::Unknown; } + QAudioFormatPrivate(const QAudioFormatPrivate &other): + QSharedData(other), + codec(other.codec), + byteOrder(other.byteOrder), + sampleType(other.sampleType), + frequency(other.frequency), + channels(other.channels), + sampleSize(other.sampleSize) + { + } + + QAudioFormatPrivate& operator=(const QAudioFormatPrivate &other) + { + codec = other.codec; + byteOrder = other.byteOrder; + sampleType = other.sampleType; + frequency = other.frequency; + channels = other.channels; + sampleSize = other.sampleSize; + + return *this; + } + QString codec; QAudioFormat::Endian byteOrder; QAudioFormat::SampleType sampleType; - int frequency; int channels; int sampleSize; -- cgit v0.12 From 7578f43d0f1358b2ed52b3a5d2b853f26e63aec0 Mon Sep 17 00:00:00 2001 From: Ariya Hidayat Date: Wed, 2 Sep 2009 06:53:49 +0200 Subject: CSS parsing speed-up: reserve CSS symbols prior to parsing. Let us be optimistic here and reserve some space in the CSS symbols array before parsing starts. This gives 3% speed-up when loading tiger.svg (tests/benchmarks/qsvgrenderer). Reviewed-by: Olivier Goffart --- src/gui/text/qcssparser.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gui/text/qcssparser.cpp b/src/gui/text/qcssparser.cpp index 6978b45..f252444 100644 --- a/src/gui/text/qcssparser.cpp +++ b/src/gui/text/qcssparser.cpp @@ -2126,6 +2126,7 @@ void Parser::init(const QString &css, bool isFile) hasEscapeSequences = false; symbols.resize(0); + symbols.reserve(8); Scanner::scan(Scanner::preprocess(styleSheet, &hasEscapeSequences), &symbols); index = 0; errorIndex = -1; -- cgit v0.12 From 0b5a81dd9aa153f6cd3a3929ee7ed82ca48f45a5 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Tue, 1 Sep 2009 22:05:57 +0200 Subject: Optimize QScriptClass Do not convert JSC::Identifier to QString to convert it later to JSC::Identivier again Reviewed-by: Kent Hansen --- src/script/api/qscriptengine.cpp | 4 +--- src/script/api/qscriptengine_p.h | 10 ++++++++++ src/script/api/qscriptstring.cpp | 10 ---------- src/script/api/qscriptstring.h | 1 + src/script/api/qscriptstring_p.h | 2 -- src/script/bridge/qscriptclassobject.cpp | 12 ++++-------- 6 files changed, 16 insertions(+), 23 deletions(-) diff --git a/src/script/api/qscriptengine.cpp b/src/script/api/qscriptengine.cpp index d467250..3ffc9c5 100644 --- a/src/script/api/qscriptengine.cpp +++ b/src/script/api/qscriptengine.cpp @@ -3622,9 +3622,7 @@ QScriptEngineAgent *QScriptEngine::agent() const QScriptString QScriptEngine::toStringHandle(const QString &str) { Q_D(QScriptEngine); - QScriptString ss; - QScriptStringPrivate::init(ss, this, JSC::Identifier(d->currentFrame, str)); - return ss; + return d->scriptStringFromJSCIdentifier(JSC::Identifier(d->currentFrame, str)); } /*! diff --git a/src/script/api/qscriptengine_p.h b/src/script/api/qscriptengine_p.h index f06f717..f8eee87 100644 --- a/src/script/api/qscriptengine_p.h +++ b/src/script/api/qscriptengine_p.h @@ -58,6 +58,7 @@ #include #include #include "qscriptvalue_p.h" +#include "qscriptstring_p.h" #include "RefPtr.h" #include "Structure.h" @@ -122,6 +123,7 @@ public: inline QScriptValue scriptValueFromJSCValue(JSC::JSValue value); inline JSC::JSValue scriptValueToJSCValue(const QScriptValue &value); + inline QScriptString scriptStringFromJSCIdentifier(const JSC::Identifier &id); QScriptValue scriptValueFromVariant(const QVariant &value); QVariant scriptValueToVariant(const QScriptValue &value, int targetType); @@ -362,6 +364,14 @@ inline QScriptValue QScriptValuePrivate::property(const QString &name, int resol return property(JSC::Identifier(exec, name), resolveMode); } +inline QScriptString QScriptEnginePrivate::scriptStringFromJSCIdentifier(const JSC::Identifier &id) +{ + QScriptString q; + q.d_ptr = new QScriptStringPrivate(q_func(), id); + return q; +} + + QT_END_NAMESPACE #endif diff --git a/src/script/api/qscriptstring.cpp b/src/script/api/qscriptstring.cpp index 58a7c2b..6de1d88 100644 --- a/src/script/api/qscriptstring.cpp +++ b/src/script/api/qscriptstring.cpp @@ -86,16 +86,6 @@ QScriptStringPrivate::~QScriptStringPrivate() } /*! - \internal -*/ -void QScriptStringPrivate::init(QScriptString &q, QScriptEngine *engine, - const JSC::Identifier &value) -{ - Q_ASSERT(!q.isValid()); - q.d_ptr = new QScriptStringPrivate(engine, value); -} - -/*! Constructs an invalid QScriptString. */ QScriptString::QScriptString() diff --git a/src/script/api/qscriptstring.h b/src/script/api/qscriptstring.h index 30e6856..e6224a2 100644 --- a/src/script/api/qscriptstring.h +++ b/src/script/api/qscriptstring.h @@ -76,6 +76,7 @@ public: private: QExplicitlySharedDataPointer d_ptr; friend class QScriptValue; + friend class QScriptEnginePrivate; Q_DECLARE_PRIVATE(QScriptString) }; diff --git a/src/script/api/qscriptstring_p.h b/src/script/api/qscriptstring_p.h index 8f76648..bba4b58 100644 --- a/src/script/api/qscriptstring_p.h +++ b/src/script/api/qscriptstring_p.h @@ -72,8 +72,6 @@ public: QScriptStringPrivate(QScriptEngine *engine, const JSC::Identifier &id); ~QScriptStringPrivate(); - static void init(QScriptString &q, QScriptEngine *engine, const JSC::Identifier &id); - QBasicAtomicInt ref; #ifndef QT_NO_QOBJECT QPointer engine; diff --git a/src/script/bridge/qscriptclassobject.cpp b/src/script/bridge/qscriptclassobject.cpp index c8633ab..fcd0124 100644 --- a/src/script/bridge/qscriptclassobject.cpp +++ b/src/script/bridge/qscriptclassobject.cpp @@ -97,8 +97,7 @@ bool ClassObjectDelegate::getOwnPropertySlot(QScriptObject* object, QScriptEnginePrivate *engine = scriptEngineFromExec(exec); QScriptValue scriptObject = engine->scriptValueFromJSCValue(object); - QString name(propertyName.ustring()); - QScriptString scriptName = QScriptEnginePrivate::get(engine)->toStringHandle(name); + QScriptString scriptName = engine->scriptStringFromJSCIdentifier(propertyName); uint id = 0; QScriptClass::QueryFlags flags = m_scriptClass->queryProperty( scriptObject, scriptName, QScriptClass::HandlesReadAccess, &id); @@ -116,8 +115,7 @@ void ClassObjectDelegate::put(QScriptObject* object, JSC::ExecState *exec, { QScriptEnginePrivate *engine = scriptEngineFromExec(exec); QScriptValue scriptObject = engine->scriptValueFromJSCValue(object); - QString name(propertyName.ustring()); - QScriptString scriptName = QScriptEnginePrivate::get(engine)->toStringHandle(name); + QScriptString scriptName = engine->scriptStringFromJSCIdentifier(propertyName); uint id = 0; QScriptClass::QueryFlags flags = m_scriptClass->queryProperty( scriptObject, scriptName, QScriptClass::HandlesWriteAccess, &id); @@ -135,8 +133,7 @@ bool ClassObjectDelegate::deleteProperty(QScriptObject* object, JSC::ExecState * // ### avoid duplication of put() QScriptEnginePrivate *engine = scriptEngineFromExec(exec); QScriptValue scriptObject = engine->scriptValueFromJSCValue(object); - QString name(propertyName.ustring()); - QScriptString scriptName = QScriptEnginePrivate::get(engine)->toStringHandle(name); + QScriptString scriptName = engine->scriptStringFromJSCIdentifier(propertyName); uint id = 0; QScriptClass::QueryFlags flags = m_scriptClass->queryProperty( scriptObject, scriptName, QScriptClass::HandlesWriteAccess, &id); @@ -155,8 +152,7 @@ bool ClassObjectDelegate::getPropertyAttributes(const QScriptObject* object, JSC { QScriptEnginePrivate *engine = scriptEngineFromExec(exec); QScriptValue scriptObject = engine->scriptValueFromJSCValue(object); - QString name(propertyName.ustring()); - QScriptString scriptName = QScriptEnginePrivate::get(engine)->toStringHandle(name); + QScriptString scriptName = engine->scriptStringFromJSCIdentifier(propertyName); uint id = 0; QScriptClass::QueryFlags flags = m_scriptClass->queryProperty( scriptObject, scriptName, QScriptClass::HandlesReadAccess, &id); -- cgit v0.12