diff options
22 files changed, 314 insertions, 76 deletions
diff --git a/src/corelib/tools/qsimd.cpp b/src/corelib/tools/qsimd.cpp index 63ebafb..bc5e9e4 100644 --- a/src/corelib/tools/qsimd.cpp +++ b/src/corelib/tools/qsimd.cpp @@ -285,7 +285,13 @@ static inline uint detectProcessorFeatures() uint features = MMX|SSE|SSE2|CMOV; uint feature_result = 0; -#if defined(Q_CC_GNU) +#if defined (Q_OS_WIN64) + { + int info[4]; + __cpuid(info, 1); + feature_result = info[2]; + } +#elif defined(Q_CC_GNU) quint64 tmp; asm ("xchg %%rbx, %1\n" "cpuid\n" @@ -294,12 +300,6 @@ static inline uint detectProcessorFeatures() : "a" (1) : "%edx" ); -#elif defined (Q_OS_WIN64) - { - int info[4]; - __cpuid(info, 1); - feature_result = info[2]; - } #endif if (feature_result & (1u)) diff --git a/src/declarative/graphicsitems/qdeclarativeitem_p.h b/src/declarative/graphicsitems/qdeclarativeitem_p.h index d8635b9..a36ee34 100644 --- a/src/declarative/graphicsitems/qdeclarativeitem_p.h +++ b/src/declarative/graphicsitems/qdeclarativeitem_p.h @@ -126,7 +126,7 @@ public: widthValid(false), heightValid(false), componentComplete(true), keepMouse(false), smooth(false), transformOriginDirty(true), doneEventPreHandler(false), keyHandler(0), - mWidth(0), mHeight(0), implicitWidth(0), implicitHeight(0) + mWidth(0), mHeight(0), implicitWidth(0), implicitHeight(0), hadSubFocusItem(false) { QGraphicsItemPrivate::acceptedMouseButtons = 0; isDeclarativeItem = 1; @@ -275,6 +275,8 @@ public: qreal implicitWidth; qreal implicitHeight; + bool hadSubFocusItem; + QPointF computeTransformOrigin() const; virtual void setPosHelper(const QPointF &pos) @@ -288,9 +290,11 @@ public: // Reimplemented from QGraphicsItemPrivate virtual void subFocusItemChange() { - if (flags & QGraphicsItem::ItemIsFocusScope || !parent) - emit q_func()->activeFocusChanged(subFocusItem != 0); + bool hasSubFocusItem = subFocusItem != 0; + if (((flags & QGraphicsItem::ItemIsFocusScope) || !parent) && hasSubFocusItem != hadSubFocusItem) + emit q_func()->activeFocusChanged(hasSubFocusItem); //see also QDeclarativeItemPrivate::focusChanged + hadSubFocusItem = hasSubFocusItem; } // Reimplemented from QGraphicsItemPrivate diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index 7ab49cb..94e1a72 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -3295,9 +3295,13 @@ void QGraphicsItemPrivate::setFocusHelper(Qt::FocusReason focusReason, bool clim } // Update the child focus chain. - if (scene && scene->focusItem()) - scene->focusItem()->d_ptr->clearSubFocus(); - f->d_ptr->setSubFocus(); + QGraphicsItem *commonAncestor = 0; + if (scene && scene->focusItem()) { + commonAncestor = scene->focusItem()->commonAncestorItem(f); + scene->focusItem()->d_ptr->clearSubFocus(scene->focusItem(), commonAncestor); + } + + f->d_ptr->setSubFocus(f, commonAncestor); // Update the scene's focus item. if (scene) { @@ -5554,7 +5558,7 @@ void QGraphicsItemPrivate::ensureSceneTransformRecursive(QGraphicsItem **topMost /*! \internal */ -void QGraphicsItemPrivate::setSubFocus(QGraphicsItem *rootItem) +void QGraphicsItemPrivate::setSubFocus(QGraphicsItem *rootItem, QGraphicsItem *stopItem) { // Update focus child chain. Stop at panels, or if this item // is hidden, stop at the first item with a visible parent. @@ -5567,7 +5571,7 @@ void QGraphicsItemPrivate::setSubFocus(QGraphicsItem *rootItem) if (parent != q_ptr && parent->d_ptr->subFocusItem) { if (parent->d_ptr->subFocusItem == q_ptr) break; - parent->d_ptr->subFocusItem->d_ptr->clearSubFocus(); + parent->d_ptr->subFocusItem->d_ptr->clearSubFocus(0, stopItem); } parent->d_ptr->subFocusItem = q_ptr; parent->d_ptr->subFocusItemChange(); @@ -5580,12 +5584,12 @@ void QGraphicsItemPrivate::setSubFocus(QGraphicsItem *rootItem) /*! \internal */ -void QGraphicsItemPrivate::clearSubFocus(QGraphicsItem *rootItem) +void QGraphicsItemPrivate::clearSubFocus(QGraphicsItem *rootItem, QGraphicsItem *stopItem) { // Reset sub focus chain. QGraphicsItem *parent = rootItem ? rootItem : q_ptr; do { - if (parent->d_ptr->subFocusItem != q_ptr) + if (parent->d_ptr->subFocusItem != q_ptr || parent == stopItem) break; parent->d_ptr->subFocusItem = 0; parent->d_ptr->subFocusItemChange(); diff --git a/src/gui/graphicsview/qgraphicsitem_p.h b/src/gui/graphicsview/qgraphicsitem_p.h index 1b7aa97..b938759 100644 --- a/src/gui/graphicsview/qgraphicsitem_p.h +++ b/src/gui/graphicsview/qgraphicsitem_p.h @@ -479,8 +479,8 @@ public: void setFocusHelper(Qt::FocusReason focusReason, bool climb, bool focusFromHide); void clearFocusHelper(bool giveFocusToParent); - void setSubFocus(QGraphicsItem *rootItem = 0); - void clearSubFocus(QGraphicsItem *rootItem = 0); + void setSubFocus(QGraphicsItem *rootItem = 0, QGraphicsItem *stopItem = 0); + void clearSubFocus(QGraphicsItem *rootItem = 0, QGraphicsItem *stopItem = 0); void resetFocusProxy(); virtual void subFocusItemChange(); virtual void focusScopeItemChange(bool isSubFocusItem); diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp index 1157b93..6ba3858 100644 --- a/src/gui/image/qimage.cpp +++ b/src/gui/image/qimage.cpp @@ -1121,9 +1121,14 @@ QImage::QImage(const char * const xpm[]) QImage::QImage(const QImage &image) : QPaintDevice() { - d = image.d; - if (d) - d->ref.ref(); + if (image.paintingActive()) { + d = 0; + operator=(image.copy()); + } else { + d = image.d; + if (d) + d->ref.ref(); + } } #ifdef QT3_SUPPORT @@ -1320,11 +1325,15 @@ QImage::~QImage() QImage &QImage::operator=(const QImage &image) { - if (image.d) - image.d->ref.ref(); - if (d && !d->ref.deref()) - delete d; - d = image.d; + if (image.paintingActive()) { + operator=(image.copy()); + } else { + if (image.d) + image.d->ref.ref(); + if (d && !d->ref.deref()) + delete d; + d = image.d; + } return *this; } diff --git a/src/gui/image/qpixmap_raster.cpp b/src/gui/image/qpixmap_raster.cpp index 53f3559..29bf5f5 100644 --- a/src/gui/image/qpixmap_raster.cpp +++ b/src/gui/image/qpixmap_raster.cpp @@ -44,11 +44,13 @@ #include "qpixmap_raster_p.h" #include "qnativeimage_p.h" #include "qimage_p.h" +#include "qpaintengine.h" #include "qbitmap.h" #include "qimage.h" #include <QBuffer> #include <QImageReader> +#include <private/qimage_p.h> #include <private/qsimd_p.h> #include <private/qwidget_p.h> #include <private/qdrawhelper_p.h> @@ -302,6 +304,15 @@ bool QRasterPixmapData::hasAlphaChannel() const QImage QRasterPixmapData::toImage() const { + if (!image.isNull()) { + QImageData *data = const_cast<QImage &>(image).data_ptr(); + if (data->paintEngine && data->paintEngine->isActive() + && data->paintEngine->paintDevice() == &image) + { + return image.copy(); + } + } + return image; } diff --git a/src/gui/kernel/qeventdispatcher_s60_p.h b/src/gui/kernel/qeventdispatcher_s60_p.h index c14fef0..539a21c 100644 --- a/src/gui/kernel/qeventdispatcher_s60_p.h +++ b/src/gui/kernel/qeventdispatcher_s60_p.h @@ -75,6 +75,13 @@ public: void complete(); private: + // Workaround for a BC break from S60 3.2 -> 5.0, where the CEikonEnv override was removed. + // To avoid linking to that when we build against 3.2, define an empty body here. + // Reserved_*() have been verified to be empty in the S60 code. + void Reserved_1() {} + void Reserved_2() {} + +private: int m_lastIterationCount; TInt m_savedStatusCode; bool m_hasAlreadyRun; diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp index a4ab278..024a69d 100644 --- a/src/gui/painting/qdrawhelper.cpp +++ b/src/gui/painting/qdrawhelper.cpp @@ -6432,6 +6432,8 @@ Q_STATIC_TEMPLATE_FUNCTION void blendTransformedTiled(int count, const QSpan *sp int px = int(tx) - (tx < 0); int py = int(ty) - (ty < 0); + px %= image_width; + py %= image_height; if (px < 0) px += image_width; if (py < 0) diff --git a/src/gui/painting/qgrayraster.c b/src/gui/painting/qgrayraster.c index ec9ebeb..001345f 100644 --- a/src/gui/painting/qgrayraster.c +++ b/src/gui/painting/qgrayraster.c @@ -963,49 +963,53 @@ const QT_FT_Vector* control2, const QT_FT_Vector* to ) { + TPos dx, dy, da, db; int top, level; int* levels; QT_FT_Vector* arc; - int mid_x = ( DOWNSCALE( ras.x ) + to->x + - 3 * (control1->x + control2->x ) ) / 8; - int mid_y = ( DOWNSCALE( ras.y ) + to->y + - 3 * (control1->y + control2->y ) ) / 8; - TPos dx = DOWNSCALE( ras.x ) + to->x - ( mid_x << 1 ); - TPos dy = DOWNSCALE( ras.y ) + to->y - ( mid_y << 1 ); + dx = DOWNSCALE( ras.x ) + to->x - ( control1->x << 1 ); if ( dx < 0 ) dx = -dx; + dy = DOWNSCALE( ras.y ) + to->y - ( control1->y << 1 ); if ( dy < 0 ) dy = -dy; if ( dx < dy ) dx = dy; + da = dx; + + dx = DOWNSCALE( ras.x ) + to->x - 3 * ( control1->x + control2->x ); + if ( dx < 0 ) + dx = -dx; + dy = DOWNSCALE( ras.y ) + to->y - 3 * ( control1->y + control2->y ); + if ( dy < 0 ) + dy = -dy; + if ( dx < dy ) + dx = dy; + db = dx; level = 1; - dx /= ras.cubic_level; - while ( dx > 0 ) + da = da / ras.cubic_level; + db = db / ras.conic_level; + while ( da > 0 || db > 0 ) { - dx >>= 2; + da >>= 2; + db >>= 3; level++; } if ( level <= 1 ) { - TPos to_x, to_y; + TPos to_x, to_y, mid_x, mid_y; to_x = UPSCALE( to->x ); to_y = UPSCALE( to->y ); - - /* Recalculation of midpoint is needed only if */ - /* UPSCALE and DOWNSCALE have any effect. */ - -#if ( PIXEL_BITS != 6 ) mid_x = ( ras.x + to_x + 3 * UPSCALE( control1->x + control2->x ) ) / 8; mid_y = ( ras.y + to_y + 3 * UPSCALE( control1->y + control2->y ) ) / 8; -#endif gray_render_line( RAS_VAR_ mid_x, mid_y ); gray_render_line( RAS_VAR_ to_x, to_y ); diff --git a/src/gui/painting/qpathclipper.cpp b/src/gui/painting/qpathclipper.cpp index a17b7c1..5060ad6 100644 --- a/src/gui/painting/qpathclipper.cpp +++ b/src/gui/painting/qpathclipper.cpp @@ -868,9 +868,9 @@ QWingedEdge::QWingedEdge() : } QWingedEdge::QWingedEdge(const QPainterPath &subject, const QPainterPath &clip) : - m_edges(subject.length()), - m_vertices(subject.length()), - m_segments(subject.length()) + m_edges(subject.elementCount()), + m_vertices(subject.elementCount()), + m_segments(subject.elementCount()) { m_segments.setPath(subject); m_segments.addPath(clip); @@ -1405,9 +1405,9 @@ bool QPathClipper::intersect() else if (clipIsRect) return subjectPath.intersects(r2); - QPathSegments a(subjectPath.length()); + QPathSegments a(subjectPath.elementCount()); a.setPath(subjectPath); - QPathSegments b(clipPath.length()); + QPathSegments b(clipPath.elementCount()); b.setPath(clipPath); QIntersectionFinder finder; @@ -1450,9 +1450,9 @@ bool QPathClipper::contains() if (clipIsRect) return subjectPath.contains(r2); - QPathSegments a(subjectPath.length()); + QPathSegments a(subjectPath.elementCount()); a.setPath(subjectPath); - QPathSegments b(clipPath.length()); + QPathSegments b(clipPath.elementCount()); b.setPath(clipPath); QIntersectionFinder finder; diff --git a/src/gui/text/qtextdocument.cpp b/src/gui/text/qtextdocument.cpp index c35069f..77e6aa1 100644 --- a/src/gui/text/qtextdocument.cpp +++ b/src/gui/text/qtextdocument.cpp @@ -596,8 +596,10 @@ void QTextDocument::markContentsDirty(int from, int length) Q_D(QTextDocument); d->documentChange(from, length); if (!d->inContentsChange) { - d->lout->documentChanged(d->docChangeFrom, d->docChangeOldLength, d->docChangeLength); - d->docChangeFrom = -1; + if (d->lout) { + d->lout->documentChanged(d->docChangeFrom, d->docChangeOldLength, d->docChangeLength); + d->docChangeFrom = -1; + } } } diff --git a/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp b/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp index 705ad09..66445cd 100644 --- a/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp +++ b/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp @@ -128,14 +128,17 @@ void QGLTextureGlyphCache::createTextureData(int width, int height) m_width = width; m_height = height; - QVarLengthArray<uchar> data(width * height); - for (int i = 0; i < data.size(); ++i) - data[i] = 0; - - if (m_type == QFontEngineGlyphCache::Raster_RGBMask) - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_ALPHA, GL_UNSIGNED_BYTE, &data[0]); - else + if (m_type == QFontEngineGlyphCache::Raster_RGBMask) { + QVarLengthArray<uchar> data(width * height * 4); + for (int i = 0; i < data.size(); ++i) + data[i] = 0; + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, &data[0]); + } else { + QVarLengthArray<uchar> data(width * height); + for (int i = 0; i < data.size(); ++i) + data[i] = 0; glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, width, height, 0, GL_ALPHA, GL_UNSIGNED_BYTE, &data[0]); + } glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); @@ -287,7 +290,7 @@ void QGLTextureGlyphCache::fillTexture(const Coord &c, glyph_t glyph) if (mask.format() == QImage::Format_RGB32) { glTexSubImage2D(GL_TEXTURE_2D, 0, c.x, c.y, maskWidth, maskHeight, GL_BGRA, GL_UNSIGNED_BYTE, mask.bits()); } else { -#ifdef QT_OPENGL_ES2 +#ifdef QT_OPENGL_ES_2 glTexSubImage2D(GL_TEXTURE_2D, 0, c.x, c.y, maskWidth, maskHeight, GL_ALPHA, GL_UNSIGNED_BYTE, mask.bits()); #else // glTexSubImage2D() might cause some garbage to appear in the texture if the mask width is diff --git a/src/opengl/qwindowsurface_gl.cpp b/src/opengl/qwindowsurface_gl.cpp index bbb98d0..f64b93c 100644 --- a/src/opengl/qwindowsurface_gl.cpp +++ b/src/opengl/qwindowsurface_gl.cpp @@ -377,7 +377,18 @@ void QGLWindowSurface::hijackWindow(QWidget *widget) if (widgetPrivate->extraData()->glContext) return; - QGLContext *ctx = new QGLContext(surfaceFormat, widget); + QGLContext *ctx = NULL; + + // For translucent top-level widgets we need alpha in the format. + if (widget->testAttribute(Qt::WA_TranslucentBackground)) { + QGLFormat modFormat(surfaceFormat); + modFormat.setSampleBuffers(false); + modFormat.setSamples(0); + modFormat.setAlpha(true); + ctx = new QGLContext(modFormat, widget); + } else + ctx = new QGLContext(surfaceFormat, widget); + ctx->create(qt_gl_share_widget()->context()); #ifndef QT_NO_EGL diff --git a/src/plugins/bearer/icd/proxyconf.cpp b/src/plugins/bearer/icd/proxyconf.cpp index 37501fb..efe2da7 100644 --- a/src/plugins/bearer/icd/proxyconf.cpp +++ b/src/plugins/bearer/icd/proxyconf.cpp @@ -306,12 +306,12 @@ QList<QNetworkProxy> ProxyConfPrivate::flush(const QNetworkProxyQuery &query) if (isHostExcluded(query.peerHostName())) return result; // no proxy for this host - if (mode == "auto") { + if (mode == QLatin1String("AUTO")) { // TODO: pac currently not supported, fix me return result; } - if (mode == "manual") { + if (mode == QLatin1String("MANUAL")) { bool isHttps = false; QString protocol = query.protocolTag().toLower(); diff --git a/src/plugins/graphicssystems/meego/dithering.cpp b/src/plugins/graphicssystems/meego/dithering.cpp index 1a2e3fa..ca303a8 100644 --- a/src/plugins/graphicssystems/meego/dithering.cpp +++ b/src/plugins/graphicssystems/meego/dithering.cpp @@ -154,7 +154,10 @@ unsigned short* convertRGB32_to_RGB565(const unsigned char *in, int width, int h // Add the diffusion for this pixel we stored in the accumulator. // >> 7 because the values in accumulator are stored * 128 - component[c] += accumulator[c][x] >> 7; + if (x != 0 && x != (width - 1)) { + if (accumulator[c][x] >> 7 != 0) + component[c] += rand() % accumulator[c][x] >> 7; + } // Make sure we're not over the boundaries. CLAMP_256(component[c]); @@ -172,10 +175,10 @@ unsigned short* convertRGB32_to_RGB565(const unsigned char *in, int width, int h // Distribute the difference according to the matrix in the // accumulation bufffer. - ACCUMULATE(accumulator[c], x + 1, 0, width, diff * 7); - ACCUMULATE(accumulator[c], x - 1, 1, width, diff * 3); + ACCUMULATE(accumulator[c], x + 1, 0, width, diff * 3); + ACCUMULATE(accumulator[c], x - 1, 1, width, diff * 5); ACCUMULATE(accumulator[c], x, 1, width, diff * 5); - ACCUMULATE(accumulator[c], x + 1, 1, width, diff * 1); + ACCUMULATE(accumulator[c], x + 1, 1, width, diff * 3); } // Write the newly produced pixel diff --git a/src/plugins/graphicssystems/meego/qmeegographicssystem.cpp b/src/plugins/graphicssystems/meego/qmeegographicssystem.cpp index 507f70b..4a86082 100644 --- a/src/plugins/graphicssystems/meego/qmeegographicssystem.cpp +++ b/src/plugins/graphicssystems/meego/qmeegographicssystem.cpp @@ -124,8 +124,10 @@ QPixmapData* QMeeGoGraphicsSystem::wrapPixmapData(QPixmapData *pmd) void QMeeGoGraphicsSystem::setSurfaceFixedSize(int /*width*/, int /*height*/) { - if (QMeeGoGraphicsSystem::surfaceWasCreated) + if (QMeeGoGraphicsSystem::surfaceWasCreated) { qWarning("Trying to set surface fixed size but surface already created!"); + return; + } #ifdef QT_WAS_PATCHED QEglProperties *properties = new QEglProperties(); @@ -143,6 +145,11 @@ void QMeeGoGraphicsSystem::setSurfaceScaling(int x, int y, int width, int height void QMeeGoGraphicsSystem::setTranslucent(bool translucent) { + if (QMeeGoGraphicsSystem::surfaceWasCreated) { + qWarning("Trying to set translucency but surface already created!"); + return; + } + QGLWindowSurface::surfaceFormat.setSampleBuffers(false); QGLWindowSurface::surfaceFormat.setSamples(0); QGLWindowSurface::surfaceFormat.setAlpha(translucent); diff --git a/src/s60installs/eabi/QtGuiu.def b/src/s60installs/eabi/QtGuiu.def index 54768a1..632326d 100644 --- a/src/s60installs/eabi/QtGuiu.def +++ b/src/s60installs/eabi/QtGuiu.def @@ -4658,11 +4658,11 @@ EXPORTS _ZN20QGraphicsEllipseItemD1Ev @ 4657 NONAME _ZN20QGraphicsEllipseItemD2Ev @ 4658 NONAME _ZN20QGraphicsItemPrivate11removeChildEP13QGraphicsItem @ 4659 NONAME - _ZN20QGraphicsItemPrivate11setSubFocusEP13QGraphicsItem @ 4660 NONAME + _ZN20QGraphicsItemPrivate11setSubFocusEP13QGraphicsItem @ 4660 NONAME ABSENT _ZN20QGraphicsItemPrivate12remapItemPosEP6QEventP13QGraphicsItem @ 4661 NONAME _ZN20QGraphicsItemPrivate12resolveDepthEv @ 4662 NONAME _ZN20QGraphicsItemPrivate12setPosHelperERK7QPointF @ 4663 NONAME - _ZN20QGraphicsItemPrivate13clearSubFocusEP13QGraphicsItem @ 4664 NONAME + _ZN20QGraphicsItemPrivate13clearSubFocusEP13QGraphicsItem @ 4664 NONAME ABSENT _ZN20QGraphicsItemPrivate14setFocusHelperEN2Qt11FocusReasonEb @ 4665 NONAME ABSENT _ZN20QGraphicsItemPrivate15resetFocusProxyEv @ 4666 NONAME _ZN20QGraphicsItemPrivate16setEnabledHelperEbbb @ 4667 NONAME @@ -12105,4 +12105,6 @@ EXPORTS _ZN15QStaticTextItemD1Ev @ 12104 NONAME _ZN15QStaticTextItemD2Ev @ 12105 NONAME _ZN19QEventDispatcherS6031reactivateDeferredActiveObjectsEv @ 12106 NONAME + _ZN20QGraphicsItemPrivate11setSubFocusEP13QGraphicsItemS1_ @ 12107 NONAME + _ZN20QGraphicsItemPrivate13clearSubFocusEP13QGraphicsItemS1_ @ 12108 NONAME diff --git a/tests/auto/declarative/qdeclarativefocusscope/data/forceActiveFocus.qml b/tests/auto/declarative/qdeclarativefocusscope/data/forceActiveFocus.qml new file mode 100644 index 0000000..6c39d4a --- /dev/null +++ b/tests/auto/declarative/qdeclarativefocusscope/data/forceActiveFocus.qml @@ -0,0 +1,26 @@ +import QtQuick 1.0 + +Rectangle { + objectName: "root" + FocusScope { + objectName: "scope" + Item { + objectName: "item-a1" + FocusScope { + objectName: "scope-a" + Item { + objectName: "item-a2" + } + } + } + Item { + objectName: "item-b1" + FocusScope { + objectName: "scope-b" + Item { + objectName: "item-b2" + } + } + } + } +} diff --git a/tests/auto/declarative/qdeclarativefocusscope/tst_qdeclarativefocusscope.cpp b/tests/auto/declarative/qdeclarativefocusscope/tst_qdeclarativefocusscope.cpp index 1645dac..6a3627b 100644 --- a/tests/auto/declarative/qdeclarativefocusscope/tst_qdeclarativefocusscope.cpp +++ b/tests/auto/declarative/qdeclarativefocusscope/tst_qdeclarativefocusscope.cpp @@ -71,6 +71,7 @@ private slots: void noParentFocus(); void signalEmission(); void qtBug13380(); + void forceActiveFocus(); }; /* @@ -432,6 +433,114 @@ void tst_qdeclarativefocusscope::qtBug13380() delete view; } +void tst_qdeclarativefocusscope::forceActiveFocus() +{ + QDeclarativeView *view = new QDeclarativeView; + view->setSource(QUrl::fromLocalFile(SRCDIR "/data/forceActiveFocus.qml")); + + QGraphicsObject *rootObject = view->rootObject(); + QVERIFY(rootObject); + + QDeclarativeItem *scope = findItem<QDeclarativeItem>(rootObject, QLatin1String("scope")); + QDeclarativeItem *itemA1 = findItem<QDeclarativeItem>(rootObject, QLatin1String("item-a1")); + QDeclarativeItem *scopeA = findItem<QDeclarativeItem>(rootObject, QLatin1String("scope-a")); + QDeclarativeItem *itemA2 = findItem<QDeclarativeItem>(rootObject, QLatin1String("item-a2")); + QDeclarativeItem *itemB1 = findItem<QDeclarativeItem>(rootObject, QLatin1String("item-b1")); + QDeclarativeItem *scopeB = findItem<QDeclarativeItem>(rootObject, QLatin1String("scope-b")); + QDeclarativeItem *itemB2 = findItem<QDeclarativeItem>(rootObject, QLatin1String("item-b2")); + + QVERIFY(scope); + QVERIFY(itemA1); + QVERIFY(scopeA); + QVERIFY(itemA2); + QVERIFY(itemB1); + QVERIFY(scopeB); + QVERIFY(itemB2); + + QSignalSpy rootSpy(rootObject, SIGNAL(activeFocusChanged(bool))); + QSignalSpy scopeSpy(scope, SIGNAL(activeFocusChanged(bool))); + QSignalSpy scopeASpy(scopeA, SIGNAL(activeFocusChanged(bool))); + QSignalSpy scopeBSpy(scopeB, SIGNAL(activeFocusChanged(bool))); + + // First, walk the focus from item-a1 down to item-a2 and back again + itemA1->forceActiveFocus(); + QVERIFY(itemA1->hasActiveFocus()); + QCOMPARE(rootSpy.count(), 1); + QCOMPARE(scopeSpy.count(), 1); + + scopeA->forceActiveFocus(); + QVERIFY(!itemA1->hasActiveFocus()); + QVERIFY(scopeA->hasActiveFocus()); + QCOMPARE(scopeASpy.count(), 1); + QCOMPARE(rootSpy.count(), 1); + QCOMPARE(scopeSpy.count(), 1); + + itemA2->forceActiveFocus(); + QVERIFY(!itemA1->hasActiveFocus()); + QVERIFY(itemA2->hasActiveFocus()); + QVERIFY(scopeA->hasActiveFocus()); + QCOMPARE(scopeASpy.count(), 1); + QCOMPARE(rootSpy.count(), 1); + QCOMPARE(scopeSpy.count(), 1); + + scopeA->forceActiveFocus(); + QVERIFY(!itemA1->hasActiveFocus()); + QVERIFY(itemA2->hasActiveFocus()); + QVERIFY(scopeA->hasActiveFocus()); + QCOMPARE(scopeASpy.count(), 1); + QCOMPARE(rootSpy.count(), 1); + QCOMPARE(scopeSpy.count(), 1); + + itemA1->forceActiveFocus(); + QVERIFY(itemA1->hasActiveFocus()); + QVERIFY(!scopeA->hasActiveFocus()); + QVERIFY(!itemA2->hasActiveFocus()); + QCOMPARE(scopeASpy.count(), 2); + QCOMPARE(rootSpy.count(), 1); + QCOMPARE(scopeSpy.count(), 1); + + // Then jump back and forth between branch 'a' and 'b' + itemB1->forceActiveFocus(); + QVERIFY(itemB1->hasActiveFocus()); + QCOMPARE(rootSpy.count(), 1); + QCOMPARE(scopeSpy.count(), 1); + + scopeA->forceActiveFocus(); + QVERIFY(!itemA1->hasActiveFocus()); + QVERIFY(!itemB1->hasActiveFocus()); + QVERIFY(scopeA->hasActiveFocus()); + QCOMPARE(scopeASpy.count(), 3); + QCOMPARE(rootSpy.count(), 1); + QCOMPARE(scopeSpy.count(), 1); + + scopeB->forceActiveFocus(); + QVERIFY(!scopeA->hasActiveFocus()); + QVERIFY(!itemB1->hasActiveFocus()); + QVERIFY(scopeB->hasActiveFocus()); + QCOMPARE(scopeASpy.count(), 4); + QCOMPARE(scopeBSpy.count(), 1); + QCOMPARE(rootSpy.count(), 1); + QCOMPARE(scopeSpy.count(), 1); + + itemA2->forceActiveFocus(); + QVERIFY(!scopeB->hasActiveFocus()); + QVERIFY(itemA2->hasActiveFocus()); + QCOMPARE(scopeASpy.count(), 5); + QCOMPARE(scopeBSpy.count(), 2); + QCOMPARE(rootSpy.count(), 1); + QCOMPARE(scopeSpy.count(), 1); + + itemB2->forceActiveFocus(); + QVERIFY(!itemA2->hasActiveFocus()); + QVERIFY(itemB2->hasActiveFocus()); + QCOMPARE(scopeASpy.count(), 6); + QCOMPARE(scopeBSpy.count(), 3); + QCOMPARE(rootSpy.count(), 1); + QCOMPARE(scopeSpy.count(), 1); + + delete view; +} + QTEST_MAIN(tst_qdeclarativefocusscope) #include "tst_qdeclarativefocusscope.moc" diff --git a/tests/auto/qimage/tst_qimage.cpp b/tests/auto/qimage/tst_qimage.cpp index b446941..b2c59fc 100644 --- a/tests/auto/qimage/tst_qimage.cpp +++ b/tests/auto/qimage/tst_qimage.cpp @@ -142,6 +142,8 @@ private slots: void rgbSwapped_data(); void rgbSwapped(); + + void deepCopyWhenPaintingActive(); }; tst_QImage::tst_QImage() @@ -1886,5 +1888,19 @@ void tst_QImage::rgbSwapped() QCOMPARE(memcmp(image.constBits(), imageSwappedTwice.constBits(), image.numBytes()), 0); } +void tst_QImage::deepCopyWhenPaintingActive() +{ + QImage image(64, 64, QImage::Format_ARGB32_Premultiplied); + image.fill(0); + + QPainter painter(&image); + QImage copy = image; + + painter.setBrush(Qt::black); + painter.drawEllipse(image.rect()); + + QVERIFY(copy != image); +} + QTEST_MAIN(tst_QImage) #include "tst_qimage.moc" diff --git a/tests/auto/qpixmap/tst_qpixmap.cpp b/tests/auto/qpixmap/tst_qpixmap.cpp index 51e6cf5..419518a1 100644 --- a/tests/auto/qpixmap/tst_qpixmap.cpp +++ b/tests/auto/qpixmap/tst_qpixmap.cpp @@ -129,10 +129,7 @@ private slots: void isNull(); void task_246446(); -#ifdef Q_WS_QWS void convertFromImageNoDetach(); -#endif - void convertFromImageDetach(); #if defined(Q_WS_WIN) @@ -185,6 +182,8 @@ private slots: void preserveDepth(); void splash_crash(); + void toImageDeepCopy(); + void loadAsBitmapOrPixmap(); }; @@ -911,11 +910,13 @@ void tst_QPixmap::isNull() } } -#ifdef Q_WS_QWS void tst_QPixmap::convertFromImageNoDetach() { + QPixmap randomPixmap(10, 10); + if (randomPixmap.pixmapData()->classId() != QPixmapData::RasterClass) + QSKIP("Test only valid for raster pixmaps", SkipAll); + //first get the screen format - QPixmap randomPixmap(10,10); QImage::Format screenFormat = randomPixmap.toImage().format(); QVERIFY(screenFormat != QImage::Format_Invalid); @@ -930,7 +931,6 @@ void tst_QPixmap::convertFromImageNoDetach() const QImage constCopy = copy; QVERIFY(constOrig.bits() == constCopy.bits()); } -#endif //Q_WS_QWS void tst_QPixmap::convertFromImageDetach() { @@ -1751,6 +1751,21 @@ void tst_QPixmap::loadAsBitmapOrPixmap() QVERIFY(bitmap.isQBitmap()); } +void tst_QPixmap::toImageDeepCopy() +{ + QPixmap pixmap(64, 64); + pixmap.fill(Qt::white); + + QPainter painter(&pixmap); + QImage first = pixmap.toImage(); + + painter.setBrush(Qt::black); + painter.drawEllipse(pixmap.rect()); + + QImage second = pixmap.toImage(); + + QVERIFY(first != second); +} QTEST_MAIN(tst_QPixmap) diff --git a/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.h b/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.h index d47c829..6df3c22 100644 --- a/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.h +++ b/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.h @@ -181,6 +181,9 @@ public: This function needs to be called *before* any widget/content is created. When called with true, the base window surface will be translucent and initialized with QGLFormat.alpha == true. + + This function is *deprecated*. Set Qt::WA_TranslucentBackground attribute + on the top-level widget *before* you show it instead. */ static void setTranslucent(bool translucent); }; |