From 5538d52eec9454404d3e02d9d23cc562b91a68e0 Mon Sep 17 00:00:00 2001 From: Benjamin C Meyer Date: Tue, 21 Jul 2009 13:46:20 +1000 Subject: Match the behavior of the Windows configure and allow the user to type 'y' rather then 'yes' Merge-request: 945 Reviewed-by: Rohan McGovern --- configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure b/configure index f7e8005..13bdf7f 100755 --- a/configure +++ b/configure @@ -3769,7 +3769,7 @@ elif [ "$Edition" = "OpenSource" ]; then read acceptance fi echo - if [ "$acceptance" = "yes" ]; then + if [ "$acceptance" = "yes" ] || [ "$acceptance" = "y" ]; then break elif [ "$acceptance" = "no" ]; then echo "You are not licensed to use this software." -- cgit v0.12 From c6d243df383514f2bf30e178eba087a312191b0f Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Tue, 21 Jul 2009 10:03:17 +0200 Subject: Doc: mark QImage/QPixmap alphaChannel and setAlphaChannel as obsolete. They are expensive - which is why QImage::setALphaChannel had been obsoleted in Qt 4.5. Reviewed-by: Gunnar --- src/gui/image/qimage.cpp | 9 +++--- src/gui/image/qpixmap.cpp | 70 +++++++++++++++++++++++------------------------ 2 files changed, 38 insertions(+), 41 deletions(-) diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp index ad55dcd..7d7dde1 100644 --- a/src/gui/image/qimage.cpp +++ b/src/gui/image/qimage.cpp @@ -612,9 +612,6 @@ bool QImageData::checkForAlphaPixels() const \table \header \o Function \o Description \row - \o setAlphaChannel() - \o Sets the alpha channel of the image. - \row \o setDotsPerMeterX() \o Defines the aspect ratio by setting the number of pixels that fit horizontally in a physical meter. @@ -5587,7 +5584,7 @@ bool QImage::isDetached() const Note that the image will be converted to the Format_ARGB32_Premultiplied format if the function succeeds. - Use one of the composition mods in QPainter::CompositionMode instead. + Use one of the composition modes in QPainter::CompositionMode instead. \warning This function is expensive. @@ -5665,6 +5662,8 @@ void QImage::setAlphaChannel(const QImage &alphaChannel) /*! + \obsolete + Returns the alpha channel of the image as a new grayscale QImage in which each pixel's red, green, and blue values are given the alpha value of the original image. The color depth of the returned image is 8-bit. @@ -5744,7 +5743,7 @@ QImage QImage::alphaChannel() const Returns true if the image has a format that respects the alpha channel, otherwise returns false. - \sa alphaChannel(), {QImage#Image Information}{Image Information} + \sa {QImage#Image Information}{Image Information} */ bool QImage::hasAlphaChannel() const { diff --git a/src/gui/image/qpixmap.cpp b/src/gui/image/qpixmap.cpp index 72fdec0..3e5c9b7 100644 --- a/src/gui/image/qpixmap.cpp +++ b/src/gui/image/qpixmap.cpp @@ -1572,24 +1572,24 @@ QPixmap QPixmap::transformed(const QMatrix &matrix, Qt::TransformationMode mode) designed and optimized for showing images on screen. QBitmap is only a convenience class that inherits QPixmap, ensuring a depth of 1. The isQBitmap() function returns true if a QPixmap object is - really a bitmap, otherwise returns false. Finally, the QPicture class is a - paint device that records and replays QPainter commands. + really a bitmap, otherwise returns false. Finally, the QPicture class + is a paint device that records and replays QPainter commands. A QPixmap can easily be displayed on the screen using QLabel or one of QAbstractButton's subclasses (such as QPushButton and QToolButton). QLabel has a pixmap property, whereas - QAbstractButton has an icon property. And because QPixmap is a - QPaintDevice subclass, QPainter can be used to draw directly onto - pixmaps. + QAbstractButton has an icon property. In addition to the ordinary constructors, a QPixmap can be constructed using the static grabWidget() and grabWindow() functions which creates a QPixmap and paints the given widget, or - window, in it. + window, into it. + + QPixmap objects can be passed around by value since the QPixmap + class uses implicit data sharing. For more information, see the \l + {Implicit Data Sharing} documentation. QPixmap objects can also be + streamed. - Note that the pixel data in a pixmap is internal and is managed by - the underlying window system. Pixels can only be accessed through - QPainter functions or by converting the QPixmap to a QImage. Depending on the system, QPixmap is stored using a RGB32 or a premultiplied alpha format. If the image has an alpha channel, and if the system allows, the preferred format is premultiplied alpha. @@ -1600,6 +1600,13 @@ QPixmap QPixmap::transformed(const QMatrix &matrix, Qt::TransformationMode mode) QPixmap are stored on the client side and don't use any GDI resources). + Note that the pixel data in a pixmap is internal and is managed by + the underlying window system. Because QPixmap is a QPaintDevice + subclass, QPainter can be used to draw directly onto pixmaps. + Pixels can only be accessed through QPainter functions or by + converting the QPixmap to a QImage. However, the fill() function + is available for initializing the entire pixmap with a given color. + There are functions to convert between QImage and QPixmap. Typically, the QImage class is used to load an image file, optionally manipulating the image data, before the QImage @@ -1614,11 +1621,6 @@ QPixmap QPixmap::transformed(const QMatrix &matrix, Qt::TransformationMode mode) there are several functions that enables transformation of the pixmap. - QPixmap objects can be passed around by value since the QPixmap - class uses implicit data sharing. For more information, see the \l - {Implicit Data Sharing} documentation. QPixmap objects can also be - streamed. - \tableofcontents \section1 Reading and Writing Image Files @@ -1675,12 +1677,15 @@ QPixmap QPixmap::transformed(const QMatrix &matrix, Qt::TransformationMode mode) The hasAlphaChannel() returns true if the pixmap has a format that respects the alpha channel, otherwise returns false, while the hasAlpha() function returns true if the pixmap has an alpha - channel \e or a mask (otherwise false). + channel \e or a mask (otherwise false). The mask() function returns + the mask as a QBitmap object, which can be set using setMask(). - The alphaChannel() function returns the alpha channel as a new - QPixmap object, while the mask() function returns the mask as a - QBitmap object. The alpha channel and mask can be set using the - setAlphaChannel() and setMask() functions, respectively. + The createHeuristicMask() function creates and returns a 1-bpp + heuristic mask (i.e. a QBitmap) for this pixmap. It works by + selecting a color from one of the corners and then chipping away + pixels of that color, starting at all the edges. The + createMaskFromColor() function creates and returns a mask (i.e. a + QBitmap) for the pixmap based on a given color. \row \o Low-level information @@ -1718,14 +1723,7 @@ QPixmap QPixmap::transformed(const QMatrix &matrix, Qt::TransformationMode mode) \section1 Pixmap Transformations QPixmap supports a number of functions for creating a new pixmap - that is a transformed version of the original: The - createHeuristicMask() function creates and returns a 1-bpp - heuristic mask (i.e. a QBitmap) for this pixmap. It works by - selecting a color from one of the corners and then chipping away - pixels of that color, starting at all the edges. The - createMaskFromColor() function creates and returns a mask (i.e. a - QBitmap) for the pixmap based on a given color. - + that is a transformed version of the original: The scaled(), scaledToWidth() and scaledToHeight() functions return scaled copies of the pixmap, while the copy() function @@ -1740,11 +1738,6 @@ QPixmap QPixmap::transformed(const QMatrix &matrix, Qt::TransformationMode mode) function returns the actual matrix used for transforming the pixmap. - There are also functions for changing attributes of a pixmap. - in-place: The fill() function fills the entire image with the - given color, the setMask() function sets a mask bitmap, and the - setAlphaChannel() function sets the pixmap's alpha channel. - \sa QBitmap, QImage, QImageReader, QImageWriter */ @@ -1763,7 +1756,7 @@ QPixmap QPixmap::transformed(const QMatrix &matrix, Qt::TransformationMode mode) Returns true if this pixmap has an alpha channel, \e or has a mask, otherwise returns false. - \sa hasAlphaChannel(), alphaChannel(), mask() + \sa hasAlphaChannel(), mask() */ bool QPixmap::hasAlpha() const { @@ -1774,7 +1767,7 @@ bool QPixmap::hasAlpha() const Returns true if the pixmap has a format that respects the alpha channel, otherwise returns false. - \sa alphaChannel(), hasAlpha() + \sa hasAlpha() */ bool QPixmap::hasAlphaChannel() const { @@ -1791,6 +1784,7 @@ int QPixmap::metric(PaintDeviceMetric metric) const /*! \fn void QPixmap::setAlphaChannel(const QPixmap &alphaChannel) + \obsolete Sets the alpha channel of this pixmap to the given \a alphaChannel by converting the \a alphaChannel into 32 bit and using the @@ -1828,6 +1822,8 @@ void QPixmap::setAlphaChannel(const QPixmap &alphaChannel) } /*! + \obsolete + Returns the alpha channel of the pixmap as a new grayscale QPixmap in which each pixel's red, green, and blue values are given the alpha value of the original pixmap. The color depth of the returned pixmap is the system depth @@ -1846,7 +1842,9 @@ void QPixmap::setAlphaChannel(const QPixmap &alphaChannel) \image alphachannelimage.png The pixmap and channelImage QPixmaps \warning This is an expensive operation. The alpha channel of the - pixmap is extracted dynamically from the pixeldata. + pixmap is extracted dynamically from the pixeldata. Most usecases of this + function are covered by QPainter and compositionModes which will normally + execute faster. \sa setAlphaChannel(), {QPixmap#Pixmap Information}{Pixmap Information} @@ -1867,7 +1865,7 @@ QPaintEngine *QPixmap::paintEngine() const /*! \fn QBitmap QPixmap::mask() const - Extracts a bitmap mask from the pixmap's alphachannel. + Extracts a bitmap mask from the pixmap's alpha channel. \warning This is potentially an expensive operation. The mask of the pixmap is extracted dynamically from the pixeldata. -- cgit v0.12 From 0571d9617633a993f3a40e388ac426d78a376ce2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Arve=20S=C3=A6ther?= Date: Tue, 21 Jul 2009 10:02:27 +0200 Subject: LayeredPane should not be reported as an IP address edit control to MSAA The reason was that ROLE_SYSTEM_IPADDRESS = 0x3F has been added to MSAA at one point in time. (Can be found in recent versions of OleAcc.idl). Since the MSAA bridge used a direct mapping between QAccessible::Role and MSAA roles this lead to that LayeredPane was interpreted to be an IP address edit control, affecting QStackedWidget (and some relatives). This caused some screen readers to be confused when the same accessible interface had children such as push buttons. I also discussed this change with Harald. Task-number: 257958 --- src/gui/accessible/qaccessible.h | 1 + src/gui/accessible/qaccessible_win.cpp | 2 ++ 2 files changed, 3 insertions(+) diff --git a/src/gui/accessible/qaccessible.h b/src/gui/accessible/qaccessible.h index 19080de..8dc8159 100644 --- a/src/gui/accessible/qaccessible.h +++ b/src/gui/accessible/qaccessible.h @@ -210,6 +210,7 @@ public: PageTabList = 0x0000003C, Clock = 0x0000003D, Splitter = 0x0000003E, + // Additional Qt roles where enum value does not map directly to MSAA: LayeredPane = 0x0000003F, UserRole = 0x0000ffff }; diff --git a/src/gui/accessible/qaccessible_win.cpp b/src/gui/accessible/qaccessible_win.cpp index bfacb94..85f1a8d 100644 --- a/src/gui/accessible/qaccessible_win.cpp +++ b/src/gui/accessible/qaccessible_win.cpp @@ -1051,6 +1051,8 @@ HRESULT STDMETHODCALLTYPE QWindowsAccessible::get_accRole(VARIANT varID, VARIANT Role role = accessible->role(varID.lVal); if (role != NoRole) { + if (role == LayeredPane) + role = QAccessible::Pane; (*pvarRole).vt = VT_I4; (*pvarRole).lVal = role; } else { -- cgit v0.12 From 1341fe5198bbf58c1a25a5680fbffec3b9b75eb6 Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Mon, 20 Jul 2009 17:25:06 +0200 Subject: Fixes memory leak of global data. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Task-number: related to 253013 Reviewed-by: João Abecasis --- src/corelib/tools/qlocale.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/corelib/tools/qlocale.cpp b/src/corelib/tools/qlocale.cpp index 296d5a0..85e49c7 100644 --- a/src/corelib/tools/qlocale.cpp +++ b/src/corelib/tools/qlocale.cpp @@ -5299,7 +5299,11 @@ struct p5s_deleter { ~p5s_deleter() { - Bfree(p5s); + while (p5s) { + Bigint *next = p5s->next; + Bfree(p5s); + p5s = next; + } } }; -- cgit v0.12 From 1ccdf7cb7d5da92676d401105e9b03bfa747a926 Mon Sep 17 00:00:00 2001 From: hjk Date: Tue, 21 Jul 2009 11:30:49 +0200 Subject: Compile fix with namespaced Qt --- src/xmlpatterns/api/qxmlschema.cpp | 4 ++++ src/xmlpatterns/api/qxmlschema_p.cpp | 4 ++++ src/xmlpatterns/api/qxmlschemavalidator.cpp | 4 ++++ 3 files changed, 12 insertions(+) diff --git a/src/xmlpatterns/api/qxmlschema.cpp b/src/xmlpatterns/api/qxmlschema.cpp index af4c715..e64b388 100644 --- a/src/xmlpatterns/api/qxmlschema.cpp +++ b/src/xmlpatterns/api/qxmlschema.cpp @@ -45,6 +45,8 @@ #include #include +QT_BEGIN_NAMESPACE + /*! \class QXmlSchema @@ -293,3 +295,5 @@ QNetworkAccessManager *QXmlSchema::networkAccessManager() const { return d->networkAccessManager(); } + +QT_END_NAMESPACE diff --git a/src/xmlpatterns/api/qxmlschema_p.cpp b/src/xmlpatterns/api/qxmlschema_p.cpp index 0bcb565..2dad359 100644 --- a/src/xmlpatterns/api/qxmlschema_p.cpp +++ b/src/xmlpatterns/api/qxmlschema_p.cpp @@ -47,6 +47,8 @@ #include #include +QT_BEGIN_NAMESPACE + QXmlSchemaPrivate::QXmlSchemaPrivate(const QXmlNamePool &namePool) : m_namePool(namePool) , m_userMessageHandler(0) @@ -197,3 +199,5 @@ QNetworkAccessManager *QXmlSchemaPrivate::networkAccessManager() const return m_networkAccessManager.data()->value; } + +QT_END_NAMESPACE diff --git a/src/xmlpatterns/api/qxmlschemavalidator.cpp b/src/xmlpatterns/api/qxmlschemavalidator.cpp index 9234d83..a864d40 100644 --- a/src/xmlpatterns/api/qxmlschemavalidator.cpp +++ b/src/xmlpatterns/api/qxmlschemavalidator.cpp @@ -51,6 +51,8 @@ #include #include +QT_BEGIN_NAMESPACE + /*! \class QXmlSchemaValidator @@ -338,3 +340,5 @@ QNetworkAccessManager *QXmlSchemaValidator::networkAccessManager() const return d->m_networkAccessManager.data()->value; } + +QT_END_NAMESPACE -- cgit v0.12 From d159db5214b6bd489d4a1e16d6b8077eb242e6da Mon Sep 17 00:00:00 2001 From: hjk Date: Tue, 21 Jul 2009 12:30:58 +0200 Subject: Fix compiler warning about initialization order reviewed-by: Kim Motoyoshi Kalland --- src/svg/qsvgstyle.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/svg/qsvgstyle.cpp b/src/svg/qsvgstyle.cpp index 4c8247b..b693429 100644 --- a/src/svg/qsvgstyle.cpp +++ b/src/svg/qsvgstyle.cpp @@ -81,12 +81,12 @@ void QSvgQualityStyle::revert(QPainter *, QSvgExtraStates &) } QSvgFillStyle::QSvgFillStyle(const QBrush &brush) - : m_fill(brush), m_style(0), m_fillRuleSet(false), m_fillOpacitySet(false), m_fillRule(Qt::WindingFill), m_fillOpacity(1.0), m_gradientResolved (true) + : m_fill(brush), m_style(0), m_fillRuleSet(false), m_fillRule(Qt::WindingFill), m_fillOpacitySet(false), m_fillOpacity(1.0), m_gradientResolved (true) { } QSvgFillStyle::QSvgFillStyle(QSvgStyleProperty *style) - : m_style(style), m_fillRuleSet(false), m_fillOpacitySet(false), m_fillRule(Qt::WindingFill), m_fillOpacity(1.0), m_gradientResolved (true) + : m_style(style), m_fillRuleSet(false), m_fillRule(Qt::WindingFill), m_fillOpacitySet(false), m_fillOpacity(1.0), m_gradientResolved (true) { } -- cgit v0.12 From 573235120825c6d95c73adf374fde6ed4f38cafa Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Tue, 21 Jul 2009 12:24:42 +0200 Subject: sunpro doesn't like templated friend classes, either --- tools/linguist/shared/profileevaluator.cpp | 2 +- tools/linguist/shared/profileevaluator.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/linguist/shared/profileevaluator.cpp b/tools/linguist/shared/profileevaluator.cpp index 9a27eb0..5a9095a 100644 --- a/tools/linguist/shared/profileevaluator.cpp +++ b/tools/linguist/shared/profileevaluator.cpp @@ -256,7 +256,7 @@ public: ProFile *m_prevProFile; // See m_prevLineNo }; -#if !defined(__GNUC__) || __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ > 3) +#if (!defined(__GNUC__) || __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ > 3)) && !defined(__SUNPRO_CC) Q_DECLARE_TYPEINFO(ProFileEvaluator::Private::State, Q_PRIMITIVE_TYPE); Q_DECLARE_TYPEINFO(ProFileEvaluator::Private::ProLoop, Q_MOVABLE_TYPE); #endif diff --git a/tools/linguist/shared/profileevaluator.h b/tools/linguist/shared/profileevaluator.h index 88b7590..f3498c1 100644 --- a/tools/linguist/shared/profileevaluator.h +++ b/tools/linguist/shared/profileevaluator.h @@ -96,7 +96,7 @@ private: class Private; Private *d; - // This doesn't help gcc 3.3 ... + // This doesn't help gcc 3.3 and sunpro ... template friend class QTypeInfo; }; -- cgit v0.12 From 2ee9e0ea326540ebb29ed5a60eb32ac686c45730 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Arve=20S=C3=A6ther?= Date: Tue, 21 Jul 2009 11:09:23 +0200 Subject: Doc fixes to QEasingCurve. * Remove some references to QAnimation. QAnimation does not exist. * Clarify the documentation for QEasingCurve::Linear. (avoid "tweening" and "no easing") * In the diagrams, change "ease" to "value". * Change the diagram generation code to use antialiased drawing (just as we do in the easingcurve example) Reviewed-by: leo --- doc/src/diagrams/programs/easingcurve/main.cpp | 29 +++++++++++++++---------- doc/src/images/qeasingcurve-cosinecurve.png | Bin 2544 -> 3419 bytes doc/src/images/qeasingcurve-inback.png | Bin 2225 -> 2808 bytes doc/src/images/qeasingcurve-inbounce.png | Bin 2378 -> 3154 bytes doc/src/images/qeasingcurve-incirc.png | Bin 2138 -> 2605 bytes doc/src/images/qeasingcurve-incubic.png | Bin 2230 -> 2722 bytes doc/src/images/qeasingcurve-incurve.png | Bin 2325 -> 2692 bytes doc/src/images/qeasingcurve-inelastic.png | Bin 2314 -> 3304 bytes doc/src/images/qeasingcurve-inexpo.png | Bin 2183 -> 2675 bytes doc/src/images/qeasingcurve-inoutback.png | Bin 2460 -> 3241 bytes doc/src/images/qeasingcurve-inoutbounce.png | Bin 2522 -> 3386 bytes doc/src/images/qeasingcurve-inoutcirc.png | Bin 2352 -> 2843 bytes doc/src/images/qeasingcurve-inoutcubic.png | Bin 2410 -> 2931 bytes doc/src/images/qeasingcurve-inoutelastic.png | Bin 2485 -> 3461 bytes doc/src/images/qeasingcurve-inoutexpo.png | Bin 2383 -> 3004 bytes doc/src/images/qeasingcurve-inoutquad.png | Bin 2392 -> 2893 bytes doc/src/images/qeasingcurve-inoutquart.png | Bin 2331 -> 2925 bytes doc/src/images/qeasingcurve-inoutquint.png | Bin 2244 -> 2823 bytes doc/src/images/qeasingcurve-inoutsine.png | Bin 2405 -> 2891 bytes doc/src/images/qeasingcurve-inquad.png | Bin 2283 -> 2733 bytes doc/src/images/qeasingcurve-inquart.png | Bin 2261 -> 2727 bytes doc/src/images/qeasingcurve-inquint.png | Bin 2178 -> 2630 bytes doc/src/images/qeasingcurve-insine.png | Bin 2167 -> 2567 bytes doc/src/images/qeasingcurve-linear.png | Bin 2165 -> 2318 bytes doc/src/images/qeasingcurve-outback.png | Bin 2371 -> 2852 bytes doc/src/images/qeasingcurve-outbounce.png | Bin 2481 -> 3360 bytes doc/src/images/qeasingcurve-outcirc.png | Bin 2269 -> 2796 bytes doc/src/images/qeasingcurve-outcubic.png | Bin 2336 -> 2792 bytes doc/src/images/qeasingcurve-outcurve.png | Bin 2389 -> 2724 bytes doc/src/images/qeasingcurve-outelastic.png | Bin 2402 -> 3423 bytes doc/src/images/qeasingcurve-outexpo.png | Bin 2299 -> 2803 bytes doc/src/images/qeasingcurve-outinback.png | Bin 2400 -> 3026 bytes doc/src/images/qeasingcurve-outinbounce.png | Bin 2568 -> 3629 bytes doc/src/images/qeasingcurve-outincirc.png | Bin 2339 -> 2822 bytes doc/src/images/qeasingcurve-outincubic.png | Bin 2393 -> 2872 bytes doc/src/images/qeasingcurve-outinelastic.png | Bin 2517 -> 3941 bytes doc/src/images/qeasingcurve-outinexpo.png | Bin 2377 -> 2923 bytes doc/src/images/qeasingcurve-outinquad.png | Bin 2380 -> 2858 bytes doc/src/images/qeasingcurve-outinquart.png | Bin 2319 -> 2830 bytes doc/src/images/qeasingcurve-outinquint.png | Bin 2248 -> 2724 bytes doc/src/images/qeasingcurve-outinsine.png | Bin 2388 -> 2817 bytes doc/src/images/qeasingcurve-outquad.png | Bin 2324 -> 2760 bytes doc/src/images/qeasingcurve-outquart.png | Bin 2304 -> 2764 bytes doc/src/images/qeasingcurve-outquint.png | Bin 2242 -> 2687 bytes doc/src/images/qeasingcurve-outsine.png | Bin 2364 -> 2773 bytes doc/src/images/qeasingcurve-sinecurve.png | Bin 2470 -> 3329 bytes src/corelib/tools/qeasingcurve.cpp | 15 +++++++------ 47 files changed, 25 insertions(+), 19 deletions(-) diff --git a/doc/src/diagrams/programs/easingcurve/main.cpp b/doc/src/diagrams/programs/easingcurve/main.cpp index 8a2d53b..f249dbc 100644 --- a/doc/src/diagrams/programs/easingcurve/main.cpp +++ b/doc/src/diagrams/programs/easingcurve/main.cpp @@ -85,32 +85,37 @@ void createCurveIcons() qreal curveScale = iconSize.height()/2; - painter.drawLine(yAxis - 2, xAxis - curveScale, yAxis + 2, xAxis - curveScale); // hor + painter.drawLine(yAxis - 2, xAxis - curveScale, yAxis + 2, xAxis - curveScale); // hor painter.drawLine(yAxis + curveScale, xAxis + 2, yAxis + curveScale, xAxis - 2); // ver painter.drawText(yAxis + curveScale - 8, xAxis - curveScale - 4, QLatin1String("(1,1)")); - + painter.drawText(yAxis + 42, xAxis + 10, QLatin1String("progress")); - painter.drawText(15, xAxis - curveScale - 10, QLatin1String("ease")); - - painter.setPen(QPen(Qt::red, 1, Qt::DotLine)); + painter.drawText(15, xAxis - curveScale - 10, QLatin1String("value")); + + painter.setPen(QPen(Qt::red, 1, Qt::DotLine)); painter.drawLine(yAxis, xAxis - curveScale, yAxis + curveScale, xAxis - curveScale); // hor painter.drawLine(yAxis + curveScale, xAxis, yAxis + curveScale, xAxis - curveScale); // ver - - QPoint currentPos(yAxis, xAxis); - + + QPoint start(yAxis, xAxis - curveScale * curve.valueForProgress(0)); + painter.setPen(Qt::black); QFont font = oldFont; font.setPixelSize(oldFont.pixelSize() + 15); painter.setFont(font); painter.drawText(0, iconSize.height() - 20, iconSize.width(), 20, Qt::AlignHCenter, name); - - for (qreal t = 0; t < 1.0; t+=1.0/curveScale) { + + QPainterPath curvePath; + curvePath.moveTo(start); + for (qreal t = 0; t <= 1.0; t+=1.0/curveScale) { QPoint to; to.setX(yAxis + curveScale * t); to.setY(xAxis - curveScale * curve.valueForProgress(t)); - painter.drawLine(currentPos, to); - currentPos = to; + curvePath.lineTo(to); } + painter.setRenderHint(QPainter::Antialiasing, true); + painter.strokePath(curvePath, QColor(32, 32, 32)); + painter.setRenderHint(QPainter::Antialiasing, false); + QString fileName(QString::fromAscii("qeasingcurve-%1.png").arg(name.toLower())); printf("%s\n", qPrintable(fileName)); pix.save(QString::fromAscii("%1/%2").arg(output).arg(fileName), "PNG"); diff --git a/doc/src/images/qeasingcurve-cosinecurve.png b/doc/src/images/qeasingcurve-cosinecurve.png index b27e763..8cee978 100644 Binary files a/doc/src/images/qeasingcurve-cosinecurve.png and b/doc/src/images/qeasingcurve-cosinecurve.png differ diff --git a/doc/src/images/qeasingcurve-inback.png b/doc/src/images/qeasingcurve-inback.png index 8506c0f..0064cb3 100644 Binary files a/doc/src/images/qeasingcurve-inback.png and b/doc/src/images/qeasingcurve-inback.png differ diff --git a/doc/src/images/qeasingcurve-inbounce.png b/doc/src/images/qeasingcurve-inbounce.png index 275b38c..eaa64f8 100644 Binary files a/doc/src/images/qeasingcurve-inbounce.png and b/doc/src/images/qeasingcurve-inbounce.png differ diff --git a/doc/src/images/qeasingcurve-incirc.png b/doc/src/images/qeasingcurve-incirc.png index b985e9c..7bd0f09 100644 Binary files a/doc/src/images/qeasingcurve-incirc.png and b/doc/src/images/qeasingcurve-incirc.png differ diff --git a/doc/src/images/qeasingcurve-incubic.png b/doc/src/images/qeasingcurve-incubic.png index e417ee1..1ac9eaf 100644 Binary files a/doc/src/images/qeasingcurve-incubic.png and b/doc/src/images/qeasingcurve-incubic.png differ diff --git a/doc/src/images/qeasingcurve-incurve.png b/doc/src/images/qeasingcurve-incurve.png index d9a9340..578259e 100644 Binary files a/doc/src/images/qeasingcurve-incurve.png and b/doc/src/images/qeasingcurve-incurve.png differ diff --git a/doc/src/images/qeasingcurve-inelastic.png b/doc/src/images/qeasingcurve-inelastic.png index b242fd3..f976b5a 100644 Binary files a/doc/src/images/qeasingcurve-inelastic.png and b/doc/src/images/qeasingcurve-inelastic.png differ diff --git a/doc/src/images/qeasingcurve-inexpo.png b/doc/src/images/qeasingcurve-inexpo.png index f06316c..1af3652 100644 Binary files a/doc/src/images/qeasingcurve-inexpo.png and b/doc/src/images/qeasingcurve-inexpo.png differ diff --git a/doc/src/images/qeasingcurve-inoutback.png b/doc/src/images/qeasingcurve-inoutback.png index 9fd1446..480bc05 100644 Binary files a/doc/src/images/qeasingcurve-inoutback.png and b/doc/src/images/qeasingcurve-inoutback.png differ diff --git a/doc/src/images/qeasingcurve-inoutbounce.png b/doc/src/images/qeasingcurve-inoutbounce.png index fb65f31..de62309 100644 Binary files a/doc/src/images/qeasingcurve-inoutbounce.png and b/doc/src/images/qeasingcurve-inoutbounce.png differ diff --git a/doc/src/images/qeasingcurve-inoutcirc.png b/doc/src/images/qeasingcurve-inoutcirc.png index 123cc54..b4be8ac 100644 Binary files a/doc/src/images/qeasingcurve-inoutcirc.png and b/doc/src/images/qeasingcurve-inoutcirc.png differ diff --git a/doc/src/images/qeasingcurve-inoutcubic.png b/doc/src/images/qeasingcurve-inoutcubic.png index b07695c..49dfbef 100644 Binary files a/doc/src/images/qeasingcurve-inoutcubic.png and b/doc/src/images/qeasingcurve-inoutcubic.png differ diff --git a/doc/src/images/qeasingcurve-inoutelastic.png b/doc/src/images/qeasingcurve-inoutelastic.png index 65851e1..5b0e54a 100644 Binary files a/doc/src/images/qeasingcurve-inoutelastic.png and b/doc/src/images/qeasingcurve-inoutelastic.png differ diff --git a/doc/src/images/qeasingcurve-inoutexpo.png b/doc/src/images/qeasingcurve-inoutexpo.png index 7cbfb13..776984a 100644 Binary files a/doc/src/images/qeasingcurve-inoutexpo.png and b/doc/src/images/qeasingcurve-inoutexpo.png differ diff --git a/doc/src/images/qeasingcurve-inoutquad.png b/doc/src/images/qeasingcurve-inoutquad.png index c5eed06..2643330 100644 Binary files a/doc/src/images/qeasingcurve-inoutquad.png and b/doc/src/images/qeasingcurve-inoutquad.png differ diff --git a/doc/src/images/qeasingcurve-inoutquart.png b/doc/src/images/qeasingcurve-inoutquart.png index 3b66c0d..31fc0c8 100644 Binary files a/doc/src/images/qeasingcurve-inoutquart.png and b/doc/src/images/qeasingcurve-inoutquart.png differ diff --git a/doc/src/images/qeasingcurve-inoutquint.png b/doc/src/images/qeasingcurve-inoutquint.png index c74efe9..4d7a745 100644 Binary files a/doc/src/images/qeasingcurve-inoutquint.png and b/doc/src/images/qeasingcurve-inoutquint.png differ diff --git a/doc/src/images/qeasingcurve-inoutsine.png b/doc/src/images/qeasingcurve-inoutsine.png index 5964f31..012ff75 100644 Binary files a/doc/src/images/qeasingcurve-inoutsine.png and b/doc/src/images/qeasingcurve-inoutsine.png differ diff --git a/doc/src/images/qeasingcurve-inquad.png b/doc/src/images/qeasingcurve-inquad.png index 3373310..e697c20 100644 Binary files a/doc/src/images/qeasingcurve-inquad.png and b/doc/src/images/qeasingcurve-inquad.png differ diff --git a/doc/src/images/qeasingcurve-inquart.png b/doc/src/images/qeasingcurve-inquart.png index 28086d8..6d65175 100644 Binary files a/doc/src/images/qeasingcurve-inquart.png and b/doc/src/images/qeasingcurve-inquart.png differ diff --git a/doc/src/images/qeasingcurve-inquint.png b/doc/src/images/qeasingcurve-inquint.png index 330aa85..faaaea7 100644 Binary files a/doc/src/images/qeasingcurve-inquint.png and b/doc/src/images/qeasingcurve-inquint.png differ diff --git a/doc/src/images/qeasingcurve-insine.png b/doc/src/images/qeasingcurve-insine.png index 63d9238..0944903 100644 Binary files a/doc/src/images/qeasingcurve-insine.png and b/doc/src/images/qeasingcurve-insine.png differ diff --git a/doc/src/images/qeasingcurve-linear.png b/doc/src/images/qeasingcurve-linear.png index 2a05885..fb3aaf3 100644 Binary files a/doc/src/images/qeasingcurve-linear.png and b/doc/src/images/qeasingcurve-linear.png differ diff --git a/doc/src/images/qeasingcurve-outback.png b/doc/src/images/qeasingcurve-outback.png index 7cb34c6..83b3fa2 100644 Binary files a/doc/src/images/qeasingcurve-outback.png and b/doc/src/images/qeasingcurve-outback.png differ diff --git a/doc/src/images/qeasingcurve-outbounce.png b/doc/src/images/qeasingcurve-outbounce.png index 932fc16..27ac979 100644 Binary files a/doc/src/images/qeasingcurve-outbounce.png and b/doc/src/images/qeasingcurve-outbounce.png differ diff --git a/doc/src/images/qeasingcurve-outcirc.png b/doc/src/images/qeasingcurve-outcirc.png index a1a6cb6..0019370 100644 Binary files a/doc/src/images/qeasingcurve-outcirc.png and b/doc/src/images/qeasingcurve-outcirc.png differ diff --git a/doc/src/images/qeasingcurve-outcubic.png b/doc/src/images/qeasingcurve-outcubic.png index aa1d604..45477c0 100644 Binary files a/doc/src/images/qeasingcurve-outcubic.png and b/doc/src/images/qeasingcurve-outcubic.png differ diff --git a/doc/src/images/qeasingcurve-outcurve.png b/doc/src/images/qeasingcurve-outcurve.png index a949ae4..295b471 100644 Binary files a/doc/src/images/qeasingcurve-outcurve.png and b/doc/src/images/qeasingcurve-outcurve.png differ diff --git a/doc/src/images/qeasingcurve-outelastic.png b/doc/src/images/qeasingcurve-outelastic.png index 2a9ba39..1d407ed 100644 Binary files a/doc/src/images/qeasingcurve-outelastic.png and b/doc/src/images/qeasingcurve-outelastic.png differ diff --git a/doc/src/images/qeasingcurve-outexpo.png b/doc/src/images/qeasingcurve-outexpo.png index e771c2e..5685155 100644 Binary files a/doc/src/images/qeasingcurve-outexpo.png and b/doc/src/images/qeasingcurve-outexpo.png differ diff --git a/doc/src/images/qeasingcurve-outinback.png b/doc/src/images/qeasingcurve-outinback.png index 7523727..4700ab0 100644 Binary files a/doc/src/images/qeasingcurve-outinback.png and b/doc/src/images/qeasingcurve-outinback.png differ diff --git a/doc/src/images/qeasingcurve-outinbounce.png b/doc/src/images/qeasingcurve-outinbounce.png index ab73d02..12cc1a8 100644 Binary files a/doc/src/images/qeasingcurve-outinbounce.png and b/doc/src/images/qeasingcurve-outinbounce.png differ diff --git a/doc/src/images/qeasingcurve-outincirc.png b/doc/src/images/qeasingcurve-outincirc.png index ec4b8d3..c8a5c86 100644 Binary files a/doc/src/images/qeasingcurve-outincirc.png and b/doc/src/images/qeasingcurve-outincirc.png differ diff --git a/doc/src/images/qeasingcurve-outincubic.png b/doc/src/images/qeasingcurve-outincubic.png index 8b8ae68..42af870 100644 Binary files a/doc/src/images/qeasingcurve-outincubic.png and b/doc/src/images/qeasingcurve-outincubic.png differ diff --git a/doc/src/images/qeasingcurve-outinelastic.png b/doc/src/images/qeasingcurve-outinelastic.png index 89dde2c..308be57 100644 Binary files a/doc/src/images/qeasingcurve-outinelastic.png and b/doc/src/images/qeasingcurve-outinelastic.png differ diff --git a/doc/src/images/qeasingcurve-outinexpo.png b/doc/src/images/qeasingcurve-outinexpo.png index 5909901..0692baa 100644 Binary files a/doc/src/images/qeasingcurve-outinexpo.png and b/doc/src/images/qeasingcurve-outinexpo.png differ diff --git a/doc/src/images/qeasingcurve-outinquad.png b/doc/src/images/qeasingcurve-outinquad.png index 7ddefee..9e3cd83 100644 Binary files a/doc/src/images/qeasingcurve-outinquad.png and b/doc/src/images/qeasingcurve-outinquad.png differ diff --git a/doc/src/images/qeasingcurve-outinquart.png b/doc/src/images/qeasingcurve-outinquart.png index 00ef597..9a3c16f 100644 Binary files a/doc/src/images/qeasingcurve-outinquart.png and b/doc/src/images/qeasingcurve-outinquart.png differ diff --git a/doc/src/images/qeasingcurve-outinquint.png b/doc/src/images/qeasingcurve-outinquint.png index 361bfaa4..add9feb 100644 Binary files a/doc/src/images/qeasingcurve-outinquint.png and b/doc/src/images/qeasingcurve-outinquint.png differ diff --git a/doc/src/images/qeasingcurve-outinsine.png b/doc/src/images/qeasingcurve-outinsine.png index 1737041..4bc2aaf 100644 Binary files a/doc/src/images/qeasingcurve-outinsine.png and b/doc/src/images/qeasingcurve-outinsine.png differ diff --git a/doc/src/images/qeasingcurve-outquad.png b/doc/src/images/qeasingcurve-outquad.png index 6f27cbd..c505ff9 100644 Binary files a/doc/src/images/qeasingcurve-outquad.png and b/doc/src/images/qeasingcurve-outquad.png differ diff --git a/doc/src/images/qeasingcurve-outquart.png b/doc/src/images/qeasingcurve-outquart.png index d45a0b8..6eac058 100644 Binary files a/doc/src/images/qeasingcurve-outquart.png and b/doc/src/images/qeasingcurve-outquart.png differ diff --git a/doc/src/images/qeasingcurve-outquint.png b/doc/src/images/qeasingcurve-outquint.png index 6e7df0e..77a9ad4 100644 Binary files a/doc/src/images/qeasingcurve-outquint.png and b/doc/src/images/qeasingcurve-outquint.png differ diff --git a/doc/src/images/qeasingcurve-outsine.png b/doc/src/images/qeasingcurve-outsine.png index 7546a0d..d135b2f 100644 Binary files a/doc/src/images/qeasingcurve-outsine.png and b/doc/src/images/qeasingcurve-outsine.png differ diff --git a/doc/src/images/qeasingcurve-sinecurve.png b/doc/src/images/qeasingcurve-sinecurve.png index ca67d44..6134a01 100644 Binary files a/doc/src/images/qeasingcurve-sinecurve.png and b/doc/src/images/qeasingcurve-sinecurve.png differ diff --git a/src/corelib/tools/qeasingcurve.cpp b/src/corelib/tools/qeasingcurve.cpp index 18a252a..34ad599 100644 --- a/src/corelib/tools/qeasingcurve.cpp +++ b/src/corelib/tools/qeasingcurve.cpp @@ -60,8 +60,8 @@ Easing curves describe a function that controls how the speed of the interpolation between 0 and 1 should be. Easing curves allow transitions from one value to another to appear more natural than a simple constant speed would allow. - The QEasingCurve class is usually used in conjunction with the QAnimation class, - but can be used on its own. + The QEasingCurve class is usually used in conjunction with the QVariantAnimation and + QPropertyAnimation classes but can be used on its own. To calculate the speed of the interpolation, the easing curve provides the function valueForProgress(), where the \a progress argument specifies the progress of the @@ -80,10 +80,10 @@ \endcode will print the effective progress of the interpolation between 0 and 1. - When using a QAnimation, the easing curve will be used to control the + When using a QPropertyAnimation, the associated easing curve will be used to control the progress of the interpolation between startValue and endValue: \code - QAnimation animation; + QPropertyAnimation animation; animation.setStartValue(0); animation.setEndValue(1000); animation.setDuration(1000); @@ -98,8 +98,7 @@ \value Linear \inlineimage qeasingcurve-linear.png \br - Easing equation function for a simple linear tweening, - with no easing. + Easing equation function for a linear (t) easing curve. \value InQuad \inlineimage qeasingcurve-inquad.png \br Easing equation function for a quadratic (t^2) easing @@ -280,7 +279,9 @@ \omitvalue OutCurve \omitvalue SineCurve \omitvalue CosineCurve - \value Custom This is returned if the user have specified a custom curve type with setCustomType(). Note that you cannot call setType() with this value, but type() can return it. + \value Custom This is returned if the user specified a custom curve type with + setCustomType(). Note that you cannot call setType() with this value, + but type() can return it. \omitvalue NCurveTypes */ -- cgit v0.12 From 99ddd27d400c92949d730ebf4f31eb2fea857650 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Arve=20S=C3=A6ther?= Date: Tue, 21 Jul 2009 12:43:58 +0200 Subject: Try to express ourselves better in the explanation for the curve types. Don't use easing too much. Also add an explanation of what "ease in" and "ease out" is. --- src/corelib/tools/qeasingcurve.cpp | 165 +++++++++++++++++++------------------ 1 file changed, 84 insertions(+), 81 deletions(-) diff --git a/src/corelib/tools/qeasingcurve.cpp b/src/corelib/tools/qeasingcurve.cpp index 34ad599..0828c61 100644 --- a/src/corelib/tools/qeasingcurve.cpp +++ b/src/corelib/tools/qeasingcurve.cpp @@ -61,7 +61,9 @@ between 0 and 1 should be. Easing curves allow transitions from one value to another to appear more natural than a simple constant speed would allow. The QEasingCurve class is usually used in conjunction with the QVariantAnimation and - QPropertyAnimation classes but can be used on its own. + QPropertyAnimation classes but can be used on its own. It is usually used to accelerate + the interpolation from zero velocity (ease in) or decelerate to zero velocity (ease out). + Ease in and ease out can also be combined in the same easing curve. To calculate the speed of the interpolation, the easing curve provides the function valueForProgress(), where the \a progress argument specifies the progress of the @@ -98,182 +100,183 @@ \value Linear \inlineimage qeasingcurve-linear.png \br - Easing equation function for a linear (t) easing curve. + Easing curve for a linear (t) function: + velocity is constant. \value InQuad \inlineimage qeasingcurve-inquad.png \br - Easing equation function for a quadratic (t^2) easing - in: accelerating from zero velocity. + Easing curve for a quadratic (t^2) function: + accelerating from zero velocity. \value OutQuad \inlineimage qeasingcurve-outquad.png \br - Easing equation function for a quadratic (t^2) easing - out: decelerating to zero velocity. + Easing curve for a quadratic (t^2) function: + decelerating to zero velocity. \value InOutQuad \inlineimage qeasingcurve-inoutquad.png \br - Easing equation function for a quadratic (t^2) easing - in/out: acceleration until halfway, then deceleration. + Easing curve for a quadratic (t^2) function: + acceleration until halfway, then deceleration. \value OutInQuad \inlineimage qeasingcurve-outinquad.png \br - Easing equation function for a quadratic (t^2) easing - out/in: deceleration until halfway, then acceleration. + Easing curve for a quadratic (t^2) function: + deceleration until halfway, then acceleration. \value InCubic \inlineimage qeasingcurve-incubic.png \br - Easing equation function for a cubic (t^3) easing - in: accelerating from zero velocity. + Easing curve for a cubic (t^3) function: + accelerating from zero velocity. \value OutCubic \inlineimage qeasingcurve-outcubic.png \br - Easing equation function for a cubic (t^3) easing - out: decelerating from zero velocity. + Easing curve for a cubic (t^3) function: + decelerating from zero velocity. \value InOutCubic \inlineimage qeasingcurve-inoutcubic.png \br - Easing equation function for a cubic (t^3) easing - in/out: acceleration until halfway, then deceleration. + Easing curve for a cubic (t^3) function: + acceleration until halfway, then deceleration. \value OutInCubic \inlineimage qeasingcurve-outincubic.png \br - Easing equation function for a cubic (t^3) easing - out/in: deceleration until halfway, then acceleration. + Easing curve for a cubic (t^3) function: + deceleration until halfway, then acceleration. \value InQuart \inlineimage qeasingcurve-inquart.png \br - Easing equation function for a quartic (t^4) easing - in: accelerating from zero velocity. + Easing curve for a quartic (t^4) function: + accelerating from zero velocity. \value OutQuart \inlineimage qeasingcurve-outquart.png \br - Easing equation function for a quartic (t^4) easing - out: decelerating from zero velocity. + Easing curve for a cubic (t^4) function: + decelerating from zero velocity. \value InOutQuart \inlineimage qeasingcurve-inoutquart.png \br - Easing equation function for a quartic (t^4) easing - in/out: acceleration until halfway, then deceleration. + Easing curve for a cubic (t^4) function: + acceleration until halfway, then deceleration. \value OutInQuart \inlineimage qeasingcurve-outinquart.png \br - Easing equation function for a quartic (t^4) easing - out/in: deceleration until halfway, then acceleration. + Easing curve for a cubic (t^4) function: + deceleration until halfway, then acceleration. \value InQuint \inlineimage qeasingcurve-inquint.png \br - Easing equation function for a quintic (t^5) easing + Easing curve for a quintic (t^5) easing in: accelerating from zero velocity. \value OutQuint \inlineimage qeasingcurve-outquint.png \br - Easing equation function for a quintic (t^5) easing - out: decelerating from zero velocity. + Easing curve for a cubic (t^5) function: + decelerating from zero velocity. \value InOutQuint \inlineimage qeasingcurve-inoutquint.png \br - Easing equation function for a quintic (t^5) easing - in/out: acceleration until halfway, then deceleration. + Easing curve for a cubic (t^5) function: + acceleration until halfway, then deceleration. \value OutInQuint \inlineimage qeasingcurve-outinquint.png \br - Easing equation function for a quintic (t^5) easing - out/in: deceleration until halfway, then acceleration. + Easing curve for a cubic (t^5) function: + deceleration until halfway, then acceleration. \value InSine \inlineimage qeasingcurve-insine.png \br - Easing equation function for a sinusoidal (sin(t)) easing - in: accelerating from zero velocity. + Easing curve for a sinusoidal (sin(t)) function: + accelerating from zero velocity. \value OutSine \inlineimage qeasingcurve-outsine.png \br - Easing equation function for a sinusoidal (sin(t)) easing - out: decelerating from zero velocity. + Easing curve for a sinusoidal (sin(t)) function: + decelerating from zero velocity. \value InOutSine \inlineimage qeasingcurve-inoutsine.png \br - Easing equation function for a sinusoidal (sin(t)) easing - in/out: acceleration until halfway, then deceleration. + Easing curve for a sinusoidal (sin(t)) function: + acceleration until halfway, then deceleration. \value OutInSine \inlineimage qeasingcurve-outinsine.png \br - Easing equation function for a sinusoidal (sin(t)) easing - out/in: deceleration until halfway, then acceleration. + Easing curve for a sinusoidal (sin(t)) function: + deceleration until halfway, then acceleration. \value InExpo \inlineimage qeasingcurve-inexpo.png \br - Easing equation function for an exponential (2^t) easing - in: accelerating from zero velocity. + Easing curve for an exponential (2^t) function: + accelerating from zero velocity. \value OutExpo \inlineimage qeasingcurve-outexpo.png \br - Easing equation function for an exponential (2^t) easing - out: decelerating from zero velocity. + Easing curve for an exponential (2^t) function: + decelerating from zero velocity. \value InOutExpo \inlineimage qeasingcurve-inoutexpo.png \br - Easing equation function for an exponential (2^t) easing - in/out: acceleration until halfway, then deceleration. + Easing curve for an exponential (2^t) function: + acceleration until halfway, then deceleration. \value OutInExpo \inlineimage qeasingcurve-outinexpo.png \br - Easing equation function for an exponential (2^t) easing - out/in: deceleration until halfway, then acceleration. + Easing curve for an exponential (2^t) function: + deceleration until halfway, then acceleration. \value InCirc \inlineimage qeasingcurve-incirc.png \br - Easing equation function for a circular (sqrt(1-t^2)) easing - in: accelerating from zero velocity. + Easing curve for a circular (sqrt(1-t^2)) function: + accelerating from zero velocity. \value OutCirc \inlineimage qeasingcurve-outcirc.png \br - Easing equation function for a circular (sqrt(1-t^2)) easing - out: decelerating from zero velocity. + Easing curve for a circular (sqrt(1-t^2)) function: + decelerating from zero velocity. \value InOutCirc \inlineimage qeasingcurve-inoutcirc.png \br - Easing equation function for a circular (sqrt(1-t^2)) easing - in/out: acceleration until halfway, then deceleration. + Easing curve for a circular (sqrt(1-t^2)) function: + acceleration until halfway, then deceleration. \value OutInCirc \inlineimage qeasingcurve-outincirc.png \br - Easing equation function for a circular (sqrt(1-t^2)) easing - out/in: deceleration until halfway, then acceleration. + Easing curve for a circular (sqrt(1-t^2)) function: + deceleration until halfway, then acceleration. \value InElastic \inlineimage qeasingcurve-inelastic.png \br - Easing equation function for an elastic - (exponentially decaying sine wave) easing in: + Easing curve for an elastic + (exponentially decaying sine wave) function: accelerating from zero velocity. The peak amplitude can be set with the \e amplitude parameter, and the period of decay by the \e period parameter. \value OutElastic \inlineimage qeasingcurve-outelastic.png \br - Easing equation function for an elastic - (exponentially decaying sine wave) easing out: + Easing curve for an elastic + (exponentially decaying sine wave) function: decelerating from zero velocity. The peak amplitude can be set with the \e amplitude parameter, and the period of decay by the \e period parameter. \value InOutElastic \inlineimage qeasingcurve-inoutelastic.png \br - Easing equation function for an elastic - (exponentially decaying sine wave) easing in/out: + Easing curve for an elastic + (exponentially decaying sine wave) function: acceleration until halfway, then deceleration. \value OutInElastic \inlineimage qeasingcurve-outinelastic.png \br - Easing equation function for an elastic - (exponentially decaying sine wave) easing out/in: + Easing curve for an elastic + (exponentially decaying sine wave) function: deceleration until halfway, then acceleration. \value InBack \inlineimage qeasingcurve-inback.png \br - Easing equation function for a back (overshooting - cubic easing: (s+1)*t^3 - s*t^2) easing in: + Easing curve for a back (overshooting + cubic function: (s+1)*t^3 - s*t^2) easing in: accelerating from zero velocity. \value OutBack \inlineimage qeasingcurve-outback.png \br - Easing equation function for a back (overshooting - cubic easing: (s+1)*t^3 - s*t^2) easing out: - decelerating from zero velocity. + Easing curve for a back (overshooting + cubic function: (s+1)*t^3 - s*t^2) easing out: + decelerating to zero velocity. \value InOutBack \inlineimage qeasingcurve-inoutback.png \br - Easing equation function for a back (overshooting - cubic easing: (s+1)*t^3 - s*t^2) easing in/out: + Easing curve for a back (overshooting + cubic function: (s+1)*t^3 - s*t^2) easing in/out: acceleration until halfway, then deceleration. \value OutInBack \inlineimage qeasingcurve-outinback.png \br - Easing equation function for a back (overshooting + Easing curve for a back (overshooting cubic easing: (s+1)*t^3 - s*t^2) easing out/in: deceleration until halfway, then acceleration. \value InBounce \inlineimage qeasingcurve-inbounce.png \br - Easing equation function for a bounce (exponentially - decaying parabolic bounce) easing in: accelerating + Easing curve for a bounce (exponentially + decaying parabolic bounce) function: accelerating from zero velocity. \value OutBounce \inlineimage qeasingcurve-outbounce.png \br - Easing equation function for a bounce (exponentially - decaying parabolic bounce) easing out: decelerating + Easing curve for a bounce (exponentially + decaying parabolic bounce) function: decelerating from zero velocity. \value InOutBounce \inlineimage qeasingcurve-inoutbounce.png \br - Easing equation function for a bounce (exponentially - decaying parabolic bounce) easing in/out: + Easing curve for a bounce (exponentially + decaying parabolic bounce) function easing in/out: acceleration until halfway, then deceleration. \value OutInBounce \inlineimage qeasingcurve-outinbounce.png \br - Easing equation function for a bounce (exponentially - decaying parabolic bounce) easing out/in: + Easing curve for a bounce (exponentially + decaying parabolic bounce) function easing out/in: deceleration until halfway, then acceleration. \omitvalue InCurve \omitvalue OutCurve -- cgit v0.12 From c5eff466432988b338d9d0f340e9d31955109eea Mon Sep 17 00:00:00 2001 From: Harald Fernengel Date: Tue, 21 Jul 2009 12:51:14 +0200 Subject: Compile with QT_NO_PROCESS or QT_NO_SETTINGS Feature define logic was wrong Reviewed-by: Robert Griebl --- src/testlib/qtestcase.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp index 70c8c8d..5de37dc 100644 --- a/src/testlib/qtestcase.cpp +++ b/src/testlib/qtestcase.cpp @@ -937,7 +937,7 @@ static void qParseArgs(int argc, char *argv[]) " -iterations n : Sets the number of accumulation iterations.\n" " -median n : Sets the number of median iterations.\n" " -vb : Print out verbose benchmarking information.\n" -#if !defined(QT_NO_PROCESS) || !defined(QT_NO_SETTINGS) +#if !defined(QT_NO_PROCESS) && !defined(QT_NO_SETTINGS) " -chart : Create chart based on the benchmark result.\n" #endif "\n" @@ -1053,7 +1053,7 @@ static void qParseArgs(int argc, char *argv[]) } else if (strcmp(argv[i], "-vb") == 0) { QBenchmarkGlobalData::current->verboseOutput = true; -#if !defined(QT_NO_PROCESS) || !defined(QT_NO_SETTINGS) +#if !defined(QT_NO_PROCESS) && !defined(QT_NO_SETTINGS) } else if (strcmp(argv[i], "-chart") == 0) { QBenchmarkGlobalData::current->createChart = true; QTestLog::setLogMode(QTestLog::XML); @@ -1627,7 +1627,7 @@ int QTest::qExec(QObject *testObject, int argc, char **argv) #endif -#if !defined(QT_NO_PROCESS) || !defined(QT_NO_SETTINGS) +#if !defined(QT_NO_PROCESS) && !defined(QT_NO_SETTINGS) if (QBenchmarkGlobalData::current->createChart) { QString chartLocation = QLibraryInfo::location(QLibraryInfo::BinariesPath); #ifdef Q_OS_WIN -- cgit v0.12 From ffd978a76d91aaef92a36c465325256633f2fa97 Mon Sep 17 00:00:00 2001 From: "Bradley T. Hughes" Date: Tue, 21 Jul 2009 12:27:42 +0200 Subject: Remove unused gesture related defines and structures We don't use all of them. I also changed the typedefs for the touch related functions to follow the same naming convention. --- src/gui/kernel/qapplication_p.h | 141 ++++++++++++------------------------ src/gui/kernel/qapplication_win.cpp | 16 ++-- 2 files changed, 56 insertions(+), 101 deletions(-) diff --git a/src/gui/kernel/qapplication_p.h b/src/gui/kernel/qapplication_p.h index 3692160..595f220 100644 --- a/src/gui/kernel/qapplication_p.h +++ b/src/gui/kernel/qapplication_p.h @@ -192,99 +192,54 @@ extern "C" { #endif #if defined(Q_WS_WIN) -typedef BOOL (WINAPI *qt_RegisterTouchWindowPtr)(HWND, ULONG); -typedef BOOL (WINAPI *qt_GetTouchInputInfoPtr)(HANDLE, UINT, PVOID, int); -typedef BOOL (WINAPI *qt_CloseTouchInputHandlePtr)(HANDLE); - -typedef BOOL (WINAPI *PtrGetGestureInfo)(HANDLE hGestureInfo, PVOID pGestureInfo); -typedef BOOL (WINAPI *PtrGetGestureExtraArgs)(HANDLE hGestureInfo, UINT cbExtraArgs, PBYTE pExtraArgs); -typedef BOOL (WINAPI *PtrCloseGestureInfoHandle)(HANDLE hGestureInfo); -typedef BOOL (WINAPI *PtrSetGestureConfig)(HWND hwnd, DWORD dwReserved, UINT cIDs, - PVOID pGestureConfig, - UINT cbSize); -typedef BOOL (WINAPI *PtrGetGestureConfig)(HWND hwnd, DWORD dwReserved, - DWORD dwFlags, PUINT pcIDs, - PVOID pGestureConfig, - UINT cbSize); - -typedef BOOL (WINAPI *PtrBeginPanningFeedback)(HWND hwnd); -typedef BOOL (WINAPI *PtrUpdatePanningFeedback)(HWND hwnd, LONG, LONG, BOOL); -typedef BOOL (WINAPI *PtrEndPanningFeedback)(HWND hwnd, BOOL); +typedef BOOL (WINAPI *PtrRegisterTouchWindow)(HWND, ULONG); +typedef BOOL (WINAPI *PtrGetTouchInputInfo)(HANDLE, UINT, PVOID, int); +typedef BOOL (WINAPI *PtrCloseTouchInputHandle)(HANDLE); + +typedef BOOL (WINAPI *PtrGetGestureInfo)(HANDLE, PVOID); +typedef BOOL (WINAPI *PtrGetGestureExtraArgs)(HANDLE, UINT, PBYTE); +typedef BOOL (WINAPI *PtrCloseGestureInfoHandle)(HANDLE); +typedef BOOL (WINAPI *PtrSetGestureConfig)(HWND, DWORD, UINT, PVOID, UINT); +typedef BOOL (WINAPI *PtrGetGestureConfig)(HWND, DWORD, DWORD, PUINT, PVOID, UINT); + +typedef BOOL (WINAPI *PtrBeginPanningFeedback)(HWND); +typedef BOOL (WINAPI *PtrUpdatePanningFeedback)(HWND, LONG, LONG, BOOL); +typedef BOOL (WINAPI *PtrEndPanningFeedback)(HWND, BOOL); #ifndef WM_GESTURE +# define WM_GESTURE 0x0119 + +# define GID_BEGIN 1 +# define GID_END 2 +# define GID_ZOOM 3 +# define GID_PAN 4 +# define GID_ROTATE 5 +# define GID_TWOFINGERTAP 6 +# define GID_ROLLOVER 7 -#define WM_GESTURE 0x0119 -#define WM_GESTURE_NOTIFY 0x011A - -DECLARE_HANDLE(HGESTUREINFO); - -#define GF_BEGIN 0x00000001 -#define GF_INERTIA 0x00000002 -#define GF_END 0x00000004 - -/* - * Gesture IDs - */ -#define GID_BEGIN 1 -#define GID_END 2 -#define GID_ZOOM 3 -#define GID_PAN 4 -#define GID_ROTATE 5 -#define GID_TWOFINGERTAP 6 -#define GID_ROLLOVER 7 - -typedef struct tagGESTUREINFO { - UINT cbSize; // size, in bytes, of this structure (including variable length Args field) - DWORD dwFlags; // see GF_* flags - DWORD dwID; // gesture ID, see GID_* defines - HWND hwndTarget; // handle to window targeted by this gesture - POINTS ptsLocation; // current location of this gesture - DWORD dwInstanceID; // internally used - DWORD dwSequenceID; // internally used - ULONGLONG ullArguments; // arguments for gestures whose arguments fit in 8 BYTES - UINT cbExtraArgs; // size, in bytes, of extra arguments, if any, that accompany this gesture -} GESTUREINFO, *PGESTUREINFO; -typedef GESTUREINFO const * PCGESTUREINFO; - -typedef struct tagGESTURENOTIFYSTRUCT { - UINT cbSize; // size, in bytes, of this structure - DWORD dwFlags; // unused - HWND hwndTarget; // handle to window targeted by the gesture - POINTS ptsLocation; // starting location - DWORD dwInstanceID; // internally used -} GESTURENOTIFYSTRUCT, *PGESTURENOTIFYSTRUCT; - -/* - * Gesture argument helpers - * - Angle should be a double in the range of -2pi to +2pi - * - Argument should be an unsigned 16-bit value - */ -#define GID_ROTATE_ANGLE_TO_ARGUMENT(_arg_) ((USHORT)((((_arg_) + 2.0 * 3.14159265) / (4.0 * 3.14159265)) * 65535.0)) -#define GID_ROTATE_ANGLE_FROM_ARGUMENT(_arg_) ((((double)(_arg_) / 65535.0) * 4.0 * 3.14159265) - 2.0 * 3.14159265) - -typedef struct tagGESTURECONFIG { - DWORD dwID; // gesture ID - DWORD dwWant; // settings related to gesture ID that are to be turned on - DWORD dwBlock; // settings related to gesture ID that are to be turned off -} GESTURECONFIG, *PGESTURECONFIG; - -#define GC_ALLGESTURES 0x00000001 -#define GC_ZOOM 0x00000001 -#define GC_PAN 0x00000001 -#define GC_PAN_WITH_SINGLE_FINGER_VERTICALLY 0x00000002 -#define GC_PAN_WITH_SINGLE_FINGER_HORIZONTALLY 0x00000004 -#define GC_PAN_WITH_GUTTER 0x00000008 -#define GC_PAN_WITH_INERTIA 0x00000010 -#define GC_ROTATE 0x00000001 -#define GC_TWOFINGERTAP 0x00000001 -#define GC_ROLLOVER 0x00000001 -#define GESTURECONFIGMAXCOUNT 256 // Maximum number of gestures that can be included - // in a single call to SetGestureConfig / GetGestureConfig - - - -#define GCF_INCLUDE_ANCESTORS 0x00000001 // If specified, GetGestureConfig returns consolidated configuration - // for the specified window and it's parent window chain +typedef struct tagGESTUREINFO +{ + UINT cbSize; + DWORD dwFlags; + DWORD dwID; + HWND hwndTarget; + POINTS ptsLocation; + DWORD dwInstanceID; + DWORD dwSequenceID; + ULONGLONG ullArguments; + UINT cbExtraArgs; +} GESTUREINFO; + +# define GC_PAN 0x00000001 +# define GC_PAN_WITH_SINGLE_FINGER_VERTICALLY 0x00000002 +# define GC_PAN_WITH_SINGLE_FINGER_HORIZONTALLY 0x00000004 + +typedef struct tagGESTURECONFIG +{ + DWORD dwID; + DWORD dwWant; + DWORD dwBlock; +} GESTURECONFIG; #endif // WM_GESTURE @@ -559,9 +514,9 @@ public: const QList &touchPoints); #if defined(Q_WS_WIN) - static qt_RegisterTouchWindowPtr RegisterTouchWindow; - static qt_GetTouchInputInfoPtr GetTouchInputInfo; - static qt_CloseTouchInputHandlePtr CloseTouchInputHandle; + static PtrRegisterTouchWindow RegisterTouchWindow; + static PtrGetTouchInputInfo GetTouchInputInfo; + static PtrCloseTouchInputHandle CloseTouchInputHandle; QHash touchInputIDToTouchPointID; QList appAllTouchPoints; diff --git a/src/gui/kernel/qapplication_win.cpp b/src/gui/kernel/qapplication_win.cpp index cbcac9a..d5c820c 100644 --- a/src/gui/kernel/qapplication_win.cpp +++ b/src/gui/kernel/qapplication_win.cpp @@ -3727,7 +3727,7 @@ bool QETWidget::translateGestureEvent(const MSG &msg) gi.dwSequenceID = 0; QApplicationPrivate *qAppPriv = getQApplicationPrivateInternal(); - BOOL bResult = qAppPriv->GetGestureInfo((HGESTUREINFO)msg.lParam, &gi); + BOOL bResult = qAppPriv->GetGestureInfo((HANDLE)msg.lParam, &gi); const QPoint widgetPos = QPoint(gi.ptsLocation.x, gi.ptsLocation.y); QWidget *alienWidget = !internalWinId() ? this : childAt(widgetPos); @@ -3765,7 +3765,7 @@ bool QETWidget::translateGestureEvent(const MSG &msg) if (dwErr > 0) qWarning() << "translateGestureEvent: error = " << dwErr; } - qAppPriv->CloseGestureInfoHandle((HGESTUREINFO)msg.lParam); + qAppPriv->CloseGestureInfoHandle((HANDLE)msg.lParam); return true; } @@ -3951,17 +3951,17 @@ void QSessionManager::cancel() #endif //QT_NO_SESSIONMANAGER -qt_RegisterTouchWindowPtr QApplicationPrivate::RegisterTouchWindow = 0; -qt_GetTouchInputInfoPtr QApplicationPrivate::GetTouchInputInfo = 0; -qt_CloseTouchInputHandlePtr QApplicationPrivate::CloseTouchInputHandle = 0; +PtrRegisterTouchWindow QApplicationPrivate::RegisterTouchWindow = 0; +PtrGetTouchInputInfo QApplicationPrivate::GetTouchInputInfo = 0; +PtrCloseTouchInputHandle QApplicationPrivate::CloseTouchInputHandle = 0; void QApplicationPrivate::initializeMultitouch_sys() { QLibrary library(QLatin1String("user32")); // MinGW (g++ 3.4.5) accepts only C casts. - RegisterTouchWindow = (qt_RegisterTouchWindowPtr)(library.resolve("RegisterTouchWindow")); - GetTouchInputInfo = (qt_GetTouchInputInfoPtr)(library.resolve("GetTouchInputInfo")); - CloseTouchInputHandle = (qt_CloseTouchInputHandlePtr)(library.resolve("CloseTouchInputHandle")); + RegisterTouchWindow = (PtrRegisterTouchWindow)(library.resolve("RegisterTouchWindow")); + GetTouchInputInfo = (PtrGetTouchInputInfo)(library.resolve("GetTouchInputInfo")); + CloseTouchInputHandle = (PtrCloseTouchInputHandle)(library.resolve("CloseTouchInputHandle")); touchInputIDToTouchPointID.clear(); } -- cgit v0.12 From 4b4e4ecf808b036e906c3bf22ce97b56808bb20e Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Tue, 21 Jul 2009 12:58:07 +0200 Subject: Remove Stickman editor The editor was a just a detail to make the animations and shouldn't be included in the example. --- .../animation/stickman/editor/animationdialog.cpp | 192 --------------------- .../animation/stickman/editor/animationdialog.h | 84 --------- examples/animation/stickman/editor/editor.pri | 2 - examples/animation/stickman/editor/mainwindow.cpp | 76 -------- examples/animation/stickman/editor/mainwindow.h | 58 ------- examples/animation/stickman/graphicsview.cpp | 23 --- examples/animation/stickman/stickman.pro | 2 - 7 files changed, 437 deletions(-) delete mode 100644 examples/animation/stickman/editor/animationdialog.cpp delete mode 100644 examples/animation/stickman/editor/animationdialog.h delete mode 100644 examples/animation/stickman/editor/editor.pri delete mode 100644 examples/animation/stickman/editor/mainwindow.cpp delete mode 100644 examples/animation/stickman/editor/mainwindow.h diff --git a/examples/animation/stickman/editor/animationdialog.cpp b/examples/animation/stickman/editor/animationdialog.cpp deleted file mode 100644 index 853046d..0000000 --- a/examples/animation/stickman/editor/animationdialog.cpp +++ /dev/null @@ -1,192 +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 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://www.qtsoftware.com/contact. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "animationdialog.h" -#include "stickman.h" -#include "animation.h" -#include "node.h" - -#include -#include -#include -#include -#include -#include -#include -#include - -AnimationDialog::AnimationDialog(StickMan *stickman, QWidget *parent) - : QDialog(parent), m_animation(0), m_stickman(stickman) -{ - initUi(); -} - -AnimationDialog::~AnimationDialog() -{ - delete m_animation; -} - -void AnimationDialog::initUi() -{ - setWindowTitle("Animation"); - setEnabled(false); - - // Second page - m_currentFrame = new QSpinBox(); - m_totalFrames = new QSpinBox(); - m_name = new QLineEdit(); - - connect(m_currentFrame, SIGNAL(valueChanged(int)), this, SLOT(currentFrameChanged(int))); - connect(m_totalFrames, SIGNAL(valueChanged(int)), this, SLOT(totalFramesChanged(int))); - connect(m_name, SIGNAL(textChanged(QString)), this, SLOT(setCurrentAnimationName(QString))); - - QGridLayout *gridLayout = new QGridLayout(this); - gridLayout->addWidget(new QLabel("Name:"), 0, 0, 1, 2); - gridLayout->addWidget(m_name, 0, 2, 1, 2); - gridLayout->addWidget(new QLabel("Frame:"), 1, 0); - gridLayout->addWidget(m_currentFrame, 1, 1); - gridLayout->addWidget(new QLabel("of total # of frames: "), 1, 2); - gridLayout->addWidget(m_totalFrames, 1, 3); -} - -void AnimationDialog::initFromAnimation() -{ - m_currentFrame->setRange(0, m_animation->totalFrames()-1); - m_currentFrame->setValue(m_animation->currentFrame()); - - m_totalFrames->setRange(1, 1000); - m_totalFrames->setValue(m_animation->totalFrames()); - - m_name->setText(m_animation->name()); -} - -void AnimationDialog::saveAnimation() -{ - saveCurrentFrame(); - - QString fileName = QFileDialog::getSaveFileName(this, "Save animation"); - - QFile file(fileName); - if (file.open(QIODevice::WriteOnly)) - m_animation->save(&file); -} - -void AnimationDialog::loadAnimation() -{ - if (maybeSave() != QMessageBox::Cancel) { - QString fileName = QFileDialog::getOpenFileName(this, "Open animation"); - - QFile file(fileName); - if (file.open(QIODevice::ReadOnly)) { - if (m_animation == 0) - newAnimation(); - - m_animation->load(&file); - stickManFromCurrentFrame(); - initFromAnimation(); - } - } -} - -QMessageBox::StandardButton AnimationDialog::maybeSave() -{ - if (m_animation == 0) - return QMessageBox::No; - - QMessageBox::StandardButton button = QMessageBox::question(this, "Save?", "Do you want to save your changes?", - QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel); - if (button == QMessageBox::Save) - saveAnimation(); - - return button; -} - -void AnimationDialog::newAnimation() -{ - if (maybeSave() != QMessageBox::Cancel) { - setEnabled(true); - delete m_animation; - m_animation = new Animation(); - initFromAnimation(); - } -} - -// Gets the data from the stickman and stores it in current frame -void AnimationDialog::saveCurrentFrame() -{ - int count = m_stickman->nodeCount(); - m_animation->setNodeCount(count); - for (int i=0; inode(i); - m_animation->setNodePos(i, node->pos()); - } -} - -// Gets the data from the current frame and sets the stickman -void AnimationDialog::stickManFromCurrentFrame() -{ - int count = m_animation->nodeCount(); - for (int i=0;inode(i); - node->setPos(m_animation->nodePos(i)); - } -} - -void AnimationDialog::currentFrameChanged(int currentFrame) -{ - saveCurrentFrame(); - qDebug("currentFrame: %d", currentFrame); - m_animation->setCurrentFrame(currentFrame); - stickManFromCurrentFrame(); - initFromAnimation(); -} - -void AnimationDialog::totalFramesChanged(int totalFrames) -{ - m_animation->setTotalFrames(totalFrames); - stickManFromCurrentFrame(); - initFromAnimation(); -} - -void AnimationDialog::setCurrentAnimationName(const QString &name) -{ - m_animation->setName(name); -} diff --git a/examples/animation/stickman/editor/animationdialog.h b/examples/animation/stickman/editor/animationdialog.h deleted file mode 100644 index 293f0d4..0000000 --- a/examples/animation/stickman/editor/animationdialog.h +++ /dev/null @@ -1,84 +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 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://www.qtsoftware.com/contact. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef ANIMATIONDIALOG_H -#define ANIMATIONDIALOG_H - -#include -#include - -QT_BEGIN_NAMESPACE -class QSpinBox; -class QLineEdit; -QT_END_NAMESPACE -class StickMan; -class Animation; -class AnimationDialog: public QDialog -{ - Q_OBJECT -public: - AnimationDialog(StickMan *stickMan, QWidget *parent = 0); - ~AnimationDialog(); - -public slots: - void currentFrameChanged(int currentFrame); - void totalFramesChanged(int totalFrames); - void setCurrentAnimationName(const QString &name); - - void newAnimation(); - void saveAnimation(); - void loadAnimation(); - -private: - void saveCurrentFrame(); - void stickManFromCurrentFrame(); - void initFromAnimation(); - void initUi(); - QMessageBox::StandardButton maybeSave(); - - QSpinBox *m_currentFrame; - QSpinBox *m_totalFrames; - QLineEdit *m_name; - Animation *m_animation; - StickMan *m_stickman; -}; - -#endif diff --git a/examples/animation/stickman/editor/editor.pri b/examples/animation/stickman/editor/editor.pri deleted file mode 100644 index 7ad9edb..0000000 --- a/examples/animation/stickman/editor/editor.pri +++ /dev/null @@ -1,2 +0,0 @@ -SOURCES += $$PWD/animationdialog.cpp $$PWD/mainwindow.cpp -HEADERS += $$PWD/animationdialog.h $$PWD/mainwindow.h diff --git a/examples/animation/stickman/editor/mainwindow.cpp b/examples/animation/stickman/editor/mainwindow.cpp deleted file mode 100644 index e1d08cc..0000000 --- a/examples/animation/stickman/editor/mainwindow.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 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://www.qtsoftware.com/contact. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "mainwindow.h" -#include "animationdialog.h" -#include "stickman.h" - -#include -#include - -MainWindow::MainWindow(StickMan *stickMan) -{ - initActions(stickMan); -} - -MainWindow::~MainWindow() -{ -} - -void MainWindow::initActions(StickMan *stickMan) -{ - AnimationDialog *dialog = new AnimationDialog(stickMan, this); - dialog->show(); - - QMenu *fileMenu = menuBar()->addMenu("&File"); - QAction *loadAction = fileMenu->addAction("&Open"); - QAction *saveAction = fileMenu->addAction("&Save"); - QAction *exitAction = fileMenu->addAction("E&xit"); - - QMenu *animationMenu = menuBar()->addMenu("&Animation"); - QAction *newAnimationAction = animationMenu->addAction("&New animation"); - - connect(loadAction, SIGNAL(triggered()), dialog, SLOT(loadAnimation())); - connect(saveAction, SIGNAL(triggered()), dialog, SLOT(saveAnimation())); - connect(exitAction, SIGNAL(triggered()), QApplication::instance(), SLOT(quit())); - connect(newAnimationAction, SIGNAL(triggered()), dialog, SLOT(newAnimation())); - -} diff --git a/examples/animation/stickman/editor/mainwindow.h b/examples/animation/stickman/editor/mainwindow.h deleted file mode 100644 index ef122d9..0000000 --- a/examples/animation/stickman/editor/mainwindow.h +++ /dev/null @@ -1,58 +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 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://www.qtsoftware.com/contact. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef MAINWINDOW_H -#define MAINWINDOW_H - -#include - -class StickMan; -class MainWindow: public QMainWindow -{ -public: - MainWindow(StickMan *stickMan); - ~MainWindow(); - -private: - void initActions(StickMan *stickMan); -}; - -#endif diff --git a/examples/animation/stickman/graphicsview.cpp b/examples/animation/stickman/graphicsview.cpp index 760c31b..89f2430 100644 --- a/examples/animation/stickman/graphicsview.cpp +++ b/examples/animation/stickman/graphicsview.cpp @@ -40,7 +40,6 @@ ****************************************************************************/ #include "graphicsview.h" -#include "editor/mainwindow.h" #include "stickman.h" #include @@ -53,28 +52,6 @@ void GraphicsView::keyPressEvent(QKeyEvent *e) { if (e->key() == Qt::Key_Escape) close(); - -#if 0 - if (e->key() == Qt::Key_F1) { - if (m_editor == 0) { - QGraphicsScene *scene = new QGraphicsScene; - StickMan *stickMan = new StickMan; - stickMan->setDrawSticks(true); - scene->addItem(stickMan); - - QGraphicsView *view = new QGraphicsView; - view->setBackgroundBrush(Qt::black); - view->setRenderHints(QPainter::Antialiasing); - view->setScene(scene); - - m_editor = new MainWindow(stickMan); - m_editor->setCentralWidget(view); - } - - m_editor->showMaximized(); - } -#endif - emit keyPressed(Qt::Key(e->key())); } diff --git a/examples/animation/stickman/stickman.pro b/examples/animation/stickman/stickman.pro index 1dbbce9..7f8be33 100644 --- a/examples/animation/stickman/stickman.pro +++ b/examples/animation/stickman/stickman.pro @@ -12,8 +12,6 @@ SOURCES += main.cpp \ INCLUDEPATH += $$PWD -include(editor/editor.pri) - # install target.path = $$[QT_INSTALL_EXAMPLES]/animation/stickman sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS stickman.pro -- cgit v0.12 From 2db22b1b12cc7579d08a83ad889efe7f8f07c843 Mon Sep 17 00:00:00 2001 From: Harald Fernengel Date: Tue, 21 Jul 2009 13:18:46 +0200 Subject: use /usr/bin/env perl as interpreter --- tests/auto/test.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/auto/test.pl b/tests/auto/test.pl index 9fd5c9d..a9e3da8 100755 --- a/tests/auto/test.pl +++ b/tests/auto/test.pl @@ -1,4 +1,4 @@ -#!/usr/bin/perl +#!/usr/bin/env perl use strict; use Cwd; -- cgit v0.12 From 31e358f2290c145b839fc5b7b277922c1ab6e19b Mon Sep 17 00:00:00 2001 From: Harald Fernengel Date: Tue, 21 Jul 2009 13:19:49 +0200 Subject: fix tests for QT_NO_PROCESS and when running tests as root --- tests/auto/bic/tst_bic.cpp | 6 ++++- .../auto/compilerwarnings/tst_compilerwarnings.cpp | 6 ++++- tests/auto/moc/tst_moc.cpp | 20 ++++++++-------- tests/auto/qapplication/tst_qapplication.cpp | 2 ++ tests/auto/qbytearray/tst_qbytearray.cpp | 2 ++ tests/auto/qclipboard/tst_qclipboard.cpp | 2 ++ tests/auto/qcopchannel/tst_qcopchannel.cpp | 2 +- tests/auto/qdir/tst_qdir.cpp | 17 ++++++++++--- tests/auto/qdirectpainter/tst_qdirectpainter.cpp | 4 ++++ tests/auto/qfile/tst_qfile.cpp | 28 +++++++++++++++------- tests/auto/qobject/tst_qobject.cpp | 4 ++++ tests/auto/qprocess/tst_qprocess.cpp | 5 ++++ tests/auto/qsettings/tst_qsettings.cpp | 6 +++-- tests/auto/qtextcodec/tst_qtextcodec.cpp | 4 ++++ 14 files changed, 82 insertions(+), 26 deletions(-) diff --git a/tests/auto/bic/tst_bic.cpp b/tests/auto/bic/tst_bic.cpp index cec5e76..36c35ff 100644 --- a/tests/auto/bic/tst_bic.cpp +++ b/tests/auto/bic/tst_bic.cpp @@ -43,6 +43,10 @@ #include #include +#ifdef QT_NO_PROCESS +QTEST_NOOP_MAIN +#else + #include "qbic.h" #include @@ -367,4 +371,4 @@ void tst_Bic::sizesAndVTables() QTEST_APPLESS_MAIN(tst_Bic) #include "tst_bic.moc" - +#endif diff --git a/tests/auto/compilerwarnings/tst_compilerwarnings.cpp b/tests/auto/compilerwarnings/tst_compilerwarnings.cpp index 57795c9..d5fef1b 100644 --- a/tests/auto/compilerwarnings/tst_compilerwarnings.cpp +++ b/tests/auto/compilerwarnings/tst_compilerwarnings.cpp @@ -47,6 +47,10 @@ #include +#ifdef QT_NO_PROCESS +QTEST_NOOP_MAIN +#else + #include QT_USE_NAMESPACE @@ -248,4 +252,4 @@ void tst_CompilerWarnings::warnings() QTEST_APPLESS_MAIN(tst_CompilerWarnings) #include "tst_compilerwarnings.moc" - +#endif // QT_NO_PROCESS diff --git a/tests/auto/moc/tst_moc.cpp b/tests/auto/moc/tst_moc.cpp index 3a40ae0..898cfe1 100644 --- a/tests/auto/moc/tst_moc.cpp +++ b/tests/auto/moc/tst_moc.cpp @@ -510,7 +510,7 @@ private: void tst_Moc::initTestCase() { -#if defined(Q_OS_UNIX) +#if defined(Q_OS_UNIX) && !defined(QT_NO_PROCESS) QProcess proc; proc.start("qmake", QStringList() << "-query" << "QT_INSTALL_HEADERS"); QVERIFY(proc.waitForFinished()); @@ -555,7 +555,7 @@ void tst_Moc::oldStyleCasts() #ifdef MOC_CROSS_COMPILED QSKIP("Not tested when cross-compiled", SkipAll); #endif -#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) +#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && !defined(QT_NO_PROCESS) QProcess proc; proc.start("moc", QStringList(srcify("/oldstyle-casts.h"))); QVERIFY(proc.waitForFinished()); @@ -585,7 +585,7 @@ void tst_Moc::warnOnExtraSignalSlotQualifiaction() #ifdef MOC_CROSS_COMPILED QSKIP("Not tested when cross-compiled", SkipAll); #endif -#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) +#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && !defined(QT_NO_PROCESS) QProcess proc; proc.start("moc", QStringList(srcify("extraqualification.h"))); QVERIFY(proc.waitForFinished()); @@ -627,7 +627,7 @@ void tst_Moc::inputFileNameWithDotsButNoExtension() #ifdef MOC_CROSS_COMPILED QSKIP("Not tested when cross-compiled", SkipAll); #endif -#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) +#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && !defined(QT_NO_PROCESS) QProcess proc; proc.setWorkingDirectory(QString(SRCDIR) + "/task71021"); proc.start("moc", QStringList("../Header")); @@ -835,7 +835,7 @@ void tst_Moc::warnOnMultipleInheritance() #ifdef MOC_CROSS_COMPILED QSKIP("Not tested when cross-compiled", SkipAll); #endif -#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) +#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && !defined(QT_NO_PROCESS) QProcess proc; QStringList args; args << "-I" << qtIncludePath + "/QtGui" @@ -858,7 +858,7 @@ void tst_Moc::forgottenQInterface() #ifdef MOC_CROSS_COMPILED QSKIP("Not tested when cross-compiled", SkipAll); #endif -#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) +#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && !defined(QT_NO_PROCESS) QProcess proc; QStringList args; args << "-I" << qtIncludePath + "/QtCore" @@ -940,7 +940,7 @@ void tst_Moc::frameworkSearchPath() #ifdef MOC_CROSS_COMPILED QSKIP("Not tested when cross-compiled", SkipAll); #endif -#if defined(Q_OS_UNIX) +#if defined(Q_OS_UNIX) && !defined(QT_NO_PROCESS) QStringList args; args << "-F" << srcify(".") << srcify("interface-from-framework.h") @@ -978,7 +978,7 @@ void tst_Moc::templateGtGt() #ifdef MOC_CROSS_COMPILED QSKIP("Not tested when cross-compiled", SkipAll); #endif -#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) +#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && !defined(QT_NO_PROCESS) QProcess proc; proc.start("moc", QStringList(srcify("template-gtgt.h"))); QVERIFY(proc.waitForFinished()); @@ -994,7 +994,7 @@ void tst_Moc::templateGtGt() void tst_Moc::defineMacroViaCmdline() { -#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) +#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && !defined(QT_NO_PROCESS) QProcess proc; QStringList args; @@ -1082,7 +1082,7 @@ void tst_Moc::warnOnPropertyWithoutREAD() #ifdef MOC_CROSS_COMPILED QSKIP("Not tested when cross-compiled", SkipAll); #endif -#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) +#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && !defined(QT_NO_PROCESS) QProcess proc; proc.start("moc", QStringList(srcify("warn-on-property-without-read.h"))); QVERIFY(proc.waitForFinished()); diff --git a/tests/auto/qapplication/tst_qapplication.cpp b/tests/auto/qapplication/tst_qapplication.cpp index 8532723..7cb6bfa 100644 --- a/tests/auto/qapplication/tst_qapplication.cpp +++ b/tests/auto/qapplication/tst_qapplication.cpp @@ -1382,6 +1382,7 @@ void tst_QApplication::testDeleteLaterProcessEvents() */ void tst_QApplication::desktopSettingsAware() { +#ifndef QT_NO_PROCESS QProcess testProcess; #ifdef Q_OS_WINCE int argc = 0; @@ -1399,6 +1400,7 @@ void tst_QApplication::desktopSettingsAware() QVERIFY(testProcess.waitForFinished(10000)); QCOMPARE(int(testProcess.state()), int(QProcess::NotRunning)); QVERIFY(int(testProcess.error()) != int(QProcess::Crashed)); +#endif } void tst_QApplication::setActiveWindow() diff --git a/tests/auto/qbytearray/tst_qbytearray.cpp b/tests/auto/qbytearray/tst_qbytearray.cpp index 78fbf32..b7e4717 100644 --- a/tests/auto/qbytearray/tst_qbytearray.cpp +++ b/tests/auto/qbytearray/tst_qbytearray.cpp @@ -235,6 +235,8 @@ void tst_QByteArray::qUncompress() QSKIP("Corrupt data causes this tests to lock up on HP-UX / PA-RISC with gcc", SkipAll); #elif defined Q_OS_SOLARIS QSKIP("Corrupt data causes this tests to lock up on Solaris", SkipAll); +#elif defined Q_OS_QNX + QSKIP("Currupt data cuases this test to lock up on QNX", SkipAll); #endif QTEST(::qUncompress(in), "out"); diff --git a/tests/auto/qclipboard/tst_qclipboard.cpp b/tests/auto/qclipboard/tst_qclipboard.cpp index f400754..bcdf043 100644 --- a/tests/auto/qclipboard/tst_qclipboard.cpp +++ b/tests/auto/qclipboard/tst_qclipboard.cpp @@ -192,6 +192,7 @@ void tst_QClipboard::testSignals() */ void tst_QClipboard::copy_exit_paste() { +#ifndef QT_NO_PROCESS #if defined Q_WS_X11 || defined Q_WS_QWS QSKIP("This test does not make sense on X11 and embedded, copied data disappears from the clipboard when the application exits ", SkipAll); // ### It's still possible to test copy/paste - just keep the apps running @@ -205,6 +206,7 @@ void tst_QClipboard::copy_exit_paste() QTest::qWait(100); #endif QCOMPARE(QProcess::execute("paster/paster", stringArgument), 0); +#endif } void tst_QClipboard::setMimeData() diff --git a/tests/auto/qcopchannel/tst_qcopchannel.cpp b/tests/auto/qcopchannel/tst_qcopchannel.cpp index d07898a..ce97eae 100644 --- a/tests/auto/qcopchannel/tst_qcopchannel.cpp +++ b/tests/auto/qcopchannel/tst_qcopchannel.cpp @@ -42,7 +42,7 @@ #include -#ifdef Q_WS_QWS +#if defined(Q_WS_QWS) && !defined(QT_NO_PROCESS) //TESTED_CLASS= //TESTED_FILES= diff --git a/tests/auto/qdir/tst_qdir.cpp b/tests/auto/qdir/tst_qdir.cpp index 1fd5e88..e5b23ab 100644 --- a/tests/auto/qdir/tst_qdir.cpp +++ b/tests/auto/qdir/tst_qdir.cpp @@ -571,10 +571,21 @@ void tst_QDir::entryList() return; } - for (int i=0; i 100); // sanity check proc.kill(); +#endif } class MyObject : public QObject diff --git a/tests/auto/qfile/tst_qfile.cpp b/tests/auto/qfile/tst_qfile.cpp index 8d9c2be..66f29dd 100644 --- a/tests/auto/qfile/tst_qfile.cpp +++ b/tests/auto/qfile/tst_qfile.cpp @@ -382,6 +382,12 @@ void tst_QFile::open() QFETCH( bool, ok ); +#ifdef Q_OS_UNIX + if (::getuid() == 0) + // root and Chuck Norris don't care for file permissions. Skip. + QSKIP("Running this test as root doesn't make sense", SkipAll); +#endif + #if defined(Q_OS_WIN32) || defined(Q_OS_WINCE) QEXPECT_FAIL("noreadfile", "Windows does not currently support non-readable files.", Abort); #endif @@ -2493,14 +2499,20 @@ void tst_QFile::map() file.close(); - // Change permissions on a file, just to confirm it would fail - QFile::Permissions originalPermissions = file.permissions(); - QVERIFY(file.setPermissions(QFile::ReadOther)); - QVERIFY(!file.open(QFile::ReadWrite)); - memory = file.map(offset, size); - QCOMPARE(file.error(), QFile::PermissionsError); - QVERIFY(!memory); - QVERIFY(file.setPermissions(originalPermissions)); +#ifdef Q_OS_UNIX + if (::getuid() != 0) + // root always has permissions +#endif + { + // Change permissions on a file, just to confirm it would fail + QFile::Permissions originalPermissions = file.permissions(); + QVERIFY(file.setPermissions(QFile::ReadOther)); + QVERIFY(!file.open(QFile::ReadWrite)); + memory = file.map(offset, size); + QCOMPARE(file.error(), QFile::PermissionsError); + QVERIFY(!memory); + QVERIFY(file.setPermissions(originalPermissions)); + } QVERIFY(file.remove()); } diff --git a/tests/auto/qobject/tst_qobject.cpp b/tests/auto/qobject/tst_qobject.cpp index 8ce7c3a..4f25af6 100644 --- a/tests/auto/qobject/tst_qobject.cpp +++ b/tests/auto/qobject/tst_qobject.cpp @@ -2426,11 +2426,15 @@ void tst_QObject::dynamicProperties() void tst_QObject::recursiveSignalEmission() { +#ifdef QT_NO_PROCESS + QSKIP("Test requires QProcess", SkipAll); +#else QProcess proc; proc.start("./signalbug"); QVERIFY(proc.waitForFinished()); QVERIFY(proc.exitStatus() == QProcess::NormalExit); QCOMPARE(proc.exitCode(), 0); +#endif } void tst_QObject::blockingQueuedConnection() diff --git a/tests/auto/qprocess/tst_qprocess.cpp b/tests/auto/qprocess/tst_qprocess.cpp index c19d0a5..d235dff 100644 --- a/tests/auto/qprocess/tst_qprocess.cpp +++ b/tests/auto/qprocess/tst_qprocess.cpp @@ -50,6 +50,10 @@ #include #include +#ifdef QT_NO_PROCESS +QTEST_NOOP_MAIN +#else + #if defined(Q_OS_WIN) #include #endif @@ -2132,3 +2136,4 @@ void tst_QProcess::invalidProgramString() QTEST_MAIN(tst_QProcess) #include "tst_qprocess.moc" +#endif diff --git a/tests/auto/qsettings/tst_qsettings.cpp b/tests/auto/qsettings/tst_qsettings.cpp index 77fef1f..5b9e9e1 100644 --- a/tests/auto/qsettings/tst_qsettings.cpp +++ b/tests/auto/qsettings/tst_qsettings.cpp @@ -716,6 +716,9 @@ void tst_QSettings::testErrorHandling() #ifdef QT_BUILD_INTERNAL #ifdef Q_OS_WIN QSKIP("Windows doesn't support most file modes, including read-only directories, so this test is moot.", SkipAll); +#elif defined(Q_OS_UNIX) + if (::getuid() == 0) + QSKIP("Running this test as root doesn't work, since file perms do not bother him", SkipAll); #else QFETCH(int, filePerms); QFETCH(int, dirPerms); @@ -724,8 +727,7 @@ void tst_QSettings::testErrorHandling() QFETCH(int, statusAfterGet); QFETCH(int, statusAfterSetAndSync); - - system(QString("chmod 700 %1 2>/dev/null").arg(settingsPath("someDir")).toLatin1()); + system(QString("chmod 700 %1 2>/dev/null").arg(settingsPath("someDir")).toLatin1()); system(QString("chmod -R u+rwx %1 2>/dev/null").arg(settingsPath("someDir")).toLatin1()); system(QString("rm -fr %1").arg(settingsPath("someDir")).toLatin1()); diff --git a/tests/auto/qtextcodec/tst_qtextcodec.cpp b/tests/auto/qtextcodec/tst_qtextcodec.cpp index f2da1ec..9f51805 100644 --- a/tests/auto/qtextcodec/tst_qtextcodec.cpp +++ b/tests/auto/qtextcodec/tst_qtextcodec.cpp @@ -1875,6 +1875,9 @@ void tst_QTextCodec::codecForUtfText() #ifdef Q_OS_UNIX void tst_QTextCodec::toLocal8Bit() { +#ifdef QT_NO_PROCESS + QSKIP("This test requires QProcess", SkipAll); +#else QProcess process; process.start("echo/echo"); QString string(QChar(0x410)); @@ -1884,6 +1887,7 @@ void tst_QTextCodec::toLocal8Bit() process.waitForFinished(); QCOMPARE(process.exitStatus(), QProcess::NormalExit); QCOMPARE(process.exitCode(), 0); +#endif } #endif -- cgit v0.12 From 08b3511a0c20cfbfdec91e547a2592afce67f0e6 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Tue, 21 Jul 2009 13:48:25 +0200 Subject: configure -dont-process must build the host tools on Windows CE Reviewed-by: mauricek --- configure.exe | Bin 1102848 -> 1131520 bytes tools/configure/configureapp.cpp | 2 +- tools/configure/main.cpp | 2 +- 3 files changed, 2 insertions(+), 2 deletions(-) diff --git a/configure.exe b/configure.exe index b4b7c50..14eaef4 100644 Binary files a/configure.exe and b/configure.exe differ diff --git a/tools/configure/configureapp.cpp b/tools/configure/configureapp.cpp index a899adb..61daca8 100644 --- a/tools/configure/configureapp.cpp +++ b/tools/configure/configureapp.cpp @@ -3109,6 +3109,7 @@ void Configure::buildQmake() void Configure::buildHostTools() { + dictionary[ "DONE" ] = "yes"; if (!dictionary.contains("XQMAKESPEC")) return; @@ -3332,7 +3333,6 @@ void Configure::generateMakefiles() } else { cout << "Processing of project files have been disabled." << endl; cout << "Only use this option if you really know what you're doing." << endl << endl; - dictionary[ "DONE" ] = "yes"; return; } } diff --git a/tools/configure/main.cpp b/tools/configure/main.cpp index 0e13c7a..e5c04cc 100644 --- a/tools/configure/main.cpp +++ b/tools/configure/main.cpp @@ -95,7 +95,7 @@ int runConfigure( int argc, char** argv ) #endif if( !app.isDone() ) app.generateMakefiles(); - if( !app.isDone() && app.isOk() ) + if( !app.isDone() ) app.buildHostTools(); if( !app.isDone() ) app.showSummary(); -- cgit v0.12 From 2c1e529e4d9edf9892d9a8d30806ecdfa8d093a3 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 21 Jul 2009 13:53:00 +0200 Subject: New Binary --- configure.exe | Bin 1131520 -> 1892397 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/configure.exe b/configure.exe index 14eaef4..5c5c199 100644 Binary files a/configure.exe and b/configure.exe differ -- cgit v0.12 From f616cebd67a6044d6e26d57bc26975ee153479ea Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 21 Jul 2009 14:06:07 +0200 Subject: Disable visibility on CC 5.9 since the compiler doesn't like it --- src/corelib/global/qglobal.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index 0ef48fa..866247a 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -665,7 +665,8 @@ namespace QT_NAMESPACE {} # define Q_ALIGNOF(type) __alignof__(type) # define Q_TYPEOF(expr) __typeof__(expr) # define Q_DECL_ALIGN(n) __attribute__((__aligned__(n))) -# define Q_DECL_EXPORT __attribute__((__visibility__("default"))) +// using CC 5.9: Warning: attribute visibility is unsupported and will be skipped.. +//# define Q_DECL_EXPORT __attribute__((__visibility__("default"))) # endif # if !defined(_BOOL) # define Q_NO_BOOL_TYPE -- cgit v0.12 From 8714892977269591bb9b348c6eb549a7f2c45cbc Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 21 Jul 2009 14:06:50 +0200 Subject: There's no need to include qstringmatcher.h in qstringlist.h --- src/corelib/tools/qstringlist.cpp | 1 + src/corelib/tools/qstringlist.h | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/tools/qstringlist.cpp b/src/corelib/tools/qstringlist.cpp index 5a2b37a..5c550af 100644 --- a/src/corelib/tools/qstringlist.cpp +++ b/src/corelib/tools/qstringlist.cpp @@ -41,6 +41,7 @@ #include #include +#include QT_BEGIN_NAMESPACE diff --git a/src/corelib/tools/qstringlist.h b/src/corelib/tools/qstringlist.h index 665c0d0..f36567a 100644 --- a/src/corelib/tools/qstringlist.h +++ b/src/corelib/tools/qstringlist.h @@ -47,7 +47,6 @@ #include #include #include -#include #ifdef QT_INCLUDE_COMPAT #include #endif -- cgit v0.12 From ba191b0a26b966ad1fb596a905307399922bc44a Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 21 Jul 2009 14:28:01 +0200 Subject: Fix warning with Sun CC 5.9 and xlC 7: no new types inside anonymous unions. These compilers compile this code fine, but this warning shows up *everywhere* when building Qt (or used to, since qstringlist.h included qstringmatcher.h). Move the structure definition to outside the union. --- src/corelib/tools/qstringmatcher.h | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/corelib/tools/qstringmatcher.h b/src/corelib/tools/qstringmatcher.h index 2b8edc9..61b7a95 100644 --- a/src/corelib/tools/qstringmatcher.h +++ b/src/corelib/tools/qstringmatcher.h @@ -81,13 +81,14 @@ private: // explicitely allow anonymous unions for RVCT to prevent compiler warnings #pragma anon_unions #endif + struct Data { + uchar q_skiptable[256]; + const QChar *uc; + int len; + }; union { uint q_data[256]; - struct { - uchar q_skiptable[256]; - const QChar *uc; - int len; - } p; + Data p; }; }; -- cgit v0.12 From 650f11129b74297f502f5ddd81f52a3193ea65c0 Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Tue, 21 Jul 2009 14:15:01 +0200 Subject: Doc: Updated link and a bit more documentation for QWebSecurityOrigin and QWebDatabase. --- src/3rdparty/webkit/WebKit/qt/Api/qwebdatabase.cpp | 21 ++++++++++++++++----- .../webkit/WebKit/qt/Api/qwebsecurityorigin.cpp | 15 ++++++++++----- 2 files changed, 26 insertions(+), 10 deletions(-) diff --git a/src/3rdparty/webkit/WebKit/qt/Api/qwebdatabase.cpp b/src/3rdparty/webkit/WebKit/qt/Api/qwebdatabase.cpp index 7e85eaa..0d11381 100644 --- a/src/3rdparty/webkit/WebKit/qt/Api/qwebdatabase.cpp +++ b/src/3rdparty/webkit/WebKit/qt/Api/qwebdatabase.cpp @@ -34,9 +34,20 @@ using namespace WebCore; \brief The QWebDatabase class provides access to HTML 5 databases created with JavaScript. The upcoming HTML 5 standard includes support for SQL databases that web sites can create and - access on a local computer through JavaScript. QWebDatabase is the C++ interface to these databases. + access on a local computer through JavaScript. QWebDatabase is the C++ interface to these + databases. - For more information refer to the \l{http://www.w3.org/html/wg/html5/#sql}{HTML 5 Draft Standard}. + To get access to all databases defined by a security origin, use QWebSecurityOrigin::databases(). + Each database has an internal name(), as well as a user-friendly name, provided by displayName(). + + WebKit uses SQLite to create and access the local SQL databases. The location of the database + file in the local file system is returned by fileName(). You can access the database directly + through the QtSql database module. + + For each database the web site can define an expectedSize(). The current size of the database + in bytes is returned by size(). + + For more information refer to the \l{http://dev.w3.org/html5/webdatabase/}{HTML 5 Draft Standard}. \sa QWebSecurityOrigin */ @@ -127,7 +138,7 @@ QWebDatabase::QWebDatabase(QWebDatabasePrivate* priv) \endcode \note Concurrent access to a database from multiple threads or processes - is not very efficient because Sqlite is used as WebKit's database backend. + is not very efficient because SQLite is used as WebKit's database backend. */ QString QWebDatabase::fileName() const { @@ -149,8 +160,8 @@ QWebSecurityOrigin QWebDatabase::origin() const } /*! - Removes the database \a db from its security origin. All data stored in this database - will be destroyed. + Removes the database \a db from its security origin. All data stored in the + database \a db will be destroyed. */ void QWebDatabase::removeDatabase(const QWebDatabase &db) { diff --git a/src/3rdparty/webkit/WebKit/qt/Api/qwebsecurityorigin.cpp b/src/3rdparty/webkit/WebKit/qt/Api/qwebsecurityorigin.cpp index da9278c..d2eaf10 100644 --- a/src/3rdparty/webkit/WebKit/qt/Api/qwebsecurityorigin.cpp +++ b/src/3rdparty/webkit/WebKit/qt/Api/qwebsecurityorigin.cpp @@ -36,10 +36,9 @@ using namespace WebCore; \brief The QWebSecurityOrigin class defines a security boundary for web sites. QWebSecurityOrigin provides access to the security domains defined by web sites. - An origin consists of a host name, a scheme, and a port number. Web sites with the same - security origin can access each other's resources for client-side scripting or databases. - - ### diagram + An origin consists of a host name, a scheme, and a port number. Web sites + with the same security origin can access each other's resources for client-side + scripting or databases. For example the site \c{http://www.example.com/my/page.html} is allowed to share the same database as \c{http://www.example.com/my/overview.html}, or access each other's @@ -47,7 +46,13 @@ using namespace WebCore; \c{http://www.malicious.com/evil.html} from accessing \c{http://www.example.com/}'s resources, because they are of a different security origin. - QWebSecurity also provides access to all databases defined within a security origin. + Call QWebFrame::securityOrigin() to get the QWebSecurityOrigin for a frame in a + web page, and use host(), scheme() and port() to identify the security origin. + + Use databases() to access the databases defined within a security origin. The + disk usage of the origin's databases can be limited with setDatabaseQuota(). + databaseQuota() and databaseUsage() report the current limit as well as the + current usage. For more information refer to the \l{http://en.wikipedia.org/wiki/Same_origin_policy}{"Same origin policy" Wikipedia Article}. -- cgit v0.12 From 1ba8d525d3c898c198821e493c7fa6c4eb4689a3 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 16 Jul 2009 13:55:04 +0200 Subject: Fix compilation with xlC 7: the cast is necessary to get delete[] to understand what to delete Reviewed-By: Trust Me --- src/corelib/kernel/qobject.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index eb1bd0b..6503ab0 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -854,7 +854,7 @@ QObject::~QObject() QObjectPrivate::Connection::~Connection() { if (argumentTypes != &DIRECT_CONNECTION_ONLY) - delete [] argumentTypes; + delete [] static_cast(argumentTypes); } -- cgit v0.12 From 6c5cbdbee91ea200321480dcee243ae061a3a902 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 16 Jul 2009 14:14:28 +0200 Subject: Add code to the Unix configure script to get the xlC version number --- configure | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/configure b/configure index 13bdf7f..87fe281 100755 --- a/configure +++ b/configure @@ -6114,8 +6114,34 @@ case "$XPLATFORM" in canBuildWebKit="no" ;; aix-xlc*) - canBuildWebKit="no" - canBuildQtXmlPatterns="no" + # Get the xlC version + cat > xlcver.c < +int main() +{ + printf("%d.%d\n", __xlC__ >> 8, __xlC__ & 0xFF); + return 0; +} +EOF + xlcver= + if ${QMAKE_CONF_COMPILER} -o xlcver xlcver.c >/dev/null 2>/dev/null; then + xlcver=`./xlcver 2>/dev/null` + rm -f ./xlcver + fi + if [ "$OPT_VERBOSE" = "yes" ]; then + if [ -n "$xlcver" ]; then + echo Found IBM xlC version: $xlcver. + else + echo Could not determine IBM xlC version, assuming oldest supported. + fi + fi + + case "$xlcver" in + *) + canBuildWebKit="no" + canBuildQtXmlPatterns="no" + ;; + esac ;; irix-cc*) canBuildWebKit="no" -- cgit v0.12 From cb64ac587249f5dc6563a035e2ef5a3ad2bc5d13 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 16 Jul 2009 15:38:27 +0200 Subject: xlC 7 cannot compile QtConcurrent with these templates here --- src/corelib/concurrent/qfuture.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/concurrent/qfuture.h b/src/corelib/concurrent/qfuture.h index 47015ee..f2db5ac 100644 --- a/src/corelib/concurrent/qfuture.h +++ b/src/corelib/concurrent/qfuture.h @@ -210,7 +210,7 @@ public: bool operator==(const QFuture &other) const { return (d == other.d); } bool operator!=(const QFuture &other) const { return (d != other.d); } -#ifndef QT_NO_MEMBER_TEMPLATES +#if !defined(QT_NO_MEMBER_TEMPLATES) && !defined(Q_CC_XLC) template QFuture(const QFuture &other) : d(other.d) -- cgit v0.12 From 9025b909da8e52c700b0e0ac2f62bf441233c8c5 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Sun, 19 Jul 2009 13:42:06 +0200 Subject: Fix compilation of QHash with xlC 7. Make sure that the function is found properly. It can't be static, for whatever reason. Reviewed-By: Peter Hartmann --- src/xmlpatterns/type/qprimitives_p.h | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/xmlpatterns/type/qprimitives_p.h b/src/xmlpatterns/type/qprimitives_p.h index 78bd4ae..b77698a 100644 --- a/src/xmlpatterns/type/qprimitives_p.h +++ b/src/xmlpatterns/type/qprimitives_p.h @@ -74,17 +74,6 @@ QT_BEGIN_NAMESPACE class QString; /** - * @internal - * - * A method to allow a QHash or QSet with QUrl - * as key type. - */ -inline uint qHash(const QUrl &uri) -{ - return qHash(uri.toString()); -} - -/** * @short The namespace for the internal API of QtXmlPatterns * @internal */ @@ -92,6 +81,17 @@ namespace QPatternist { /** + * @internal + * + * A method to allow a QHash or QSet with QUrl + * as key type. + */ + inline uint qHash(const QUrl &uri) + { + return qHash(uri.toString()); + } + + /** * @defgroup Patternist_cppWXSTypes C++ Primitives for W3C XML Schema Number Types * * The implementations of W3C XML Schema's(WXS) number types, more specifically @@ -208,6 +208,8 @@ namespace QPatternist QString Q_AUTOTEST_EXPORT escape(const QString &input); } +using QPatternist::qHash; + QT_END_NAMESPACE QT_END_HEADER -- cgit v0.12 From 4278109e1f6cca83e687977db55b193ef4f7fcd7 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Sun, 19 Jul 2009 14:02:10 +0200 Subject: Fix compilation with xlC 7: the compiler doesn't find statics in template expansions. parser/qmaintainingreader.cpp", line 175.40: 1540-0274 (S) The name lookup for "formatKeyword" did not find a declaration. parser/qmaintainingreader.cpp", line 175.40: 1540-1292 (I) Static declarations are not considered for a function call if the function is not qualified. Reviewed-By: Peter Hartmann Reviewed-By: Frans Englich --- src/xmlpatterns/utils/qpatternistlocale_p.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/xmlpatterns/utils/qpatternistlocale_p.h b/src/xmlpatterns/utils/qpatternistlocale_p.h index dc287bd..d8288c7 100644 --- a/src/xmlpatterns/utils/qpatternistlocale_p.h +++ b/src/xmlpatterns/utils/qpatternistlocale_p.h @@ -93,7 +93,8 @@ namespace QPatternist Q_DISABLE_COPY(QtXmlPatterns) }; - static inline QString formatKeyword(const QString &keyword) + // don't make this function static, otherwise xlC 7 cannot find it + inline QString formatKeyword(const QString &keyword) { return QLatin1String("") + escape(keyword) + -- cgit v0.12 From 9317e521f0b0f689c87b95b927102dbf55edb89f Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Sun, 19 Jul 2009 14:03:49 +0200 Subject: Fix compilation with xlC 7: the compiler tries to expand qIsForwardIteratorEnd with QString This is used in other places too, so move the definition to the header. Reviewed-By: Trust Me --- src/xmlpatterns/api/qabstractxmlforwarditerator_p.h | 15 ++++++++++++++- src/xmlpatterns/functions/qsequencegeneratingfns.cpp | 13 ------------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/xmlpatterns/api/qabstractxmlforwarditerator_p.h b/src/xmlpatterns/api/qabstractxmlforwarditerator_p.h index d3188d3..b4eefeb 100644 --- a/src/xmlpatterns/api/qabstractxmlforwarditerator_p.h +++ b/src/xmlpatterns/api/qabstractxmlforwarditerator_p.h @@ -55,7 +55,7 @@ #include #include #include - +#include QT_BEGIN_HEADER @@ -74,6 +74,19 @@ inline bool qIsForwardIteratorEnd(const T &unit) return !unit; } +/** + * @short Helper class for StringSplitter + * + * Needed by the QAbstractXmlForwardIterator sub-class. + * + * @relates StringSplitter + */ +template<> +inline bool qIsForwardIteratorEnd(const QString &unit) +{ + return unit.isNull(); +} + template class QAbstractXmlForwardIterator; class QAbstractXmlForwardIteratorPrivate; diff --git a/src/xmlpatterns/functions/qsequencegeneratingfns.cpp b/src/xmlpatterns/functions/qsequencegeneratingfns.cpp index 81724f8..e3f30c5 100644 --- a/src/xmlpatterns/functions/qsequencegeneratingfns.cpp +++ b/src/xmlpatterns/functions/qsequencegeneratingfns.cpp @@ -69,19 +69,6 @@ Item IdFN::mapToItem(const QString &id, } /** - * @short Helper class for StringSplitter - * - * Needed by the QAbstractXmlForwardIterator sub-class. - * - * @relates StringSplitter - */ -template<> -bool qIsForwardIteratorEnd(const QString &unit) -{ - return unit.isNull(); -} - -/** * @short Helper class for IdFN. * * StringSplitter takes an Iterator which delivers strings of this kind: -- cgit v0.12 From 08ff267fe37dcccb7f63a8158b260e2e3b1e0965 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 16 Jul 2009 15:37:54 +0200 Subject: Use the configure script to enable/disable QtConcurrent and QtXmlPatterns Using qglobal.h and checking the compiler version with the preprocessor has the side-effect that moc won't generate proper code since it doesn't know about the compiler version. Enable both modules under Sun CC 5.9 and IBM xlC 7.0. --- configure | 44 +++++++++++++++++++++++++++++++------------- src/corelib/global/qglobal.h | 23 +++++------------------ 2 files changed, 36 insertions(+), 31 deletions(-) diff --git a/configure b/configure index 87fe281..e05e1d5 100755 --- a/configure +++ b/configure @@ -6057,6 +6057,7 @@ fi # canBuildQtXmlPatterns="yes" canBuildWebKit="$HAVE_STL" +canBuildQtConcurrent="yes" # WebKit requires stdint.h "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/stdint "Stdint" $L_FLAGS $I_FLAGS $l_FLAGS @@ -6088,9 +6089,9 @@ case "$XPLATFORM" in case "$(${QMAKE_CONF_COMPILER} -dumpversion)" in 4*|3.4*) ;; - 3.3*) - canBuildWebKit="no" - ;; + 3.3*) + canBuildWebKit="no" + ;; *) canBuildWebKit="no" canBuildQtXmlPatterns="no" @@ -6098,17 +6099,22 @@ case "$XPLATFORM" in esac ;; solaris-cc*) - # Check the compiler version - case `${QMAKE_CONF_COMPILER} -V 2>&1 | awk '{print $4}'` in - *) - canBuildWebKit="no" - canBuildQtXmlPatterns="no" - ;; - esac - ;; + # Check the compiler version + case `${QMAKE_CONF_COMPILER} -V 2>&1 | awk '{print $4}'` in + 5.[012345678]) + canBuildWebKit="no" + canBuildQtXmlPatterns="no" + canBuildQtConcurrent="no" + ;; + 5.9) + canBuildWebKit="no" + ;; + esac + ;; hpux-acc*) canBuildWebKit="no" canBuildQtXmlPatterns="no" + canBuildQtConcurrent="no" ;; hpuxi-acc*) canBuildWebKit="no" @@ -6137,17 +6143,28 @@ EOF fi case "$xlcver" in - *) + [123456].*) canBuildWebKit="no" canBuildQtXmlPatterns="no" + canBuildQtConcurrent="no" + ;; + *) + canBuildWebKit="no" ;; esac - ;; + ;; irix-cc*) canBuildWebKit="no" + canBuildQtConcurrent="no" ;; esac +CFG_CONCURRENT="yes" +if [ "$canBuildQtConcurrent" = "no" ]; then + QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_CONCURRENT" + CFG_CONCURRENT="no" +fi + if [ "$CFG_XMLPATTERNS" = "yes" -a "$CFG_EXCEPTIONS" = "no" ]; then echo "QtXmlPatterns was requested, but it can't be built due to exceptions being disabled." exit 1 @@ -7056,6 +7073,7 @@ echo "Qt 3 compatibility .. $CFG_QT3SUPPORT" [ "$CFG_DBUS" = "no" ] && echo "QtDBus module ....... no" [ "$CFG_DBUS" = "yes" ] && echo "QtDBus module ....... yes (run-time)" [ "$CFG_DBUS" = "linked" ] && echo "QtDBus module ....... yes (linked)" +echo "QtConcurrent code.... $CFG_CONCURRENT" echo "QtScriptTools module $CFG_SCRIPTTOOLS" echo "QtXmlPatterns module $CFG_XMLPATTERNS" echo "Phonon module ....... $CFG_PHONON" diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index 866247a..7b16dff 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -2408,28 +2408,15 @@ QT_LICENSED_MODULE(DBus) # define QT_NO_QFUTURE #endif -/* - Turn off certain features for compilers that have problems parsing - the code. -*/ -#if (defined(Q_CC_HPACC) && defined(QT_ARCH_PARISC)) \ - || defined(Q_CC_MIPS) \ - || defined(Q_CC_XLC) -// HP aCC A.03.*, MIPSpro, and xlC cannot handle -// the template function declarations for the QtConcurrent functions -# define QT_NO_QFUTURE -# define QT_NO_CONCURRENT -#endif - -// MSVC 6.0, MSVC .NET 2002, and old versions of Sun CC can`t handle the map(), etc templates, +// MSVC 6.0 and MSVC .NET 2002, can`t handle the map(), etc templates, // but the QFuture class compiles. -#if (defined(Q_CC_MSVC) && _MSC_VER <= 1300) || (defined (__SUNPRO_CC) && __SUNPRO_CC <= 0x590) +#if (defined(Q_CC_MSVC) && _MSC_VER <= 1300) # define QT_NO_CONCURRENT #endif -// Mingw uses a gcc 3 version which has problems with some of the -// map/filter overloads. So does IRIX and Solaris. -#if (defined(Q_OS_IRIX) || defined(Q_CC_MINGW) || defined (Q_OS_SOLARIS)) && (__GNUC__ < 4) +// gcc 3 version has problems with some of the +// map/filter overloads. +#if defined(Q_CC_GNU) && (__GNUC__ < 4) # define QT_NO_CONCURRENT_MAP # define QT_NO_CONCURRENT_FILTER #endif -- cgit v0.12 From 77d9528d802b4e36423814ae2c52abc3e36de40c Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Tue, 21 Jul 2009 15:27:50 +0200 Subject: Doc: More docu for the QPixmapCache::Key --- src/gui/image/qpixmapcache.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/gui/image/qpixmapcache.cpp b/src/gui/image/qpixmapcache.cpp index 82069d0..ecdcd8c 100644 --- a/src/gui/image/qpixmapcache.cpp +++ b/src/gui/image/qpixmapcache.cpp @@ -64,7 +64,8 @@ QT_BEGIN_NAMESPACE access the global pixmap cache. It creates an internal QCache object for caching the pixmaps. - The cache associates a pixmap with a string as a key or with a QPixmapCache::Key. + The cache associates a pixmap with a user-provided string as a key, + or with a QPixmapCache::Key that the cache generates. Using QPixmapCache::Key for keys is faster than using strings. The string API is very convenient for complex keys but the QPixmapCache::Key API will be very efficient and convenient for a one-to-one object-to-pixmap mapping \mdash in @@ -92,6 +93,17 @@ static int cache_limit = 10240; // 10 MB cache limit for desktop #endif /*! + \class QPixmapCache::Key + \brief The QPixmapCache::Key class can be used for efficient access + to the QPixmapCache. + \since 4.6 + + Use QPixmapCache::insert() to receive an instance of Key generated + by the pixmap cache. You can store the key in your own objects for + a very efficient one-to-one object-to-pixmap mapping. +*/ + +/*! Constructs an empty Key object. */ QPixmapCache::Key::Key() : d(0) -- cgit v0.12 From dcb735f92d87aacade6aa65079fe3da06efca553 Mon Sep 17 00:00:00 2001 From: Kent Hansen Date: Tue, 21 Jul 2009 15:23:17 +0200 Subject: add autotest for adding transition from state machine's root It's not supported because the root state has no ancestor, which is a requirement for the state machine's transition selection algorithm. --- tests/auto/qstatemachine/tst_qstatemachine.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/auto/qstatemachine/tst_qstatemachine.cpp b/tests/auto/qstatemachine/tst_qstatemachine.cpp index efcb983..bafd848 100644 --- a/tests/auto/qstatemachine/tst_qstatemachine.cpp +++ b/tests/auto/qstatemachine/tst_qstatemachine.cpp @@ -127,6 +127,7 @@ private slots: void targetStateWithNoParent(); void targetStateDeleted(); void transitionToRootState(); + void transitionFromRootState(); void transitionEntersParent(); void defaultErrorState(); @@ -279,6 +280,15 @@ void tst_QStateMachine::transitionToRootState() QVERIFY(machine.configuration().contains(initialState)); } +void tst_QStateMachine::transitionFromRootState() +{ + QStateMachine machine; + QState *root = machine.rootState(); + QState *s1 = new QState(root); + QTest::ignoreMessage(QtWarningMsg, "QState::addTransition: cannot add transition from root state"); + root->addTransition(new EventTransition(QEvent::User, s1)); +} + void tst_QStateMachine::transitionEntersParent() { QStateMachine machine; -- cgit v0.12 From 641ba0bb2c144a4bef25982d90ac49d9af354202 Mon Sep 17 00:00:00 2001 From: Kent Hansen Date: Tue, 21 Jul 2009 15:41:16 +0200 Subject: Fix memory leak with wrapped events Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/corelib/statemachine/qstatemachine.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/corelib/statemachine/qstatemachine.cpp b/src/corelib/statemachine/qstatemachine.cpp index bf3ee31..a00e7e1 100644 --- a/src/corelib/statemachine/qstatemachine.cpp +++ b/src/corelib/statemachine/qstatemachine.cpp @@ -2155,6 +2155,8 @@ QSignalEvent::~QSignalEvent() Constructs a new QWrappedEvent object with the given \a object and \a event. + + The QWrappedEvent object takes ownership of \a event. */ QWrappedEvent::QWrappedEvent(QObject *object, QEvent *event) : QEvent(QEvent::Wrapped), m_object(object), m_event(event) @@ -2166,6 +2168,7 @@ QWrappedEvent::QWrappedEvent(QObject *object, QEvent *event) */ QWrappedEvent::~QWrappedEvent() { + delete m_event; } /*! -- cgit v0.12 From ea7830a2551f1c68e5dbc53ee9a5ce3a8fcbe872 Mon Sep 17 00:00:00 2001 From: Kent Hansen Date: Tue, 21 Jul 2009 15:47:37 +0200 Subject: Fix memleaks in the autotests --- tests/auto/qstatemachine/tst_qstatemachine.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/tests/auto/qstatemachine/tst_qstatemachine.cpp b/tests/auto/qstatemachine/tst_qstatemachine.cpp index bafd848..44fc998 100644 --- a/tests/auto/qstatemachine/tst_qstatemachine.cpp +++ b/tests/auto/qstatemachine/tst_qstatemachine.cpp @@ -285,8 +285,11 @@ void tst_QStateMachine::transitionFromRootState() QStateMachine machine; QState *root = machine.rootState(); QState *s1 = new QState(root); + EventTransition *trans = new EventTransition(QEvent::User, s1); QTest::ignoreMessage(QtWarningMsg, "QState::addTransition: cannot add transition from root state"); - root->addTransition(new EventTransition(QEvent::User, s1)); + root->addTransition(trans); + QCOMPARE(trans->sourceState(), (QState*)0); + delete trans; } void tst_QStateMachine::transitionEntersParent() @@ -3113,6 +3116,8 @@ void tst_QStateMachine::specificTargetValueOfAnimation() QVERIFY(machine.configuration().contains(s3)); QCOMPARE(object->property("foo").toDouble(), 2.0); QCOMPARE(anim->endValue().toDouble(), 10.0); + + delete anim; } void tst_QStateMachine::addDefaultAnimation() @@ -3145,6 +3150,8 @@ void tst_QStateMachine::addDefaultAnimation() QVERIFY(machine.configuration().contains(s3)); QCOMPARE(object->property("foo").toDouble(), 2.0); + + delete object; } void tst_QStateMachine::addDefaultAnimationWithUnusedAnimation() @@ -3224,6 +3231,9 @@ void tst_QStateMachine::removeDefaultAnimation() machine.removeDefaultAnimation(anim2); QCOMPARE(machine.defaultAnimations().size(), 0); + + delete anim; + delete anim2; } void tst_QStateMachine::overrideDefaultAnimationWithSpecific() @@ -3264,6 +3274,9 @@ void tst_QStateMachine::overrideDefaultAnimationWithSpecific() QVERIFY(machine.configuration().contains(s3)); QCOMPARE(counter.counter, 2); // specific animation started and stopped + + delete defaultAnimation; + delete moreSpecificAnimation; } /* -- cgit v0.12 From b6b12bc6b8296d7e199cab0ece35c9eb9ae7fe64 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 18 Mar 2009 14:36:52 +0100 Subject: Implement strict STD3 checking of hostnames in URLs. Made the toPunycodeHelper function write to a QString. Renamed qt_from_ACE to qt_ACE_do to indicate what it actually does. Added the STD3 rules for hostnames, forcing hostnames to have to strictly comply to STD3. Also, execute nameprep in the correct order (before trying to encode to Punycode). Validate hostnames when QUrlPrivate::canonicalHost() called, including validation of IP Literals. Validation of IPv4 is missing. Adapted other functions to use qt_ACE_do, notably QUrl::toAce (avoid code duplication). --- src/corelib/io/qurl.cpp | 241 ++++++++++++++++++++++++++++++------------- tests/auto/qurl/tst_qurl.cpp | 96 ++++++++++++++--- 2 files changed, 256 insertions(+), 81 deletions(-) diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp index 180e9ec..dc27dfb 100644 --- a/src/corelib/io/qurl.cpp +++ b/src/corelib/io/qurl.cpp @@ -2901,8 +2901,17 @@ static bool isBidirectionalL(const QChar &ch) return false; } +#ifdef QT_BUILD_INTERNAL +// export for tst_qurl.cpp +Q_AUTOTEST_EXPORT QString qt_nameprep(const QString &); +Q_AUTOTEST_EXPORT bool qt_check_std3rules(const QStringRef &); +#else +// non-test build, keep the symbols for ourselves +static QString qt_nameprep(const QString &); +static bool qt_check_std3rules(const QStringRef &); +#endif -Q_AUTOTEST_EXPORT QString qt_nameprep(const QString &source) +QString qt_nameprep(const QString &source) { QString mapped = source; @@ -2959,8 +2968,32 @@ Q_AUTOTEST_EXPORT QString qt_nameprep(const QString &source) return mapped; } +bool qt_check_std3rules(const QStringRef &source) +{ + int len = source.length(); + if (len > 63) + return false; + + for (int i = 0; i < len; ++i) { + register ushort c = source.at(i).unicode(); + if (c == '-' && (i == 0 || i == len - 1)) + return false; -static inline char encodeDigit(uint digit) + // verifying the absence of LDH is the same as verifying that + // only LDH is present + if (c == '-' || (c >= '0' && c <= '9') + || (c >= 'A' && c <= 'Z') + || (c >= 'a' && c <= 'z')) + continue; + + return false; + } + + return true; +} + + +static inline uint encodeDigit(uint digit) { return digit + 22 + 75 * (digit < 26); } @@ -2977,7 +3010,7 @@ static inline uint adapt(uint delta, uint numpoints, bool firsttime) return k + (((base - tmin + 1) * delta) / (delta + skew)); } -static inline void appendEncode(QByteArray* output, uint& delta, uint& bias, uint& b, uint& h) +static inline void appendEncode(QString* output, uint& delta, uint& bias, uint& b, uint& h) { uint qq; uint k; @@ -2991,17 +3024,17 @@ static inline void appendEncode(QByteArray* output, uint& delta, uint& bias, uin t = (k <= bias) ? tmin : (k >= bias + tmax) ? tmax : k - bias; if (qq < t) break; - *output += encodeDigit(t + (qq - t) % (base - t)); + *output += QChar(encodeDigit(t + (qq - t) % (base - t))); qq = (qq - t) / (base - t); } - *output += encodeDigit(qq); + *output += QChar(encodeDigit(qq)); bias = adapt(delta, h + 1, h == b); delta = 0; ++h; } -static void toPunycodeHelper(const QChar *s, int ucLength, QByteArray *output) +static void toPunycodeHelper(const QChar *s, int ucLength, QString *output) { uint n = initial_n; uint delta = 0; @@ -3010,7 +3043,7 @@ static void toPunycodeHelper(const QChar *s, int ucLength, QByteArray *output) int outLen = output->length(); output->resize(outLen + ucLength); - char *d = output->data() + outLen; + QChar *d = output->data() + outLen; bool skipped = false; // copy all basic code points verbatim to output. for (uint j = 0; j < (uint) ucLength; ++j) { @@ -3035,7 +3068,7 @@ static void toPunycodeHelper(const QChar *s, int ucLength, QByteArray *output) // if basic code points were copied, add the delimiter character. if (h > 0) - *output += 0x2d; + *output += QChar(0x2d); // while there are still unprocessed non-basic code points left in // the input string... @@ -3083,7 +3116,7 @@ static void toPunycodeHelper(const QChar *s, int ucLength, QByteArray *output) } // prepend ACE prefix - output->insert(outLen, "xn--"); + output->insert(outLen, QLatin1String("xn--")); return; } @@ -3164,46 +3197,118 @@ static bool qt_is_idn_enabled(const QString &domain) return equal(tld, len, idn_whitelist[i]); } -static QString qt_from_ACE(const QString &domainMC) +static inline bool isDotDelimiter(ushort uc) { + // IDNA / rfc3490 describes these four delimiters used for + // separating labels in unicode international domain + // names. + return uc == 0x2e || uc == 0x3002 || uc == 0xff0e || uc == 0xff61; +} + +static int nextDotDelimiter(const QString &domain, int from = 0) +{ + const QChar *b = domain.unicode(); + const QChar *ch = b + from; + const QChar *e = b + domain.length(); + while (ch < e) { + if (isDotDelimiter(ch->unicode())) + break; + else + ++ch; + } + return ch - b; +} + +enum AceOperation { ToAceOnly, NormalizeAce }; +static QString qt_ACE_do(const QString &domainMC, AceOperation op) +{ + if (domainMC.isEmpty()) + return domainMC; QString domain = domainMC.toLower(); - int idx = domain.indexOf(QLatin1Char('.')); - if (idx != -1) { - if (!domain.contains(QLatin1String("xn--"))) { - bool simple = true; - for (int i = 0; i < domain.size(); ++i) { - ushort ch = domain.at(i).unicode(); - if (ch > 'z' || ch < '-' || ch == '/' || (ch > '9' && ch < 'A') || (ch > 'Z' && ch < 'a')) { - simple = false; - break; - } + + QString result; + result.reserve(domain.length()); + + const bool isIdnEnabled = op == NormalizeAce ? qt_is_idn_enabled(domain) : false; + int lastIdx = 0; + while (1) { + int idx = nextDotDelimiter(domain, lastIdx); + if (idx == lastIdx) + return QString(); // two delimiters in a row -- empty label not allowed + + // RFC 3490 says, about the ToASCII operation: + // 3. If the UseSTD3ASCIIRules flag is set, then perform these checks: + // + // (a) Verify the absence of non-LDH ASCII code points; that is, the + // absence of 0..2C, 2E..2F, 3A..40, 5B..60, and 7B..7F. + // + // (b) Verify the absence of leading and trailing hyphen-minus; that + // is, the absence of U+002D at the beginning and end of the + // sequence. + // and: + // 8. Verify that the number of code points is in the range 1 to 63 + // inclusive. + + bool simple = true; + for (int i = lastIdx; i < idx; ++i) { + ushort ch = domain.at(i).unicode(); + if (ch > 0x7f) { + simple = false; + break; } - if (simple) - return domain; } - - const bool isIdnEnabled = qt_is_idn_enabled(domain); - int lastIdx = 0; - QString result; - while (1) { + + if (simple && idx > lastIdx + 4) { + // ACE form domains are simple, but we can't consider them simple + // is this an ACE form? + static const ushort acePrefixUtf16[] = { 'x', 'n', '-', '-' }; + if (memcmp(domain.utf16() + lastIdx, acePrefixUtf16, sizeof acePrefixUtf16) == 0) + simple = false; + } + + QString aux; + QStringRef label; + if (simple) { + // fastest conversion: this is the common case (non IDN-domains) + // just memcpy from source (domain) to destination (result) + // there's no need to nameprep since everything is ASCII already + int prevLen = result.size(); + result.resize(prevLen + idx - lastIdx); + memcpy(result.data() + prevLen, domain.constData() + lastIdx, (idx - lastIdx) * sizeof(QChar)); + + label = QStringRef(&result, prevLen, result.length() - prevLen); + } else { // Nameprep the host. If the labels in the hostname are Punycode // encoded, we decode them immediately, then nameprep them. - QByteArray label; - toPunycodeHelper(domain.constData() + lastIdx, idx - lastIdx, &label); - result += qt_nameprep(isIdnEnabled ? QUrl::fromPunycode(label) : QString::fromLatin1(label)); - lastIdx = idx + 1; - if (lastIdx < domain.size() + 1) - result += QLatin1Char('.'); - else - break; - idx = domain.indexOf(QLatin1Char('.'), lastIdx); - if (idx == -1) - idx = domain.size(); + QString tmp = domain.mid(lastIdx, idx - lastIdx); + tmp = qt_nameprep(tmp); + + if (isIdnEnabled) { + toPunycodeHelper(tmp.constData(), tmp.size(), &aux); + label = QStringRef(&aux); + + tmp = QUrl::fromPunycode(aux.toLatin1()); + if (tmp.isEmpty()) + return QString(); + result += tmp; + } else { + int prevLen = result.size(); + toPunycodeHelper(tmp.constData(), tmp.size(), &result); + + label = QStringRef(&result, prevLen, result.length() - prevLen); + } } - return result; - } else { - return qt_nameprep(domain); + + if (!qt_check_std3rules(label)) + return QString(); + + lastIdx = idx + 1; + if (lastIdx < domain.size() + 1) + result += QLatin1Char('.'); + else + break; } + return result; } @@ -3246,12 +3351,27 @@ QUrlPrivate::QUrlPrivate(const QUrlPrivate ©) QString QUrlPrivate::canonicalHost() const { - if (QURL_HASFLAG(stateFlags, HostCanonicalized)) + if (QURL_HASFLAG(stateFlags, HostCanonicalized) || host.isEmpty()) return host; QUrlPrivate *that = const_cast(this); QURL_SETFLAG(that->stateFlags, HostCanonicalized); - that->host = qt_from_ACE(host); + if (host.contains(QLatin1Char(':'))) { + // This is an IP Literal, use _IPLiteral to validate + QByteArray ba = host.toLatin1(); + if (!ba.startsWith('[')) { + // surround the IP Literal with [ ] if it's not already done so + ba.reserve(ba.length() + 2); + ba.prepend('['); + ba.append(']'); + } + + const char *ptr = ba.constData(); + if (!_IPLiteral(&ptr)) + that->host.clear(); + } else { + that->host = qt_ACE_do(host, NormalizeAce); + } return that->host; } @@ -3737,7 +3857,10 @@ QByteArray QUrlPrivate::toEncoded(QUrl::FormattingOptions options) const } } - url += QUrl::toAce(host); + if (host.startsWith(QLatin1Char('['))) + url += host.toLatin1(); + else + url += QUrl::toAce(host); if (!(options & QUrl::RemovePort) && port != -1) { url += ':'; url += QString::number(port).toAscii(); @@ -4412,8 +4535,6 @@ void QUrl::setHost(const QString &host) QURL_UNSETFLAG(d->stateFlags, QUrlPrivate::Validated | QUrlPrivate::Normalized | QUrlPrivate::HostCanonicalized); d->host = host; - if (d->host.contains(QLatin1Char(':'))) - d->host = QLatin1Char('[') + d->host + QLatin1Char(']'); } /*! @@ -5425,9 +5546,9 @@ QByteArray QUrl::toPercentEncoding(const QString &input, const QByteArray &exclu */ QByteArray QUrl::toPunycode(const QString &uc) { - QByteArray output; + QString output; toPunycodeHelper(uc.constData(), uc.size(), &output); - return output; + return output.toLatin1(); } /*! @@ -5528,7 +5649,7 @@ QString QUrl::fromPunycode(const QByteArray &pc) */ QString QUrl::fromAce(const QByteArray &domain) { - return qt_from_ACE(QString::fromLatin1(domain)); + return qt_ACE_do(QString::fromLatin1(domain), NormalizeAce); } /*! @@ -5545,26 +5666,8 @@ QString QUrl::fromAce(const QByteArray &domain) */ QByteArray QUrl::toAce(const QString &domain) { - // IDNA / rfc3490 describes these four delimiters used for - // separating labels in unicode international domain - // names. - QString nameprepped = qt_nameprep(domain); - int lastIdx = 0; - QByteArray result; - for (int i = 0; i < nameprepped.size(); ++i) { - ushort uc = nameprepped.at(i).unicode(); - if (uc == 0x2e || uc == 0x3002 || uc == 0xff0e || uc == 0xff61) { - if (lastIdx) - result += '.'; - toPunycodeHelper(nameprepped.constData() + lastIdx, i - lastIdx, &result); - lastIdx = i + 1; - } - } - if (lastIdx) - result += '.'; - toPunycodeHelper(nameprepped.constData() + lastIdx, nameprepped.size() - lastIdx, &result); - - return result; + QString result = qt_ACE_do(domain, ToAceOnly); + return result.toLatin1(); } /*! diff --git a/tests/auto/qurl/tst_qurl.cpp b/tests/auto/qurl/tst_qurl.cpp index 723f882..fcced37 100644 --- a/tests/auto/qurl/tst_qurl.cpp +++ b/tests/auto/qurl/tst_qurl.cpp @@ -162,6 +162,8 @@ private slots: void nameprep_testsuite(); void ace_testsuite_data(); void ace_testsuite(); + void std3violations_data(); + void std3violations(); void tldRestrictions_data(); void tldRestrictions(); void emptyQueryOrFragment(); @@ -3100,6 +3102,11 @@ void tst_QUrl::ace_testsuite_data() QTest::newRow("ascii-upper") << "FLUKE" << "fluke" << "fluke" << "fluke"; QTest::newRow("asciifolded") << QString::fromLatin1("stra\337e") << "strasse" << "." << "strasse"; + QTest::newRow("asciifolded-dotcom") << QString::fromLatin1("stra\337e.example.com") << "strasse.example.com" << "." << "strasse.example.com"; + QTest::newRow("greek-mu") << QString::fromLatin1("\265V") + <<"xn--v-lmb" + << "." + << QString::fromUtf8("\316\274v"); QTest::newRow("non-ascii-lower") << QString::fromLatin1("alqualond\353") << "xn--alqualond-34a" @@ -3132,6 +3139,9 @@ void tst_QUrl::ace_testsuite_data() QTest::newRow("idn-upper") << "XN--ALQUALOND-34A" << "xn--alqualond-34a" << QString::fromLatin1("alqualond\353") << QString::fromLatin1("alqualond\353"); + + QTest::newRow("separator-3002") << QString::fromUtf8("example\343\200\202com") + << "example.com" << "." << "example.com"; } void tst_QUrl::ace_testsuite() @@ -3142,23 +3152,85 @@ void tst_QUrl::ace_testsuite() QFETCH(QString, fromace); QFETCH(QString, unicode); - QString domain = in + canonsuffix; - QCOMPARE(QString::fromLatin1(QUrl::toAce(domain)), toace + canonsuffix); + const char *suffix = canonsuffix; + if (toace.contains('.')) + suffix = 0; + + QString domain = in + suffix; + QCOMPARE(QString::fromLatin1(QUrl::toAce(domain)), toace + suffix); if (fromace != ".") - QCOMPARE(QUrl::fromAce(domain.toLatin1()), fromace + canonsuffix); - QCOMPARE(QUrl::fromAce(QUrl::toAce(domain)), unicode + canonsuffix); + QCOMPARE(QUrl::fromAce(domain.toLatin1()), fromace + suffix); + QCOMPARE(QUrl::fromAce(QUrl::toAce(domain)), unicode + suffix); - domain = in + ".troll.No"; - QCOMPARE(QString::fromLatin1(QUrl::toAce(domain)), toace + canonsuffix); + domain = in + (suffix ? ".troll.No" : ""); + QCOMPARE(QString::fromLatin1(QUrl::toAce(domain)), toace + suffix); if (fromace != ".") - QCOMPARE(QUrl::fromAce(domain.toLatin1()), fromace + canonsuffix); - QCOMPARE(QUrl::fromAce(QUrl::toAce(domain)), unicode + canonsuffix); + QCOMPARE(QUrl::fromAce(domain.toLatin1()), fromace + suffix); + QCOMPARE(QUrl::fromAce(QUrl::toAce(domain)), unicode + suffix); - domain = in + ".troll.NO"; - QCOMPARE(QString::fromLatin1(QUrl::toAce(domain)), toace + canonsuffix); + domain = in + (suffix ? ".troll.NO" : ""); + QCOMPARE(QString::fromLatin1(QUrl::toAce(domain)), toace + suffix); if (fromace != ".") - QCOMPARE(QUrl::fromAce(domain.toLatin1()), fromace + canonsuffix); - QCOMPARE(QUrl::fromAce(QUrl::toAce(domain)), unicode + canonsuffix); + QCOMPARE(QUrl::fromAce(domain.toLatin1()), fromace + suffix); + QCOMPARE(QUrl::fromAce(QUrl::toAce(domain)), unicode + suffix); +} + +void tst_QUrl::std3violations_data() +{ + QTest::addColumn("source"); + QTest::addColumn("validUrl"); + + QTest::newRow("too-long") << "this-domain-is-far-too-long-for-its-own-good-and-should-have-been-limited-to-63-chars" << false; + QTest::newRow("dash-begin") << "-x-foo" << false; + QTest::newRow("dash-end") << "x-foo-" << false; + QTest::newRow("dash-begin-end") << "-foo-" << false; + + QTest::newRow("control") << "\033foo" << false; + QTest::newRow("bang") << "foo!" << false; + QTest::newRow("plus") << "foo+bar" << false; + QTest::newRow("dot") << "foo.bar"; + QTest::newRow("slash") << "foo/bar" << true; + QTest::newRow("colon") << "foo:80" << true; + QTest::newRow("question") << "foo?bar" << true; + QTest::newRow("at") << "foo@bar" << true; + QTest::newRow("backslash") << "foo\\bar" << false; + QTest::newRow("underline") << "foo_bar" << false; + + // these characters are transformed by NFKC to non-LDH characters + QTest::newRow("dot-like") << QString::fromUtf8("foo\342\200\244bar") << false; // U+2024 ONE DOT LEADER + QTest::newRow("slash-like") << QString::fromUtf8("foo\357\274\217bar") << false; // U+FF0F FULLWIDTH SOLIDUS + + // The following should be invalid but isn't + // the DIVISON SLASH doesn't case-fold to a slash + // is this a problem with RFC 3490? + //QTest::newRow("slash-like2") << QString::fromUtf8("foo\342\210\225bar") << false; // U+2215 DIVISION SLASH +} + +void tst_QUrl::std3violations() +{ + QFETCH(QString, source); + + extern QString qt_nameprep(const QString &); + extern bool qt_check_std3rules(const QStringRef &); + + { + QString prepped = qt_nameprep(source); + QVERIFY(!qt_check_std3rules(QStringRef(&prepped))); + } + + if (source.contains('.')) + return; // this test ends here + + QUrl url; + url.setHost(source); + QVERIFY(url.host().isEmpty()); + + QFETCH(bool, validUrl); + if (validUrl) + return; // test ends here for these cases + + url = QUrl("http://" + source + "/some/path"); + QVERIFY(!url.isValid()); } void tst_QUrl::tldRestrictions_data() -- cgit v0.12 From e3c5ca076ee15975dd2d8973b871ec0115c614fc Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 18 Mar 2009 21:42:04 +0100 Subject: Add qt_string_normalize to do in-place Unicode normalization. This way, we can improve QUrl parsing performance by avoiding unnecessary copies. --- src/corelib/tools/qchar.cpp | 28 +++++++++++--------------- src/corelib/tools/qstring.cpp | 46 ++++++++++++++++++++++++------------------- 2 files changed, 37 insertions(+), 37 deletions(-) diff --git a/src/corelib/tools/qchar.cpp b/src/corelib/tools/qchar.cpp index 88053d6..1558f7d 100644 --- a/src/corelib/tools/qchar.cpp +++ b/src/corelib/tools/qchar.cpp @@ -1421,16 +1421,15 @@ QDataStream &operator>>(QDataStream &in, QChar &chr) // --------------------------------------------------------------------------- -static QString decomposeHelper - (const QString &str, bool canonical, QChar::UnicodeVersion version) +static void decomposeHelper(QString *str, bool canonical, QChar::UnicodeVersion version, int from) { unsigned short buffer[3]; - QString s = str; + QString &s = *str; const unsigned short *utf16 = s.utf16(); const unsigned short *uc = utf16 + s.length(); - while (uc != utf16) { + while (uc != utf16 + from) { uint ucs4 = *(--uc); if (QChar(ucs4).isLowSurrogate() && uc != utf16) { ushort high = *(uc - 1); @@ -1453,8 +1452,6 @@ static QString decomposeHelper utf16 = s.utf16(); uc = utf16 + pos + length; } - - return s; } @@ -1489,17 +1486,17 @@ static ushort ligatureHelper(ushort u1, ushort u2) return 0; } -static QString composeHelper(const QString &str) +static void composeHelper(QString *str, int from) { - QString s = str; + QString &s = *str; - if (s.length() < 2) - return s; + if (s.length() - from < 2) + return; // the loop can partly ignore high Unicode as all ligatures are in the BMP int starter = 0; int lastCombining = 0; - int pos = 0; + int pos = from; while (pos < s.length()) { uint uc = s.utf16()[pos]; if (QChar(uc).isHighSurrogate() && pos < s.length()-1) { @@ -1524,16 +1521,14 @@ static QString composeHelper(const QString &str) lastCombining = combining; ++pos; } - return s; } -static QString canonicalOrderHelper - (const QString &str, QChar::UnicodeVersion version) +static void canonicalOrderHelper(QString *str, QChar::UnicodeVersion version, int from) { - QString s = str; + QString &s = *str; const int l = s.length()-1; - int pos = 0; + int pos = from; while (pos < l) { int p2 = pos+1; uint u1 = s.at(pos).unicode(); @@ -1593,7 +1588,6 @@ static QString canonicalOrderHelper ++pos; } } - return s; } int QT_FASTCALL QUnicodeTables::script(unsigned int uc) diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index b97ba45..99fbaa9 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -6028,6 +6028,7 @@ QString QString::repeated(int times) const return result; } +void qt_string_normalize(QString *data, QString::NormalizationForm mode, QChar::UnicodeVersion version, int from); /*! \overload \fn QString QString::normalized(NormalizationForm mode, QChar::UnicodeVersion version) const @@ -6037,42 +6038,48 @@ QString QString::repeated(int times) const */ QString QString::normalized(QString::NormalizationForm mode, QChar::UnicodeVersion version) const { + QString copy = *this; + qt_string_normalize(©, mode, version, 0); + return copy; +} + +void qt_string_normalize(QString *data, QString::NormalizationForm mode, QChar::UnicodeVersion version, int from) +{ bool simple = true; - for (int i = 0; i < d->size; ++i) { - if (d->data[i] >= 0x80) { + const QChar *p = data->constData(); + int len = data->length(); + for (int i = from; i < len; ++i) { + if (p[i].unicode() >= 0x80) { simple = false; break; } } if (simple) - return *this; + return; - QString s = *this; + QString &s = *data; if (version != CURRENT_VERSION) { for (int i = 0; i < NumNormalizationCorrections; ++i) { const NormalizationCorrection &n = uc_normalization_corrections[i]; if (n.version > version) { + int pos = from; if (n.ucs4 > 0xffff) { ushort ucs4High = QChar::highSurrogate(n.ucs4); ushort ucs4Low = QChar::lowSurrogate(n.ucs4); ushort oldHigh = QChar::highSurrogate(n.old_mapping); ushort oldLow = QChar::lowSurrogate(n.old_mapping); - int pos = 0; - while (pos < s.d->size - 1) { - if (s.d->data[pos] == ucs4High && s.d->data[pos + 1] == ucs4Low) { - s.detach(); - s.d->data[pos] = oldHigh; - s.d->data[pos + 1] = oldLow; + while (pos < s.length() - 1) { + if (s.at(pos).unicode() == ucs4High && s.at(pos + 1).unicode() == ucs4Low) { + s[pos] = oldHigh; + s[pos + 1] = oldLow; ++pos; } ++pos; } } else { - int pos = 0; - while (pos < s.d->size) { - if (s.d->data[pos] == n.ucs4) { - s.detach(); - s.d->data[pos] = n.old_mapping; + while (pos < s.length()) { + if (s.at(pos).unicode() == n.ucs4) { + s[pos] = n.old_mapping; } ++pos; } @@ -6080,15 +6087,14 @@ QString QString::normalized(QString::NormalizationForm mode, QChar::UnicodeVersi } } } - s = decomposeHelper(s, mode < QString::NormalizationForm_KD, version); + decomposeHelper(data, mode < QString::NormalizationForm_KD, version, from); - s = canonicalOrderHelper(s, version); + canonicalOrderHelper(data, version, from); if (mode == QString::NormalizationForm_D || mode == QString::NormalizationForm_KD) - return s; - - return composeHelper(s); + return; + composeHelper(data, from); } -- cgit v0.12 From 3b545a4008fed0250d61ce1bb54af1a47fd8df92 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 18 Mar 2009 22:39:03 +0100 Subject: Change qt_nameprep to do in-line nameprepping This will allow to do less allocations in qt_ACE_do. --- src/corelib/io/qurl.cpp | 50 +++++++++++++++++++++----------------------- tests/auto/qurl/tst_qurl.cpp | 12 +++++------ 2 files changed, 30 insertions(+), 32 deletions(-) diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp index dc27dfb..d65cee2 100644 --- a/src/corelib/io/qurl.cpp +++ b/src/corelib/io/qurl.cpp @@ -2336,12 +2336,12 @@ static const NameprepCaseFoldingEntry NameprepCaseFolding[] = { { 0x1D7BB, { 0x03C3, 0x0000, 0x0000, 0x0000 } } }; -static void mapToLowerCase(QString *str) +static void mapToLowerCase(QString *str, int from) { int N = sizeof(NameprepCaseFolding) / sizeof(NameprepCaseFolding[0]); QChar *d = 0; - for (int i = 0; i < str->size(); ++i) { + for (int i = from; i < str->size(); ++i) { int uc = str->at(i).unicode(); if (uc < 0x80) { if (uc <= 'Z' && uc >= 'A') { @@ -2388,11 +2388,11 @@ static bool isMappedToNothing(const QChar &ch) } -static void stripProhibitedOutput(QString *str) +static void stripProhibitedOutput(QString *str, int from) { - ushort *out = (ushort *)str->data(); + ushort *out = (ushort *)str->data() + from; const ushort *in = out; - const ushort *end = out + str->size(); + const ushort *end = (ushort *)str->data() + str->size(); while (in < end) { ushort uc = *in; if (uc < 0x80 || @@ -2903,36 +2903,34 @@ static bool isBidirectionalL(const QChar &ch) #ifdef QT_BUILD_INTERNAL // export for tst_qurl.cpp -Q_AUTOTEST_EXPORT QString qt_nameprep(const QString &); +Q_AUTOTEST_EXPORT void qt_nameprep(QString *source, int from); Q_AUTOTEST_EXPORT bool qt_check_std3rules(const QStringRef &); #else // non-test build, keep the symbols for ourselves -static QString qt_nameprep(const QString &); +static QString void qt_nameprep(QString *source, int from) static bool qt_check_std3rules(const QStringRef &); #endif -QString qt_nameprep(const QString &source) +void qt_nameprep(QString *source, int from) { - QString mapped = source; + QString &mapped = *source; - bool simple = true; - for (int i = 0; i < mapped.size(); ++i) { - ushort uc = mapped.at(i).unicode(); + for ( ; from < mapped.size(); ++from) { + ushort uc = mapped.at(from).unicode(); if (uc > 0x80) { - simple = false; break; } else if (uc >= 'A' && uc <= 'Z') { - mapped[i] = QChar(uc | 0x20); + mapped[from] = QChar(uc | 0x20); } } - if (simple) - return mapped; + if (from == mapped.size()) + return; // everything was mapped easily (lowercased, actually) // Characters commonly mapped to nothing are simply removed // (Table B.1) - QChar *out = mapped.data(); + QChar *out = mapped.data() + from; const QChar *in = out; - const QChar *e = in + mapped.size(); + const QChar *e = mapped.constData() + mapped.size(); while (in < e) { if (!isMappedToNothing(*in)) *out++ = *in; @@ -2942,30 +2940,30 @@ QString qt_nameprep(const QString &source) mapped.truncate(out - mapped.constData()); // Map to lowercase (Table B.2) - mapToLowerCase(&mapped); + mapToLowerCase(&mapped, from); // Normalize to Unicode 3.2 form KC - mapped = mapped.normalized(QString::NormalizationForm_KC, QChar::Unicode_3_2); + extern void qt_string_normalize(QString *data, QString::NormalizationForm mode, + QChar::UnicodeVersion version, int from); + qt_string_normalize(&mapped, QString::NormalizationForm_KC, QChar::Unicode_3_2, from); // Strip prohibited output - stripProhibitedOutput(&mapped); + stripProhibitedOutput(&mapped, from); // Check for valid bidirectional characters bool containsLCat = false; bool containsRandALCat = false; - for (int j = 0; j < mapped.size() && (!containsLCat || !containsRandALCat); ++j) { + for (int j = from; j < mapped.size() && (!containsLCat || !containsRandALCat); ++j) { if (isBidirectionalL(mapped.at(j))) containsLCat = true; else if (isBidirectionalRorAL(mapped.at(j))) containsRandALCat = true; } if (containsRandALCat) { - if (containsLCat || (!isBidirectionalRorAL(mapped.at(0)) + if (containsLCat || (!isBidirectionalRorAL(mapped.at(from)) || !isBidirectionalRorAL(mapped.at(mapped.size() - 1)))) mapped.clear(); } - - return mapped; } bool qt_check_std3rules(const QStringRef &source) @@ -3281,7 +3279,7 @@ static QString qt_ACE_do(const QString &domainMC, AceOperation op) // Nameprep the host. If the labels in the hostname are Punycode // encoded, we decode them immediately, then nameprep them. QString tmp = domain.mid(lastIdx, idx - lastIdx); - tmp = qt_nameprep(tmp); + qt_nameprep(&tmp, 0); if (isIdnEnabled) { toPunycodeHelper(tmp.constData(), tmp.size(), &aux); diff --git a/tests/auto/qurl/tst_qurl.cpp b/tests/auto/qurl/tst_qurl.cpp index fcced37..94abbb3 100644 --- a/tests/auto/qurl/tst_qurl.cpp +++ b/tests/auto/qurl/tst_qurl.cpp @@ -3061,7 +3061,8 @@ void tst_QUrl::nameprep_testsuite_data() #ifdef QT_BUILD_INTERNAL QT_BEGIN_NAMESPACE -extern QString qt_nameprep(const QString &source); +extern void qt_nameprep(QString *source, int from); +extern bool qt_check_std3rules(const QStringRef &); QT_END_NAMESPACE #endif @@ -3086,7 +3087,8 @@ void tst_QUrl::nameprep_testsuite() "Investigate further", Continue); QEXPECT_FAIL("Larger test (expanding)", "Investigate further", Continue); - QCOMPARE(qt_nameprep(in), out); + qt_nameprep(&in, 0); + QCOMPARE(in, out); #endif } @@ -3210,11 +3212,9 @@ void tst_QUrl::std3violations() { QFETCH(QString, source); - extern QString qt_nameprep(const QString &); - extern bool qt_check_std3rules(const QStringRef &); - { - QString prepped = qt_nameprep(source); + QString prepped = source; + qt_nameprep(&prepped, 0); QVERIFY(!qt_check_std3rules(QStringRef(&prepped))); } -- cgit v0.12 From b01ae86c02d2ca81f30055be4641ca418ac94d9b Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 19 Mar 2009 11:34:54 +0100 Subject: Improve performance in QUrl parsing by doing in-line operations. Unfortunately, I can't do it all inline because the punycode encoding and decoding requires reading the source several times. (Maybe the decoding can be done with some effort in the future) --- src/corelib/io/qurl.cpp | 63 ++++++++++++++++++++++---------------------- tests/auto/qurl/tst_qurl.cpp | 4 +-- 2 files changed, 34 insertions(+), 33 deletions(-) diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp index d65cee2..fcae0d6 100644 --- a/src/corelib/io/qurl.cpp +++ b/src/corelib/io/qurl.cpp @@ -2904,11 +2904,11 @@ static bool isBidirectionalL(const QChar &ch) #ifdef QT_BUILD_INTERNAL // export for tst_qurl.cpp Q_AUTOTEST_EXPORT void qt_nameprep(QString *source, int from); -Q_AUTOTEST_EXPORT bool qt_check_std3rules(const QStringRef &); +Q_AUTOTEST_EXPORT bool qt_check_std3rules(const QChar *uc, int len); #else // non-test build, keep the symbols for ourselves -static QString void qt_nameprep(QString *source, int from) -static bool qt_check_std3rules(const QStringRef &); +static void qt_nameprep(QString *source, int from); +static bool qt_check_std3rules(const QChar *uc, int len); #endif void qt_nameprep(QString *source, int from) @@ -2966,14 +2966,13 @@ void qt_nameprep(QString *source, int from) } } -bool qt_check_std3rules(const QStringRef &source) +bool qt_check_std3rules(const QChar *uc, int len) { - int len = source.length(); if (len > 63) return false; for (int i = 0; i < len; ++i) { - register ushort c = source.at(i).unicode(); + register ushort c = uc[i].unicode(); if (c == '-' && (i == 0 || i == len - 1)) return false; @@ -3264,41 +3263,43 @@ static QString qt_ACE_do(const QString &domainMC, AceOperation op) simple = false; } - QString aux; - QStringRef label; + // copy the label to the destination, which also serves as our scratch area + int prevLen = result.size(); + result.resize(prevLen + idx - lastIdx); + memcpy(result.data() + prevLen, domain.constData() + lastIdx, (idx - lastIdx) * sizeof(QChar)); + if (simple) { - // fastest conversion: this is the common case (non IDN-domains) - // just memcpy from source (domain) to destination (result) + // fastest case: this is the common case (non IDN-domains) // there's no need to nameprep since everything is ASCII already - int prevLen = result.size(); - result.resize(prevLen + idx - lastIdx); - memcpy(result.data() + prevLen, domain.constData() + lastIdx, (idx - lastIdx) * sizeof(QChar)); - - label = QStringRef(&result, prevLen, result.length() - prevLen); - } else { + // so we're done + if (!qt_check_std3rules(result.constData() + prevLen, result.length() - prevLen)) + return QString(); + } else { // Nameprep the host. If the labels in the hostname are Punycode - // encoded, we decode them immediately, then nameprep them. - QString tmp = domain.mid(lastIdx, idx - lastIdx); - qt_nameprep(&tmp, 0); + // encoded, we decode them immediately. + qt_nameprep(&result, prevLen); - if (isIdnEnabled) { - toPunycodeHelper(tmp.constData(), tmp.size(), &aux); - label = QStringRef(&aux); + // Punycode encoding and decoding cannot be done in-place + // That means we need one or two temporaries + QString aceForm; + aceForm.reserve(result.size() - prevLen + 4 + 4); // "xn--" and "-xyz" + toPunycodeHelper(result.constData() + prevLen, result.size() - prevLen, &aceForm); - tmp = QUrl::fromPunycode(aux.toLatin1()); + if (isIdnEnabled) { + QString tmp = QUrl::fromPunycode(aceForm.toLatin1()); if (tmp.isEmpty()) - return QString(); - result += tmp; + return QString(); // shouldn't happen, since we've just punycode-encoded it + result.resize(prevLen + tmp.size()); + memcpy(result.data() + prevLen, tmp.constData(), tmp.size() * sizeof(QChar)); } else { - int prevLen = result.size(); - toPunycodeHelper(tmp.constData(), tmp.size(), &result); - - label = QStringRef(&result, prevLen, result.length() - prevLen); + result.resize(prevLen + aceForm.size()); + memcpy(result.data() + prevLen, aceForm.constData(), aceForm.size() * sizeof(QChar)); } + + if (!qt_check_std3rules(aceForm.constData(), aceForm.size())) + return QString(); } - if (!qt_check_std3rules(label)) - return QString(); lastIdx = idx + 1; if (lastIdx < domain.size() + 1) diff --git a/tests/auto/qurl/tst_qurl.cpp b/tests/auto/qurl/tst_qurl.cpp index 94abbb3..78ea146 100644 --- a/tests/auto/qurl/tst_qurl.cpp +++ b/tests/auto/qurl/tst_qurl.cpp @@ -3062,7 +3062,7 @@ void tst_QUrl::nameprep_testsuite_data() #ifdef QT_BUILD_INTERNAL QT_BEGIN_NAMESPACE extern void qt_nameprep(QString *source, int from); -extern bool qt_check_std3rules(const QStringRef &); +extern bool qt_check_std3rules(const QChar *, int); QT_END_NAMESPACE #endif @@ -3215,7 +3215,7 @@ void tst_QUrl::std3violations() { QString prepped = source; qt_nameprep(&prepped, 0); - QVERIFY(!qt_check_std3rules(QStringRef(&prepped))); + QVERIFY(!qt_check_std3rules(prepped.constData(), prepped.length())); } if (source.contains('.')) -- cgit v0.12 From 8e6293712a9126c2740bf5628e02325d04721b2e Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 19 Mar 2009 11:55:18 +0100 Subject: One more improvement in QUrl: avoid an extra lowercasing step. Since we're going to do nameprepping anyways, avoid the lowercasing step at the function entry (and thus, one extra temporary). The nameprepping step is also faster than QString::toLower for the ASCII case. --- src/corelib/io/qurl.cpp | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp index fcae0d6..fe3ad82 100644 --- a/src/corelib/io/qurl.cpp +++ b/src/corelib/io/qurl.cpp @@ -3178,7 +3178,7 @@ static bool qt_is_idn_enabled(const QString &domain) int len = domain.size() - idx - 1; if (user_idn_whitelist) - return user_idn_whitelist->contains(QString(tld, len)); + return user_idn_whitelist->contains(QString::fromRawData(tld, len).toLower()); int l = 0; int r = sizeof(idn_whitelist)/sizeof(const char *) - 1; @@ -3217,11 +3217,10 @@ static int nextDotDelimiter(const QString &domain, int from = 0) } enum AceOperation { ToAceOnly, NormalizeAce }; -static QString qt_ACE_do(const QString &domainMC, AceOperation op) +static QString qt_ACE_do(const QString &domain, AceOperation op) { - if (domainMC.isEmpty()) - return domainMC; - QString domain = domainMC.toLower(); + if (domain.isEmpty()) + return domain; QString result; result.reserve(domain.length()); @@ -3255,30 +3254,27 @@ static QString qt_ACE_do(const QString &domainMC, AceOperation op) } } + // copy the label to the destination, which also serves as our scratch area + // then nameprep it (in the case of "simple", it will cause a simple lowercasing) + int prevLen = result.size(); + result.resize(prevLen + idx - lastIdx); + memcpy(result.data() + prevLen, domain.constData() + lastIdx, (idx - lastIdx) * sizeof(QChar)); + qt_nameprep(&result, prevLen); + if (simple && idx > lastIdx + 4) { - // ACE form domains are simple, but we can't consider them simple + // ACE form domains contain only ASCII characters, but we can't consider them simple // is this an ACE form? static const ushort acePrefixUtf16[] = { 'x', 'n', '-', '-' }; - if (memcmp(domain.utf16() + lastIdx, acePrefixUtf16, sizeof acePrefixUtf16) == 0) + if (memcmp(result.utf16() + prevLen, acePrefixUtf16, sizeof acePrefixUtf16) == 0) simple = false; } - // copy the label to the destination, which also serves as our scratch area - int prevLen = result.size(); - result.resize(prevLen + idx - lastIdx); - memcpy(result.data() + prevLen, domain.constData() + lastIdx, (idx - lastIdx) * sizeof(QChar)); - if (simple) { // fastest case: this is the common case (non IDN-domains) - // there's no need to nameprep since everything is ASCII already // so we're done if (!qt_check_std3rules(result.constData() + prevLen, result.length() - prevLen)) return QString(); } else { - // Nameprep the host. If the labels in the hostname are Punycode - // encoded, we decode them immediately. - qt_nameprep(&result, prevLen); - // Punycode encoding and decoding cannot be done in-place // That means we need one or two temporaries QString aceForm; -- cgit v0.12 From 4c64137c6dfbfcc5a6fecbb04f5159ec491842e1 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 19 Mar 2009 14:43:41 +0100 Subject: Fix bug in locating non-lowercase TLDs: must lowercase. Use qt_nameprep after all since it's extremely fast for ASCII only and it does in-place replacement. --- src/corelib/io/qurl.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp index fe3ad82..78e314e 100644 --- a/src/corelib/io/qurl.cpp +++ b/src/corelib/io/qurl.cpp @@ -3174,11 +3174,15 @@ static bool qt_is_idn_enabled(const QString &domain) int idx = domain.lastIndexOf(QLatin1Char('.')); if (idx == -1) return false; - const QChar *tld = domain.constData() + idx + 1; + int len = domain.size() - idx - 1; + QString tldString(domain.constData() + idx + 1, len); + qt_nameprep(&tldString, 0); + + const QChar *tld = tldString.constData(); if (user_idn_whitelist) - return user_idn_whitelist->contains(QString::fromRawData(tld, len).toLower()); + return user_idn_whitelist->contains(tldString); int l = 0; int r = sizeof(idn_whitelist)/sizeof(const char *) - 1; -- cgit v0.12 From 52f5eee17a629fca785f79dcfc8b7bf0b23d1da2 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 19 Mar 2009 14:45:41 +0100 Subject: Minor performance improvements in nameprepping. Avoid calling functions that may have other side effects, like QString::utf16(). Use pointers whenever possible when iterating over the string. --- src/corelib/io/qurl.cpp | 43 +++++++++++++++++++++++-------------------- src/corelib/tools/qchar.cpp | 10 +++++----- 2 files changed, 28 insertions(+), 25 deletions(-) diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp index 78e314e..49c0d538 100644 --- a/src/corelib/io/qurl.cpp +++ b/src/corelib/io/qurl.cpp @@ -2913,56 +2913,59 @@ static bool qt_check_std3rules(const QChar *uc, int len); void qt_nameprep(QString *source, int from) { - QString &mapped = *source; - - for ( ; from < mapped.size(); ++from) { - ushort uc = mapped.at(from).unicode(); + QChar *src = source->data(); // causes a detach, so we're sure the only one using it + QChar *out = src + from; + const QChar *e = src + source->size(); + + for ( ; out < e; ++out) { + register ushort uc = out->unicode(); if (uc > 0x80) { break; } else if (uc >= 'A' && uc <= 'Z') { - mapped[from] = QChar(uc | 0x20); + *out = QChar(uc | 0x20); } } - if (from == mapped.size()) + if (out == e) return; // everything was mapped easily (lowercased, actually) - + int firstNonAscii = out - src; + // Characters commonly mapped to nothing are simply removed // (Table B.1) - QChar *out = mapped.data() + from; const QChar *in = out; - const QChar *e = mapped.constData() + mapped.size(); while (in < e) { if (!isMappedToNothing(*in)) *out++ = *in; ++in; } if (out != in) - mapped.truncate(out - mapped.constData()); + source->truncate(out - src); // Map to lowercase (Table B.2) - mapToLowerCase(&mapped, from); + mapToLowerCase(source, firstNonAscii); // Normalize to Unicode 3.2 form KC extern void qt_string_normalize(QString *data, QString::NormalizationForm mode, QChar::UnicodeVersion version, int from); - qt_string_normalize(&mapped, QString::NormalizationForm_KC, QChar::Unicode_3_2, from); + qt_string_normalize(source, QString::NormalizationForm_KC, QChar::Unicode_3_2, firstNonAscii); // Strip prohibited output - stripProhibitedOutput(&mapped, from); + stripProhibitedOutput(source, firstNonAscii); // Check for valid bidirectional characters bool containsLCat = false; bool containsRandALCat = false; - for (int j = from; j < mapped.size() && (!containsLCat || !containsRandALCat); ++j) { - if (isBidirectionalL(mapped.at(j))) + src = source->data(); + e = src + source->size(); + for (in = src + from; in < e && (!containsLCat || !containsRandALCat); ++in) { + if (isBidirectionalL(*in)) containsLCat = true; - else if (isBidirectionalRorAL(mapped.at(j))) + else if (isBidirectionalRorAL(*in)) containsRandALCat = true; } if (containsRandALCat) { - if (containsLCat || (!isBidirectionalRorAL(mapped.at(from)) - || !isBidirectionalRorAL(mapped.at(mapped.size() - 1)))) - mapped.clear(); + if (containsLCat || (!isBidirectionalRorAL(src[from]) + || !isBidirectionalRorAL(e[-1]))) + source->resize(from); // not allowed, clear the label } } @@ -3269,7 +3272,7 @@ static QString qt_ACE_do(const QString &domain, AceOperation op) // ACE form domains contain only ASCII characters, but we can't consider them simple // is this an ACE form? static const ushort acePrefixUtf16[] = { 'x', 'n', '-', '-' }; - if (memcmp(result.utf16() + prevLen, acePrefixUtf16, sizeof acePrefixUtf16) == 0) + if (memcmp(result.constData() + prevLen, acePrefixUtf16, sizeof acePrefixUtf16) == 0) simple = false; } diff --git a/src/corelib/tools/qchar.cpp b/src/corelib/tools/qchar.cpp index 1558f7d..458a383 100644 --- a/src/corelib/tools/qchar.cpp +++ b/src/corelib/tools/qchar.cpp @@ -1427,7 +1427,7 @@ static void decomposeHelper(QString *str, bool canonical, QChar::UnicodeVersion QString &s = *str; - const unsigned short *utf16 = s.utf16(); + const unsigned short *utf16 = reinterpret_cast(s.data()); const unsigned short *uc = utf16 + s.length(); while (uc != utf16 + from) { uint ucs4 = *(--uc); @@ -1449,7 +1449,7 @@ static void decomposeHelper(QString *str, bool canonical, QChar::UnicodeVersion s.replace(uc - utf16, ucs4 > 0x10000 ? 2 : 1, (const QChar *)d, length); // since the insert invalidates the pointers and we do decomposition recursive int pos = uc - utf16; - utf16 = s.utf16(); + utf16 = reinterpret_cast(s.data()); uc = utf16 + pos + length; } } @@ -1498,9 +1498,9 @@ static void composeHelper(QString *str, int from) int lastCombining = 0; int pos = from; while (pos < s.length()) { - uint uc = s.utf16()[pos]; + uint uc = s.at(pos).unicode(); if (QChar(uc).isHighSurrogate() && pos < s.length()-1) { - ushort low = s.utf16()[pos+1]; + ushort low = s.at(pos+1).unicode(); if (QChar(low).isLowSurrogate()) { uc = QChar::surrogateToUcs4(uc, low); ++pos; @@ -1509,7 +1509,7 @@ static void composeHelper(QString *str, int from) int combining = QChar::combiningClass(uc); if (starter == pos - 1 || combining > lastCombining) { // allowed to form ligature with S - QChar ligature = ligatureHelper(s.utf16()[starter], uc); + QChar ligature = ligatureHelper(s.at(starter).unicode(), uc); if (ligature.unicode()) { s[starter] = ligature; s.remove(pos, 1); -- cgit v0.12 From f15d4e5e02e109003b6e28cad71441f19b6ea608 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 19 Mar 2009 15:27:45 +0100 Subject: Slight performance improvement by caching the label size. --- src/corelib/io/qurl.cpp | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp index 49c0d538..096e37e 100644 --- a/src/corelib/io/qurl.cpp +++ b/src/corelib/io/qurl.cpp @@ -3234,9 +3234,12 @@ static QString qt_ACE_do(const QString &domain, AceOperation op) const bool isIdnEnabled = op == NormalizeAce ? qt_is_idn_enabled(domain) : false; int lastIdx = 0; + QString aceForm; // this variable is here for caching + while (1) { int idx = nextDotDelimiter(domain, lastIdx); - if (idx == lastIdx) + int labelLength = idx - lastIdx; + if (labelLength == 0) return QString(); // two delimiters in a row -- empty label not allowed // RFC 3490 says, about the ToASCII operation: @@ -3264,13 +3267,15 @@ static QString qt_ACE_do(const QString &domain, AceOperation op) // copy the label to the destination, which also serves as our scratch area // then nameprep it (in the case of "simple", it will cause a simple lowercasing) int prevLen = result.size(); - result.resize(prevLen + idx - lastIdx); - memcpy(result.data() + prevLen, domain.constData() + lastIdx, (idx - lastIdx) * sizeof(QChar)); + result.resize(prevLen + labelLength); + memcpy(result.data() + prevLen, domain.constData() + lastIdx, labelLength * sizeof(QChar)); qt_nameprep(&result, prevLen); + labelLength = result.length() - prevLen; - if (simple && idx > lastIdx + 4) { + if (simple && labelLength > 6) { // ACE form domains contain only ASCII characters, but we can't consider them simple // is this an ACE form? + // the shortest valid ACE domain is 6 characters long (U+0080 would be 1, but it's not allowed) static const ushort acePrefixUtf16[] = { 'x', 'n', '-', '-' }; if (memcmp(result.constData() + prevLen, acePrefixUtf16, sizeof acePrefixUtf16) == 0) simple = false; @@ -3279,15 +3284,17 @@ static QString qt_ACE_do(const QString &domain, AceOperation op) if (simple) { // fastest case: this is the common case (non IDN-domains) // so we're done - if (!qt_check_std3rules(result.constData() + prevLen, result.length() - prevLen)) + if (!qt_check_std3rules(result.constData() + prevLen, labelLength)) return QString(); } else { // Punycode encoding and decoding cannot be done in-place // That means we need one or two temporaries - QString aceForm; - aceForm.reserve(result.size() - prevLen + 4 + 4); // "xn--" and "-xyz" + register int toReserve = labelLength + 4 + 6; // "xn--" plus some extra bytes + if (toReserve > aceForm.capacity()) + aceForm.reserve(toReserve); toPunycodeHelper(result.constData() + prevLen, result.size() - prevLen, &aceForm); + // We use resize()+memcpy() here because we're overwriting the data we've copied if (isIdnEnabled) { QString tmp = QUrl::fromPunycode(aceForm.toLatin1()); if (tmp.isEmpty()) -- cgit v0.12 From ff1280178ac8739e5943fd081be5317b70717fa8 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 19 Mar 2009 15:46:32 +0100 Subject: Merge the memcpy with the lowercasing and the non-ASCII detection. This gives a 5% improvement in performance by avoiding iterating over the contents more than once. --- src/corelib/io/qurl.cpp | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp index 096e37e..79cd2f0 100644 --- a/src/corelib/io/qurl.cpp +++ b/src/corelib/io/qurl.cpp @@ -3255,23 +3255,25 @@ static QString qt_ACE_do(const QString &domain, AceOperation op) // 8. Verify that the number of code points is in the range 1 to 63 // inclusive. + // copy the label to the destination, which also serves as our scratch area, lowercasing it + int prevLen = result.size(); bool simple = true; - for (int i = lastIdx; i < idx; ++i) { - ushort ch = domain.at(i).unicode(); - if (ch > 0x7f) { - simple = false; - break; + result.resize(prevLen + labelLength); + { + QChar *out = result.data() + prevLen; + const QChar *in = domain.constData() + lastIdx; + const QChar *e = in + labelLength; + for (; in < e; ++in, ++out) { + register ushort uc = in->unicode(); + if (uc > 0x7f) + simple = false; + if (uc >= 'A' && uc <= 'Z') + *out = QChar(uc | 0x20); + else + *out = *in; } } - // copy the label to the destination, which also serves as our scratch area - // then nameprep it (in the case of "simple", it will cause a simple lowercasing) - int prevLen = result.size(); - result.resize(prevLen + labelLength); - memcpy(result.data() + prevLen, domain.constData() + lastIdx, labelLength * sizeof(QChar)); - qt_nameprep(&result, prevLen); - labelLength = result.length() - prevLen; - if (simple && labelLength > 6) { // ACE form domains contain only ASCII characters, but we can't consider them simple // is this an ACE form? @@ -3289,6 +3291,8 @@ static QString qt_ACE_do(const QString &domain, AceOperation op) } else { // Punycode encoding and decoding cannot be done in-place // That means we need one or two temporaries + qt_nameprep(&result, prevLen); + labelLength = result.length() - prevLen; register int toReserve = labelLength + 4 + 6; // "xn--" plus some extra bytes if (toReserve > aceForm.capacity()) aceForm.reserve(toReserve); -- cgit v0.12 From 3c2ebb7f209035f85a35dbb05e76dd7e80238ecb Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 21 Jul 2009 15:46:29 +0200 Subject: Add the information about QUrl being more strict to the changelog --- dist/changes-4.6.0 | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/dist/changes-4.6.0 b/dist/changes-4.6.0 index bef2923..6c7e450 100644 --- a/dist/changes-4.6.0 +++ b/dist/changes-4.6.0 @@ -72,5 +72,18 @@ information about a particular change. QGraphicsWidget and QGraphicsProxyWidget). - QDesktopWidget on X11 no longer emits the resized(int) signal when screens - are added or removed. This was not done on other platforms. Use the + are added or removed. This was not done on other platforms. Use the screenCountChanged signal instead + +- QUrl's parser is more strict when for hostnames in URLs. QUrl now + enforces STD 3 rules: + + * each individual hostname section (between dots) must be at most + 63 ASCII characters in length; + + * only letters, digits, and the hyphen character are allowed in the + ASCII range; letters outside the ASCII range follow the normal + IDN rules + + That means QUrl no longer accepts some URLs that were invalid + before, but weren't interpreted as such. -- cgit v0.12 From 40649c420601bcc1f639fc8b337bfd7375d2b37e Mon Sep 17 00:00:00 2001 From: Kim Motoyoshi Kalland Date: Mon, 20 Jul 2009 15:49:15 +0200 Subject: Fixed inheritence of SVG 'use' element fill attributes. Inheritence of fill attributes was implemented by copying attributes from the parent node. This approach wouldn't work if the node is referenced by a 'use' element. Now, only the fill attributes which have been explicitly set are applied on the painter while drawing. Reviewed-by: Tor Arne --- src/svg/qsvghandler.cpp | 25 +++++-------------------- src/svg/qsvgstyle.cpp | 38 ++++++++++++++++++++++++++++++-------- src/svg/qsvgstyle_p.h | 1 + 3 files changed, 36 insertions(+), 28 deletions(-) diff --git a/src/svg/qsvghandler.cpp b/src/svg/qsvghandler.cpp index 5f9d1dd..5857e1c 100644 --- a/src/svg/qsvghandler.cpp +++ b/src/svg/qsvghandler.cpp @@ -644,26 +644,19 @@ static void parseBrush(QSvgNode *node, QString opacity = attributes.value(QLatin1String("fill-opacity")).toString(); QString myId = someId(attributes); - QSvgFillStyle *inherited = - static_cast(node->parent()->styleProperty( - QSvgStyleProperty::FILL)); - QSvgFillStyle *prop = new QSvgFillStyle(QColor(Qt::black)); + QSvgFillStyle *prop = new QSvgFillStyle(0); //fill-rule attribute handling - Qt::FillRule f = Qt::WindingFill; if (!fillRule.isEmpty() && fillRule != QLatin1String("inherit")) { if (fillRule == QLatin1String("evenodd")) - f = Qt::OddEvenFill; - } else if (inherited) { - f = inherited->fillRule(); + prop->setFillRule(Qt::OddEvenFill); + else if (fillRule == QLatin1String("nonzero")) + prop->setFillRule(Qt::WindingFill); } //fill-opacity atttribute handling - qreal fillOpacity = 1.0; if (!opacity.isEmpty() && opacity != QLatin1String("inherit")) { - fillOpacity = qMin(qreal(1.0), qMax(qreal(0.0), toDouble(opacity))); - } else if (inherited) { - fillOpacity = inherited->fillOpacity(); + prop->setFillOpacity(qMin(qreal(1.0), qMax(qreal(0.0), toDouble(opacity)))); } //fill attribute handling @@ -685,15 +678,7 @@ static void parseBrush(QSvgNode *node, } else { prop->setBrush(QBrush(Qt::NoBrush)); } - } else if (inherited) { - if (inherited->style()) { - prop->setFillStyle(inherited->style()); - } else { - prop->setBrush(inherited->qbrush()); - } } - prop->setFillOpacity(fillOpacity); - prop->setFillRule(f); node->appendStyleProperty(prop,myId); } diff --git a/src/svg/qsvgstyle.cpp b/src/svg/qsvgstyle.cpp index b693429..c3c0a68 100644 --- a/src/svg/qsvgstyle.cpp +++ b/src/svg/qsvgstyle.cpp @@ -81,12 +81,25 @@ void QSvgQualityStyle::revert(QPainter *, QSvgExtraStates &) } QSvgFillStyle::QSvgFillStyle(const QBrush &brush) - : m_fill(brush), m_style(0), m_fillRuleSet(false), m_fillRule(Qt::WindingFill), m_fillOpacitySet(false), m_fillOpacity(1.0), m_gradientResolved (true) + : m_fill(brush) + , m_style(0) + , m_fillRuleSet(false) + , m_fillRule(Qt::WindingFill) + , m_fillOpacitySet(false) + , m_fillOpacity(1.0) + , m_gradientResolved(true) + , m_fillSet(true) { } QSvgFillStyle::QSvgFillStyle(QSvgStyleProperty *style) - : m_style(style), m_fillRuleSet(false), m_fillRule(Qt::WindingFill), m_fillOpacitySet(false), m_fillOpacity(1.0), m_gradientResolved (true) + : m_style(style) + , m_fillRuleSet(false) + , m_fillRule(Qt::WindingFill) + , m_fillOpacitySet(false) + , m_fillOpacity(1.0) + , m_gradientResolved(true) + , m_fillSet(style != 0) { } @@ -105,11 +118,14 @@ void QSvgFillStyle::setFillOpacity(qreal opacity) void QSvgFillStyle::setFillStyle(QSvgStyleProperty* style) { m_style = style; + m_fillSet = true; } void QSvgFillStyle::setBrush(QBrush brush) { m_fill = brush; + m_style = 0; + m_fillSet = true; } static void recursivelySetFill(QSvgNode *node, Qt::FillRule f) @@ -136,20 +152,26 @@ void QSvgFillStyle::apply(QPainter *p, const QRectF &rect, QSvgNode *node, QSvgE recursivelySetFill(node, m_fillRule); m_fillRuleSet = false;//set it only on the first run } - p->setBrush(m_fill); + if (m_fillSet) { + if (m_style) + m_style->apply(p, rect, node, states); + else + p->setBrush(m_fill); + } if (m_fillOpacitySet) states.fillOpacity = m_fillOpacity; - if (m_style) - m_style->apply(p, rect, node, states); } void QSvgFillStyle::revert(QPainter *p, QSvgExtraStates &states) { - if (m_style) - m_style->revert(p, states); - p->setBrush(m_oldFill); if (m_fillOpacitySet) states.fillOpacity = m_oldOpacity; + if (m_fillSet) { + if (m_style) + m_style->revert(p, states); + else + p->setBrush(m_oldFill); + } } QSvgViewportFillStyle::QSvgViewportFillStyle(const QBrush &brush) diff --git a/src/svg/qsvgstyle_p.h b/src/svg/qsvgstyle_p.h index ac5e109..70ecf5b 100644 --- a/src/svg/qsvgstyle_p.h +++ b/src/svg/qsvgstyle_p.h @@ -281,6 +281,7 @@ private: qreal m_oldOpacity; QString m_gradientId; bool m_gradientResolved; + bool m_fillSet; }; class QSvgViewportFillStyle : public QSvgStyleProperty -- cgit v0.12 From 8c97cd7a91e99a2665e871efe1bf577e33eaff3a Mon Sep 17 00:00:00 2001 From: Kim Motoyoshi Kalland Date: Mon, 20 Jul 2009 12:41:47 +0200 Subject: Fixed GL2 engine shader manager to work with more than one context. I added a QGLContextResource class which can be used internally in Qt for sharing resources between contexts. The QGLContextResource is a hash map where the context is used as 'key', and the resource is the 'value'. All the sharing contexts point to the same resource, and the resource is automatically deleted when it is not referenced any more. Now, the shader manager uses the QGLContextResource class. I also added a pointer to a struct in the QGLContextPrivate class. The struct is shared between all the sharing contexts and is deleted automatically. Currently, the struct only contains the resolved OpenGL function pointers. The shared context register code has been simplified. Reviewed-by: Tom --- .../gl2paintengineex/qglengineshadermanager.cpp | 22 +++ .../gl2paintengineex/qglengineshadermanager_p.h | 3 + .../gl2paintengineex/qpaintengineex_opengl2.cpp | 11 +- src/opengl/qgl.cpp | 159 ++++++++++++++++++++- src/opengl/qgl.h | 1 + src/opengl/qgl_p.h | 95 ++++++------ 6 files changed, 228 insertions(+), 63 deletions(-) diff --git a/src/opengl/gl2paintengineex/qglengineshadermanager.cpp b/src/opengl/gl2paintengineex/qglengineshadermanager.cpp index 27636f4..d7c91b8 100644 --- a/src/opengl/gl2paintengineex/qglengineshadermanager.cpp +++ b/src/opengl/gl2paintengineex/qglengineshadermanager.cpp @@ -49,6 +49,28 @@ QT_BEGIN_NAMESPACE +static void QGLEngineShaderManager_free(void *ptr) +{ + delete reinterpret_cast(ptr); +} + +Q_GLOBAL_STATIC_WITH_ARGS(QGLContextResource, qt_shader_managers, (QGLEngineShaderManager_free)) + +QGLEngineShaderManager *QGLEngineShaderManager::managerForContext(const QGLContext *context) +{ + QGLEngineShaderManager *p = reinterpret_cast(qt_shader_managers()->value(context)); + if (!p) { + QGLContext *oldContext = const_cast(QGLContext::currentContext()); + if (oldContext != context) + const_cast(context)->makeCurrent(); + p = new QGLEngineShaderManager(const_cast(context)); + qt_shader_managers()->insert(context, p); + if (oldContext && oldContext != context) + oldContext->makeCurrent(); + } + return p; +} + const char* QGLEngineShaderManager::qglEngineShaderSourceCode[] = { 0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0, diff --git a/src/opengl/gl2paintengineex/qglengineshadermanager_p.h b/src/opengl/gl2paintengineex/qglengineshadermanager_p.h index 442edfe..99711bd40 100644 --- a/src/opengl/gl2paintengineex/qglengineshadermanager_p.h +++ b/src/opengl/gl2paintengineex/qglengineshadermanager_p.h @@ -220,6 +220,7 @@ #include #include #include +#include QT_BEGIN_HEADER @@ -314,6 +315,8 @@ public: QGLShaderProgram* simpleProgram(); // Used to draw into e.g. stencil buffers QGLShaderProgram* blitProgram(); // Used to blit a texture into the framebuffer + static QGLEngineShaderManager *managerForContext(const QGLContext *context); + enum ShaderName { MainVertexShader, MainWithTexCoordsVertexShader, diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp index 2bfbf4a..9b0321d 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp @@ -266,10 +266,6 @@ extern QImage qt_imageForBrush(int brushStyle, bool invert); QGL2PaintEngineExPrivate::~QGL2PaintEngineExPrivate() { - if (shaderManager) { - delete shaderManager; - shaderManager = 0; - } } void QGL2PaintEngineExPrivate::updateTextureFilter(GLenum target, GLenum wrapMode, bool smoothPixmapTransform, GLuint id) @@ -1209,11 +1205,8 @@ bool QGL2PaintEngineEx::begin(QPaintDevice *pdev) qt_resolve_version_2_0_functions(d->ctx); #endif - if (d->shaderManager) { - d->shaderManager->setDirty(); - } else { - d->shaderManager = new QGLEngineShaderManager(d->ctx); - } + d->shaderManager = QGLEngineShaderManager::managerForContext(d->ctx); + d->shaderManager->setDirty(); glViewport(0, 0, d->width, d->height); diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index 0169ea2..f51b271 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -3363,8 +3363,13 @@ bool QGLWidget::event(QEvent *e) #elif defined(Q_WS_WIN) if (e->type() == QEvent::ParentChange) { QGLContext *newContext = new QGLContext(d->glcx->requestedFormat(), this); - qgl_share_reg()->replaceShare(d->glcx, newContext); + QList shares = qgl_share_reg()->shares(d->glcx); setContext(newContext); + for (int i = 0; i < shares.size(); ++i) { + if (newContext != shares.at(i)) + qgl_share_reg()->addShare(newContext, shares.at(i)); + } + // the overlay needs to be recreated as well delete d->olcx; if (isValid() && context()->format().hasOverlay()) { @@ -4612,4 +4617,156 @@ bool QGLDrawable::autoFillBackground() const return false; } + +bool QGLShareRegister::checkSharing(const QGLContext *context1, const QGLContext *context2) { + bool sharing = (context1 && context2 && context1->d_ptr->groupResources == context2->d_ptr->groupResources); + return sharing; +} + +void QGLShareRegister::addShare(const QGLContext *context, const QGLContext *share) { + Q_ASSERT(context && share); + if (context->d_ptr->groupResources == share->d_ptr->groupResources) + 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); + + // 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(); + + // Maintain a list of all the contexts in each group of sharing contexts. + SharingHash::iterator it = reg.find(share->d_ptr->groupResources); + if (it == reg.end()) + it = reg.insert(share->d_ptr->groupResources, ContextList() << share); + it.value() << context; +} + +QList QGLShareRegister::shares(const QGLContext *context) { + SharingHash::const_iterator it = reg.find(context->d_ptr->groupResources); + if (it == reg.end()) + return ContextList(); + return it.value(); +} + +void QGLShareRegister::removeShare(const QGLContext *context) { + SharingHash::iterator it = reg.find(context->d_ptr->groupResources); + if (it == reg.end()) + return; + + int count = it.value().removeAll(context); + Q_ASSERT(count == 1); + + Q_ASSERT(it.value().size() != 0); + if (it.value().size() == 1) + reg.erase(it); +} + +QGLContextResource::QGLContextResource(FreeFunc f, QObject *parent) + : QObject(parent), free(f) +{ + connect(QGLSignalProxy::instance(), SIGNAL(aboutToDestroyContext(const QGLContext *)), this, SLOT(aboutToDestroyContext(const QGLContext *))); +} + +QGLContextResource::~QGLContextResource() +{ + while (!m_resources.empty()) + remove(m_resources.begin().key()); +} + +void QGLContextResource::insert(const QGLContext *key, void *value) +{ + QList shares = qgl_share_reg()->shares(key); + if (shares.size() == 0) + shares.append(key); + void *oldValue = 0; + for (int i = 0; i < shares.size(); ++i) { + ResourceHash::iterator it = m_resources.find(shares.at(i)); + if (it != m_resources.end()) { + Q_ASSERT(oldValue == 0 || oldValue == it.value()); + oldValue = it.value(); + it.value() = value; + } else { + m_resources.insert(shares.at(i), value); + } + } + if (oldValue != 0 && oldValue != value) { + QGLContext *oldContext = const_cast(QGLContext::currentContext()); + if (oldContext != key) + const_cast(key)->makeCurrent(); + free(oldValue); + if (oldContext && oldContext != key) + oldContext->makeCurrent(); + } +} + +void *QGLContextResource::value(const QGLContext *key) +{ + ResourceHash::const_iterator it = m_resources.find(key); + // Check if there is a value associated with 'key'. + if (it != m_resources.end()) + return it.value(); + // Check if there is a value associated with sharing contexts. + QList shares = qgl_share_reg()->shares(key); + for (int i = 0; i < shares.size() && it == m_resources.end(); ++i) + it = m_resources.find(shares.at(i)); + if (it == m_resources.end()) + return 0; // Didn't find anything. + + // Found something! Share this info with all the buddies. + for (int i = 0; i < shares.size(); ++i) + m_resources.insert(shares.at(i), it.value()); + return it.value(); +} + +void QGLContextResource::remove(const QGLContext *key) +{ + QList shares = qgl_share_reg()->shares(key); + if (shares.size() == 0) + shares.append(key); + void *oldValue = 0; + for (int i = 0; i < shares.size(); ++i) { + ResourceHash::iterator it = m_resources.find(shares.at(i)); + if (it != m_resources.end()) { + Q_ASSERT(oldValue == 0 || oldValue == it.value()); + oldValue = it.value(); + m_resources.erase(it); + } + } + if (oldValue != 0) { + QGLContext *oldContext = const_cast(QGLContext::currentContext()); + if (oldContext != key) + const_cast(key)->makeCurrent(); + free(oldValue); + if (oldContext && oldContext != key) + oldContext->makeCurrent(); + } +} + +void QGLContextResource::aboutToDestroyContext(const QGLContext *key) +{ + ResourceHash::iterator it = m_resources.find(key); + if (it == m_resources.end()) + return; + + QList shares = qgl_share_reg()->shares(key); + if (shares.size() > 1) { + Q_ASSERT(key->isSharing()); + // At least one of the shared contexts must stay in the cache. + // Otherwise, the value pointer is lost. + for (int i = 0; i < 2/*shares.size()*/; ++i) + m_resources.insert(shares.at(i), it.value()); + } else { + QGLContext *oldContext = const_cast(QGLContext::currentContext()); + if (oldContext != key) + const_cast(key)->makeCurrent(); + free(it.value()); + if (oldContext && oldContext != key) + oldContext->makeCurrent(); + } + m_resources.erase(it); +} + QT_END_NAMESPACE diff --git a/src/opengl/qgl.h b/src/opengl/qgl.h index 86555da..31b9543 100644 --- a/src/opengl/qgl.h +++ b/src/opengl/qgl.h @@ -364,6 +364,7 @@ private: friend class QGLPixmapData; friend class QGLPixmapFilterBase; friend class QGLTextureGlyphCache; + friend class QGLShareRegister; friend QGLFormat::OpenGLVersionFlags QGLFormat::openGLVersionFlags(); #ifdef Q_WS_MAC public: diff --git a/src/opengl/qgl_p.h b/src/opengl/qgl_p.h index ac19d64..fda0257 100644 --- a/src/opengl/qgl_p.h +++ b/src/opengl/qgl_p.h @@ -196,12 +196,19 @@ public: #endif }; +struct QGLContextGroupResources +{ + QGLContextGroupResources() : refs(1) { } + QGLExtensionFuncs extensionFuncs; + QAtomicInt refs; +}; + class QGLContextPrivate { Q_DECLARE_PUBLIC(QGLContext) public: - explicit QGLContextPrivate(QGLContext *context) : internal_context(false), q_ptr(context) {} - ~QGLContextPrivate() {} + explicit QGLContextPrivate(QGLContext *context) : internal_context(false), q_ptr(context) {groupResources = new QGLContextGroupResources;} + ~QGLContextPrivate() {if (!groupResources->refs.deref()) delete groupResources;} GLuint bindTexture(const QImage &image, GLenum target, GLint format, const qint64 key, bool clean = false); GLuint bindTexture(const QPixmap &pixmap, GLenum target, GLint format, bool clean); @@ -257,14 +264,14 @@ public: QGLContext *q_ptr; QGLFormat::OpenGLVersionFlags version_flags; - QGLExtensionFuncs extensionFuncs; + QGLContextGroupResources *groupResources; GLint max_texture_size; GLuint current_fbo; QPaintEngine *active_engine; #ifdef Q_WS_WIN - static inline QGLExtensionFuncs& qt_get_extension_funcs(const QGLContext *ctx) { return ctx->d_ptr->extensionFuncs; } + static inline QGLExtensionFuncs& qt_get_extension_funcs(const QGLContext *ctx) { return ctx->d_ptr->groupResources->extensionFuncs; } #endif #if defined(Q_WS_X11) || defined(Q_WS_MAC) || defined(Q_WS_QWS) @@ -371,62 +378,21 @@ struct QGLThreadContext { }; extern QThreadStorage qgl_context_storage; -typedef QMultiHash QGLSharingHash; class QGLShareRegister { public: QGLShareRegister() {} ~QGLShareRegister() { reg.clear(); } - bool checkSharing(const QGLContext *context1, const QGLContext *context2, const QGLContext * skip=0) { - if (context1 == context2) - return true; - QList shares = reg.values(context1); - for (int k=0; k shares(const QGLContext *context) { - return reg.values(context); - } - + bool checkSharing(const QGLContext *context1, const QGLContext *context2); + void addShare(const QGLContext *context, const QGLContext *share); + QList shares(const QGLContext *context); + void removeShare(const QGLContext *context); private: - QGLSharingHash reg; + // Use a context's 'groupResources' pointer to uniquely identify a group. + typedef QList ContextList; + typedef QHash SharingHash; + SharingHash reg; }; extern Q_OPENGL_EXPORT QGLShareRegister* qgl_share_reg(); @@ -464,6 +430,29 @@ inline GLenum qt_gl_preferredTextureTarget() #endif } +// One resource per group of shared contexts. +class QGLContextResource : public QObject +{ + Q_OBJECT +public: + typedef void (*FreeFunc)(void *); + QGLContextResource(FreeFunc f, QObject *parent = 0); + ~QGLContextResource(); + // Set resource 'value' for 'key' and all its shared contexts. + void insert(const QGLContext *key, void *value); + // Return resource for 'key' or a shared context. + void *value(const QGLContext *key); + // Free resource for 'key' and all its shared contexts. + void remove(const QGLContext *key); +private slots: + // Remove entry 'key' from cache and delete resource if there are no shared contexts. + void aboutToDestroyContext(const QGLContext *key); +private: + typedef QHash ResourceHash; + ResourceHash m_resources; + FreeFunc free; +}; + QT_END_NAMESPACE #endif // QGL_P_H -- cgit v0.12 From 6aeb2f208f2978f1445ba2ac0043491db75359aa Mon Sep 17 00:00:00 2001 From: Kim Motoyoshi Kalland Date: Tue, 30 Jun 2009 10:54:59 +0200 Subject: Used QGLContextResource for the gradient cache in the GL2 paint engine. Reviewed-by: Tom --- src/opengl/gl2paintengineex/qglgradientcache.cpp | 29 +++++++++++++++++----- src/opengl/gl2paintengineex/qglgradientcache_p.h | 27 ++++++-------------- .../gl2paintengineex/qpaintengineex_opengl2.cpp | 5 +--- 3 files changed, 31 insertions(+), 30 deletions(-) diff --git a/src/opengl/gl2paintengineex/qglgradientcache.cpp b/src/opengl/gl2paintengineex/qglgradientcache.cpp index 8c6b4f0..7c54bb9 100644 --- a/src/opengl/gl2paintengineex/qglgradientcache.cpp +++ b/src/opengl/gl2paintengineex/qglgradientcache.cpp @@ -46,6 +46,28 @@ QT_BEGIN_NAMESPACE +static void QGL2GradientCache_free(void *ptr) +{ + delete reinterpret_cast(ptr); +} + +Q_GLOBAL_STATIC_WITH_ARGS(QGLContextResource, qt_gradient_caches, (QGL2GradientCache_free)) + +QGL2GradientCache *QGL2GradientCache::cacheForContext(const QGLContext *context) +{ + QGL2GradientCache *p = reinterpret_cast(qt_gradient_caches()->value(context)); + if (!p) { + QGLContext *oldContext = const_cast(QGLContext::currentContext()); + if (oldContext != context) + const_cast(context)->makeCurrent(); + p = new QGL2GradientCache; + qt_gradient_caches()->insert(context, p); + if (oldContext && oldContext != context) + oldContext->makeCurrent(); + } + return p; +} + void QGL2GradientCache::cleanCache() { QGLGradientColorTableHash::const_iterator it = cache.constBegin(); for (; it != cache.constEnd(); ++it) { @@ -55,13 +77,8 @@ void QGL2GradientCache::cleanCache() { cache.clear(); } -GLuint QGL2GradientCache::getBuffer(const QGradient &gradient, qreal opacity, const QGLContext *ctx) +GLuint QGL2GradientCache::getBuffer(const QGradient &gradient, qreal opacity) { - if (buffer_ctx && !qgl_share_reg()->checkSharing(buffer_ctx, ctx)) - cleanCache(); - - buffer_ctx = ctx; - quint64 hash_val = 0; QGradientStops stops = gradient.stops(); diff --git a/src/opengl/gl2paintengineex/qglgradientcache_p.h b/src/opengl/gl2paintengineex/qglgradientcache_p.h index 55c7b65..ba698bc 100644 --- a/src/opengl/gl2paintengineex/qglgradientcache_p.h +++ b/src/opengl/gl2paintengineex/qglgradientcache_p.h @@ -53,12 +53,12 @@ #include #include #include +#include QT_BEGIN_NAMESPACE -class QGL2GradientCache : public QObject +class QGL2GradientCache { - Q_OBJECT struct CacheInfo { inline CacheInfo(QGradientStops s, qreal op, QGradient::InterpolationMode mode) : @@ -73,16 +73,12 @@ class QGL2GradientCache : public QObject typedef QMultiHash QGLGradientColorTableHash; public: - QGL2GradientCache() : QObject(), buffer_ctx(0) - { -/* - connect(QGLSignalProxy::instance(), - SIGNAL(aboutToDestroyContext(const QGLContext *)), - SLOT(cleanupGLContextRefs(const QGLContext *))); -*/ - } + static QGL2GradientCache *cacheForContext(const QGLContext *context); + + QGL2GradientCache() { } + ~QGL2GradientCache() {cleanCache();} - GLuint getBuffer(const QGradient &gradient, qreal opacity, const QGLContext *ctx); + GLuint getBuffer(const QGradient &gradient, qreal opacity); inline int paletteSize() const { return 1024; } protected: @@ -95,15 +91,6 @@ protected: void cleanCache(); QGLGradientColorTableHash cache; - const QGLContext *buffer_ctx; - -public slots: - void cleanupGLContextRefs(const QGLContext *context) { - if (context == buffer_ctx) { - cleanCache(); - buffer_ctx = 0; - } - } }; QT_END_NAMESPACE diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp index 9b0321d..939cd0d 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp @@ -334,9 +334,6 @@ void QGL2PaintEngineExPrivate::useSimpleShader() } } - -Q_GLOBAL_STATIC(QGL2GradientCache, qt_opengl_gradient_cache) - void QGL2PaintEngineExPrivate::updateBrushTexture() { // qDebug("QGL2PaintEngineExPrivate::updateBrushTexture()"); @@ -357,7 +354,7 @@ void QGL2PaintEngineExPrivate::updateBrushTexture() // We apply global opacity in the fragment shaders, so we always pass 1.0 // for opacity to the cache. - GLuint texId = qt_opengl_gradient_cache()->getBuffer(*g, 1.0, ctx); + GLuint texId = QGL2GradientCache::cacheForContext(ctx)->getBuffer(*g, 1.0); if (g->spread() == QGradient::RepeatSpread || g->type() == QGradient::ConicalGradient) updateTextureFilter(GL_TEXTURE_2D, GL_REPEAT, true); -- cgit v0.12 From fdacdd4335f80aea8385b5cfb745df9eda99ece6 Mon Sep 17 00:00:00 2001 From: Kim Motoyoshi Kalland Date: Thu, 2 Jul 2009 13:16:45 +0200 Subject: Fixed crash in the GL2 engine's texture glyph cache. Reviewed-by: Tom --- src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp index 939cd0d..3007b4c 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp @@ -115,6 +115,7 @@ public Q_SLOTS: glDeleteFramebuffers(1, &m_fbo); if (m_width || m_height) glDeleteTextures(1, &m_texture); + ctx = 0; } else { // since the context holding the texture is shared, and // about to be destroyed, we have to transfer ownership @@ -151,10 +152,17 @@ QGLTextureGlyphCache::QGLTextureGlyphCache(QGLContext *context, QFontEngineGlyph QGLTextureGlyphCache::~QGLTextureGlyphCache() { - glDeleteFramebuffers(1, &m_fbo); - - if (m_width || m_height) - glDeleteTextures(1, &m_texture); + if (ctx) { + QGLContext *oldContext = const_cast(QGLContext::currentContext()); + if (oldContext != ctx) + ctx->makeCurrent(); + glDeleteFramebuffers(1, &m_fbo); + + if (m_width || m_height) + glDeleteTextures(1, &m_texture); + if (oldContext && oldContext != ctx) + oldContext->makeCurrent(); + } } void QGLTextureGlyphCache::createTextureData(int width, int height) -- cgit v0.12 From 492a32d53f31a0617f0aac45aad3e8a5c9e3f5ed Mon Sep 17 00:00:00 2001 From: Kim Motoyoshi Kalland Date: Mon, 6 Jul 2009 11:17:39 +0200 Subject: Corrected the value of GL_MAX_SAMPLES_EXT. Reviewed-by: Tom --- src/opengl/qglextensions_p.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/opengl/qglextensions_p.h b/src/opengl/qglextensions_p.h index 3bb42c8..4f15197 100644 --- a/src/opengl/qglextensions_p.h +++ b/src/opengl/qglextensions_p.h @@ -535,7 +535,7 @@ struct QGLExtensionFuncs #endif #ifndef GL_MAX_SAMPLES_EXT -#define GL_MAX_SAMPLES_EXT 0x8D5 +#define GL_MAX_SAMPLES_EXT 0x8D57 #endif #ifndef GL_DRAW_FRAMEBUFFER_EXT -- cgit v0.12 From 89038235d08a039145792e545c3efedfd3d93323 Mon Sep 17 00:00:00 2001 From: Kim Motoyoshi Kalland Date: Tue, 21 Jul 2009 14:39:30 +0200 Subject: Fixed gradient bug in the GL2 paint engine. Texture filtering was set before binding the texture, so the gradient spread was not set correctly. Reviewed-by: Tom --- src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp index 3007b4c..fa6b966 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp @@ -364,15 +364,15 @@ void QGL2PaintEngineExPrivate::updateBrushTexture() // for opacity to the cache. GLuint texId = QGL2GradientCache::cacheForContext(ctx)->getBuffer(*g, 1.0); + glActiveTexture(GL_TEXTURE0 + QT_BRUSH_TEXTURE_UNIT); + glBindTexture(GL_TEXTURE_2D, texId); + if (g->spread() == QGradient::RepeatSpread || g->type() == QGradient::ConicalGradient) updateTextureFilter(GL_TEXTURE_2D, GL_REPEAT, true); else if (g->spread() == QGradient::ReflectSpread) updateTextureFilter(GL_TEXTURE_2D, GL_MIRRORED_REPEAT_IBM, true); else updateTextureFilter(GL_TEXTURE_2D, GL_CLAMP_TO_EDGE, true); - - glActiveTexture(GL_TEXTURE0 + QT_BRUSH_TEXTURE_UNIT); - glBindTexture(GL_TEXTURE_2D, texId); } else if (style == Qt::TexturePattern) { const QPixmap& texPixmap = currentBrush->texture(); -- cgit v0.12 From 704bfb1c67dd20d465f56bb1704500cd044f9494 Mon Sep 17 00:00:00 2001 From: Kim Motoyoshi Kalland Date: Fri, 17 Jul 2009 14:36:47 +0200 Subject: Fixed opacity bug in the GL2 paint engine. When premultiplying a color with the opacity, the color's alpha channel was not set correcly. Reviewed-by: Tom --- 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 fa6b966..7e8a281 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp @@ -299,6 +299,7 @@ void QGL2PaintEngineExPrivate::updateTextureFilter(GLenum target, GLenum wrapMod QColor QGL2PaintEngineExPrivate::premultiplyColor(QColor c, GLfloat opacity) { qreal alpha = c.alphaF() * opacity; + c.setAlphaF(alpha); c.setRedF(c.redF() * alpha); c.setGreenF(c.greenF() * alpha); c.setBlueF(c.blueF() * alpha); -- cgit v0.12 From 134396b0100c33e271561edc8f5ec141fe0d611e Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Tue, 21 Jul 2009 16:01:56 +0200 Subject: Doc: document reimplementations of internal functions as internal. --- src/gui/embedded/qscreenproxy_qws.cpp | 8 ++++---- src/qt3support/dialogs/q3tabdialog.cpp | 2 +- src/qt3support/itemviews/q3table.cpp | 2 +- src/qt3support/widgets/q3scrollview.cpp | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/gui/embedded/qscreenproxy_qws.cpp b/src/gui/embedded/qscreenproxy_qws.cpp index ade16ca..3d7451b 100644 --- a/src/gui/embedded/qscreenproxy_qws.cpp +++ b/src/gui/embedded/qscreenproxy_qws.cpp @@ -537,7 +537,7 @@ int QProxyScreen::transformOrientation() const } /*! -\reimp +\internal */ int QProxyScreen::memoryNeeded(const QString &str) { @@ -548,7 +548,7 @@ int QProxyScreen::memoryNeeded(const QString &str) } /*! -\reimp +\internal */ int QProxyScreen::sharedRamSize(void *ptr) { @@ -559,7 +559,7 @@ int QProxyScreen::sharedRamSize(void *ptr) } /*! -\reimp +\internal */ void QProxyScreen::haltUpdates() { @@ -568,7 +568,7 @@ void QProxyScreen::haltUpdates() } /*! -\reimp +\internal */ void QProxyScreen::resumeUpdates() { diff --git a/src/qt3support/dialogs/q3tabdialog.cpp b/src/qt3support/dialogs/q3tabdialog.cpp index 50dbd48..a65affc 100644 --- a/src/qt3support/dialogs/q3tabdialog.cpp +++ b/src/qt3support/dialogs/q3tabdialog.cpp @@ -1038,7 +1038,7 @@ QString Q3TabDialog::tabLabel(QWidget * w) } -/*! \reimp +/*! \internal */ void Q3TabDialog::styleChange(QStyle& s) { diff --git a/src/qt3support/itemviews/q3table.cpp b/src/qt3support/itemviews/q3table.cpp index 11c70b4..6c3e90c 100644 --- a/src/qt3support/itemviews/q3table.cpp +++ b/src/qt3support/itemviews/q3table.cpp @@ -6411,7 +6411,7 @@ void Q3Table::startDrag() #endif -/*! \reimp */ +/*! \internal */ void Q3Table::windowActivationChange(bool oldActive) { if (oldActive && autoScrollTimer) diff --git a/src/qt3support/widgets/q3scrollview.cpp b/src/qt3support/widgets/q3scrollview.cpp index cea385a..95e2117 100644 --- a/src/qt3support/widgets/q3scrollview.cpp +++ b/src/qt3support/widgets/q3scrollview.cpp @@ -669,7 +669,7 @@ bool Q3ScrollView::isVerticalSliderPressed() } /*! - \reimp + \internal */ void Q3ScrollView::styleChange(QStyle& old) { @@ -679,7 +679,7 @@ void Q3ScrollView::styleChange(QStyle& old) } /*! - \reimp + \internal */ void Q3ScrollView::fontChange(const QFont &old) { -- cgit v0.12 From 5fd5f9da3b4b433d43a4fe5c6d1a07cbc4712128 Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Tue, 21 Jul 2009 16:33:25 +0200 Subject: Silence compiler warnings on shadowing of member functions. --- src/corelib/tools/qcontiguouscache.h | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/corelib/tools/qcontiguouscache.h b/src/corelib/tools/qcontiguouscache.h index 7d52f1e..0020d22 100644 --- a/src/corelib/tools/qcontiguouscache.h +++ b/src/corelib/tools/qcontiguouscache.h @@ -166,8 +166,8 @@ void QContiguousCache::detach_helper() T *dest = x.d->array + x.d->start; T *src = d->array + d->start; - int count = x.d->count; - while (count--) { + int oldcount = x.d->count; + while (oldcount--) { if (QTypeInfo::isComplex) { new (dest) T(*src); } else { @@ -200,8 +200,8 @@ void QContiguousCache::setCapacity(int asize) x.d->start = x.d->offset % x.d->alloc; T *dest = x.d->array + (x.d->start + x.d->count-1) % x.d->alloc; T *src = d->array + (d->start + d->count-1) % d->alloc; - int count = x.d->count; - while (count--) { + int oldcount = x.d->count; + while (oldcount--) { if (QTypeInfo::isComplex) { new (dest) T(*src); } else { @@ -224,10 +224,10 @@ void QContiguousCache::clear() { if (d->ref == 1) { if (QTypeInfo::isComplex) { - int count = d->count; + int oldcount = d->count; T * i = d->array + d->start; T * e = d->array + d->alloc; - while (count--) { + while (oldcount--) { i->~T(); i++; if (i == e) @@ -254,11 +254,11 @@ inline QContiguousCacheData *QContiguousCache::malloc(int aalloc) } template -QContiguousCache::QContiguousCache(int capacity) +QContiguousCache::QContiguousCache(int cap) { - p = malloc(capacity); + p = malloc(cap); d->ref = 1; - d->alloc = capacity; + d->alloc = cap; d->count = d->start = d->offset = 0; d->sharable = true; } @@ -295,10 +295,10 @@ template void QContiguousCache::free(Data *x) { if (QTypeInfo::isComplex) { - int count = d->count; + int oldcount = d->count; T * i = d->array + d->start; T * e = d->array + d->alloc; - while (count--) { + while (oldcount--) { i->~T(); i++; if (i == e) -- cgit v0.12 From a033edc2517a0a108fc3c23190557a22465c96fb Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Tue, 21 Jul 2009 18:06:13 +0200 Subject: Doc: make potentially incorrect overloads obsolete. Also add additional overload. Reviewed-by: Andreas --- src/gui/graphicsview/qgraphicsscene.cpp | 23 ++++++++++++++++++++++- src/gui/graphicsview/qgraphicsscene.h | 5 +++-- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp index 38e5938..21fe49a 100644 --- a/src/gui/graphicsview/qgraphicsscene.cpp +++ b/src/gui/graphicsview/qgraphicsscene.cpp @@ -1926,21 +1926,42 @@ QPainterPath QGraphicsScene::selectionArea() const } /*! + \since 4.6 + Sets the selection area to \a path. All items within this area are immediately selected, and all items outside are unselected. You can get the list of all selected items by calling selectedItems(). + \a deviceTransform is the transformation that applies to the view, and needs to + be provided if the scene contains items that ignore transformations. + For an item to be selected, it must be marked as \e selectable (QGraphicsItem::ItemIsSelectable). \sa clearSelection(), selectionArea() */ +void QGraphicsScene::setSelectionArea(const QPainterPath &path, const QTransform &deviceTransform) +{ + setSelectionArea(path, Qt::IntersectsItemShape, deviceTransform); +} + +/*! + \obsolete + \overload + + Sets the selection area to \a path. + + This function is deprecated and leads to incorrect results if the scene + contains items that ignore transformations. Use the overload that takes + a QTransform instead. +*/ void QGraphicsScene::setSelectionArea(const QPainterPath &path) { - setSelectionArea(path, Qt::IntersectsItemShape); + setSelectionArea(path, Qt::IntersectsItemShape, QTransform()); } /*! + \obsolete \overload \since 4.3 diff --git a/src/gui/graphicsview/qgraphicsscene.h b/src/gui/graphicsview/qgraphicsscene.h index d790f90..c0c6e75 100644 --- a/src/gui/graphicsview/qgraphicsscene.h +++ b/src/gui/graphicsview/qgraphicsscene.h @@ -182,8 +182,9 @@ public: QList selectedItems() const; QPainterPath selectionArea() const; - void setSelectionArea(const QPainterPath &path); - void setSelectionArea(const QPainterPath &path, Qt::ItemSelectionMode mode); + void setSelectionArea(const QPainterPath &path); // ### obsolete + void setSelectionArea(const QPainterPath &path, const QTransform &deviceTransform); + void setSelectionArea(const QPainterPath &path, Qt::ItemSelectionMode mode); // ### obsolete void setSelectionArea(const QPainterPath &path, Qt::ItemSelectionMode mode, const QTransform &deviceTransform); QGraphicsItemGroup *createItemGroup(const QList &items); -- cgit v0.12 From 685e98b24ce27fee3085e9f2359494960a7952ff Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Tue, 21 Jul 2009 18:27:04 +0200 Subject: Doc: documentation for boolean properties should say what happens when the property is set, not what doesn't happen when the property is not set. --- src/gui/graphicsview/qgraphicsscene.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp index 21fe49a..b017022 100644 --- a/src/gui/graphicsview/qgraphicsscene.cpp +++ b/src/gui/graphicsview/qgraphicsscene.cpp @@ -2694,15 +2694,17 @@ void QGraphicsScene::clearFocus() /*! \property QGraphicsScene::stickyFocus - \brief whether or not clicking the scene will clear focus + \brief whether clicking into the scene background will clear focus \since 4.6 - If this property is false (the default), then clicking on the scene - background or on an item that does not accept focus, will clear - focus. Otherwise, focus will remain unchanged. + In a QGraphicsScene with stickyFocus set to true, focus will remain + unchanged when the user clicks into the scene background or on an item + that does not accept focus. Otherwise, focus will be cleared. - The focus change happens in response to a mouse press. You can reimplement + By default, this property is false. + + Focus changes in response to a mouse press. You can reimplement mousePressEvent() in a subclass of QGraphicsScene to toggle this property based on where the user has clicked. -- cgit v0.12 From b9b6258729585803e00b71280e175618b6bd50c2 Mon Sep 17 00:00:00 2001 From: Rohan McGovern Date: Wed, 22 Jul 2009 09:28:35 +1000 Subject: Fixed valgrind warnings related to sigaction from every testcase. Whoops, don't do sigaction for (nonexistent) signal 0. --- src/testlib/qtestcase.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp index 5de37dc..1d0bbcf 100644 --- a/src/testlib/qtestcase.cpp +++ b/src/testlib/qtestcase.cpp @@ -1480,7 +1480,7 @@ FatalSignalHandler::~FatalSignalHandler() struct sigaction oldact; - for (int i = 0; i < 32; ++i) { + for (int i = 1; i < 32; ++i) { if (!sigismember(&handledSignals, i)) continue; sigaction(i, &act, &oldact); -- cgit v0.12 From 5be62fbd822206c625cab4892ab485923dc79a00 Mon Sep 17 00:00:00 2001 From: Rohan McGovern Date: Wed, 22 Jul 2009 10:19:34 +1000 Subject: Fixed compile with -qtnamespace and MSVC. When an extern function is declared in the scope of another function, MSVC sometimes ignores the enclosing namespace {}. --- src/gui/kernel/qapplication.cpp | 10 ++++++---- src/opengl/qpixmapdata_gl.cpp | 3 ++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp index b168188..3453408 100644 --- a/src/gui/kernel/qapplication.cpp +++ b/src/gui/kernel/qapplication.cpp @@ -819,6 +819,12 @@ QApplication::QApplication(Display *dpy, int &argc, char **argv, #endif // Q_WS_X11 extern void qInitDrawhelperAsm(); +extern int qRegisterGuiVariant(); +extern int qUnregisterGuiVariant(); +#ifndef QT_NO_STATEMACHINE +extern int qRegisterGuiStateMachine(); +extern int qUnregisterGuiStateMachine(); +#endif /*! \fn void QApplicationPrivate::initialize() @@ -832,11 +838,9 @@ void QApplicationPrivate::initialize() if (qt_appType != QApplication::Tty) (void) QApplication::style(); // trigger creation of application style // trigger registering of QVariant's GUI types - extern int qRegisterGuiVariant(); qRegisterGuiVariant(); #ifndef QT_NO_STATEMACHINE // trigger registering of QStateMachine's GUI types - extern int qRegisterGuiStateMachine(); qRegisterGuiStateMachine(); #endif @@ -1060,11 +1064,9 @@ QApplication::~QApplication() #ifndef QT_NO_STATEMACHINE // trigger unregistering of QStateMachine's GUI types - extern int qUnregisterGuiStateMachine(); qUnregisterGuiStateMachine(); #endif // trigger unregistering of QVariant's GUI types - extern int qUnregisterGuiVariant(); qUnregisterGuiVariant(); } diff --git a/src/opengl/qpixmapdata_gl.cpp b/src/opengl/qpixmapdata_gl.cpp index f0c7e20..fe3bb0c 100644 --- a/src/opengl/qpixmapdata_gl.cpp +++ b/src/opengl/qpixmapdata_gl.cpp @@ -303,6 +303,8 @@ QImage QGLPixmapData::fillImage(const QColor &color) const return img; } +extern QImage qt_gl_read_texture(const QSize &size, bool alpha_format, bool include_alpha); + QImage QGLPixmapData::toImage() const { if (!isValid()) @@ -319,7 +321,6 @@ QImage QGLPixmapData::toImage() const } QGLShareContextScope ctx(qt_gl_share_widget()->context()); - extern QImage qt_gl_read_texture(const QSize &size, bool alpha_format, bool include_alpha); glBindTexture(GL_TEXTURE_2D, m_textureId); return qt_gl_read_texture(QSize(w, h), true, true); } -- cgit v0.12