diff options
49 files changed, 734 insertions, 189 deletions
diff --git a/demos/browser/browser.pro b/demos/browser/browser.pro index f54afe4..afc25e3 100644 --- a/demos/browser/browser.pro +++ b/demos/browser/browser.pro @@ -3,7 +3,7 @@ TARGET = browser QT += webkit network CONFIG += qt warn_on -contains(QT_BUILD_PARTS, tools):!symbian: CONFIG += uitools +contains(QT_BUILD_PARTS, tools):!symbian:!embedded: CONFIG += uitools else: DEFINES += QT_NO_UITOOLS FORMS += \ diff --git a/doc/src/snippets/code/doc_src_stylesheet.qdoc b/doc/src/snippets/code/doc_src_stylesheet.qdoc index f79f7ff..1c0440c 100644 --- a/doc/src/snippets/code/doc_src_stylesheet.qdoc +++ b/doc/src/snippets/code/doc_src_stylesheet.qdoc @@ -1007,6 +1007,11 @@ QHeaderView::section { border: 1px solid #6c6c6c; } +QHeaderView::section:checked +{ + background-color: red; +} + /* style the sort indicator */ QHeaderView::down-arrow { image: url(down_arrow.png); diff --git a/doc/src/snippets/code/src_gui_painting_qpainter.cpp b/doc/src/snippets/code/src_gui_painting_qpainter.cpp index 8dfda66..0226161 100644 --- a/doc/src/snippets/code/src_gui_painting_qpainter.cpp +++ b/doc/src/snippets/code/src_gui_painting_qpainter.cpp @@ -241,3 +241,20 @@ QImage image(":/images/myImage.png"); QPainter painter(this); painter.drawImage(target, image, source); //! [20] + + +//! [21] +QPainter painter(this); +painter.fillRect(0, 0, 128, 128, Qt::green); +painter.beginNativePainting(); + +glEnable(GL_SCISSOR_TEST); +glScissor(0, 0, 64, 64); + +glClearColor(1, 0, 0, 1); +glClear(GL_COLOR_BUFFER_BIT); + +glDisable(GL_SCISSOR_TEST); + +painter.endNativePainting(); +//! [21] diff --git a/doc/src/widgets-and-layouts/stylesheet.qdoc b/doc/src/widgets-and-layouts/stylesheet.qdoc index c40795a..d2538f4 100644 --- a/doc/src/widgets-and-layouts/stylesheet.qdoc +++ b/doc/src/widgets-and-layouts/stylesheet.qdoc @@ -840,7 +840,8 @@ \l{#first-ps}{:first}, \l{#last-ps}{:last}, \l{#only-one-ps}{:only-one}, \l{#next-selected-ps}{:next-selected}, \l{#previous-selected-ps}{:previous-selected}, - \l{#selected-ps}{:selected} pseudo states. + \l{#selected-ps}{:selected}, + and \l{#checked-ps}{:checked} pseudo states. Sort indicator in can be styled using the \l{#up-arrow-sub}{::up-arrow} and the diff --git a/examples/opengl/opengl.pro b/examples/opengl/opengl.pro index b86e0ba..2cb8227 100644 --- a/examples/opengl/opengl.pro +++ b/examples/opengl/opengl.pro @@ -5,9 +5,9 @@ contains(QT_CONFIG, opengles1)|contains(QT_CONFIG, opengles1cl)|contains(QT_CONF SUBDIRS = hellogl_es2 } else { SUBDIRS = hellogl_es - !contains(QT_CONFIG, opengles1cl) { - SUBDIRS += textures - } + } + !contains(QT_CONFIG, opengles1cl) { + SUBDIRS += textures } } else { SUBDIRS = 2dpainting \ diff --git a/examples/opengl/textures/glwidget.cpp b/examples/opengl/textures/glwidget.cpp index 024133b..6efd31a 100644 --- a/examples/opengl/textures/glwidget.cpp +++ b/examples/opengl/textures/glwidget.cpp @@ -44,16 +44,6 @@ #include "glwidget.h" -class CubeObject -{ -public: - GLuint textures[6]; - QVector<QVector3D> vertices; - QVector<QVector2D> texCoords; - - void draw(); -}; - GLWidget::GLWidget(QWidget *parent, QGLWidget *shareWidget) : QGLWidget(parent, shareWidget) { @@ -61,12 +51,13 @@ GLWidget::GLWidget(QWidget *parent, QGLWidget *shareWidget) xRot = 0; yRot = 0; zRot = 0; - cube = 0; +#ifdef QT_OPENGL_ES_2 + program = 0; +#endif } GLWidget::~GLWidget() { - delete cube; } QSize GLWidget::minimumSizeHint() const @@ -99,19 +90,90 @@ void GLWidget::initializeGL() glEnable(GL_DEPTH_TEST); glEnable(GL_CULL_FACE); +#ifndef QT_OPENGL_ES_2 glEnable(GL_TEXTURE_2D); +#endif + +#ifdef QT_OPENGL_ES_2 + +#define PROGRAM_VERTEX_ATTRIBUTE 0 +#define PROGRAM_TEXCOORD_ATTRIBUTE 1 + + QGLShader *vshader = new QGLShader(QGLShader::VertexShader, this); + const char *vsrc = + "attribute highp vec4 vertex;\n" + "attribute mediump vec4 texCoord;\n" + "varying mediump vec4 texc;\n" + "uniform mediump mat4 matrix;\n" + "void main(void)\n" + "{\n" + " gl_Position = matrix * vertex;\n" + " texc = texCoord;\n" + "}\n"; + vshader->compile(vsrc); + + QGLShader *fshader = new QGLShader(QGLShader::FragmentShader, this); + const char *fsrc = + "uniform sampler2D texture;\n" + "varying mediump vec4 texc;\n" + "void main(void)\n" + "{\n" + " gl_FragColor = texture2D(texture, texc.st);\n" + "}\n"; + fshader->compile(fsrc); + + program = new QGLShaderProgram(this); + program->addShader(vshader); + program->addShader(fshader); + program->bindAttributeLocation("vertex", PROGRAM_VERTEX_ATTRIBUTE); + program->bindAttributeLocation("texCoord", PROGRAM_TEXCOORD_ATTRIBUTE); + program->link(); + + program->enable(); + program->setUniformValue("texture", 0); + +#endif } void GLWidget::paintGL() { qglClearColor(clearColor); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + +#if !defined(QT_OPENGL_ES_2) + glLoadIdentity(); glTranslatef(0.0f, 0.0f, -10.0f); glRotatef(xRot / 16.0f, 1.0f, 0.0f, 0.0f); glRotatef(yRot / 16.0f, 0.0f, 1.0f, 0.0f); glRotatef(zRot / 16.0f, 0.0f, 0.0f, 1.0f); - cube->draw(); + + glVertexPointer(3, GL_FLOAT, 0, vertices.constData()); + glTexCoordPointer(2, GL_FLOAT, 0, texCoords.constData()); + glEnableClientState(GL_VERTEX_ARRAY); + glEnableClientState(GL_TEXTURE_COORD_ARRAY); + +#else + + QMatrix4x4 m; + m.ortho(-0.5f, +0.5f, +0.5f, -0.5f, 4.0f, 15.0f); + m.translate(0.0f, 0.0f, -10.0f); + m.rotate(xRot / 16.0f, 1.0f, 0.0f, 0.0f); + m.rotate(yRot / 16.0f, 0.0f, 1.0f, 0.0f); + m.rotate(zRot / 16.0f, 0.0f, 0.0f, 1.0f); + + program->setUniformValue("matrix", m); + program->setAttributeArray + (PROGRAM_VERTEX_ATTRIBUTE, vertices.constData()); + program->setAttributeArray + (PROGRAM_TEXCOORD_ATTRIBUTE, texCoords.constData()); + +#endif + + for (int i = 0; i < 6; ++i) { + glBindTexture(GL_TEXTURE_2D, textures[i]); + glDrawArrays(GL_TRIANGLE_FAN, i * 4, 4); + } } void GLWidget::resizeGL(int width, int height) @@ -119,6 +181,7 @@ void GLWidget::resizeGL(int width, int height) int side = qMin(width, height); glViewport((width - side) / 2, (height - side) / 2, side, side); +#if !defined(QT_OPENGL_ES_2) glMatrixMode(GL_PROJECTION); glLoadIdentity(); #ifndef QT_OPENGL_ES @@ -127,6 +190,7 @@ void GLWidget::resizeGL(int width, int height) glOrthof(-0.5, +0.5, +0.5, -0.5, 4.0, 15.0); #endif glMatrixMode(GL_MODELVIEW); +#endif } void GLWidget::mousePressEvent(QMouseEvent *event) @@ -163,32 +227,18 @@ void GLWidget::makeObject() { { -1, -1, +1 }, { +1, -1, +1 }, { +1, +1, +1 }, { -1, +1, +1 } } }; - cube = new CubeObject(); - for (int j=0; j < 6; ++j) { - cube->textures[j] = bindTexture + textures[j] = bindTexture (QPixmap(QString(":/images/side%1.png").arg(j + 1)), GL_TEXTURE_2D); } for (int i = 0; i < 6; ++i) { for (int j = 0; j < 4; ++j) { - cube->texCoords.append + texCoords.append (QVector2D(j == 0 || j == 3, j == 0 || j == 1)); - cube->vertices.append + vertices.append (QVector3D(0.2 * coords[i][j][0], 0.2 * coords[i][j][1], 0.2 * coords[i][j][2])); } } } - -void CubeObject::draw() -{ - glVertexPointer(3, GL_FLOAT, 0, vertices.constData()); - glTexCoordPointer(2, GL_FLOAT, 0, texCoords.constData()); - glEnableClientState(GL_VERTEX_ARRAY); - glEnableClientState(GL_TEXTURE_COORD_ARRAY); - for (int i = 0; i < 6; ++i) { - glBindTexture(GL_TEXTURE_2D, textures[i]); - glDrawArrays(GL_TRIANGLE_FAN, i * 4, 4); - } -} diff --git a/examples/opengl/textures/glwidget.h b/examples/opengl/textures/glwidget.h index 46507ce..4dcff3b 100644 --- a/examples/opengl/textures/glwidget.h +++ b/examples/opengl/textures/glwidget.h @@ -42,9 +42,10 @@ #ifndef GLWIDGET_H #define GLWIDGET_H +#include <QtGui> #include <QGLWidget> -class CubeObject; +class QGLShaderProgram; class GLWidget : public QGLWidget { @@ -78,7 +79,12 @@ private: int xRot; int yRot; int zRot; - CubeObject *cube; + GLuint textures[6]; + QVector<QVector3D> vertices; + QVector<QVector2D> texCoords; +#ifdef QT_OPENGL_ES_2 + QGLShaderProgram *program; +#endif }; #endif diff --git a/examples/openvg/star/star.pro b/examples/openvg/star/star.pro index 90c236d..6ae1238 100644 --- a/examples/openvg/star/star.pro +++ b/examples/openvg/star/star.pro @@ -4,3 +4,4 @@ CONFIG += qt debug warn_on QT += openvg SOURCES = starwidget.cpp main.cpp HEADERS = starwidget.h +LIBS += $$QMAKE_LIBS_OPENVG
\ No newline at end of file diff --git a/src/corelib/animation/qpropertyanimation.cpp b/src/corelib/animation/qpropertyanimation.cpp index d6ded62..b64d7df 100644 --- a/src/corelib/animation/qpropertyanimation.cpp +++ b/src/corelib/animation/qpropertyanimation.cpp @@ -106,13 +106,19 @@ void QPropertyAnimationPrivate::updateMetaProperty() return; } + //propertyType will be set to a valid type only if there is a Q_PROPERTY + //otherwise it will be set to QVariant::Invalid at the end of this function propertyType = targetValue->property(propertyName).userType(); propertyIndex = targetValue->metaObject()->indexOfProperty(propertyName); - if (propertyIndex == -1 && !targetValue->dynamicPropertyNames().contains(propertyName)) - qWarning("QPropertyAnimation: you're trying to animate a non-existing property %s of your QObject", propertyName.constData()); if (propertyType != QVariant::Invalid) convertValues(propertyType); + if (propertyIndex == -1) { + //there is no Q_PROPERTY on the object + propertyType = QVariant::Invalid; + if (!targetValue->dynamicPropertyNames().contains(propertyName)) + qWarning("QPropertyAnimation: you're trying to animate a non-existing property %s of your QObject", propertyName.constData()); + } } void QPropertyAnimationPrivate::updateProperty(const QVariant &newValue) @@ -125,7 +131,7 @@ void QPropertyAnimationPrivate::updateProperty(const QVariant &newValue) return; } - if (propertyIndex != -1 && newValue.userType() == propertyType) { + if (newValue.userType() == propertyType) { //no conversion is needed, we directly call the QObject::qt_metacall void *data = const_cast<void*>(newValue.constData()); targetValue->qt_metacall(QMetaObject::WriteProperty, propertyIndex, &data); @@ -273,9 +279,9 @@ void QPropertyAnimation::updateState(QAbstractAnimation::State oldState, if (oldState == Stopped) { d->setDefaultStartEndValue(d->targetValue->property(d->propertyName.constData())); //let's check if we have a start value and an end value - if (d->direction == Forward && !startValue().isValid() && !d->defaultStartEndValue.isValid()) + if (!startValue().isValid() && (d->direction == Backward || !d->defaultStartEndValue.isValid())) qWarning("QPropertyAnimation::updateState: starting an animation without start value"); - if (d->direction == Backward && !endValue().isValid() && !d->defaultStartEndValue.isValid()) + if (!endValue().isValid() && (d->direction == Forward || !d->defaultStartEndValue.isValid())) qWarning("QPropertyAnimation::updateState: starting an animation without end value"); } } else if (hash.value(key) == this) { diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp index a790dc1..9909b7b 100644 --- a/src/corelib/global/qglobal.cpp +++ b/src/corelib/global/qglobal.cpp @@ -75,6 +75,11 @@ #if defined(Q_OS_SYMBIAN) #include <e32def.h> #include <e32debug.h> +#include <f32file.h> +# include "private/qcore_symbian_p.h" + +_LIT(qt_S60Filter, "Series60v?.*.sis"); +_LIT(qt_S60SystemInstallDir, "z:\\system\\install\\"); #endif QT_BEGIN_NAMESPACE @@ -1786,28 +1791,31 @@ QSysInfo::S60Version QSysInfo::s60Version() if (cachedS60Version != -1) return cachedS60Version; - QDir dir(QLatin1String("z:\\system\\install")); - QStringList filters; - filters << QLatin1String("Series60v?.*.sis"); - dir.setNameFilters(filters); - - QStringList names = dir.entryList(QDir::NoFilter, QDir::Name | QDir::Reversed | QDir::IgnoreCase); - if (names.size() == 0) - return cachedS60Version = SV_S60_Unknown; - - int major, minor; - major = names[0][9].toAscii() - '0'; - minor = names[0][11].toAscii() - '0'; - if (major == 3) { - if (minor == 1) { - return cachedS60Version = SV_S60_3_1; - } else if (minor == 2) { - return cachedS60Version = SV_S60_3_2; - } - } else if (major == 5) { - if (minor == 0) { - return cachedS60Version = SV_S60_5_0; + // Use pure Symbian code, because if done using QDir, there will be a call back + // to this method, resulting doing this expensive operation twice before the cache kicks in. + // Pure Symbian code also makes this method ~10x faster, speeding up the application launch. + RFs rfs = qt_s60GetRFs(); + TFindFile fileFinder(rfs); + CDir* contents; + TInt err = fileFinder.FindWildByDir(qt_S60Filter, qt_S60SystemInstallDir, contents); + if (err == KErrNone) { + err = contents->Sort(EDescending|ESortByName); + if (err == KErrNone) { + TInt major = (*contents)[0].iName[9] - '0'; + TInt minor = (*contents)[0].iName[11] - '0'; + if (major == 3) { + if (minor == 1) { + return cachedS60Version = SV_S60_3_1; + } else if (minor == 2) { + return cachedS60Version = SV_S60_3_2; + } + } else if (major == 5) { + if (minor == 0) { + return cachedS60Version = SV_S60_5_0; + } + } } + delete contents; } return cachedS60Version = SV_S60_Unknown; diff --git a/src/gui/graphicsview/qgraphicsanchorlayout.cpp b/src/gui/graphicsview/qgraphicsanchorlayout.cpp index 3bb8c29..c7033c6 100644 --- a/src/gui/graphicsview/qgraphicsanchorlayout.cpp +++ b/src/gui/graphicsview/qgraphicsanchorlayout.cpp @@ -383,7 +383,7 @@ void QGraphicsAnchorLayout::setGeometry(const QRectF &geom) QGraphicsLayout::setGeometry(geom); d->calculateVertexPositions(QGraphicsAnchorLayoutPrivate::Horizontal); d->calculateVertexPositions(QGraphicsAnchorLayoutPrivate::Vertical); - d->setItemsGeometries(); + d->setItemsGeometries(geom); } /*! diff --git a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp index 787060f..f81ede0 100644 --- a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp +++ b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp @@ -1772,20 +1772,42 @@ QGraphicsAnchorLayoutPrivate::getGraphParts(Orientation orientation) Use the current vertices distance to calculate and set the geometry of each item. */ -void QGraphicsAnchorLayoutPrivate::setItemsGeometries() +void QGraphicsAnchorLayoutPrivate::setItemsGeometries(const QRectF &geom) { + Q_Q(QGraphicsAnchorLayout); AnchorVertex *firstH, *secondH, *firstV, *secondV; + qreal top; + qreal left; + qreal right; + + q->getContentsMargins(&left, &top, &right, 0); + const Qt::LayoutDirection visualDir = visualDirection(); + if (visualDir == Qt::RightToLeft) + qSwap(left, right); + + left += geom.left(); + top += geom.top(); + right = geom.right() - right; + foreach (QGraphicsLayoutItem *item, items) { firstH = internalVertex(item, Qt::AnchorLeft); secondH = internalVertex(item, Qt::AnchorRight); firstV = internalVertex(item, Qt::AnchorTop); secondV = internalVertex(item, Qt::AnchorBottom); - QPointF topLeft(firstH->distance, firstV->distance); - QPointF bottomRight(secondH->distance, secondV->distance); + QRectF newGeom; + newGeom.setTop(top + firstV->distance); + newGeom.setBottom(top + secondV->distance); - item->setGeometry(QRectF(topLeft, bottomRight)); + if (visualDir == Qt::LeftToRight) { + newGeom.setLeft(left + firstH->distance); + newGeom.setRight(left + secondH->distance); + } else { + newGeom.setLeft(right - secondH->distance); + newGeom.setRight(right - firstH->distance); + } + item->setGeometry(newGeom); } } @@ -1798,26 +1820,13 @@ void QGraphicsAnchorLayoutPrivate::setItemsGeometries() void QGraphicsAnchorLayoutPrivate::calculateVertexPositions( QGraphicsAnchorLayoutPrivate::Orientation orientation) { - Q_Q(QGraphicsAnchorLayout); QQueue<QPair<AnchorVertex *, AnchorVertex *> > queue; QSet<AnchorVertex *> visited; // Get root vertex AnchorVertex *root = graph[orientation].rootVertex(); - qreal widgetMargin; - qreal layoutMargin; - - // Initialize the first vertex - if (orientation == Horizontal) { - widgetMargin = q->geometry().x(); - q->getContentsMargins(&layoutMargin, 0, 0, 0); - } else { - // Root position is equal to the top margin - widgetMargin = q->geometry().y(); - q->getContentsMargins(0, &layoutMargin, 0, 0); - } - root->distance = widgetMargin + layoutMargin; + root->distance = 0; visited.insert(root); // Add initial edges to the queue diff --git a/src/gui/graphicsview/qgraphicsanchorlayout_p.h b/src/gui/graphicsview/qgraphicsanchorlayout_p.h index 1470fb3..31da1a1 100644 --- a/src/gui/graphicsview/qgraphicsanchorlayout_p.h +++ b/src/gui/graphicsview/qgraphicsanchorlayout_p.h @@ -437,7 +437,7 @@ public: void removeInternalVertex(QGraphicsLayoutItem *item, Qt::AnchorPoint edge); // Geometry interpolation methods - void setItemsGeometries(); + void setItemsGeometries(const QRectF &geom); void calculateVertexPositions(Orientation orientation); void setupEdgesInterpolation(Orientation orientation); diff --git a/src/gui/kernel/qcocoamenuloader_mac.mm b/src/gui/kernel/qcocoamenuloader_mac.mm index ce2a92c..9ab077f 100644 --- a/src/gui/kernel/qcocoamenuloader_mac.mm +++ b/src/gui/kernel/qcocoamenuloader_mac.mm @@ -44,6 +44,7 @@ #include <qaction.h> #include <qcoreapplication.h> #include <private/qcocoamenuloader_mac_p.h> +#include <private/qapplication_p.h> #include <private/qt_mac_p.h> #include <qmenubar.h> @@ -198,6 +199,7 @@ QT_USE_NAMESPACE - (IBAction)qtDispatcherToQAction:(id)sender { + QScopedLoopLevelCounter loopLevelCounter(QApplicationPrivate::instance()->threadData); NSMenuItem *item = static_cast<NSMenuItem *>(sender); if (QAction *action = reinterpret_cast<QAction *>([item tag])) { action->trigger(); diff --git a/src/gui/kernel/qwidget_mac.mm b/src/gui/kernel/qwidget_mac.mm index faf7f82..6b040bc 100644 --- a/src/gui/kernel/qwidget_mac.mm +++ b/src/gui/kernel/qwidget_mac.mm @@ -120,7 +120,7 @@ QT_BEGIN_NAMESPACE extern "C" { extern OSStatus _HIViewScrollRectWithOptions(HIViewRef, const HIRect *, CGFloat, CGFloat, - OptionBits); + OptionBits) __attribute__ ((weak)); } #define kHIViewScrollRectAdjustInvalid 1 #define kHIViewScrollRectDontInvalidateRevealedArea 2 @@ -3785,7 +3785,10 @@ static void qt_mac_update_widget_posisiton(QWidget *q, QRect oldRect, QRect newR (oldRect.isValid() == false || newRect.isValid() == false) || // the position update is a part of a drag-and-drop operation - QDragManager::self()->object + QDragManager::self()->object || + + // we are on Panther (no HIViewSetNeedsDisplayInRect) + QSysInfo::MacintoshVersion < QSysInfo::MV_10_4 ){ HIViewSetFrame(view, &bounds); return; diff --git a/src/gui/kernel/qwidget_s60.cpp b/src/gui/kernel/qwidget_s60.cpp index 94f3532..744d20f 100644 --- a/src/gui/kernel/qwidget_s60.cpp +++ b/src/gui/kernel/qwidget_s60.cpp @@ -315,7 +315,7 @@ void QWidgetPrivate::create_sys(WId window, bool /* initializeWindow */, bool de id = (WId)control; setWinId(id); QT_TRAP_THROWING(control->ConstructL(true,desktop)); - + if (!desktop) { TInt stackingFlags; if ((q->windowType() & Qt::Popup) == Qt::Popup) { @@ -989,6 +989,32 @@ void QWidget::setWindowState(Qt::WindowStates newstate) return; if (isWindow()) { +#ifdef Q_WS_S60 + // Change window decoration visibility if switching to or from fullsccreen + // In addition decoration visibility is changed when the initial has been + // WindowNoState. + // The window decoration visibility has to be changed before doing actual + // window state change since in that order the availableGeometry will return + // directly the right size and we will avoid unnecessarty redraws + if((oldstate & Qt::WindowFullScreen) != (newstate & Qt::WindowFullScreen) || + oldstate == Qt::WindowNoState) { + CEikStatusPane* statusPane = S60->statusPane(); + CEikButtonGroupContainer* buttonGroup = S60->buttonGroupContainer(); + if (newstate & Qt::WindowFullScreen) { + if (statusPane) + statusPane->MakeVisible(false); + if (buttonGroup) + buttonGroup->MakeVisible(false); + } else { + if (statusPane) + statusPane->MakeVisible(true); + if (buttonGroup) + buttonGroup->MakeVisible(true); + } + + } +#endif // Q_WS_S60 + createWinId(); Q_ASSERT(testAttribute(Qt::WA_WState_Created)); QTLWExtra *top = d->topData(); @@ -1013,30 +1039,15 @@ void QWidget::setWindowState(Qt::WindowStates newstate) } } if ((oldstate & Qt::WindowFullScreen) != (newstate & Qt::WindowFullScreen)) { -#ifdef Q_WS_S60 - CEikStatusPane* statusPane = S60->statusPane(); - CEikButtonGroupContainer* buttonGroup = S60->buttonGroupContainer(); -#endif if (newstate & Qt::WindowFullScreen) { const QRect normalGeometry = geometry(); const QRect r = top->normalGeometry; setGeometry(qApp->desktop()->screenGeometry(this)); -#ifdef Q_WS_S60 - if (statusPane) - statusPane->MakeVisible(false); - if (buttonGroup) - buttonGroup->MakeVisible(false); -#endif + top->normalGeometry = r; if (top->normalGeometry.width() < 0) top->normalGeometry = normalGeometry; } else { -#ifdef Q_WS_S60 - if (statusPane) - statusPane->MakeVisible(true); - if (buttonGroup) - buttonGroup->MakeVisible(true); -#endif if (newstate & Qt::WindowMaximized) { const QRect r = top->normalGeometry; setGeometry(qApp->desktop()->availableGeometry(this)); @@ -1199,10 +1210,9 @@ void QWidget::activateWindow() Q_D(QWidget); QWidget *tlw = window(); if (tlw->isVisible()) { - S60->windowGroup().SetOrdinalPosition(0); window()->createWinId(); - RDrawableWindow* rw = tlw->d_func()->topData()->rwindow; - rw->SetOrdinalPosition(0); + WId id = tlw->internalWinId(); + id->SetFocus(true); } } QT_END_NAMESPACE diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp index 2dcc20c..a9257c7 100644 --- a/src/gui/painting/qpainter.cpp +++ b/src/gui/painting/qpainter.cpp @@ -1894,8 +1894,13 @@ QPaintEngine *QPainter::paintEngine() const /*! Flushes the painting pipeline and prepares for the user issuing - native painting commands. Must be followed by a call to - endNativePainting(). + commands directly to the underlying graphics context. Must be + followed by a call to endNativePainting(). + + Here is an example that shows intermixing of painter commands + and raw OpenGL commands: + + \snippet doc/src/snippets/code/src_gui_painting_qpainter.cpp 21 \sa endNativePainting() */ diff --git a/src/gui/painting/qprintengine_win.cpp b/src/gui/painting/qprintengine_win.cpp index bd1d304..e59155c 100644 --- a/src/gui/painting/qprintengine_win.cpp +++ b/src/gui/painting/qprintengine_win.cpp @@ -367,11 +367,11 @@ void QWin32PrintEngine::drawTextItem(const QPointF &p, const QTextItem &textItem return ; } - // We only want to convert the glyphs to text if the entire string is latin1 - bool latin1String = true; + // We only want to convert the glyphs to text if the entire string is compatible with ASCII + bool convertToText = true; for (int i=0; i < ti.num_chars; ++i) { - if (ti.chars[i].unicode() >= 0x100) { - latin1String = false; + if (ti.chars[i].unicode() >= 0x80) { + convertToText = false; break; } } @@ -381,7 +381,7 @@ void QWin32PrintEngine::drawTextItem(const QPointF &p, const QTextItem &textItem SelectObject(d->hdc, CreatePen(PS_SOLID, 1, cf)); SetTextColor(d->hdc, cf); - draw_text_item_win(p, ti, d->hdc, latin1String, d->matrix, d->devPaperRect.topLeft()); + draw_text_item_win(p, ti, d->hdc, convertToText, d->matrix, d->devPaperRect.topLeft()); DeleteObject(SelectObject(d->hdc,GetStockObject(HOLLOW_BRUSH))); DeleteObject(SelectObject(d->hdc,GetStockObject(BLACK_PEN))); } diff --git a/src/gui/text/qfontengine_qws.cpp b/src/gui/text/qfontengine_qws.cpp index 62a674a..888e1be 100644 --- a/src/gui/text/qfontengine_qws.cpp +++ b/src/gui/text/qfontengine_qws.cpp @@ -381,6 +381,8 @@ class QFontEngineQPF1Data public: QPFFontMetrics fm; QPFGlyphTree *tree; + void *mmapStart; + size_t mmapLength; }; @@ -410,6 +412,8 @@ QFontEngineQPF1::QFontEngineQPF1(const QFontDef&, const QString &fn) QT_CLOSE(f); d = new QFontEngineQPF1Data; + d->mmapStart = data; + d->mmapLength = st.st_size; memcpy(reinterpret_cast<char*>(&d->fm),data,sizeof(d->fm)); data += sizeof(d->fm); @@ -431,6 +435,8 @@ QFontEngineQPF1::QFontEngineQPF1(const QFontDef&, const QString &fn) QFontEngineQPF1::~QFontEngineQPF1() { + if (d->mmapStart) + munmap(d->mmapStart, d->mmapLength); delete d->tree; delete d; } diff --git a/src/network/access/qnetworkreplyimpl.cpp b/src/network/access/qnetworkreplyimpl.cpp index 1dad58c..83afddd 100644 --- a/src/network/access/qnetworkreplyimpl.cpp +++ b/src/network/access/qnetworkreplyimpl.cpp @@ -582,10 +582,6 @@ void QNetworkReplyImpl::abort() return; // stop both upload and download - if (d->backend) { - d->backend->deleteLater(); - d->backend = 0; - } if (d->outgoingData) disconnect(d->outgoingData, 0, this, 0); if (d->copyDevice) @@ -599,6 +595,12 @@ void QNetworkReplyImpl::abort() d->finished(); } d->state = QNetworkReplyImplPrivate::Aborted; + + // finished may access the backend + if (d->backend) { + d->backend->deleteLater(); + d->backend = 0; + } } void QNetworkReplyImpl::close() diff --git a/src/network/socket/qlocalsocket_win.cpp b/src/network/socket/qlocalsocket_win.cpp index d6e70be..8a745ab 100644 --- a/src/network/socket/qlocalsocket_win.cpp +++ b/src/network/socket/qlocalsocket_win.cpp @@ -375,7 +375,8 @@ void QLocalSocket::close() QIODevice::close(); d->state = ClosingState; emit stateChanged(d->state); - emit readChannelFinished(); + if (!d->pipeClosed) + emit readChannelFinished(); d->serverName = QString(); d->fullServerName = QString(); diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp index 4427ee9..e32bbbd 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp @@ -1405,8 +1405,8 @@ void QGL2PaintEngineEx::ensureActive() glViewport(0, 0, d->width, d->height); glDepthMask(false); glDepthFunc(GL_LESS); - setState(state()); d->needsSync = false; + setState(state()); } } @@ -1519,6 +1519,8 @@ void QGL2PaintEngineEx::clip(const QVectorPath &path, Qt::ClipOperation op) // qDebug("QGL2PaintEngineEx::clip()"); Q_D(QGL2PaintEngineEx); + ensureActive(); + if (op == Qt::ReplaceClip && !d->hasClipOperations()) op = Qt::IntersectClip; diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index 8a9ea1c..9148456 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -2070,6 +2070,9 @@ QGLTexture* QGLContextPrivate::bindTexture(const QImage &image, GLenum target, G glBindTexture(target, tx_id); glTexParameterf(target, GL_TEXTURE_MAG_FILTER, filtering); +#if defined(QT_OPENGL_ES_2) + bool genMipmap = false; +#endif if (glFormat.directRendering() && QGLExtensions::glExtensions & QGLExtensions::GenerateMipmap && target == GL_TEXTURE_2D @@ -2078,12 +2081,17 @@ QGLTexture* QGLContextPrivate::bindTexture(const QImage &image, GLenum target, G #ifdef QGL_BIND_TEXTURE_DEBUG printf(" - generating mipmaps\n"); #endif +#if !defined(QT_OPENGL_ES_2) glHint(GL_GENERATE_MIPMAP_HINT_SGIS, GL_NICEST); #ifndef QT_OPENGL_ES glTexParameteri(target, GL_GENERATE_MIPMAP_SGIS, GL_TRUE); #else glTexParameterf(target, GL_GENERATE_MIPMAP_SGIS, GL_TRUE); #endif +#else + glHint(GL_GENERATE_MIPMAP_HINT, GL_NICEST); + genMipmap = true; +#endif glTexParameterf(target, GL_TEXTURE_MIN_FILTER, options & QGLContext::LinearFilteringBindOption ? GL_LINEAR_MIPMAP_LINEAR : GL_NEAREST_MIPMAP_NEAREST); } else { @@ -2183,13 +2191,17 @@ QGLTexture* QGLContextPrivate::bindTexture(const QImage &image, GLenum target, G } } #ifdef QGL_BIND_TEXTURE_DEBUG - printf(" - uploading, image.format=%d, externalFormat=0x%d, internalFormat=0x%d\n", - img.format(), externalFormat, internalFormat); + printf(" - uploading, image.format=%d, externalFormat=0x%x, internalFormat=0x%x, pixel_type=0x%x\n", + img.format(), externalFormat, internalFormat, pixel_type); #endif const QImage &constRef = img; // to avoid detach in bits()... glTexImage2D(target, 0, internalFormat, img.width(), img.height(), 0, externalFormat, pixel_type, constRef.bits()); +#if defined(QT_OPENGL_ES_2) + if (genMipmap) + glGenerateMipmap(target); +#endif #ifndef QT_NO_DEBUG GLenum error = glGetError(); if (error != GL_NO_ERROR) { @@ -4815,6 +4827,19 @@ void QGLExtensions::init_extensions() glExtensions |= FramebufferObject; glExtensions |= GenerateMipmap; #endif +#if defined(QT_OPENGL_ES_1) || defined(QT_OPENGL_ES_1_CL) + if (extensions.contains(QLatin1String("OES_framebuffer_object"))) + glExtensions |= FramebufferObject; +#endif +#if defined(QT_OPENGL_ES) + if (extensions.contains(QLatin1String("OES_packed_depth_stencil"))) + glExtensions |= PackedDepthStencil; +#endif + if (extensions.contains(QLatin1String("ARB_framebuffer_object"))) { + // ARB_framebuffer_object also includes EXT_framebuffer_blit. + glExtensions |= FramebufferObject; + glExtensions |= FramebufferBlit; + } if (extensions.contains(QLatin1String("EXT_framebuffer_blit"))) glExtensions |= FramebufferBlit; diff --git a/src/opengl/qgl_qws.cpp b/src/opengl/qgl_qws.cpp index c71ceeb..759f9de 100644 --- a/src/opengl/qgl_qws.cpp +++ b/src/opengl/qgl_qws.cpp @@ -41,6 +41,7 @@ #include "qgl.h" #include "qgl_egl_p.h" +#include "qglpixelbuffer.h" #include <qglscreen_qws.h> #include <qscreenproxy_qws.h> @@ -411,7 +412,29 @@ void QGLExtensions::init() if (init_done) return; init_done = true; + + // We need a context current to initialize the extensions, + // but getting a valid EGLNativeWindowType this early can be + // problematic under QWS. So use a pbuffer instead. + // + // Unfortunately OpenGL/ES 2.0 systems don't normally + // support pbuffers, so we have no choice but to try + // our luck with a window on those systems. +#if defined(QT_OPENGL_ES_2) + QGLWidget tmpWidget; + tmpWidget.makeCurrent(); + init_extensions(); + + tmpWidget.doneCurrent(); +#else + QGLPixelBuffer pbuffer(16, 16); + pbuffer.makeCurrent(); + + init_extensions(); + + pbuffer.doneCurrent(); +#endif } QT_END_NAMESPACE diff --git a/src/opengl/qgl_wince.cpp b/src/opengl/qgl_wince.cpp index 881d7f7..83efca8 100644 --- a/src/opengl/qgl_wince.cpp +++ b/src/opengl/qgl_wince.cpp @@ -730,7 +730,14 @@ void QGLExtensions::init() if (init_done) return; init_done = true; + + // We need a context current to initialize the extensions. + QGLWidget tmpWidget; + tmpWidget.makeCurrent(); + init_extensions(); + + tmpWidget.doneCurrent(); } QT_END_NAMESPACE diff --git a/src/opengl/qgl_x11egl.cpp b/src/opengl/qgl_x11egl.cpp index 055138d..c54315f 100644 --- a/src/opengl/qgl_x11egl.cpp +++ b/src/opengl/qgl_x11egl.cpp @@ -470,7 +470,14 @@ void QGLExtensions::init() if (init_done) return; init_done = true; + + // We need a context current to initialize the extensions. + QGLWidget tmpWidget; + tmpWidget.makeCurrent(); + init_extensions(); + + tmpWidget.doneCurrent(); } // Re-creates the EGL surface if the window ID has changed or if force is true diff --git a/src/opengl/qglextensions.cpp b/src/opengl/qglextensions.cpp index 8c8d46c..3699d62 100644 --- a/src/opengl/qglextensions.cpp +++ b/src/opengl/qglextensions.cpp @@ -43,6 +43,52 @@ QT_BEGIN_NAMESPACE +static void *qt_gl_getProcAddress_search + (QGLContext *ctx, const char *name1, const char *name2, + const char *name3, const char *name4) +{ + void *addr; + + addr = ctx->getProcAddress(QLatin1String(name1)); + if (addr) + return addr; + + addr = ctx->getProcAddress(QLatin1String(name2)); + if (addr) + return addr; + + addr = ctx->getProcAddress(QLatin1String(name3)); + if (addr) + return addr; + + if (name4) + return ctx->getProcAddress(QLatin1String(name4)); + + return 0; +} + +// Search for an extension function starting with the most likely +// function suffix first, and then trying the other variations. +#if defined(QT_OPENGL_ES) +#define qt_gl_getProcAddress(ctx,name) \ + qt_gl_getProcAddress_search((ctx), name, name "OES", name "EXT", name "ARB") +#define qt_gl_getProcAddressEXT(ctx,name) \ + qt_gl_getProcAddress_search((ctx), name "OES", name, name "EXT", name "ARB") +#define qt_gl_getProcAddressARB(ctx,name) \ + qt_gl_getProcAddress_search((ctx), name "OES", name, name "ARB", name "EXT") +#define qt_gl_getProcAddressOES(ctx,name) \ + qt_gl_getProcAddress_search((ctx), name "OES", name, name "EXT", name "ARB") +#else +#define qt_gl_getProcAddress(ctx,name) \ + qt_gl_getProcAddress_search((ctx), name, name "ARB", name "EXT", 0) +#define qt_gl_getProcAddressEXT(ctx,name) \ + qt_gl_getProcAddress_search((ctx), name "EXT", name, name "ARB", 0) +#define qt_gl_getProcAddressARB(ctx,name) \ + qt_gl_getProcAddress_search((ctx), name "ARB", name, name "EXT", 0) +#define qt_gl_getProcAddressOES(ctx,name) \ + qt_gl_getProcAddress_search((ctx), name "OES", name, name "EXT", name "ARB") +#endif + bool qt_resolve_framebufferobject_extensions(QGLContext *ctx) { #if defined(QT_OPENGL_ES_2) @@ -62,30 +108,32 @@ bool qt_resolve_framebufferobject_extensions(QGLContext *ctx) } - glBlitFramebufferEXT = (_glBlitFramebufferEXT) ctx->getProcAddress(QLatin1String("glBlitFramebufferEXT")); + glBlitFramebufferEXT = (_glBlitFramebufferEXT) qt_gl_getProcAddressEXT(ctx, "glBlitFramebuffer"); glRenderbufferStorageMultisampleEXT = - (_glRenderbufferStorageMultisampleEXT) ctx->getProcAddress(QLatin1String("glRenderbufferStorageMultisampleEXT")); + (_glRenderbufferStorageMultisampleEXT) qt_gl_getProcAddressEXT(ctx, "glRenderbufferStorageMultisample"); #if !defined(QT_OPENGL_ES_2) - glIsRenderbuffer = (_glIsRenderbuffer) ctx->getProcAddress(QLatin1String("glIsRenderbufferEXT")); - glBindRenderbuffer = (_glBindRenderbuffer) ctx->getProcAddress(QLatin1String("glBindRenderbufferEXT")); - glDeleteRenderbuffers = (_glDeleteRenderbuffers) ctx->getProcAddress(QLatin1String("glDeleteRenderbuffersEXT")); - glGenRenderbuffers = (_glGenRenderbuffers) ctx->getProcAddress(QLatin1String("glGenRenderbuffersEXT")); - glRenderbufferStorage = (_glRenderbufferStorage) ctx->getProcAddress(QLatin1String("glRenderbufferStorageEXT")); + glIsRenderbuffer = (_glIsRenderbuffer) qt_gl_getProcAddressEXT(ctx, "glIsRenderbuffer"); + if (!glIsRenderbuffer) + return false; // Not much point searching for anything else. + glBindRenderbuffer = (_glBindRenderbuffer) qt_gl_getProcAddressEXT(ctx, "glBindRenderbuffer"); + glDeleteRenderbuffers = (_glDeleteRenderbuffers) qt_gl_getProcAddressEXT(ctx, "glDeleteRenderbuffers"); + glGenRenderbuffers = (_glGenRenderbuffers) qt_gl_getProcAddressEXT(ctx, "glGenRenderbuffers"); + glRenderbufferStorage = (_glRenderbufferStorage) qt_gl_getProcAddressEXT(ctx, "glRenderbufferStorage"); glGetRenderbufferParameteriv = - (_glGetRenderbufferParameteriv) ctx->getProcAddress(QLatin1String("glGetRenderbufferParameterivEXT")); - glIsFramebuffer = (_glIsFramebuffer) ctx->getProcAddress(QLatin1String("glIsFramebufferEXT")); - glBindFramebuffer = (_glBindFramebuffer) ctx->getProcAddress(QLatin1String("glBindFramebufferEXT")); - glDeleteFramebuffers = (_glDeleteFramebuffers) ctx->getProcAddress(QLatin1String("glDeleteFramebuffersEXT")); - glGenFramebuffers = (_glGenFramebuffers) ctx->getProcAddress(QLatin1String("glGenFramebuffersEXT")); - glCheckFramebufferStatus = (_glCheckFramebufferStatus) ctx->getProcAddress(QLatin1String("glCheckFramebufferStatusEXT")); - glFramebufferTexture2D = (_glFramebufferTexture2D) ctx->getProcAddress(QLatin1String("glFramebufferTexture2DEXT")); - glFramebufferRenderbuffer = (_glFramebufferRenderbuffer) ctx->getProcAddress(QLatin1String("glFramebufferRenderbufferEXT")); + (_glGetRenderbufferParameteriv) qt_gl_getProcAddressEXT(ctx, "glGetRenderbufferParameteriv"); + glIsFramebuffer = (_glIsFramebuffer) qt_gl_getProcAddressEXT(ctx, "glIsFramebuffer"); + glBindFramebuffer = (_glBindFramebuffer) qt_gl_getProcAddressEXT(ctx, "glBindFramebuffer"); + glDeleteFramebuffers = (_glDeleteFramebuffers) qt_gl_getProcAddressEXT(ctx, "glDeleteFramebuffers"); + glGenFramebuffers = (_glGenFramebuffers) qt_gl_getProcAddressEXT(ctx, "glGenFramebuffers"); + glCheckFramebufferStatus = (_glCheckFramebufferStatus) qt_gl_getProcAddressEXT(ctx, "glCheckFramebufferStatus"); + glFramebufferTexture2D = (_glFramebufferTexture2D) qt_gl_getProcAddressEXT(ctx, "glFramebufferTexture2D"); + glFramebufferRenderbuffer = (_glFramebufferRenderbuffer) qt_gl_getProcAddressEXT(ctx, "glFramebufferRenderbuffer"); glGetFramebufferAttachmentParameteriv = - (_glGetFramebufferAttachmentParameteriv) ctx->getProcAddress(QLatin1String("glGetFramebufferAttachmentParameterivEXT")); - glGenerateMipmap = (_glGenerateMipmap) ctx->getProcAddress(QLatin1String("glGenerateMipmapEXT")); + (_glGetFramebufferAttachmentParameteriv) qt_gl_getProcAddressEXT(ctx, "glGetFramebufferAttachmentParameteriv"); + glGenerateMipmap = (_glGenerateMipmap) qt_gl_getProcAddressEXT(ctx, "glGenerateMipmap"); - return glIsRenderbuffer; + return glIsRenderbuffer != 0; #else return true; #endif @@ -151,13 +199,13 @@ bool qt_resolve_buffer_extensions(QGLContext *ctx) return true; #if !defined(QT_OPENGL_ES_2) - glBindBuffer = (_glBindBuffer) ctx->getProcAddress(QLatin1String("glBindBufferARB")); - glDeleteBuffers = (_glDeleteBuffers) ctx->getProcAddress(QLatin1String("glDeleteBuffersARB")); - glGenBuffers = (_glGenBuffers) ctx->getProcAddress(QLatin1String("glGenBuffersARB")); - glBufferData = (_glBufferData) ctx->getProcAddress(QLatin1String("glBufferDataARB")); + glBindBuffer = (_glBindBuffer) qt_gl_getProcAddressARB(ctx, "glBindBuffer"); + glDeleteBuffers = (_glDeleteBuffers) qt_gl_getProcAddressARB(ctx, "glDeleteBuffers"); + glGenBuffers = (_glGenBuffers) qt_gl_getProcAddressARB(ctx, "glGenBuffers"); + glBufferData = (_glBufferData) qt_gl_getProcAddressARB(ctx, "glBufferData"); #endif - glMapBufferARB = (_glMapBufferARB) ctx->getProcAddress(QLatin1String("glMapBufferARB")); - glUnmapBufferARB = (_glUnmapBufferARB) ctx->getProcAddress(QLatin1String("glUnmapBufferARB")); + glMapBufferARB = (_glMapBufferARB) qt_gl_getProcAddressARB(ctx, "glMapBuffer"); + glUnmapBufferARB = (_glUnmapBufferARB) qt_gl_getProcAddressARB(ctx, "glUnmapBuffer"); return glMapBufferARB && glUnmapBufferARB diff --git a/src/opengl/qglframebufferobject.cpp b/src/opengl/qglframebufferobject.cpp index f15aa01..81f2aa9 100644 --- a/src/opengl/qglframebufferobject.cpp +++ b/src/opengl/qglframebufferobject.cpp @@ -854,6 +854,7 @@ bool QGLFramebufferObject::bind() d->valid = d->checkFramebufferStatus(); const QGLContext *context = QGLContext::currentContext(); if (d->valid && context) { + Q_ASSERT(QGLContextPrivate::contextGroup(context) == ctx); // Save the previous setting to automatically restore in release(). if (context->d_ptr->current_fbo != d->fbo) { d->previous_fbo = context->d_ptr->current_fbo; @@ -885,6 +886,7 @@ bool QGLFramebufferObject::release() const QGLContext *context = QGLContext::currentContext(); if (context) { + Q_ASSERT(QGLContextPrivate::contextGroup(context) == ctx); // Restore the previous setting for stacked framebuffer objects. if (d->previous_fbo != context->d_ptr->current_fbo) { context->d_ptr->current_fbo = d->previous_fbo; diff --git a/src/opengl/qwindowsurface_gl.cpp b/src/opengl/qwindowsurface_gl.cpp index efea369..e89352d 100644 --- a/src/opengl/qwindowsurface_gl.cpp +++ b/src/opengl/qwindowsurface_gl.cpp @@ -71,6 +71,7 @@ #include <private/qgraphicssystem_gl_p.h> #include <private/qpaintengineex_opengl2_p.h> +#include <private/qpixmapdata_gl_p.h> #ifndef QT_OPENGL_ES_2 #include <private/qpaintengine_opengl_p.h> @@ -399,6 +400,11 @@ void QGLWindowSurface::endPaint(const QRegion &rgn) void QGLWindowSurface::flush(QWidget *widget, const QRegion &rgn, const QPoint &offset) { + if (context() && widget != window()) { + qWarning("No native child widget support in GL window surface without FBOs or pixel buffers"); + return; + } + QWidget *parent = widget->internalWinId() ? widget : widget->nativeParentWidget(); Q_ASSERT(parent); @@ -473,7 +479,22 @@ void QGLWindowSurface::flush(QWidget *widget, const QRegion &rgn, const QPoint & return; } + QGLContext *previous_ctx = const_cast<QGLContext *>(QGLContext::currentContext()); QGLContext *ctx = reinterpret_cast<QGLContext *>(parent->d_func()->extraData()->glContext); + + if (ctx != previous_ctx) { + if (d_ptr->fbo && d_ptr->fbo->isBound()) + d_ptr->fbo->release(); + ctx->makeCurrent(); + } + + QSize size = widget->rect().size(); + if (d_ptr->destructive_swap_buffers && ctx->format().doubleBuffer()) { + rect = parent->rect(); + br = rect.translated(wOffset + offset); + size = parent->size(); + } + GLuint texture; if (d_ptr->fbo) { texture = d_ptr->fbo->texture(); @@ -486,31 +507,54 @@ void QGLWindowSurface::flush(QWidget *widget, const QRegion &rgn, const QPoint & glBindTexture(target, 0); } - QSize size = widget->rect().size(); - if (d_ptr->destructive_swap_buffers && ctx->format().doubleBuffer()) { - rect = parent->rect(); - br = rect.translated(wOffset); - size = parent->size(); - } - glDisable(GL_SCISSOR_TEST); - if (d_ptr->fbo && QGLExtensions::glExtensions & QGLExtensions::FramebufferBlit) { + if (d_ptr->fbo && (QGLExtensions::glExtensions & QGLExtensions::FramebufferBlit)) { const int h = d_ptr->fbo->height(); - const int x0 = rect.left(); - const int x1 = rect.left() + rect.width(); - const int y0 = h - (rect.top() + rect.height()); - const int y1 = h - rect.top(); + const int sx0 = br.left(); + const int sx1 = br.left() + br.width(); + const int sy0 = h - (br.top() + br.height()); + const int sy1 = h - br.top(); + + const int tx0 = rect.left(); + const int tx1 = rect.left() + rect.width(); + const int ty0 = parent->height() - (rect.top() + rect.height()); + const int ty1 = parent->height() - rect.top(); + + if (window() == parent || d_ptr->fbo->format().samples() <= 1) { + glBindFramebuffer(GL_DRAW_FRAMEBUFFER_EXT, 0); - glBindFramebuffer(GL_DRAW_FRAMEBUFFER_EXT, 0); + glBlitFramebufferEXT(sx0, sy0, sx1, sy1, + tx0, ty0, tx1, ty1, + GL_COLOR_BUFFER_BIT, + GL_NEAREST); - glBlitFramebufferEXT(x0, y0, x1, y1, - x0, y0, x1, y1, - GL_COLOR_BUFFER_BIT, - GL_NEAREST); + glBindFramebuffer(GL_DRAW_FRAMEBUFFER_EXT, d_ptr->fbo->handle()); + } else { + // can't do sub-region blits with multisample FBOs + QGLFramebufferObject *temp = qgl_fbo_pool()->acquire(d_ptr->fbo->size(), QGLFramebufferObjectFormat()); + + glBindFramebuffer(GL_DRAW_FRAMEBUFFER_EXT, temp->handle()); + glBindFramebuffer(GL_READ_FRAMEBUFFER_EXT, d_ptr->fbo->handle()); + + glBlitFramebufferEXT(0, 0, d_ptr->fbo->width(), d_ptr->fbo->height(), + 0, 0, d_ptr->fbo->width(), d_ptr->fbo->height(), + GL_COLOR_BUFFER_BIT, + GL_NEAREST); + + glBindFramebuffer(GL_READ_FRAMEBUFFER_EXT, temp->handle()); + glBindFramebuffer(GL_DRAW_FRAMEBUFFER_EXT, 0); - glBindFramebuffer(GL_DRAW_FRAMEBUFFER_EXT, d_ptr->fbo->handle()); + glBlitFramebufferEXT(sx0, sy0, sx1, sy1, + tx0, ty0, tx1, ty1, + GL_COLOR_BUFFER_BIT, + GL_NEAREST); + + glBindFramebuffer(GL_READ_FRAMEBUFFER_EXT, 0); + + qgl_fbo_pool()->release(temp); + } } #if !defined(QT_OPENGL_ES_2) else { @@ -579,7 +623,8 @@ void QGLWindowSurface::updateGeometry() #ifdef QT_OPENGL_ES_2 && (QGLExtensions::glExtensions & QGLExtensions::FramebufferBlit) #endif - && (d_ptr->fbo || !d_ptr->tried_fbo)) + && (d_ptr->fbo || !d_ptr->tried_fbo) + && qt_gl_preferGL2Engine()) { d_ptr->tried_fbo = true; hijackWindow(window()); diff --git a/src/opengl/util/fragmentprograms_p.h b/src/opengl/util/fragmentprograms_p.h index dad8795..18da5c8 100644 --- a/src/opengl/util/fragmentprograms_p.h +++ b/src/opengl/util/fragmentprograms_p.h @@ -38,8 +38,8 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ -#ifndef FRAGMENTPROGRAMS_H -#define FRAGMENTPROGRAMS_H +#ifndef FRAGMENTPROGRAMS_P_H +#define FRAGMENTPROGRAMS_P_H // // W A R N I N G diff --git a/src/opengl/util/generator.cpp b/src/opengl/util/generator.cpp index 548a97b..62d19ff 100644 --- a/src/opengl/util/generator.cpp +++ b/src/opengl/util/generator.cpp @@ -259,8 +259,61 @@ void writeIncludeFile(const QSet<QString> &variables, QLatin1String tab(" "); - out << "#ifndef FRAGMENTPROGRAMS_H\n" - << "#define FRAGMENTPROGRAMS_H\n\n"; + out << "/****************************************************************************\n" + "**\n" + "** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).\n" + "** All rights reserved.\n" + "** Contact: Nokia Corporation (qt-info@nokia.com)\n" + "**\n" + "** This file is part of the test suite of the Qt Toolkit.\n" + "**\n" + "** $QT_BEGIN_LICENSE:LGPL$\n" + "** No Commercial Usage\n" + "** This file contains pre-release code and may not be distributed.\n" + "** You may use this file in accordance with the terms and conditions\n" + "** contained in the Technology Preview License Agreement accompanying\n" + "** this package.\n" + "**\n" + "** GNU Lesser General Public License Usage\n" + "** Alternatively, this file may be used under the terms of the GNU Lesser\n" + "** General Public License version 2.1 as published by the Free Software\n" + "** Foundation and appearing in the file LICENSE.LGPL included in the\n" + "** packaging of this file. Please review the following information to\n" + "** ensure the GNU Lesser General Public License version 2.1 requirements\n" + "** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.\n" + "**\n" + "** In addition, as a special exception, Nokia gives you certain additional\n" + "** rights. These rights are described in the Nokia Qt LGPL Exception\n" + "** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.\n" + "**\n" + "** If you have questions regarding the use of this file, please contact\n" + "** Nokia at qt-info@nokia.com.\n" + "**\n" + "**\n" + "**\n" + "**\n" + "**\n" + "**\n" + "**\n" + "**\n" + "** $QT_END_LICENSE$\n" + "**\n" + "****************************************************************************/\n" + "\n" + "#ifndef FRAGMENTPROGRAMS_P_H\n" + "#define FRAGMENTPROGRAMS_P_H\n" + "\n" + "//\n" + "// W A R N I N G\n" + "// -------------\n" + "//\n" + "// This file is not part of the Qt API. It exists purely as an\n" + "// implementation detail. This header file may change from version to\n" + "// version without notice, or even be removed.\n" + "//\n" + "// We mean it.\n" + "//\n" + "\n"; out << "enum FragmentVariable {\n"; foreach (QString str, variables) diff --git a/src/plugins/graphicssystems/opengl/main.cpp b/src/plugins/graphicssystems/opengl/main.cpp index 0562132..c28b09a 100644 --- a/src/plugins/graphicssystems/opengl/main.cpp +++ b/src/plugins/graphicssystems/opengl/main.cpp @@ -41,6 +41,7 @@ #include <private/qgraphicssystemplugin_p.h> #include <private/qgraphicssystem_gl_p.h> +#include <qgl.h> QT_BEGIN_NAMESPACE @@ -53,11 +54,18 @@ public: QStringList QGLGraphicsSystemPlugin::keys() const { - return QStringList(QLatin1String("OpenGL")); + QStringList list; + list << QLatin1String("OpenGL") << QLatin1String("OpenGL1"); + return list; } QGraphicsSystem* QGLGraphicsSystemPlugin::create(const QString& system) { + if (system.toLower() == QLatin1String("opengl1")) { + QGL::setPreferredPaintEngine(QPaintEngine::OpenGL); + return new QGLGraphicsSystem; + } + if (system.toLower() == QLatin1String("opengl")) return new QGLGraphicsSystem; diff --git a/src/s60main/qts60main.cpp b/src/s60main/qts60main.cpp index a919593..725b17c 100644 --- a/src/s60main/qts60main.cpp +++ b/src/s60main/qts60main.cpp @@ -40,6 +40,7 @@ ****************************************************************************/ // INCLUDE FILES +#include <exception> // must be before e32base.h so uncaught_exception gets defined #include <e32base.h> #include <qglobal.h> diff --git a/src/s60main/qts60main_mcrt0.cpp b/src/s60main/qts60main_mcrt0.cpp index 9439d2a..d30e07a 100644 --- a/src/s60main/qts60main_mcrt0.cpp +++ b/src/s60main/qts60main_mcrt0.cpp @@ -48,8 +48,8 @@ // EPOC32 version of crt0.c for C programs which always want multi-threaded support #include <e32std.h> +#include <exception> // must be before e32base.h so uncaught_exception gets defined #include <e32base.h> -#include <exception> #include "estlib.h" // Needed for QT_TRYCATCH_LEAVING. diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp index 830a5ae..b7b2327 100644 --- a/src/testlib/qtestcase.cpp +++ b/src/testlib/qtestcase.cpp @@ -367,9 +367,9 @@ QT_BEGIN_NAMESPACE this macro. Unlike QBENCHMARK, the contents of the contained code block is only run - once. The elapsed time will be reported as "0" if it's to short to + once. The elapsed time will be reported as "0" if it's to short to be measured by the selected backend. (Use) - + \sa {QTestLib Manual#Creating a Benchmark}{Creating a Benchmark}, {Chapter 5: Writing a Benchmark}{Writing a Benchmark} */ @@ -738,7 +738,7 @@ QT_BEGIN_NAMESPACE \brief The QTouchEventSequence class is used to simulate a sequence of touch events. - To simulate a sequence of touch events on a specific device for a widget, call + To simulate a sequence of touch events on a specific device for a widget, call QTest::touchEvent to create a QTouchEventSequence instance. Add touch events to the sequence by calling press(), move(), release() and stationary(), and let the instance run out of scope to commit the sequence to the event system. @@ -756,7 +756,7 @@ QT_BEGIN_NAMESPACE Adds a press event for touchpoint \a touchId at position \a pt to this sequence and returns a reference to this QTouchEventSequence. - The position \a pt is interpreted as relative to \a widget. If \a widget is the null pointer, then + The position \a pt is interpreted as relative to \a widget. If \a widget is the null pointer, then \a pt is interpreted as relative to the widget provided when instantiating this QTouchEventSequence. Simulates that the user pressed the touch screen or pad with the finger identified by \a touchId. @@ -768,7 +768,7 @@ QT_BEGIN_NAMESPACE Adds a move event for touchpoint \a touchId at position \a pt to this sequence and returns a reference to this QTouchEventSequence. - The position \a pt is interpreted as relative to \a widget. If \a widget is the null pointer, then + The position \a pt is interpreted as relative to \a widget. If \a widget is the null pointer, then \a pt is interpreted as relative to the widget provided when instantiating this QTouchEventSequence. Simulates that the user moved the finger identified by \a touchId. @@ -779,8 +779,8 @@ QT_BEGIN_NAMESPACE Adds a release event for touchpoint \a touchId at position \a pt to this sequence and returns a reference to this QTouchEventSequence. - - The position \a pt is interpreted as relative to \a widget. If \a widget is the null pointer, then + + The position \a pt is interpreted as relative to \a widget. If \a widget is the null pointer, then \a pt is interpreted as relative to the widget provided when instantiating this QTouchEventSequence. Simulates that the user lifted the finger identified by \a touchId. @@ -791,7 +791,7 @@ QT_BEGIN_NAMESPACE Adds a stationary event for touchpoint \a touchId to this sequence and returns a reference to this QTouchEventSequence. - + Simulates that the user did not move the finger identified by \a touchId. */ @@ -1612,8 +1612,11 @@ int QTest::qExec(QObject *testObject, int argc, char **argv) } #endif -#ifdef Q_OS_SYMBIAN -//### FIX THIS temporary hack to delay execution of symbian os tests. Used to get emulator to stable state before running testcase +#if defined(Q_OS_SYMBIAN) && defined(Q_CC_NOKIAX86) + // Delay execution of tests in Symbian emulator. + // Needed to allow worst of other higher priority apps and services launched by emulator + // to get out of the way before we run our test. Otherwise some of the timing sensitive tests + // will not work properly. qSleep(3000); #endif @@ -2124,7 +2127,7 @@ bool QTest::compare_string_helper(const char *t1, const char *t2, const char *ac /*! \fn bool QTest::qCompare(bool const &t1, int const &t2, const char *actual, const char *expected, const char *file, int line) \internal */ - + /*! \fn bool QTest::qTest(const T& actual, const char *elementName, const char *actualStr, const char *expected, const char *file, int line) \internal */ diff --git a/tests/auto/bic/tst_bic.cpp b/tests/auto/bic/tst_bic.cpp index db0c5ba..82c8dc0 100644 --- a/tests/auto/bic/tst_bic.cpp +++ b/tests/auto/bic/tst_bic.cpp @@ -293,7 +293,7 @@ void tst_Bic::sizesAndVTables() bool isFailed = false; - qDebug() << oldLib.arg(libName); + //qDebug() << oldLib.arg(libName); if (oldLib.isEmpty() || !QFile::exists(oldLib.arg(libName))) QSKIP("No platform spec found for this platform/version.", SkipSingle); diff --git a/tests/auto/q3progressbar/tst_q3progressbar.cpp b/tests/auto/q3progressbar/tst_q3progressbar.cpp index c5485a7..34a95d3 100644 --- a/tests/auto/q3progressbar/tst_q3progressbar.cpp +++ b/tests/auto/q3progressbar/tst_q3progressbar.cpp @@ -93,11 +93,15 @@ class MyCustomProgressBar : public Q3ProgressBar void paintEvent(QPaintEvent * event) { paintNumber++; + qDebug() << "PAINT EVENT:" << paintNumber; Q3ProgressBar::paintEvent(event); } int paintNumber; }; +/* + Maybe this test should be redesigned. + */ void tst_Q3ProgressBar::setProgress() { MyCustomProgressBar * m_progressBar = new MyCustomProgressBar(); @@ -111,15 +115,21 @@ void tst_Q3ProgressBar::setProgress() m_progressBar->setProgress(m_progressBar->progress() + 1); QCOMPARE(oldValue + 1,m_progressBar->progress()); QApplication::processEvents(); - QVERIFY(m_progressBar->paintNumber >= 1); //it might be more than 1 because it is animated + // It might be > 1 because it is animated. + QVERIFY(m_progressBar->paintNumber >= 1); + qDebug() << "Animation test: paintNumber =" << m_progressBar->paintNumber; + //standard case m_progressBar->setTotalSteps(3); m_progressBar->setProgress(0); m_progressBar->paintNumber = 0; m_progressBar->setProgress(m_progressBar->progress() + 1); QApplication::processEvents(); - QCOMPARE(m_progressBar->paintNumber,1); + + // It might be > 1 because other events might cause painting. + QVERIFY(m_progressBar->paintNumber >= 1); + qDebug() << "Standard test: paintNumber =" << m_progressBar->paintNumber; } QTEST_MAIN(tst_Q3ProgressBar) diff --git a/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp b/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp index 0d311fe..95476f0 100644 --- a/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp +++ b/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp @@ -52,6 +52,7 @@ private slots: void simple(); void simple_center(); void simple_semifloat(); + void layoutDirection(); void diagonal(); void parallel(); void parallel2(); @@ -104,6 +105,39 @@ static void setAnchor(QGraphicsAnchorLayout *l, l->setAnchorSpacing(firstItem, firstEdge, secondItem, secondEdge, spacing); } +static bool checkReverseDirection(QGraphicsWidget *w) +{ + QGraphicsLayout *l = w->layout(); + Q_ASSERT(l); + qreal left, top, right, bottom; + l->getContentsMargins(&left, &top, &right, &bottom); + w->setLayoutDirection(Qt::LeftToRight); + QApplication::processEvents(); + const QRectF lg = l->geometry(); + QMap<QGraphicsLayoutItem *, QRectF> geometries; + for (int i = 0; i < l->count(); ++i) { + QGraphicsLayoutItem *w = l->itemAt(i); + geometries.insert(w, w->geometry()); + } + w->setLayoutDirection(Qt::RightToLeft); + QApplication::processEvents(); + lg.adjusted(+right, +top, -left, -bottom); + for (int i = 0; i < l->count(); ++i) { + QGraphicsLayoutItem *w = l->itemAt(i); + const QRectF rtlGeom = w->geometry(); + const QRectF ltrGeom = geometries.value(w); + QRectF expectedGeom = ltrGeom; + expectedGeom.moveRight(lg.right() - (0 + ltrGeom.left())); + if (expectedGeom != rtlGeom) { + qDebug() << "layout->geometry():" << lg + << "expected:" << expectedGeom + << "actual:" << rtlGeom; + return false; + } + } + return true; +} + void tst_QGraphicsAnchorLayout::simple() { QGraphicsWidget *w1 = createItem(); @@ -204,6 +238,46 @@ void tst_QGraphicsAnchorLayout::simple_semifloat() QCOMPARE(layoutMaximumSize, QSizeF(200, 20)); } +void tst_QGraphicsAnchorLayout::layoutDirection() +{ + QSizeF min(10, 10); + QSizeF pref(50, 10); + QSizeF max(100, 10); + + QGraphicsWidget *a = createItem(min, pref, max, "a"); + QGraphicsWidget *b = createItem(min, pref, max, "b"); + QGraphicsWidget *c = createItem(min, pref, QSizeF(100, 20), "c"); + + QGraphicsAnchorLayout *l = new QGraphicsAnchorLayout; + l->setContentsMargins(0, 5, 10, 15); + // horizontal + setAnchor(l, l, Qt::AnchorLeft, a, Qt::AnchorLeft, 0); + setAnchor(l, a, Qt::AnchorRight, b, Qt::AnchorLeft, 0); + setAnchor(l, b, Qt::AnchorRight, l, Qt::AnchorRight, 0); + setAnchor(l, a, Qt::AnchorHorizontalCenter, c, Qt::AnchorLeft, 0); + setAnchor(l, c, Qt::AnchorRight, b, Qt::AnchorHorizontalCenter, 0); + + // vertical + setAnchor(l, l, Qt::AnchorTop, a, Qt::AnchorTop, 0); + setAnchor(l, l, Qt::AnchorTop, b, Qt::AnchorTop, 0); + setAnchor(l, a, Qt::AnchorBottom, c, Qt::AnchorTop, 0); + setAnchor(l, b, Qt::AnchorBottom, c, Qt::AnchorTop, 0); + setAnchor(l, c, Qt::AnchorBottom, l, Qt::AnchorBottom, 0); + + QCOMPARE(l->count(), 3); + + QGraphicsWidget *p = new QGraphicsWidget(0, Qt::Window); + p->setLayoutDirection(Qt::LeftToRight); + p->setLayout(l); + + QGraphicsScene scene; + QGraphicsView *view = new QGraphicsView(&scene); + scene.addItem(p); + p->show(); + view->show(); + + QCOMPARE(checkReverseDirection(p), true); +} void tst_QGraphicsAnchorLayout::diagonal() { @@ -306,6 +380,8 @@ void tst_QGraphicsAnchorLayout::diagonal() QCOMPARE(d->geometry(), QRectF(0.0, 200.0, 100.0, 100.0)); QCOMPARE(e->geometry(), QRectF(100.0, 200.0, 75.0, 100.0)); QCOMPARE(p.size(), testA); + + QCOMPARE(checkReverseDirection(&p), true); } void tst_QGraphicsAnchorLayout::parallel() @@ -599,6 +675,8 @@ void tst_QGraphicsAnchorLayout::snakeOppositeDirections() QCOMPARE(b->geometry(), QRectF(90.0, 100.0, 10.0, 100.0)); QCOMPARE(c->geometry(), QRectF(90.0, 200.0, 100.0, 100.0)); QCOMPARE(p.size(), layoutMaximumSize); + + QCOMPARE(checkReverseDirection(&p), true); } void tst_QGraphicsAnchorLayout::fairDistribution() diff --git a/tests/auto/qhostinfo/tst_qhostinfo.cpp b/tests/auto/qhostinfo/tst_qhostinfo.cpp index ac6adf7..4d63e10 100644 --- a/tests/auto/qhostinfo/tst_qhostinfo.cpp +++ b/tests/auto/qhostinfo/tst_qhostinfo.cpp @@ -247,6 +247,9 @@ void tst_QHostInfo::lookupIPv4() QVERIFY(!QTestEventLoop::instance().timeout()); QVERIFY(lookupDone); + if ((int)lookupResults.error() != (int)err) { + qWarning() << hostname << "=>" << lookupResults.errorString(); + } QCOMPARE((int)lookupResults.error(), (int)err); QStringList tmp; @@ -362,6 +365,9 @@ void tst_QHostInfo::blockingLookup() tmp.append(hostInfo.addresses().at(i).toString()); tmp.sort(); + if ((int)hostInfo.error() != (int)err) { + qWarning() << hostname << "=>" << lookupResults.errorString(); + } QCOMPARE((int)hostInfo.error(), (int)err); QStringList expected = addresses.split(' '); diff --git a/tests/auto/qhttpnetworkconnection/qhttpnetworkconnection.pro b/tests/auto/qhttpnetworkconnection/qhttpnetworkconnection.pro index 5ce3a2d..0021bc1 100644 --- a/tests/auto/qhttpnetworkconnection/qhttpnetworkconnection.pro +++ b/tests/auto/qhttpnetworkconnection/qhttpnetworkconnection.pro @@ -1,7 +1,6 @@ load(qttest_p4) SOURCES += tst_qhttpnetworkconnection.cpp INCLUDEPATH += $$QT_SOURCE_TREE/src/3rdparty/zlib - requires(contains(QT_CONFIG,private_tests)) QT = core network diff --git a/tests/auto/qhttpnetworkreply/qhttpnetworkreply.pro b/tests/auto/qhttpnetworkreply/qhttpnetworkreply.pro index f86250a..1782b43 100644 --- a/tests/auto/qhttpnetworkreply/qhttpnetworkreply.pro +++ b/tests/auto/qhttpnetworkreply/qhttpnetworkreply.pro @@ -1,7 +1,6 @@ load(qttest_p4) SOURCES += tst_qhttpnetworkreply.cpp INCLUDEPATH += $$QT_SOURCE_TREE/src/3rdparty/zlib - requires(contains(QT_CONFIG,private_tests)) QT = core network diff --git a/tests/auto/qlocalsocket/tst_qlocalsocket.cpp b/tests/auto/qlocalsocket/tst_qlocalsocket.cpp index c0d870f..1180d4d 100644 --- a/tests/auto/qlocalsocket/tst_qlocalsocket.cpp +++ b/tests/auto/qlocalsocket/tst_qlocalsocket.cpp @@ -895,9 +895,9 @@ void tst_QLocalSocket::writeToClientAndDisconnect() QCOMPARE(clientSocket->write(buffer, sizeof(buffer)), (qint64)sizeof(buffer)); clientSocket->waitForBytesWritten(); clientSocket->disconnectFromServer(); - qApp->processEvents(); // give the socket the chance to receive data + QVERIFY(client.waitForReadyRead()); QCOMPARE(client.read(buffer, sizeof(buffer)), (qint64)sizeof(buffer)); - qApp->processEvents(); // give the socket the chance to close itself + QVERIFY(client.waitForDisconnected()); QCOMPARE(client.state(), QLocalSocket::UnconnectedState); } diff --git a/tests/auto/qmenubar/tst_qmenubar.cpp b/tests/auto/qmenubar/tst_qmenubar.cpp index c74bbcb..07aa9f4 100644 --- a/tests/auto/qmenubar/tst_qmenubar.cpp +++ b/tests/auto/qmenubar/tst_qmenubar.cpp @@ -1545,22 +1545,27 @@ void tst_QMenuBar::task256322_highlight() win.show(); QTest::qWait(200); + QTest::mousePress(win.menuBar(), Qt::LeftButton, 0, win.menuBar()->actionGeometry(file).center()); QTest::mouseMove(win.menuBar(), win.menuBar()->actionGeometry(file).center()); - QTest::mouseClick(win.menuBar(), Qt::LeftButton, 0, win.menuBar()->actionGeometry(file).center()); + QTest::mouseRelease(win.menuBar(), Qt::LeftButton, 0, win.menuBar()->actionGeometry(file).center()); QTRY_VERIFY(menu.isVisible()); QVERIFY(!menu2.isVisible()); QCOMPARE(win.menuBar()->activeAction(), file); + QTest::mousePress(win.menuBar(), Qt::LeftButton, 0, win.menuBar()->actionGeometry(file2).center()); QTest::mouseMove(win.menuBar(), win.menuBar()->actionGeometry(file2).center()); QTRY_VERIFY(!menu.isVisible()); QVERIFY(menu2.isVisible()); QCOMPARE(win.menuBar()->activeAction(), file2); + QTest::mouseRelease(win.menuBar(), Qt::LeftButton, 0, win.menuBar()->actionGeometry(file2).center()); QPoint nothingCenter = win.menuBar()->actionGeometry(nothing).center(); + QTest::mousePress(win.menuBar(), Qt::LeftButton, 0, nothingCenter); QTest::mouseMove(win.menuBar(), nothingCenter); QTRY_VERIFY(!menu2.isVisible()); QVERIFY(!menu.isVisible()); QCOMPARE(win.menuBar()->activeAction(), nothing); + QTest::mouseRelease(win.menuBar(), Qt::LeftButton, 0, nothingCenter); } void tst_QMenuBar::menubarSizeHint() diff --git a/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp b/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp index 60bc39e..bea399c 100644 --- a/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp +++ b/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp @@ -473,6 +473,7 @@ void tst_QPropertyAnimation::startWhenAnotherIsRunning() { //normal case: the animation finishes and is deleted QPointer<QVariantAnimation> anim = new QPropertyAnimation(&o, "ole"); + anim->setEndValue(100); QSignalSpy runningSpy(anim, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State))); anim->start(QVariantAnimation::DeleteWhenStopped); QTest::qWait(anim->duration() + 50); @@ -482,10 +483,12 @@ void tst_QPropertyAnimation::startWhenAnotherIsRunning() { QPointer<QVariantAnimation> anim = new QPropertyAnimation(&o, "ole"); + anim->setEndValue(100); QSignalSpy runningSpy(anim, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State))); anim->start(QVariantAnimation::DeleteWhenStopped); QTest::qWait(anim->duration()/2); QPointer<QVariantAnimation> anim2 = new QPropertyAnimation(&o, "ole"); + anim2->setEndValue(100); QCOMPARE(runningSpy.count(), 1); QCOMPARE(anim->state(), QVariantAnimation::Running); @@ -634,6 +637,7 @@ void tst_QPropertyAnimation::playForwardBackward() QCOMPARE(o.property("ole").toInt(), 0); QPropertyAnimation anim(&o, "ole"); + anim.setStartValue(0); anim.setEndValue(100); anim.start(); QTest::qWait(anim.duration() + 50); @@ -906,6 +910,7 @@ void tst_QPropertyAnimation::operationsInStates() QObject o; o.setProperty("ole", 42); QPropertyAnimation anim(&o, "ole"); + anim.setEndValue(100); QSignalSpy spy(&anim, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State))); anim.stop(); diff --git a/tests/auto/qsslcertificate/tst_qsslcertificate.cpp b/tests/auto/qsslcertificate/tst_qsslcertificate.cpp index b16b3cc..9cd9f39 100644 --- a/tests/auto/qsslcertificate/tst_qsslcertificate.cpp +++ b/tests/auto/qsslcertificate/tst_qsslcertificate.cpp @@ -771,7 +771,7 @@ void tst_QSslCertificate::nulInSan() QVERIFY(!dnssan.isEmpty()); QVERIFY(dnssan != "www.bank.com"); - static const char realSAN[] = "www.bank.com\0.badguy.com"; + static const char realSAN[] = "www.bank.com\0www.badguy.com"; QCOMPARE(dnssan, QString::fromLatin1(realSAN, sizeof realSAN - 1)); } diff --git a/tests/auto/qstylesheetstyle/tst_qstylesheetstyle.cpp b/tests/auto/qstylesheetstyle/tst_qstylesheetstyle.cpp index 9d76741..491330b 100644 --- a/tests/auto/qstylesheetstyle/tst_qstylesheetstyle.cpp +++ b/tests/auto/qstylesheetstyle/tst_qstylesheetstyle.cpp @@ -850,6 +850,8 @@ void tst_QStyleSheetStyle::hoverColors() QTest::mouseMove ( widget, QPoint(5,5)); QTest::qWait(60); + QVERIFY(widget->testAttribute(Qt::WA_UnderMouse)); + QImage image(frame.width(), frame.height(), QImage::Format_ARGB32); frame.render(&image); @@ -877,6 +879,8 @@ void tst_QStyleSheetStyle::hoverColors() QTest::mouseMove (widget, QPoint(5,5)); QTest::qWait(60); + QVERIFY(widget->testAttribute(Qt::WA_UnderMouse)); + frame.render(&image); QVERIFY2(testForColors(image, QColor(0xe8, 0xff, 0x66)), diff --git a/tests/auto/qtwidgets/tst_qtwidgets.cpp b/tests/auto/qtwidgets/tst_qtwidgets.cpp index 12bc02f..a765bde 100644 --- a/tests/auto/qtwidgets/tst_qtwidgets.cpp +++ b/tests/auto/qtwidgets/tst_qtwidgets.cpp @@ -72,6 +72,8 @@ tst_QtWidgets::~tst_QtWidgets() void tst_QtWidgets::snapshot() { + QSKIP("Jesper will fix this test when he has time.", SkipAll); +#if 0 StyleWidget widget(0, Qt::X11BypassWindowManagerHint); widget.show(); @@ -100,6 +102,7 @@ void tst_QtWidgets::snapshot() } QVERIFY2(ftp.error() == QFtp::NoError, ftp.errorString().toLocal8Bit().constData()); QVERIFY(!ftp.hasPendingCommands()); +#endif } diff --git a/tests/auto/qwidget/qwidget.pro b/tests/auto/qwidget/qwidget.pro index 59c1753..def28f5 100644 --- a/tests/auto/qwidget/qwidget.pro +++ b/tests/auto/qwidget/qwidget.pro @@ -16,6 +16,7 @@ OBJECTIVE_SOURCES += tst_qwidget_mac_helpers.mm symbian { INCLUDEPATH += $$MW_LAYER_SYSTEMINCLUDE + LIBS += -leikcore -lcone -leikcoctl } !wince*:!symbian:win32: LIBS += -luser32 -lgdi32 diff --git a/tests/auto/qwidget/tst_qwidget.cpp b/tests/auto/qwidget/tst_qwidget.cpp index b94f381..47cd860 100644 --- a/tests/auto/qwidget/tst_qwidget.cpp +++ b/tests/auto/qwidget/tst_qwidget.cpp @@ -74,6 +74,7 @@ #include <akntitle.h> // CAknTitlePane #include <akncontext.h> // CAknContextPane #include <eikspane.h> // CEikStatusPane +#include <eikbtgpc.h> // CEikButtonGroupContainer #endif #ifdef Q_WS_QWS @@ -367,6 +368,12 @@ private slots: void destroyBackingStore(); + void activateWindow(); + +#ifdef Q_OS_SYMBIAN + void cbaVisibility(); +#endif + private: bool ensureScreenSize(int width, int height); QWidget *testWidget; @@ -9323,5 +9330,77 @@ void tst_QWidget::setGraphicsEffect() delete anotherWidget; } +void tst_QWidget::activateWindow() +{ + // Test case for task 260685 + + // Create first mainwindow and set it active + QMainWindow* mainwindow = new QMainWindow(); + QLabel* label = new QLabel(mainwindow); + mainwindow->setCentralWidget(label); + mainwindow->setVisible(true); + mainwindow->activateWindow(); + qApp->processEvents(); + + QVERIFY(mainwindow->isActiveWindow()); + + // Create second mainwindow and set it active + QMainWindow* mainwindow2 = new QMainWindow(); + QLabel* label2 = new QLabel(mainwindow2); + mainwindow2->setCentralWidget(label2); + mainwindow2->setVisible(true); + mainwindow2->activateWindow(); + qApp->processEvents(); + + QVERIFY(!mainwindow->isActiveWindow()); + QVERIFY(mainwindow2->isActiveWindow()); + + // Revert first mainwindow back to visible active + mainwindow->setVisible(true); + mainwindow->activateWindow(); + qApp->processEvents(); + + QVERIFY(mainwindow->isActiveWindow()); + QVERIFY(!mainwindow2->isActiveWindow()); +} + +#ifdef Q_OS_SYMBIAN +void tst_QWidget::cbaVisibility() +{ + // Test case for task 261048 + + // Create first mainwindow in fullsreen and activate it + QMainWindow* mainwindow = new QMainWindow(); + QLabel* label = new QLabel(mainwindow); + mainwindow->setCentralWidget(label); + mainwindow->setWindowState(Qt::WindowFullScreen); + mainwindow->setVisible(true); + mainwindow->activateWindow(); + qApp->processEvents(); + + QVERIFY(mainwindow->isActiveWindow()); + QVERIFY(QDesktopWidget().availableGeometry().size() == mainwindow->size()); + + // Create second mainwindow in maximized and activate it + QMainWindow* mainwindow2 = new QMainWindow(); + QLabel* label2 = new QLabel(mainwindow2); + mainwindow2->setCentralWidget(label2); + mainwindow2->setWindowState(Qt::WindowMaximized); + mainwindow2->setVisible(true); + mainwindow2->activateWindow(); + qApp->processEvents(); + + QVERIFY(!mainwindow->isActiveWindow()); + QVERIFY(mainwindow2->isActiveWindow()); + QVERIFY(QDesktopWidget().availableGeometry().size() == mainwindow2->size()); + + // Verify window decorations i.e. status pane and CBA are visible. + CEikStatusPane* statusPane = CEikonEnv::Static()->AppUiFactory()->StatusPane(); + QVERIFY(statusPane->IsVisible()); + CEikButtonGroupContainer* buttonGroup = CEikonEnv::Static()->AppUiFactory()->Cba(); + QVERIFY(buttonGroup->IsVisible()); +} +#endif + QTEST_MAIN(tst_QWidget) #include "tst_qwidget.moc" |