From 755eedd9d241910112b202bc22b4b807a18ba1fb Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Tue, 22 Sep 2009 11:34:00 +0200 Subject: Make the test fail in a nicer way if it fails By default, waitForSignal() will block the entire test if it fails, adding 20 false autotest failures. Reviewed-by: TrustMe --- .../webkit/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/3rdparty/webkit/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp b/src/3rdparty/webkit/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp index c575137..47a1426 100644 --- a/src/3rdparty/webkit/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp +++ b/src/3rdparty/webkit/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp @@ -208,7 +208,7 @@ public: public slots: bool shouldInterruptJavaScript() { - return true; + return true; } }; @@ -348,7 +348,7 @@ void tst_QWebPage::userStyleSheet() m_page->settings()->setUserStyleSheetUrl(QUrl("data:text/css,p { background-image: url('http://does.not/exist.png');}")); m_view->setHtml("

hello world

"); - QVERIFY(::waitForSignal(m_view, SIGNAL(loadFinished(bool)))); + QVERIFY(::waitForSignal(m_view, SIGNAL(loadFinished(bool)), 1000)); QVERIFY(networkManager->requestedUrls.count() >= 2); QCOMPARE(networkManager->requestedUrls.at(0), QUrl("data:text/css,p { background-image: url('http://does.not/exist.png');}")); @@ -674,7 +674,7 @@ void tst_QWebPage::multiplePageGroupsAndLocalStorage() view1.page()->settings()->setAttribute(QWebSettings::LocalStorageEnabled, true); view1.page()->settings()->setLocalStoragePath(QDir::toNativeSeparators(QDir::currentPath() + "/path1")); qt_webpage_setGroupName(view1.page(), "group1"); - view2.page()->settings()->setAttribute(QWebSettings::LocalStorageEnabled, true); + view2.page()->settings()->setAttribute(QWebSettings::LocalStorageEnabled, true); view2.page()->settings()->setLocalStoragePath(QDir::toNativeSeparators(QDir::currentPath() + "/path2")); qt_webpage_setGroupName(view2.page(), "group2"); QCOMPARE(qt_webpage_groupName(view1.page()), QString("group1")); @@ -945,7 +945,7 @@ void tst_QWebPage::textSelection() QVERIFY(page->action(QWebPage::SelectStartOfDocument) != 0); QVERIFY(page->action(QWebPage::SelectEndOfDocument) != 0); - // right now they are disabled because contentEditable is false and + // right now they are disabled because contentEditable is false and // there isn't an existing selection to modify QCOMPARE(page->action(QWebPage::SelectNextChar)->isEnabled(), false); QCOMPARE(page->action(QWebPage::SelectPreviousChar)->isEnabled(), false); @@ -1114,14 +1114,14 @@ void tst_QWebPage::textEditing() QCOMPARE(page->action(QWebPage::AlignJustified)->isEnabled(), true); QCOMPARE(page->action(QWebPage::AlignLeft)->isEnabled(), true); QCOMPARE(page->action(QWebPage::AlignRight)->isEnabled(), true); - + // make sure these are disabled since there isn't a selection QCOMPARE(page->action(QWebPage::Cut)->isEnabled(), false); QCOMPARE(page->action(QWebPage::RemoveFormat)->isEnabled(), false); - + // make sure everything is selected page->triggerAction(QWebPage::SelectAll); - + // this is only true if there is an editable selection QCOMPARE(page->action(QWebPage::Cut)->isEnabled(), true); QCOMPARE(page->action(QWebPage::RemoveFormat)->isEnabled(), true); -- cgit v0.12 From 717f6ee081fdfcb7d028e3e26d252f9537878899 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Tue, 22 Sep 2009 11:50:08 +0200 Subject: Compile on all non-windows platforms Function is only used from within Q_OS_WIN or Q_WS_WIN-blocks. --- src/gui/styles/qwindowsstyle.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gui/styles/qwindowsstyle.cpp b/src/gui/styles/qwindowsstyle.cpp index f5aadb8..2ed9303 100644 --- a/src/gui/styles/qwindowsstyle.cpp +++ b/src/gui/styles/qwindowsstyle.cpp @@ -926,6 +926,7 @@ static const char *const question_xpm[] = { #endif //QT_NO_IMAGEFORMAT_XPM +#ifdef Q_OS_WIN static QPixmap loadIconFromShell32( int resourceId, int size ) { #ifdef Q_OS_WINCE @@ -943,6 +944,7 @@ static QPixmap loadIconFromShell32( int resourceId, int size ) } return QPixmap(); } +#endif /*! \reimp -- cgit v0.12 From 66ae0f190f1f07ce7b2578b81f8d0c69328cf028 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Trond=20Kjern=C3=A5sen?= Date: Tue, 22 Sep 2009 12:37:34 +0200 Subject: Fixed text drawing in the GL2 engine after sub-pixel hinting was added. 1. The mono format was not handled at all. 2. We really, really wanted to use sub-pixel hinted glyphs even when they were not available. 3. The glyphFormat type in the FT font engine wasn't updated to reflect the correct system glyph type. Reviewed-by: Kim --- src/gui/text/qfontengine_ft.cpp | 6 +++ .../gl2paintengineex/qpaintengineex_opengl2.cpp | 46 +++++++++++++--------- .../gl2paintengineex/qpaintengineex_opengl2_p.h | 2 +- 3 files changed, 35 insertions(+), 19 deletions(-) diff --git a/src/gui/text/qfontengine_ft.cpp b/src/gui/text/qfontengine_ft.cpp index a4b2e7e..788417a 100644 --- a/src/gui/text/qfontengine_ft.cpp +++ b/src/gui/text/qfontengine_ft.cpp @@ -647,8 +647,14 @@ bool QFontEngineFT::init(FaceId faceId, bool antialias, GlyphFormat format) { defaultFormat = format; this->antialias = antialias; + if (!antialias) glyphFormat = QFontEngineGlyphCache::Raster_Mono; + else if (format == Format_A8) + glyphFormat = QFontEngineGlyphCache::Raster_A8; + else if (format == Format_A32) + glyphFormat = QFontEngineGlyphCache::Raster_RGBMask; + face_id = faceId; freetype = QFreetypeFace::getFace(face_id); if (!freetype) { diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp index fb493e6..eba8844 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp @@ -289,9 +289,18 @@ void QGLTextureGlyphCache::resizeTextureData(int width, int height) void QGLTextureGlyphCache::fillTexture(const Coord &c, glyph_t glyph) { QImage mask = textureMapForGlyph(glyph); + const int maskWidth = mask.width(); + const int maskHeight = mask.height(); + + if (mask.format() == QImage::Format_Mono) { + mask = mask.convertToFormat(QImage::Format_Indexed8); + for (int y = 0; y < maskHeight; ++y) { + uchar *src = (uchar *) mask.scanLine(y); + for (int x = 0; x < maskWidth; ++x) + src[x] = -src[x]; + } + } - const uint maskWidth = mask.width(); - const uint maskHeight = mask.height(); glBindTexture(GL_TEXTURE_2D, m_texture); if (mask.format() == QImage::Format_RGB32) { @@ -309,7 +318,7 @@ void QGLTextureGlyphCache::fillTexture(const Coord &c, glyph_t glyph) // by converting it to a format with four bytes per pixel. Another is to copy one line at a // time. - for (uint i = 0; i < maskHeight; ++i) + for (int i = 0; i < maskHeight; ++i) glTexSubImage2D(GL_TEXTURE_2D, 0, c.x, c.y + i, maskWidth, 1, GL_ALPHA, GL_UNSIGNED_BYTE, mask.scanLine(i)); #endif } @@ -1226,21 +1235,27 @@ void QGL2PaintEngineEx::drawTextItem(const QPointF &p, const QTextItem &textItem if (ti.fontEngine->fontDef.pixelSize * qSqrt(s->matrix.determinant()) >= 64) drawCached = false; - if (d->glyphCacheType == QFontEngineGlyphCache::Raster_RGBMask + QFontEngineGlyphCache::Type glyphType = ti.fontEngine->glyphFormat >= 0 + ? QFontEngineGlyphCache::Type(ti.fontEngine->glyphFormat) + : d->glyphCacheType; + + if (glyphType == QFontEngineGlyphCache::Raster_RGBMask && state()->composition_mode != QPainter::CompositionMode_Source - && state()->composition_mode != QPainter::CompositionMode_SourceOver) { + && state()->composition_mode != QPainter::CompositionMode_SourceOver) + { drawCached = false; } if (drawCached) { - d->drawCachedGlyphs(p, ti); + d->drawCachedGlyphs(p, glyphType, ti); return; } QPaintEngineEx::drawTextItem(p, ti); } -void QGL2PaintEngineExPrivate::drawCachedGlyphs(const QPointF &p, const QTextItemInt &ti) +void QGL2PaintEngineExPrivate::drawCachedGlyphs(const QPointF &p, QFontEngineGlyphCache::Type glyphType, + const QTextItemInt &ti) { Q_Q(QGL2PaintEngineEx); QOpenGL2PaintEngineState *s = q->state(); @@ -1250,10 +1265,6 @@ void QGL2PaintEngineExPrivate::drawCachedGlyphs(const QPointF &p, const QTextIte QTransform matrix = QTransform::fromTranslate(p.x(), p.y()); ti.fontEngine->getGlyphPositions(ti.glyphs, matrix, ti.flags, glyphs, positions); - QFontEngineGlyphCache::Type glyphType = ti.fontEngine->glyphFormat >= 0 - ? QFontEngineGlyphCache::Type(ti.fontEngine->glyphFormat) - : glyphCacheType; - QGLTextureGlyphCache *cache = (QGLTextureGlyphCache *) ti.fontEngine->glyphCache(ctx, s->matrix); @@ -1300,13 +1311,7 @@ void QGL2PaintEngineExPrivate::drawCachedGlyphs(const QPointF &p, const QTextIte QBrush pensBrush = q->state()->pen.brush(); setBrush(&pensBrush); - if (glyphType == QFontEngineGlyphCache::Raster_A8) { - - // Greyscale antialiasing - - shaderManager->setMaskType(QGLEngineShaderManager::PixelMask); - prepareForDraw(false); // Text always causes src pixels to be transparent - } else if (glyphType == QFontEngineGlyphCache::Raster_RGBMask) { + if (glyphType == QFontEngineGlyphCache::Raster_RGBMask) { // Subpixel antialiasing without gamma correction @@ -1380,6 +1385,11 @@ void QGL2PaintEngineExPrivate::drawCachedGlyphs(const QPointF &p, const QTextIte glBlendFunc(GL_ONE, GL_ONE); } compositionModeDirty = true; + } else { + // Greyscale/mono glyphs + + shaderManager->setMaskType(QGLEngineShaderManager::PixelMask); + prepareForDraw(false); // Text always causes src pixels to be transparent } //### TODO: Gamma correction diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h index 049994f..738626f 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h @@ -182,7 +182,7 @@ public: void fill(const QVectorPath &path); void drawOutline(const QVectorPath& path); void drawTexture(const QGLRect& dest, const QGLRect& src, const QSize &textureSize, bool opaque, bool pattern = false); - void drawCachedGlyphs(const QPointF &p, const QTextItemInt &ti); + void drawCachedGlyphs(const QPointF &p, QFontEngineGlyphCache::Type glyphType, const QTextItemInt &ti); void drawVertexArrays(QGL2PEXVertexArray& vertexArray, GLenum primitive); // ^ draws whatever is in the vertex array -- cgit v0.12 From 20efdac59b4b04525773832cc2955ea1e9080b99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Trond=20Kjern=C3=A5sen?= Date: Tue, 22 Sep 2009 12:45:00 +0200 Subject: Fixed a warning. Reviewed-by: Kim --- src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp index eba8844..25f4184 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp @@ -1717,6 +1717,8 @@ void QGL2PaintEngineEx::clip(const QVectorPath &path, Qt::ClipOperation op) state()->depthTestEnabled = true; break; } + default: + break; } glDepthFunc(GL_LESS); -- cgit v0.12 From 5dda48852ae85929e9d0cf1432c0c3a51ae0ce81 Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Tue, 22 Sep 2009 13:10:09 +0200 Subject: tst_qnetworkreply: Increased timeout of uploadPerformance() --- tests/auto/qnetworkreply/tst_qnetworkreply.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp index 9f7561d..5441b09 100644 --- a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp @@ -3297,7 +3297,7 @@ void tst_QNetworkReply::uploadPerformance() connect(&reader, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop())); QTimer::singleShot(5000, &generator, SLOT(stop())); - QTestEventLoop::instance().enterLoop(10); + QTestEventLoop::instance().enterLoop(30); QCOMPARE(reply->error(), QNetworkReply::NoError); QVERIFY(!QTestEventLoop::instance().timeout()); } -- cgit v0.12 From 848b4e21f975a0b05639e8ee47fb3dcbb4dbf37d Mon Sep 17 00:00:00 2001 From: Jens Bache-Wiig Date: Tue, 22 Sep 2009 13:08:50 +0200 Subject: Fix autotest failure on combo box with Gtk+ We were not respecting the rect offset on combo box arrows. This was preventing the autotest from happily completing with GTK+ style. Reviewed-by: joao --- src/gui/styles/qgtkstyle.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/styles/qgtkstyle.cpp b/src/gui/styles/qgtkstyle.cpp index f3dc4ac..414580e 100644 --- a/src/gui/styles/qgtkstyle.cpp +++ b/src/gui/styles/qgtkstyle.cpp @@ -3063,14 +3063,14 @@ QRect QGtkStyle::subControlRect(ComplexControl control, const QStyleOptionComple if (!arrowWidget) return QCleanlooksStyle::subControlRect(control, option, subControl, widget); - QRect buttonRect(arrowWidget->allocation.x, arrowWidget->allocation.y, + QRect buttonRect(option->rect.left() + arrowWidget->allocation.x, + option->rect.top() + arrowWidget->allocation.y, arrowWidget->allocation.width, arrowWidget->allocation.height); switch (subControl) { case SC_ComboBoxArrow: // Note: this indicates the arrowbutton for editable combos rect = buttonRect; - break; case SC_ComboBoxEditField: { -- cgit v0.12 From 6e6dcc1575188751a730cdc3376b036b3df1f08e Mon Sep 17 00:00:00 2001 From: Jens Bache-Wiig Date: Tue, 22 Sep 2009 13:53:53 +0200 Subject: Fixed incorrect warning when unable to detect GTK theme If for some reason the theme name was not detectable, Qt would incorrectly print "QGtkStyle cannot be used together with the GTK_QT engine." I now added a separate "QGtkSTyle was unable to detect the current GTK+ theme." warning instead. Reviewed-by: Trust Me --- src/gui/styles/gtksymbols.cpp | 45 ++++++++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/src/gui/styles/gtksymbols.cpp b/src/gui/styles/gtksymbols.cpp index d53a280..23d25bd 100644 --- a/src/gui/styles/gtksymbols.cpp +++ b/src/gui/styles/gtksymbols.cpp @@ -423,27 +423,32 @@ static void init_gtk_window() static QString themeName; if (!gtkWidgetMap()->contains(QLS("GtkWindow")) && themeName.isEmpty()) { themeName = getThemeName(); - // Due to namespace conflicts with Qt3 and obvious recursion with Qt4, - // we cannot support the GTK_Qt Gtk engine - if (!(themeName.isEmpty() || themeName == QLS("Qt") || themeName == QLS("Qt4"))) { - resolveGtk(); - if (QGtk::gtk_init) { - // Gtk will set the Qt error handler so we have to reset it afterwards - x11ErrorHandler qt_x_errhandler = XSetErrorHandler(0); - QGtk::gtk_init (NULL, NULL); - XSetErrorHandler(qt_x_errhandler); - - GtkWidget* gtkWindow = QGtk::gtk_window_new(GTK_WINDOW_POPUP); - QGtk::gtk_widget_realize(gtkWindow); - if (displayDepth == -1) - displayDepth = QGtk::gdk_drawable_get_depth(gtkWindow->window); - gtkWidgetMap()->insert(QLS("GtkWindow"), gtkWindow); - } - else { - qWarning("QGtkStyle could not resolve GTK. Make sure you have installed the proper libraries."); - } - } else { + + if (themeName.isEmpty()) { + qWarning("QGtkStyle was unable to detect the current GTK+ theme."); + return; + } else if (themeName == QLS("Qt") || themeName == QLS("Qt4")) { + // Due to namespace conflicts with Qt3 and obvious recursion with Qt4, + // we cannot support the GTK_Qt Gtk engine qWarning("QGtkStyle cannot be used together with the GTK_Qt engine."); + return; + } + + resolveGtk(); + + if (QGtk::gtk_init) { + // Gtk will set the Qt error handler so we have to reset it afterwards + x11ErrorHandler qt_x_errhandler = XSetErrorHandler(0); + QGtk::gtk_init (NULL, NULL); + XSetErrorHandler(qt_x_errhandler); + + GtkWidget* gtkWindow = QGtk::gtk_window_new(GTK_WINDOW_POPUP); + QGtk::gtk_widget_realize(gtkWindow); + if (displayDepth == -1) + displayDepth = QGtk::gdk_drawable_get_depth(gtkWindow->window); + gtkWidgetMap()->insert(QLS("GtkWindow"), gtkWindow); + } else { + qWarning("QGtkStyle could not resolve GTK. Make sure you have installed the proper libraries."); } } } -- cgit v0.12 From 0d830dc5b0716bdb4fa7130f724ba5c9593411fa Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Tue, 22 Sep 2009 14:12:25 +0200 Subject: Fix breaking on fixed column width when text has tabs When a text in QTextLayout contained tabs, these would be counted as single glyphs when breaking the text on a fixed number of columns, rather than the number of characters they span. The patch calculates the number of characters represented by a tab by using the average character width of the font engine. Task-number: QTBUG-4468 Reviewed-by: Simon Hausmann --- src/gui/text/qtextlayout.cpp | 9 ++++++-- tests/auto/qtextlayout/tst_qtextlayout.cpp | 36 ++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 2 deletions(-) diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp index f8b0cbc..39a8bb8 100644 --- a/src/gui/text/qtextlayout.cpp +++ b/src/gui/text/qtextlayout.cpp @@ -1720,10 +1720,15 @@ void QTextLine::layout_helper(int maxGlyphs) goto found; QFixed x = line.x + line.textWidth + lbh.tmpData.textWidth + lbh.spaceData.textWidth; - lbh.spaceData.textWidth += eng->calculateTabWidth(item, x); + QFixed tabWidth = eng->calculateTabWidth(item, x); + + lbh.spaceData.textWidth += tabWidth; lbh.spaceData.length++; newItem = item + 1; - ++lbh.glyphCount; + + QFixed averageCharWidth = eng->fontEngine(current)->averageCharWidth(); + lbh.glyphCount += qRound(tabWidth / averageCharWidth); + if (lbh.checkFullOtherwiseExtend(line)) goto found; } else if (current.analysis.flags == QScriptAnalysis::LineOrParagraphSeparator) { diff --git a/tests/auto/qtextlayout/tst_qtextlayout.cpp b/tests/auto/qtextlayout/tst_qtextlayout.cpp index 9f23ece..5ccae94 100644 --- a/tests/auto/qtextlayout/tst_qtextlayout.cpp +++ b/tests/auto/qtextlayout/tst_qtextlayout.cpp @@ -109,6 +109,7 @@ private slots: void capitalization_capitalize(); void longText(); void widthOfTabs(); + void columnWrapWithTabs(); // QTextLine stuff void setNumColumnsWrapAtWordBoundaryOrAnywhere(); @@ -1275,5 +1276,40 @@ void tst_QTextLayout::widthOfTabs() QCOMPARE(qRound(engine.width(0, 5)), qRound(engine.boundingBox(0, 5).width)); } +void tst_QTextLayout::columnWrapWithTabs() +{ + QTextLayout textLayout; + { + QTextOption textOption; + textOption.setWrapMode(QTextOption::WordWrap); + textLayout.setTextOption(textOption); + } + + // Make sure string with spaces does not break + { + QString text = "Foo bar foo bar foo bar"; + textLayout.setText(text); + + textLayout.beginLayout(); + QTextLine line = textLayout.createLine(); + line.setNumColumns(30); + QCOMPARE(line.textLength(), text.length()); + textLayout.endLayout(); + } + + // Make sure string with tabs breaks + { + QString text = "Foo\tbar\tfoo\tbar\tfoo\tbar"; + textLayout.setText(text); + textLayout.beginLayout(); + QTextLine line = textLayout.createLine(); + line.setNumColumns(30); + QVERIFY(line.textLength() < text.length()); + textLayout.endLayout(); + } + +} + + QTEST_MAIN(tst_QTextLayout) #include "tst_qtextlayout.moc" -- cgit v0.12 From 003ed73811987b1ec5d9496e8ba382c1dc421e79 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Tue, 22 Sep 2009 14:22:21 +0200 Subject: Workaround a bug in QDirModel in tst_QDirModel::task196768_sorting The test was reported failing by pulse on many platform, but noone of us was able to reproduce it locally. The problem was that pulse runs the tests in a hidden dirrectory. And this exposed a bug in the QDirModel. We decided anyway that the bug was not worth fixing considered that QDirModel is kind of deprecated in favor of QFileSystemModel. (The bug is the one reported in task 255066) Reviewed-by: mbm Reviewed-by: Thierry --- tests/auto/qdirmodel/tst_qdirmodel.cpp | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/tests/auto/qdirmodel/tst_qdirmodel.cpp b/tests/auto/qdirmodel/tst_qdirmodel.cpp index a8c298d..7ecadfc 100644 --- a/tests/auto/qdirmodel/tst_qdirmodel.cpp +++ b/tests/auto/qdirmodel/tst_qdirmodel.cpp @@ -611,27 +611,24 @@ void tst_QDirModel::task196768_sorting() QString path = SRCDIR; QDirModel model; - QTreeView view; - QPersistentModelIndex index = model.index(path); - qDebug() << "Path" << path << "count" << model.rowCount(index) << "index" << index; + /* QDirModel has a bug if we show the content of the subdirectory inside a hidden directory + and we don't add QDir::Hidden. But as QDirModel is deprecated, we decided not to fix it. */ + model.setFilter(QDir::AllEntries | QDir::Hidden | QDir::AllDirs); + QTreeView view; + QPersistentModelIndex index = model.index(path); view.setModel(&model); - qDebug() << "After setModel" << index; QModelIndex index2 = model.index(path); - qDebug() << "A" << index << index2; QCOMPARE(index.data(), index2.data()); view.setRootIndex(index); index2 = model.index(path); - qDebug() << "B" << index << index2; QCOMPARE(index.data(), index2.data()); view.setCurrentIndex(index); index2 = model.index(path); - qDebug() << "C" << index << index2; QCOMPARE(index.data(), index2.data()); view.setSortingEnabled(true); index2 = model.index(path); - qDebug() << "After sorting" << index << index2 << "count" << model.rowCount(index2); QCOMPARE(index.data(), index2.data()); } -- cgit v0.12 From 0c0d9593c6e3d5cc0005a3f545002dd169e93329 Mon Sep 17 00:00:00 2001 From: axis Date: Tue, 22 Sep 2009 14:02:14 +0200 Subject: Saved some space by using bitfields instead of bools. RevBy: Shane Kearns --- src/gui/kernel/qt_s60_p.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/gui/kernel/qt_s60_p.h b/src/gui/kernel/qt_s60_p.h index b43c950..aa39f9d 100644 --- a/src/gui/kernel/qt_s60_p.h +++ b/src/gui/kernel/qt_s60_p.h @@ -101,11 +101,11 @@ public: int virtualMouseAccel; int virtualMouseMaxAccel; #ifndef Q_SYMBIAN_FIXED_POINTER_CURSORS - bool brokenPointerCursors; + int brokenPointerCursors : 1; #endif - bool hasTouchscreen; - bool mouseInteractionEnabled; - bool virtualMouseRequired; + int hasTouchscreen : 1; + int mouseInteractionEnabled : 1; + int virtualMouseRequired : 1; int qtOwnsS60Environment : 1; static inline void updateScreenSize(); static inline RWsSession& wsSession(); -- cgit v0.12 From 787d5dc3ccd913b125979ee83d5249dcf78fb8ea Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Tue, 22 Sep 2009 14:34:25 +0200 Subject: QNetworkReplyImpl: Delete the outgoingDataBuffer in destructor Fixes a memleak Reviewed-by: Peter Hartmann --- src/network/access/qnetworkreplyimpl.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/network/access/qnetworkreplyimpl.cpp b/src/network/access/qnetworkreplyimpl.cpp index 83afddd..c20812e 100644 --- a/src/network/access/qnetworkreplyimpl.cpp +++ b/src/network/access/qnetworkreplyimpl.cpp @@ -573,6 +573,8 @@ QNetworkReplyImpl::~QNetworkReplyImpl() Q_D(QNetworkReplyImpl); if (d->isCachingEnabled()) d->networkCache()->remove(url()); + if (d->outgoingDataBuffer) + delete d->outgoingDataBuffer; } void QNetworkReplyImpl::abort() -- cgit v0.12 From 394fddbe1ed93f8aafc29ace8217ad8d77e7276f Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Tue, 22 Sep 2009 14:50:48 +0200 Subject: Fix memleak in tst_qhttpnetworkconnection Reviewed-by: TrustMe --- src/corelib/io/qnoncontiguousbytedevice_p.h | 4 +++- tests/auto/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/corelib/io/qnoncontiguousbytedevice_p.h b/src/corelib/io/qnoncontiguousbytedevice_p.h index e55a46c..34d6980 100644 --- a/src/corelib/io/qnoncontiguousbytedevice_p.h +++ b/src/corelib/io/qnoncontiguousbytedevice_p.h @@ -72,9 +72,11 @@ public: void disableReset(); virtual qint64 size() = 0; + virtual ~QNonContiguousByteDevice(); + protected: QNonContiguousByteDevice(); - virtual ~QNonContiguousByteDevice(); + bool resetDisabled; Q_SIGNALS: diff --git a/tests/auto/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp b/tests/auto/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp index e1e25d2..470e57f 100644 --- a/tests/auto/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp +++ b/tests/auto/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp @@ -320,6 +320,7 @@ void tst_QHttpNetworkConnection::put() QByteArray array = data.toLatin1(); QNonContiguousByteDevice *bd = QNonContiguousByteDeviceFactory::create(&array); + bd->setParent(this); request.setUploadByteDevice(bd); finishedCalled = false; @@ -411,6 +412,7 @@ void tst_QHttpNetworkConnection::post() QByteArray array = data.toLatin1(); QNonContiguousByteDevice *bd = QNonContiguousByteDeviceFactory::create(&array); + bd->setParent(this); request.setUploadByteDevice(bd); QHttpNetworkReply *reply = connection.sendRequest(request); -- cgit v0.12 From e1a17008c6be12cb0abe6ec19b544110dce8cbdf Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Tue, 22 Sep 2009 16:16:30 +0300 Subject: Set maximum heap to 32MB for Symbian autotests. Several script and webkit tests require increased maximum heap in emulator, so just increase the maximum heap for all autotests. Reviewed-by: Janne Koskinen --- mkspecs/features/qttest_p4.prf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mkspecs/features/qttest_p4.prf b/mkspecs/features/qttest_p4.prf index 4ab5ac2..525e7b2 100644 --- a/mkspecs/features/qttest_p4.prf +++ b/mkspecs/features/qttest_p4.prf @@ -4,7 +4,7 @@ CONFIG += qt warn_on console depend_includepath qtAddLibrary(QtTest) symbian:{ -# qt.prf sets TARGET.EPOCSTACKSIZE and TARGET.EPOCHEAPSIZE + TARGET.EPOCHEAPSIZE = 0x100000 0x2000000 # DEFINES += QTEST_NO_SPECIALIZATIONS TARGET.CAPABILITY="ALL -TCB" RSS_RULES ="group_name=\"QtTests\";" -- cgit v0.12 From 1ac96b5dbc89f5eaf6336d90e5d5c39d5c8113b5 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Tue, 22 Sep 2009 16:22:45 +0300 Subject: Added explicit casts to make QScriptValue autotest compile with NokiaX86 NokiaX86 compiler has problems with implicit casts and templates, so worked around this problem with explicit casts. Reviewed-by: Janne Koskinen --- tests/auto/qscriptvalue/tst_qscriptvalue.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/auto/qscriptvalue/tst_qscriptvalue.cpp b/tests/auto/qscriptvalue/tst_qscriptvalue.cpp index 243b810..3b9da4d 100644 --- a/tests/auto/qscriptvalue/tst_qscriptvalue.cpp +++ b/tests/auto/qscriptvalue/tst_qscriptvalue.cpp @@ -2253,7 +2253,7 @@ void tst_QScriptValue::getSetScriptClass() QVERIFY(obj.isVariant()); QCOMPARE(obj.scriptClass(), (QScriptClass*)0); obj.setScriptClass(&testClass); - QCOMPARE(obj.scriptClass(), &testClass); + QCOMPARE(obj.scriptClass(), (QScriptClass*)&testClass); QVERIFY(obj.isObject()); QVERIFY(!obj.isVariant()); QVERIFY(!obj.toVariant().isValid()); @@ -2263,7 +2263,7 @@ void tst_QScriptValue::getSetScriptClass() QVERIFY(obj.isQObject()); QCOMPARE(obj.scriptClass(), (QScriptClass*)0); obj.setScriptClass(&testClass); - QCOMPARE(obj.scriptClass(), &testClass); + QCOMPARE(obj.scriptClass(), (QScriptClass*)&testClass); QVERIFY(obj.isObject()); QVERIFY(!obj.isQObject()); QVERIFY(obj.toQObject() == 0); -- cgit v0.12 From de6380c8da3e22d30b0ec292da8da1db96d721ef Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Mon, 21 Sep 2009 14:15:17 +0200 Subject: Fix a possible warning on animations used with states The problem is that sometimes timerevents get compressed. So in the unified timer, we need to make sure that some time has passed between 2 ticks. --- src/corelib/animation/qabstractanimation.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/corelib/animation/qabstractanimation.cpp b/src/corelib/animation/qabstractanimation.cpp index 3d3eafd..6306882 100644 --- a/src/corelib/animation/qabstractanimation.cpp +++ b/src/corelib/animation/qabstractanimation.cpp @@ -214,14 +214,18 @@ void QUnifiedTimer::timerEvent(QTimerEvent *event) time.start(); } } else if (event->timerId() == animationTimer.timerId()) { - const int delta = lastTick - oldLastTick; - for (currentAnimationIdx = 0; currentAnimationIdx < animations.count(); ++currentAnimationIdx) { - QAbstractAnimation *animation = animations.at(currentAnimationIdx); - int elapsed = QAbstractAnimationPrivate::get(animation)->totalCurrentTime - + (animation->direction() == QAbstractAnimation::Forward ? delta : -delta); - animation->setCurrentTime(elapsed); + //we make sure we only call update time if the time has actually changed + //it might happen in some cases that the time doesn't change because events are delayed + //when the CPU load is high + if (const int delta = lastTick - oldLastTick) { + for (currentAnimationIdx = 0; currentAnimationIdx < animations.count(); ++currentAnimationIdx) { + QAbstractAnimation *animation = animations.at(currentAnimationIdx); + int elapsed = QAbstractAnimationPrivate::get(animation)->totalCurrentTime + + (animation->direction() == QAbstractAnimation::Forward ? delta : -delta); + animation->setCurrentTime(elapsed); + } + currentAnimationIdx = 0; } - currentAnimationIdx = 0; } } -- cgit v0.12 From 770208fd7e26bf2b7a257a0865f38532144f1c2c Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Tue, 22 Sep 2009 15:29:24 +0200 Subject: Fix to the autotests of Animations to spit less warnings --- .../tst_qparallelanimationgroup.cpp | 1 + .../qpropertyanimation/tst_qpropertyanimation.cpp | 22 +++- .../tst_qsequentialanimationgroup.cpp | 121 ++++++++++----------- 3 files changed, 77 insertions(+), 67 deletions(-) diff --git a/tests/auto/qparallelanimationgroup/tst_qparallelanimationgroup.cpp b/tests/auto/qparallelanimationgroup/tst_qparallelanimationgroup.cpp index 65fed3f..a129f7f 100644 --- a/tests/auto/qparallelanimationgroup/tst_qparallelanimationgroup.cpp +++ b/tests/auto/qparallelanimationgroup/tst_qparallelanimationgroup.cpp @@ -157,6 +157,7 @@ public: : QPropertyAnimation(target, propertyName, parent), id(0) { setDuration(250); + setEndValue(0); } int duration() const { return -1; /* not time driven */ } diff --git a/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp b/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp index bea399c..b92e140 100644 --- a/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp +++ b/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp @@ -75,6 +75,20 @@ private: qreal m_x; }; +class DummyPropertyAnimation : public QPropertyAnimation +{ +public: + DummyPropertyAnimation(QObject *parent = 0) : QPropertyAnimation(parent) + { + setTargetObject(&o); + this->setPropertyName("x"); + setEndValue(100); + } + + MyObject o; +}; + + class tst_QPropertyAnimation : public QObject { Q_OBJECT @@ -224,7 +238,11 @@ void tst_QPropertyAnimation::statesAndSignals_data() void tst_QPropertyAnimation::statesAndSignals() { QFETCH(bool, uncontrolled); - QPropertyAnimation *anim = uncontrolled ? new UncontrolledAnimation : new QPropertyAnimation; + QPropertyAnimation *anim; + if (uncontrolled) + anim = new UncontrolledAnimation; + else + anim = new DummyPropertyAnimation; anim->setDuration(100); QSignalSpy finishedSpy(anim, SIGNAL(finished())); @@ -833,7 +851,7 @@ void tst_QPropertyAnimation::setStartEndValues() void tst_QPropertyAnimation::zeroDurationStart() { - QPropertyAnimation anim; + DummyPropertyAnimation anim; QSignalSpy spy(&anim, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State))); anim.setDuration(0); QCOMPARE(anim.state(), QAbstractAnimation::Stopped); diff --git a/tests/auto/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp b/tests/auto/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp index 00dc178..209e68b 100644 --- a/tests/auto/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp +++ b/tests/auto/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp @@ -142,14 +142,28 @@ public: }; }; +class DummyPropertyAnimation : public QPropertyAnimation +{ +public: + DummyPropertyAnimation(QObject *parent = 0) : QPropertyAnimation(parent) + { + setTargetObject(&o); + this->setPropertyName("value"); + setEndValue(0); + } + + AnimationObject o; +}; + class UncontrolledAnimation : public QPropertyAnimation { Q_OBJECT public: - UncontrolledAnimation(QObject *target, const QByteArray &propertyName, QObject *parent = 0) - : QPropertyAnimation(target, propertyName, parent) + UncontrolledAnimation(QObject *target, QObject *parent = 0) + : QPropertyAnimation(target, "value", parent) { setDuration(250); + setEndValue(0); } int duration() const { return -1; /* not time driven */ } @@ -165,15 +179,11 @@ protected: void tst_QSequentialAnimationGroup::setCurrentTime() { - AnimationObject s_o1; - AnimationObject s_o2; - AnimationObject s_o3; - // sequence operating on same object/property QAnimationGroup *sequence = new QSequentialAnimationGroup(); - QVariantAnimation *a1_s_o1 = new QPropertyAnimation(&s_o1, "value"); - QVariantAnimation *a2_s_o1 = new QPropertyAnimation(&s_o1, "value"); - QVariantAnimation *a3_s_o1 = new QPropertyAnimation(&s_o1, "value"); + QVariantAnimation *a1_s_o1 = new DummyPropertyAnimation; + QVariantAnimation *a2_s_o1 = new DummyPropertyAnimation; + QVariantAnimation *a3_s_o1 = new DummyPropertyAnimation; a2_s_o1->setLoopCount(3); sequence->addAnimation(a1_s_o1); sequence->addAnimation(a2_s_o1); @@ -181,8 +191,8 @@ void tst_QSequentialAnimationGroup::setCurrentTime() // sequence operating on different object/properties QAnimationGroup *sequence2 = new QSequentialAnimationGroup(); - QVariantAnimation *a1_s_o2 = new QPropertyAnimation(&s_o2, "value"); - QVariantAnimation *a1_s_o3 = new QPropertyAnimation(&s_o3, "value"); + QVariantAnimation *a1_s_o2 = new DummyPropertyAnimation; + QVariantAnimation *a1_s_o3 = new DummyPropertyAnimation; sequence2->addAnimation(a1_s_o2); sequence2->addAnimation(a1_s_o3); @@ -315,22 +325,19 @@ void tst_QSequentialAnimationGroup::setCurrentTime() void tst_QSequentialAnimationGroup::setCurrentTimeWithUncontrolledAnimation() { - AnimationObject s_o1; - AnimationObject s_o2; AnimationObject t_o1; - AnimationObject t_o2; // sequence operating on different object/properties QAnimationGroup *sequence = new QSequentialAnimationGroup(); - QAbstractAnimation *a1_s_o1 = new QPropertyAnimation(&s_o1, "value"); - QAbstractAnimation *a1_s_o2 = new QPropertyAnimation(&s_o2, "value"); + QPropertyAnimation *a1_s_o1 = new DummyPropertyAnimation; + QPropertyAnimation *a1_s_o2 = new DummyPropertyAnimation; sequence->addAnimation(a1_s_o1); sequence->addAnimation(a1_s_o2); - QAbstractAnimation *notTimeDriven = new UncontrolledAnimation(&t_o1, "value"); + QPropertyAnimation *notTimeDriven = new UncontrolledAnimation(&t_o1); QCOMPARE(notTimeDriven->totalDuration(), -1); - QAbstractAnimation *loopsForever = new QPropertyAnimation(&t_o2, "value"); + QAbstractAnimation *loopsForever = new DummyPropertyAnimation; loopsForever->setLoopCount(-1); QCOMPARE(loopsForever->totalDuration(), -1); @@ -428,24 +435,21 @@ void tst_QSequentialAnimationGroup::setCurrentTimeWithUncontrolledAnimation() void tst_QSequentialAnimationGroup::seekingForwards() { - AnimationObject s_o1; - AnimationObject s_o2; - AnimationObject s_o3; // sequence operating on same object/property - QAnimationGroup *sequence = new QSequentialAnimationGroup(); - QVariantAnimation *a1_s_o1 = new QPropertyAnimation(&s_o1, "value"); - QVariantAnimation *a2_s_o1 = new QPropertyAnimation(&s_o1, "value"); - QVariantAnimation *a3_s_o1 = new QPropertyAnimation(&s_o1, "value"); + QAnimationGroup *sequence = new QSequentialAnimationGroup; + QVariantAnimation *a1_s_o1 = new DummyPropertyAnimation; + QVariantAnimation *a2_s_o1 = new DummyPropertyAnimation; + QVariantAnimation *a3_s_o1 = new DummyPropertyAnimation; a2_s_o1->setLoopCount(3); sequence->addAnimation(a1_s_o1); sequence->addAnimation(a2_s_o1); sequence->addAnimation(a3_s_o1); // sequence operating on different object/properties - QAnimationGroup *sequence2 = new QSequentialAnimationGroup(); - QVariantAnimation *a1_s_o2 = new QPropertyAnimation(&s_o2, "value"); - QVariantAnimation *a1_s_o3 = new QPropertyAnimation(&s_o3, "value"); + QAnimationGroup *sequence2 = new QSequentialAnimationGroup; + QVariantAnimation *a1_s_o2 = new DummyPropertyAnimation; + QVariantAnimation *a1_s_o3 = new DummyPropertyAnimation; sequence2->addAnimation(a1_s_o2); sequence2->addAnimation(a1_s_o3); @@ -508,15 +512,11 @@ void tst_QSequentialAnimationGroup::seekingForwards() void tst_QSequentialAnimationGroup::seekingBackwards() { - AnimationObject s_o1; - AnimationObject s_o2; - AnimationObject s_o3; - // sequence operating on same object/property QAnimationGroup *sequence = new QSequentialAnimationGroup(); - QVariantAnimation *a1_s_o1 = new QPropertyAnimation(&s_o1, "value"); - QVariantAnimation *a2_s_o1 = new QPropertyAnimation(&s_o1, "value"); - QVariantAnimation *a3_s_o1 = new QPropertyAnimation(&s_o1, "value"); + QVariantAnimation *a1_s_o1 = new DummyPropertyAnimation; + QVariantAnimation *a2_s_o1 = new DummyPropertyAnimation; + QVariantAnimation *a3_s_o1 = new DummyPropertyAnimation; a2_s_o1->setLoopCount(3); sequence->addAnimation(a1_s_o1); sequence->addAnimation(a2_s_o1); @@ -524,8 +524,8 @@ void tst_QSequentialAnimationGroup::seekingBackwards() // sequence operating on different object/properties QAnimationGroup *sequence2 = new QSequentialAnimationGroup(); - QVariantAnimation *a1_s_o2 = new QPropertyAnimation(&s_o2, "value"); - QVariantAnimation *a1_s_o3 = new QPropertyAnimation(&s_o3, "value"); + QVariantAnimation *a1_s_o2 = new DummyPropertyAnimation; + QVariantAnimation *a1_s_o3 = new DummyPropertyAnimation; sequence2->addAnimation(a1_s_o2); sequence2->addAnimation(a1_s_o3); @@ -650,13 +650,11 @@ static bool compareStates(const QSignalSpy& spy, const StateList &expectedStates void tst_QSequentialAnimationGroup::pauseAndResume() { - AnimationObject s_o1; - // sequence operating on same object/property QAnimationGroup *sequence = new QSequentialAnimationGroup(); - QVariantAnimation *a1_s_o1 = new QPropertyAnimation(&s_o1, "value"); - QVariantAnimation *a2_s_o1 = new QPropertyAnimation(&s_o1, "value"); - QVariantAnimation *a3_s_o1 = new QPropertyAnimation(&s_o1, "value"); + QVariantAnimation *a1_s_o1 = new DummyPropertyAnimation; + QVariantAnimation *a2_s_o1 = new DummyPropertyAnimation; + QVariantAnimation *a3_s_o1 = new DummyPropertyAnimation; a2_s_o1->setLoopCount(2); sequence->addAnimation(a1_s_o1); sequence->addAnimation(a2_s_o1); @@ -765,8 +763,6 @@ void tst_QSequentialAnimationGroup::pauseAndResume() void tst_QSequentialAnimationGroup::restart() { - AnimationObject s_o1; - // sequence operating on same object/property QAnimationGroup *sequence = new QSequentialAnimationGroup(); QSignalSpy seqCurrentAnimChangedSpy(sequence, SIGNAL(currentAnimationChanged(QAbstractAnimation*))); @@ -776,7 +772,7 @@ void tst_QSequentialAnimationGroup::restart() QSignalSpy *animsStateChanged[3]; for (int i = 0; i < 3; i++) { - anims[i] = new QPropertyAnimation(&s_o1, "value"); + anims[i] = new DummyPropertyAnimation; anims[i]->setDuration(100); animsStateChanged[i] = new QSignalSpy(anims[i], SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State))); } @@ -831,15 +827,11 @@ void tst_QSequentialAnimationGroup::restart() void tst_QSequentialAnimationGroup::looping() { - AnimationObject s_o1; - AnimationObject s_o2; - AnimationObject s_o3; - // sequence operating on same object/property QSequentialAnimationGroup *sequence = new QSequentialAnimationGroup(); - QAbstractAnimation *a1_s_o1 = new QPropertyAnimation(&s_o1, "value"); - QAbstractAnimation *a2_s_o1 = new QPropertyAnimation(&s_o1, "value"); - QAbstractAnimation *a3_s_o1 = new QPropertyAnimation(&s_o1, "value"); + QAbstractAnimation *a1_s_o1 = new DummyPropertyAnimation; + QAbstractAnimation *a2_s_o1 = new DummyPropertyAnimation; + QAbstractAnimation *a3_s_o1 = new DummyPropertyAnimation; QSignalSpy a1Spy(a1_s_o1, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State))); QSignalSpy a2Spy(a2_s_o1, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State))); @@ -1030,7 +1022,7 @@ void tst_QSequentialAnimationGroup::groupWithZeroDurationAnimations() QCOMPARE(o2.property("myProperty").toInt(), 42); QCOMPARE(o2.property("myOtherProperty").toInt(), 13); - QTest::qWait(50); + QTest::qWait(100); int o2val = o2.property("myOtherProperty").toInt(); QVERIFY(o2val > 13); @@ -1181,7 +1173,7 @@ void tst_QSequentialAnimationGroup::deleteChildrenWithRunningGroup() QCOMPARE(group.state(), QAnimationGroup::Running); QCOMPARE(anim1->state(), QAnimationGroup::Running); - QTest::qWait(50); + QTest::qWait(100); QVERIFY(group.currentTime() > 0); delete anim1; @@ -1357,8 +1349,7 @@ void tst_QSequentialAnimationGroup::zeroDurationAnimation() anim2->setEndValue(100); anim2->setDuration(100); - AnimationObject o1; - QPropertyAnimation *anim3 = new QPropertyAnimation(&o1, "value"); + DummyPropertyAnimation *anim3 = new DummyPropertyAnimation; anim3->setEndValue(100); anim3->setDuration(0); @@ -1386,7 +1377,7 @@ void tst_QSequentialAnimationGroup::zeroDurationAnimation() QCOMPARE(anim2->state(), QAnimationGroup::Running); QCOMPARE(anim3->state(), QAnimationGroup::Stopped); QCOMPARE(group.state(), QAnimationGroup::Running); - QCOMPARE(o1.value(), 100); //anim3 should have been run + QCOMPARE(anim3->o.value(), 100); //anim3 should have been run } void tst_QSequentialAnimationGroup::stopUncontrolledAnimations() @@ -1394,7 +1385,7 @@ void tst_QSequentialAnimationGroup::stopUncontrolledAnimations() QSequentialAnimationGroup group; AnimationObject o1; - UncontrolledAnimation notTimeDriven(&o1, "value"); + UncontrolledAnimation notTimeDriven(&o1); QCOMPARE(notTimeDriven.totalDuration(), -1); TestAnimation loopsForever; @@ -1432,7 +1423,7 @@ void tst_QSequentialAnimationGroup::finishWithUncontrolledAnimation() //1st case: //first we test a group with one uncontrolled animation QSequentialAnimationGroup group; - UncontrolledAnimation notTimeDriven(&o1, "value", &group); + UncontrolledAnimation notTimeDriven(&o1, &group); QSignalSpy spy(&group, SIGNAL(finished())); group.start(); @@ -1451,7 +1442,7 @@ void tst_QSequentialAnimationGroup::finishWithUncontrolledAnimation() //2nd case: // lets make sure the seeking will work again spy.clear(); - QPropertyAnimation anim(&group); + DummyPropertyAnimation anim(&group); QSignalSpy animStateChangedSpy(&anim, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State))); group.setCurrentTime(300); @@ -1593,7 +1584,7 @@ void tst_QSequentialAnimationGroup::insertAnimation() { QSequentialAnimationGroup group; group.setLoopCount(2); - QPropertyAnimation *anim = new QPropertyAnimation(&group); + QPropertyAnimation *anim = new DummyPropertyAnimation(&group); QCOMPARE(group.duration(), anim->duration()); group.setCurrentTime(300); QCOMPARE(group.currentLoop(), 1); @@ -1616,7 +1607,7 @@ public slots: { stop(); clearAnimations(); - new QPropertyAnimation(this); + new DummyPropertyAnimation(this); start(); } @@ -1626,9 +1617,9 @@ public slots: void tst_QSequentialAnimationGroup::clearAnimations() { SequentialAnimationGroup group; - QPointer anim1 = new QPropertyAnimation(&group); + QPointer anim1 = new DummyPropertyAnimation(&group); group.connect(anim1, SIGNAL(finished()), SLOT(clearAnimations())); - new QPropertyAnimation(&group); + new DummyPropertyAnimation(&group); QCOMPARE(group.animationCount(), 2); group.start(); @@ -1637,7 +1628,7 @@ void tst_QSequentialAnimationGroup::clearAnimations() QCOMPARE(group.state(), QAbstractAnimation::Stopped); QCOMPARE(group.currentTime(), 0); - anim1 = new QPropertyAnimation(&group); + anim1 = new DummyPropertyAnimation(&group); group.connect(anim1, SIGNAL(finished()), SLOT(refill())); group.start(); QTest::qWait(anim1->duration() + 100); -- cgit v0.12 From 4a157ee126fc482cd1954b80f22f790ec544e241 Mon Sep 17 00:00:00 2001 From: axis Date: Tue, 22 Sep 2009 13:44:28 +0200 Subject: Prevented export of some internal functions. These should not be exported anymore after commit c13b97f2. RevBy: Jason Barron --- src/gui/widgets/qmenu.h | 4 ++-- src/gui/widgets/qmenu_symbian.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/gui/widgets/qmenu.h b/src/gui/widgets/qmenu.h index 1f77442..3d41727 100644 --- a/src/gui/widgets/qmenu.h +++ b/src/gui/widgets/qmenu.h @@ -61,8 +61,8 @@ QT_BEGIN_NAMESPACE QT_MODULE(Gui) #ifdef Q_WS_S60 - IMPORT_C void qt_symbian_show_toplevel(CEikMenuPane* menuPane); - IMPORT_C void qt_symbian_show_submenu(CEikMenuPane* menuPane, int id); +void qt_symbian_show_toplevel(CEikMenuPane* menuPane); +void qt_symbian_show_submenu(CEikMenuPane* menuPane, int id); #endif // Q_WS_S60 #ifndef QT_NO_MENU diff --git a/src/gui/widgets/qmenu_symbian.cpp b/src/gui/widgets/qmenu_symbian.cpp index 13830ba..6fc4371 100644 --- a/src/gui/widgets/qmenu_symbian.cpp +++ b/src/gui/widgets/qmenu_symbian.cpp @@ -222,7 +222,7 @@ static void rebuildMenu() } #ifdef Q_WS_S60 -Q_GUI_EXPORT void qt_symbian_show_toplevel( CEikMenuPane* menuPane) +void qt_symbian_show_toplevel( CEikMenuPane* menuPane) { if (!menuExists()) return; @@ -231,7 +231,7 @@ Q_GUI_EXPORT void qt_symbian_show_toplevel( CEikMenuPane* menuPane) QT_TRAP_THROWING(menuPane->AddMenuItemL(symbianMenus.at(i)->menuItemData)); } -Q_GUI_EXPORT void qt_symbian_show_submenu( CEikMenuPane* menuPane, int id) +void qt_symbian_show_submenu( CEikMenuPane* menuPane, int id) { SymbianMenuItem* menu = qt_symbian_find_menu(id, symbianMenus); if (menu) { -- cgit v0.12 From 03bbfb0852fd18851e2c41ad1305c60d82f835e2 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Tue, 22 Sep 2009 15:26:28 +0200 Subject: work around another set of duplicated symbols between webkit and script jscyyerror/parse/lex where exported on some platforms. Reviewed-By: Simon Hausmann --- src/script/script.pro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/script/script.pro b/src/script/script.pro index 860080d..c844d89 100644 --- a/src/script/script.pro +++ b/src/script/script.pro @@ -1,7 +1,7 @@ TARGET = QtScript QPRO_PWD = $$PWD QT = core -DEFINES += JSC=QTJSC +DEFINES += JSC=QTJSC jscyyparse=qtjscyyparse jscyylex=qtjscyylex jscyyerror=qtjscyyerror DEFINES += QT_BUILD_SCRIPT_LIB DEFINES += QT_NO_USING_NAMESPACE DEFINES += QLALR_NO_QSCRIPTGRAMMAR_DEBUG_INFO -- cgit v0.12 From 16af209f76074553c6f56b3cd0da3610a71410ab Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Tue, 22 Sep 2009 15:34:03 +0200 Subject: Fixed ellipsedrawing in raser engine for rects over 2^15 in size Reviewed-by: Samuel --- src/gui/painting/qpaintengine_raster.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp index effc99e..6037bd5 100644 --- a/src/gui/painting/qpaintengine_raster.cpp +++ b/src/gui/painting/qpaintengine_raster.cpp @@ -3663,6 +3663,7 @@ void QRasterPaintEngine::drawEllipse(const QRectF &rect) ensurePen(); if (((qpen_style(s->lastPen) == Qt::SolidLine && s->flags.fast_pen) || (qpen_style(s->lastPen) == Qt::NoPen && !s->flags.antialiased)) + && qMax(rect.width(), rect.height()) < QT_RASTER_COORD_LIMIT #ifdef FLOATING_POINT_BUGGY_OR_NO_FPU && qMax(rect.width(), rect.height()) < 128 // integer math breakdown #endif -- cgit v0.12 From ffb2de1815bb50c93734d4dcfc2fa5cab8c00d35 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Tue, 22 Sep 2009 15:42:03 +0200 Subject: Fix a regression in 4.6 in icon mode for QListView We were not restoring the hidden rows correctly. Reviewed-by: Jan-Arve --- src/gui/itemviews/qlistview.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/itemviews/qlistview.cpp b/src/gui/itemviews/qlistview.cpp index a4cebe3..9b0b00f 100644 --- a/src/gui/itemviews/qlistview.cpp +++ b/src/gui/itemviews/qlistview.cpp @@ -2429,7 +2429,7 @@ void QIconModeViewBase::appendHiddenRow(int row) void QIconModeViewBase::removeHiddenRow(int row) { - QCommonListViewBase::appendHiddenRow(row); + QCommonListViewBase::removeHiddenRow(row); if (row >= 0 && row < items.count()) //insert item tree.insertLeaf(items.at(row).rect(), row); } -- cgit v0.12 From 04b7a414f626795b8000271e133b65f8b72ea4c9 Mon Sep 17 00:00:00 2001 From: Prasanth Ullattil Date: Tue, 22 Sep 2009 15:47:22 +0200 Subject: Missing mouse release event on toolbars on Mac OS X The mouse move events were eaten regardless of the dragging state. Task-number: 238004 Reviewed-by: Thierry --- src/gui/widgets/qtoolbar.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gui/widgets/qtoolbar.cpp b/src/gui/widgets/qtoolbar.cpp index a727b2b..40c0b02 100644 --- a/src/gui/widgets/qtoolbar.cpp +++ b/src/gui/widgets/qtoolbar.cpp @@ -307,6 +307,8 @@ bool QToolBarPrivate::mouseReleaseEvent(QMouseEvent*) return true; } else { #ifdef Q_WS_MAC + if (!macWindowDragging) + return false; macWindowDragging = false; macWindowDragPressPosition = QPoint(); return true; -- cgit v0.12 From f16fd9324ae5f86dfe851cad9639d2ee2e8571ed Mon Sep 17 00:00:00 2001 From: Andreas Aardal Hanssen Date: Tue, 22 Sep 2009 11:23:48 +0200 Subject: Fix focus scope bugs, verified against examples in kinetic-declarativeui. The C++ autotests have been updated to match the expected behavior of the examples that broke (e.g., listview.qml) in kinetic-declarativeui. Reviewed-by: Alexis --- src/gui/graphicsview/qgraphicsitem.cpp | 34 ++++++++++++-------------- src/gui/graphicsview/qgraphicsscene.cpp | 13 ++-------- tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp | 14 +++++------ 3 files changed, 25 insertions(+), 36 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index 0145499..3249bb1 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -982,12 +982,10 @@ void QGraphicsItemPrivate::setParentItemHelper(QGraphicsItem *newParent) QGraphicsItem *p = newParent; while (p) { if (p->flags() & QGraphicsItem::ItemIsFocusScope) { - // ### We really want the parent's focus scope item to point - // to this item's focusItem... - if (q_ptr->flags() & QGraphicsItem::ItemIsFocusScope) - p->d_ptr->focusScopeItem = q_ptr; - else - p->d_ptr->focusScopeItem = subFocusItem ? subFocusItem : parentFocusScopeItem; + p->d_ptr->focusScopeItem = subFocusItem ? subFocusItem : parentFocusScopeItem; + // ### The below line might not make sense... + if (subFocusItem) + subFocusItem->d_ptr->clearSubFocus(); break; } p = p->d_ptr->parent; @@ -2812,15 +2810,12 @@ void QGraphicsItemPrivate::setFocusHelper(Qt::FocusReason focusReason, bool clim if (scene && scene->focusItem() == f) return; - // Update the child focus chain. - setSubFocus(); - // Update focus scope item ptr. QGraphicsItem *p = parent; while (p) { if (p->flags() & QGraphicsItem::ItemIsFocusScope) { p->d_ptr->focusScopeItem = q_ptr; - if (!q_ptr->isActive()) + if (!q_ptr->isActive() || !p->focusItem()) return; break; } @@ -2830,10 +2825,11 @@ void QGraphicsItemPrivate::setFocusHelper(Qt::FocusReason focusReason, bool clim if (climb) { while (f->d_ptr->focusScopeItem && f->d_ptr->focusScopeItem->isVisible()) f = f->d_ptr->focusScopeItem; - if (f != q_ptr) - f->d_ptr->setSubFocus(); } + // Update the child focus chain. + f->d_ptr->setSubFocus(); + // Update the scene's focus item. if (scene) { QGraphicsItem *p = q_ptr->panel(); @@ -2858,13 +2854,15 @@ void QGraphicsItemPrivate::setFocusHelper(Qt::FocusReason focusReason, bool clim void QGraphicsItem::clearFocus() { // Pass focus to the closest parent focus scope. - QGraphicsItem *p = d_ptr->parent; - while (p) { - if (p->flags() & ItemIsFocusScope) { - p->d_ptr->setFocusHelper(Qt::OtherFocusReason, /* climb = */ false); - return; + if (!d_ptr->inDestructor) { + QGraphicsItem *p = d_ptr->parent; + while (p) { + if (p->flags() & ItemIsFocusScope) { + p->d_ptr->setFocusHelper(Qt::OtherFocusReason, /* climb = */ false); + return; + } + p = p->d_ptr->parent; } - p = p->d_ptr->parent; } // Invisible items with focus must explicitly clear subfocus. diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp index f6e0aaf..a267996 100644 --- a/src/gui/graphicsview/qgraphicsscene.cpp +++ b/src/gui/graphicsview/qgraphicsscene.cpp @@ -2434,17 +2434,8 @@ void QGraphicsScene::addItem(QGraphicsItem *item) // Ensure that newly added items that have subfocus set, gain // focus automatically if there isn't a focus item already. - if (!d->focusItem) { - if (item->focusItem() == item && item != d->lastFocusItem) { - QGraphicsItem *fi = item->focusItem() ? item->focusItem() : item->focusScopeItem(); - if (fi) { - QGraphicsItem *fsi; - while ((fsi = fi->focusScopeItem()) && fsi->isVisible()) - fi = fsi; - fi->setFocus(); - } - } - } + if (!d->focusItem && item != d->lastFocusItem && item->focusItem() == item) + item->focusItem()->setFocus(); d->updateInputMethodSensitivityInViews(); } diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp index 9b8ce1f..6f37b70 100644 --- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp @@ -8299,7 +8299,7 @@ void tst_QGraphicsItem::focusScope() QVERIFY(!scope2->focusScopeItem()); scope3->setParentItem(scope2); QCOMPARE(scope2->focusScopeItem(), (QGraphicsItem *)scope3); - QCOMPARE(scope2->focusItem(), (QGraphicsItem *)scope3); + QCOMPARE(scope2->focusItem(), (QGraphicsItem *)scope2); QGraphicsRectItem *scope1 = new QGraphicsRectItem; scope1->setData(0, "scope1"); @@ -8308,9 +8308,9 @@ void tst_QGraphicsItem::focusScope() QVERIFY(!scope1->focusScopeItem()); scope2->setParentItem(scope1); - QCOMPARE(scope1->focusItem(), (QGraphicsItem *)scope3); - QCOMPARE(scope2->focusItem(), (QGraphicsItem *)scope3); - QCOMPARE(scope3->focusItem(), (QGraphicsItem *)scope3); + QCOMPARE(scope1->focusItem(), (QGraphicsItem *)scope1); + QCOMPARE(scope2->focusItem(), (QGraphicsItem *)0); + QCOMPARE(scope3->focusItem(), (QGraphicsItem *)0); QCOMPARE(scope1->focusScopeItem(), (QGraphicsItem *)scope2); QCOMPARE(scope2->focusScopeItem(), (QGraphicsItem *)scope3); QCOMPARE(scope3->focusScopeItem(), (QGraphicsItem *)0); @@ -8361,11 +8361,11 @@ void tst_QGraphicsItem::focusScope() rect5->setFocus(); rect5->setParentItem(rect4); QCOMPARE(scope3->focusScopeItem(), (QGraphicsItem *)rect5); - QVERIFY(rect5->hasFocus()); + QVERIFY(!rect5->hasFocus()); rect4->setParentItem(0); QCOMPARE(scope3->focusScopeItem(), (QGraphicsItem *)0); - QVERIFY(!scope3->hasFocus()); + QVERIFY(scope3->hasFocus()); QGraphicsRectItem *rectA = new QGraphicsRectItem; QGraphicsRectItem *scopeA = new QGraphicsRectItem(rectA); @@ -8376,7 +8376,7 @@ void tst_QGraphicsItem::focusScope() scopeB->setFocus(); scene.addItem(rectA); - QVERIFY(rect5->hasFocus()); + QVERIFY(!rect5->hasFocus()); QVERIFY(!scopeB->hasFocus()); scopeA->setFocus(); -- cgit v0.12 From 7a603159dbf5c1f931cfc257aab0239abaa1d4a1 Mon Sep 17 00:00:00 2001 From: David Boddie Date: Tue, 22 Sep 2009 15:46:39 +0200 Subject: Doc: Moved the note about QFileSystemModel to the start of the document. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-by: Alexis Ménard --- src/gui/itemviews/qdirmodel.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/gui/itemviews/qdirmodel.cpp b/src/gui/itemviews/qdirmodel.cpp index 26e1557..2973741 100644 --- a/src/gui/itemviews/qdirmodel.cpp +++ b/src/gui/itemviews/qdirmodel.cpp @@ -190,6 +190,9 @@ void QDirModelPrivate::invalidate() \ingroup model-view + \note The usage of QDirModel is not recommended anymore. The + QFileSystemModel class is a more performant alternative. + This class provides access to the local filesystem, providing functions for renaming and removing files and directories, and for creating new directories. In the simplest case, it can be used with a suitable display @@ -228,10 +231,7 @@ void QDirModelPrivate::invalidate() \note QDirModel requires an instance of a GUI application. - \note The usage of QDirModel is not recommended anymore. The - QFileSystemModel class is a more performant alternative. - - \sa nameFilters(), setFilter(), filter(), QListView, QTreeView, QFileSystemModel + \sa nameFilters(), setFilter(), filter(), QListView, QTreeView, QFileSystemModel, {Dir View Example}, {Model Classes} */ -- cgit v0.12 From b85f6a46650774e2422ab44f1f12751ada8d9373 Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Tue, 22 Sep 2009 14:57:54 +0200 Subject: Fix "... may return wrong private dir if application is on Z:, not C:" QT-805 QCoreApplication::applicationDirPath() may return wrong private dir if application is on Z:, not C: Remove the emulator ifdef, instead RFs::Drive is used to get the drive attributes (to see if it is ROM / read only) RFs::SystemDrive is used to get the system drive, which is C: on S60 phones, but in theory configurable. It is not needed to call Open() on RProcess to call functions on the current process - this eliminates some code. Elimated some unneeded code to check for Z: before creating prvate path (now, the if statement would always have evaluated the same) Task-number: QT-805 Reviewed-by: Miikka Heikkinen --- src/corelib/kernel/qcoreapplication.cpp | 63 ++++++++++++++++----------------- 1 file changed, 31 insertions(+), 32 deletions(-) diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index 9283730..c575509 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -1788,6 +1788,8 @@ bool QCoreApplicationPrivate::isTranslatorInstalled(QTranslator *translator) In Symbian this function will return the application private directory, not the path to executable itself, as those are always in \c {/sys/bin}. + If the application is in a read only drive, i.e. ROM, then the private path + on the system drive will be returned. \sa applicationFilePath() */ @@ -1803,42 +1805,39 @@ QString QCoreApplication::applicationDirPath() #if defined(Q_OS_SYMBIAN) { QString appPath; - RProcess proc; - TInt err = proc.Open(proc.Id()); + RFs& fs = qt_s60GetRFs(); + TChar driveChar; + QChar qDriveChar; + driveChar = (RProcess().FileName())[0]; + + //Check if the process is installed in a read only drive (typically ROM), + //and use the system drive (typically C:) if so. + TInt drive; + TDriveInfo driveInfo; + TInt err = fs.CharToDrive(driveChar, drive); if (err == KErrNone) { - QChar driveChar; -#if defined(Q_CC_NOKIAX86) - // In emulator, always resolve the private dir on C-drive - driveChar = QLatin1Char('C'); -#else - driveChar = QLatin1Char((proc.FileName())[0]); -#endif - proc.Close(); + err = fs.Drive(driveInfo, drive); + } + if (err != KErrNone || (driveInfo.iDriveAtt & KDriveAttRom) || (driveInfo.iMediaAtt + & KMediaAttWriteProtected)) { + driveChar = fs.GetSystemDriveChar(); + drive = fs.GetSystemDrive(); + } - driveChar = driveChar.toUpper(); + qDriveChar = QChar(QLatin1Char(driveChar)).toUpper(); - TFileName privatePath; - RFs& fs = qt_s60GetRFs(); - fs.PrivatePath(privatePath); - appPath = qt_TDesC2QString(privatePath); - appPath.prepend(QLatin1Char(':')).prepend(driveChar); - - // Create the appPath if it doesn't exist. Non-existing appPath will cause - // Platform Security violations later on if the app doesn't have AllFiles capability. - // Can't create appPath for ROM unfortunately, so applications meant for - // ROM should always deploy something to their private dir to ensure appPath exists, - // if the PlatSec violations are an issue. - char driveDiff = QLatin1Char('Z').toLatin1() - driveChar.toLatin1(); - TInt driveId = EDriveZ - static_cast(driveDiff); - if (driveId != EDriveZ) { - TInt err = fs.CreatePrivatePath(driveId); - if (err != KErrNone) - qWarning("QCoreApplication::applicationDirPath: Failed to create private path."); - } - } + TFileName privatePath; + fs.PrivatePath(privatePath); + appPath = qt_TDesC2QString(privatePath); + appPath.prepend(QLatin1Char(':')).prepend(qDriveChar); + + // Create the appPath if it doesn't exist. Non-existing appPath will cause + // Platform Security violations later on if the app doesn't have AllFiles capability. + err = fs.CreatePrivatePath(drive); + if (err != KErrNone) + qWarning("QCoreApplication::applicationDirPath: Failed to create private path."); - QFileInfo fi(appPath); - d->cachedApplicationDirPath = fi.exists() ? fi.canonicalFilePath() : QString(); + d->cachedApplicationDirPath = QFileInfo(appPath).path(); } #else d->cachedApplicationDirPath = QFileInfo(applicationFilePath()).path(); -- cgit v0.12 From 24a928dd31ea54063b802cc2d249afe852daeebe Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Tue, 22 Sep 2009 15:06:32 +0200 Subject: Fix crashes in QApplication autotest 1) Input methods caused crash due to using CCoeEnv::Fep() without checking for NULL pointer 2) Autotest itself had Q_ASSERT where it should have used Q_VERIFY Reviewed-by: axis --- src/gui/inputmethod/qcoefepinputcontext_s60.cpp | 8 ++++++-- tests/auto/qapplication/tst_qapplication.cpp | 8 ++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/gui/inputmethod/qcoefepinputcontext_s60.cpp b/src/gui/inputmethod/qcoefepinputcontext_s60.cpp index b198ae1..fc55a0f 100644 --- a/src/gui/inputmethod/qcoefepinputcontext_s60.cpp +++ b/src/gui/inputmethod/qcoefepinputcontext_s60.cpp @@ -98,7 +98,9 @@ QCoeFepInputContext::~QCoeFepInputContext() void QCoeFepInputContext::reset() { - CCoeEnv::Static()->Fep()->CancelTransaction(); + CCoeFep* fep = CCoeEnv::Static()->Fep(); + if (fep) + fep->CancelTransaction(); } void QCoeFepInputContext::ReportAknEdStateEvent(MAknEdStateObserver::EAknEdwinStateEvent aEventType) @@ -626,7 +628,9 @@ void QCoeFepInputContext::commitCurrentString(bool triggeredBySymbian) m_isEditing = false; if (!triggeredBySymbian) { - CCoeEnv::Static()->Fep()->CancelTransaction(); + CCoeFep* fep = CCoeEnv::Static()->Fep(); + if (fep) + fep->CancelTransaction(); } } diff --git a/tests/auto/qapplication/tst_qapplication.cpp b/tests/auto/qapplication/tst_qapplication.cpp index 6ffefc5..2ba5239 100644 --- a/tests/auto/qapplication/tst_qapplication.cpp +++ b/tests/auto/qapplication/tst_qapplication.cpp @@ -1148,15 +1148,15 @@ void DeleteLaterWidget::runTest() connect(w, SIGNAL(destroyed()), this, SLOT(childDeleted())); w->deleteLater(); - Q_ASSERT(!child_deleted); + QVERIFY(!child_deleted); QDialog dlg; QTimer::singleShot(500, &dlg, SLOT(reject())); dlg.exec(); - Q_ASSERT(!child_deleted); + QVERIFY(!child_deleted); app->processEvents(); - Q_ASSERT(!child_deleted); + QVERIFY(!child_deleted); QTimer::singleShot(500, this, SLOT(checkDeleteLater())); @@ -1167,7 +1167,7 @@ void DeleteLaterWidget::runTest() void DeleteLaterWidget::checkDeleteLater() { - Q_ASSERT(child_deleted); + QVERIFY(child_deleted); close(); } -- cgit v0.12 From 1931c3e4cb502ba1d7461129bcc6f3c9ee600f9c Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Tue, 22 Sep 2009 16:10:09 +0200 Subject: fix failing qdir autotest File engine was adding '/' to the result of QDir::cleanPath(), which is correct for everything except root directories, where it caused a path like "c://" Reviewed-by: axis --- src/corelib/io/qfsfileengine_unix.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/io/qfsfileengine_unix.cpp b/src/corelib/io/qfsfileengine_unix.cpp index e54bad6..4ec5772 100644 --- a/src/corelib/io/qfsfileengine_unix.cpp +++ b/src/corelib/io/qfsfileengine_unix.cpp @@ -899,7 +899,7 @@ QString QFSFileEngine::fileName(FileName file) const // Clean up the path bool isDir = ret.endsWith(slashChar); ret = QDir::cleanPath(ret); - if (isDir) + if (isDir && !ret.endsWith(slashChar)) ret += slashChar; if (file == AbsolutePathName) { -- cgit v0.12 From 5c3c0d477104f6f4eafaceeacac8278c4b97f8cc Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Tue, 22 Sep 2009 16:50:28 +0200 Subject: Fixed background gradients in ObjectBoundingMode Reviewed-by: Samuel --- src/gui/kernel/qwidget.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index e68a72d..6f5781c 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -2106,6 +2106,13 @@ static inline void fillRegion(QPainter *painter, const QRegion &rgn, const QBrus painter->drawTiledPixmap(rect, brush.texture(), rect.topLeft()); } #endif // Q_WS_MAC + + } else if (brush.gradient() + && brush.gradient()->coordinateMode() == QGradient::ObjectBoundingMode) { + painter->save(); + painter->setClipRegion(rgn); + painter->fillRect(0, 0, painter->device()->width(), painter->device()->height(), brush); + painter->restore(); } else { const QVector &rects = rgn.rects(); for (int i = 0; i < rects.size(); ++i) @@ -2146,7 +2153,6 @@ void QWidgetPrivate::paintBackground(QPainter *painter, const QRegion &rgn, int if (q->autoFillBackground()) fillRegion(painter, rgn, autoFillBrush); - if (q->testAttribute(Qt::WA_StyledBackground)) { painter->setClipRegion(rgn); QStyleOption opt; @@ -4991,7 +4997,7 @@ QGraphicsEffect *QWidget::graphicsEffect() const /*! \brief The setGraphicsEffect function is for setting the widget's graphics effect. - + Sets \a effect as the widget's effect. If there already is an effect installed on this widget, QWidget will delete the existing effect before installing the new \a effect. -- cgit v0.12 From 77b1f0ab8c8055835a3fc92d784d536efdc6acbf Mon Sep 17 00:00:00 2001 From: Kent Hansen Date: Tue, 22 Sep 2009 16:56:37 +0200 Subject: make sure the engine's currentFrame is in sync when calling out to public API The currentFrame pointer is used e.g. by QScriptValue::toString(). It needs to be in sync, otherwise we will crash. Reviewed-by: Olivier Goffart --- src/script/api/qscriptengine.cpp | 2 ++ src/script/api/qscriptengine_p.h | 23 +++++++++++++++++++++++ src/script/bridge/qscriptclassobject.cpp | 8 +++++++- 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/src/script/api/qscriptengine.cpp b/src/script/api/qscriptengine.cpp index 7a910d2..71194d3 100644 --- a/src/script/api/qscriptengine.cpp +++ b/src/script/api/qscriptengine.cpp @@ -508,6 +508,7 @@ JSC::JSValue JSC_HOST_CALL functionDisconnect(JSC::ExecState *exec, JSC::JSObjec slot = arg1; else { // ### don't go via QScriptValue + QScript::SaveFrameHelper saveFrame(engine, exec); QScriptValue tmp = engine->scriptValueFromJSCValue(arg0); QString propertyName(arg1.toString(exec)); slot = engine->scriptValueToJSCValue(tmp.property(propertyName, QScriptValue::ResolvePrototype)); @@ -591,6 +592,7 @@ JSC::JSValue JSC_HOST_CALL functionConnect(JSC::ExecState *exec, JSC::JSObject * slot = arg1; else { // ### don't go via QScriptValue + QScript::SaveFrameHelper saveFrame(engine, exec); QScriptValue tmp = engine->scriptValueFromJSCValue(arg0); QString propertyName = arg1.toString(exec); slot = engine->scriptValueToJSCValue(tmp.property(propertyName, QScriptValue::ResolvePrototype)); diff --git a/src/script/api/qscriptengine_p.h b/src/script/api/qscriptengine_p.h index c7db276..ec41cc9 100644 --- a/src/script/api/qscriptengine_p.h +++ b/src/script/api/qscriptengine_p.h @@ -265,6 +265,29 @@ public: #endif }; +namespace QScript +{ + +class SaveFrameHelper +{ +public: + SaveFrameHelper(QScriptEnginePrivate *eng, + JSC::ExecState *newFrame) + : engine(eng), oldFrame(eng->currentFrame) + { + eng->currentFrame = newFrame; + } + ~SaveFrameHelper() + { + engine->currentFrame = oldFrame; + } +private: + QScriptEnginePrivate *engine; + JSC::ExecState *oldFrame; +}; + +} // namespace QScript + inline QScriptValuePrivate *QScriptEnginePrivate::allocateScriptValuePrivate(size_t size) { if (freeScriptValues) { diff --git a/src/script/bridge/qscriptclassobject.cpp b/src/script/bridge/qscriptclassobject.cpp index a5dc670..b57909f 100644 --- a/src/script/bridge/qscriptclassobject.cpp +++ b/src/script/bridge/qscriptclassobject.cpp @@ -90,12 +90,13 @@ bool ClassObjectDelegate::getOwnPropertySlot(QScriptObject* object, const JSC::Identifier &propertyName, JSC::PropertySlot &slot) { + QScriptEnginePrivate *engine = scriptEngineFromExec(exec); + QScript::SaveFrameHelper saveFrame(engine, exec); // for compatibility with the old back-end, normal JS properties // are queried first. if (QScriptObjectDelegate::getOwnPropertySlot(object, exec, propertyName, slot)) return true; - QScriptEnginePrivate *engine = scriptEngineFromExec(exec); QScriptValue scriptObject = engine->scriptValueFromJSCValue(object); QScriptString scriptName; QScriptStringPrivate scriptName_d(engine, propertyName, QScriptStringPrivate::StackAllocated); @@ -116,6 +117,7 @@ void ClassObjectDelegate::put(QScriptObject* object, JSC::ExecState *exec, JSC::JSValue value, JSC::PutPropertySlot &slot) { QScriptEnginePrivate *engine = scriptEngineFromExec(exec); + QScript::SaveFrameHelper saveFrame(engine, exec); QScriptValue scriptObject = engine->scriptValueFromJSCValue(object); QScriptString scriptName; QScriptStringPrivate scriptName_d(engine, propertyName, QScriptStringPrivate::StackAllocated); @@ -136,6 +138,7 @@ bool ClassObjectDelegate::deleteProperty(QScriptObject* object, JSC::ExecState * { // ### avoid duplication of put() QScriptEnginePrivate *engine = scriptEngineFromExec(exec); + QScript::SaveFrameHelper saveFrame(engine, exec); QScriptValue scriptObject = engine->scriptValueFromJSCValue(object); QScriptString scriptName; QScriptStringPrivate scriptName_d(engine, propertyName, QScriptStringPrivate::StackAllocated); @@ -157,6 +160,7 @@ bool ClassObjectDelegate::getPropertyAttributes(const QScriptObject* object, JSC unsigned &attribs) const { QScriptEnginePrivate *engine = scriptEngineFromExec(exec); + QScript::SaveFrameHelper saveFrame(engine, exec); QScriptValue scriptObject = engine->scriptValueFromJSCValue(object); QScriptString scriptName; QScriptStringPrivate scriptName_d(engine, propertyName, QScriptStringPrivate::StackAllocated); @@ -188,6 +192,7 @@ void ClassObjectDelegate::getPropertyNames(QScriptObject* object, JSC::ExecState unsigned listedAttributes) { QScriptEnginePrivate *engine = scriptEngineFromExec(exec); + QScript::SaveFrameHelper saveFrame(engine, exec); QScriptValue scriptObject = engine->scriptValueFromJSCValue(object); QScriptClassPropertyIterator *it = m_scriptClass->newIterator(scriptObject); if (it != 0) { @@ -267,6 +272,7 @@ bool ClassObjectDelegate::hasInstance(QScriptObject* object, JSC::ExecState *exe return QScriptObjectDelegate::hasInstance(object, exec, value, proto); QScriptValueList args; QScriptEnginePrivate *eng_p = scriptEngineFromExec(exec); + QScript::SaveFrameHelper saveFrame(eng_p, exec); args << eng_p->scriptValueFromJSCValue(object) << eng_p->scriptValueFromJSCValue(value); QVariant result = scriptClass()->extension(QScriptClass::HasInstance, qVariantFromValue(args)); return result.toBool(); -- cgit v0.12 From 6ad6dcd4c714dfff700029461638c235469f08d7 Mon Sep 17 00:00:00 2001 From: Leonardo Sobral Cunha Date: Fri, 18 Sep 2009 16:26:43 +0200 Subject: Inverts the SortOrder in graphics scene to reflect the stacking order Inverted all references of Qt::AscendingiOrder <-> Qt::DescendingOrder to make the order parameter consistent with the stacking order, as stated in the docs. The graphics scene index was using the wrong ordering convention. Reviewed-by: andreas --- src/gui/graphicsview/qgraphicsscene.cpp | 28 +++++++++++----------- .../graphicsview/qgraphicsscenebsptreeindex.cpp | 14 +++++------ .../graphicsview/qgraphicsscenebsptreeindex_p.h | 2 +- src/gui/graphicsview/qgraphicssceneindex.cpp | 4 ++-- src/gui/graphicsview/qgraphicssceneindex_p.h | 6 ++--- src/gui/graphicsview/qgraphicsscenelinearindex.cpp | 2 +- src/gui/graphicsview/qgraphicsscenelinearindex_p.h | 2 +- src/gui/graphicsview/qgraphicsview.cpp | 16 ++++++------- 8 files changed, 37 insertions(+), 37 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp index a267996..0655ecc 100644 --- a/src/gui/graphicsview/qgraphicsscene.cpp +++ b/src/gui/graphicsview/qgraphicsscene.cpp @@ -925,19 +925,19 @@ QList QGraphicsScenePrivate::itemsAtPosition(const QPoint &scre Q_Q(const QGraphicsScene); QGraphicsView *view = widget ? qobject_cast(widget->parentWidget()) : 0; if (!view) - return q->items(scenePos, Qt::IntersectsItemShape, Qt::AscendingOrder, QTransform()); + return q->items(scenePos, Qt::IntersectsItemShape, Qt::DescendingOrder, QTransform()); const QRectF pointRect(QPointF(widget->mapFromGlobal(screenPos)), QSizeF(1, 1)); if (!view->isTransformed()) - return q->items(pointRect, Qt::IntersectsItemShape, Qt::AscendingOrder); + return q->items(pointRect, Qt::IntersectsItemShape, Qt::DescendingOrder); const QTransform viewTransform = view->viewportTransform(); if (viewTransform.type() <= QTransform::TxScale) { return q->items(viewTransform.inverted().mapRect(pointRect), Qt::IntersectsItemShape, - Qt::AscendingOrder, viewTransform); + Qt::DescendingOrder, viewTransform); } return q->items(viewTransform.inverted().map(pointRect), Qt::IntersectsItemShape, - Qt::AscendingOrder, viewTransform); + Qt::DescendingOrder, viewTransform); } /*! @@ -1584,7 +1584,7 @@ void QGraphicsScene::setItemIndexMethod(ItemIndexMethod method) d->indexMethod = method; - QList oldItems = d->index->items(Qt::AscendingOrder); + QList oldItems = d->index->items(Qt::DescendingOrder); delete d->index; if (method == BspTreeIndex) d->index = new QGraphicsSceneBspTreeIndex(this); @@ -1693,7 +1693,7 @@ QRectF QGraphicsScene::itemsBoundingRect() const QList QGraphicsScene::items() const { Q_D(const QGraphicsScene); - return d->index->items(Qt::AscendingOrder); + return d->index->items(Qt::DescendingOrder); } /*! @@ -1724,7 +1724,7 @@ QList QGraphicsScene::items(Qt::SortOrder order) const QList QGraphicsScene::items(const QPointF &pos) const { Q_D(const QGraphicsScene); - return d->index->items(pos, Qt::IntersectsItemShape, Qt::AscendingOrder); + return d->index->items(pos, Qt::IntersectsItemShape, Qt::DescendingOrder); } /*! @@ -1746,7 +1746,7 @@ QList QGraphicsScene::items(const QPointF &pos) const QList QGraphicsScene::items(const QRectF &rectangle, Qt::ItemSelectionMode mode) const { Q_D(const QGraphicsScene); - return d->index->items(rectangle, mode, Qt::AscendingOrder); + return d->index->items(rectangle, mode, Qt::DescendingOrder); } /*! @@ -1794,7 +1794,7 @@ QList QGraphicsScene::items(const QRectF &rectangle, Qt::ItemSe QList QGraphicsScene::items(const QPolygonF &polygon, Qt::ItemSelectionMode mode) const { Q_D(const QGraphicsScene); - return d->index->items(polygon, mode, Qt::AscendingOrder); + return d->index->items(polygon, mode, Qt::DescendingOrder); } /*! @@ -1816,7 +1816,7 @@ QList QGraphicsScene::items(const QPolygonF &polygon, Qt::ItemS QList QGraphicsScene::items(const QPainterPath &path, Qt::ItemSelectionMode mode) const { Q_D(const QGraphicsScene); - return d->index->items(path, mode, Qt::AscendingOrder); + return d->index->items(path, mode, Qt::DescendingOrder); } /*! @@ -1928,7 +1928,7 @@ QList QGraphicsScene::collidingItems(const QGraphicsItem *item, // Does not support ItemIgnoresTransformations. QList tmp; - foreach (QGraphicsItem *itemInVicinity, d->index->estimateItems(item->sceneBoundingRect(), Qt::AscendingOrder)) { + foreach (QGraphicsItem *itemInVicinity, d->index->estimateItems(item->sceneBoundingRect(), Qt::DescendingOrder)) { if (item != itemInVicinity && item->collidesWithItem(itemInVicinity, mode)) tmp << itemInVicinity; } @@ -1972,7 +1972,7 @@ QGraphicsItem *QGraphicsScene::itemAt(const QPointF &position) const QGraphicsItem *QGraphicsScene::itemAt(const QPointF &position, const QTransform &deviceTransform) const { QList itemsAtPoint = items(position, Qt::IntersectsItemShape, - Qt::AscendingOrder, deviceTransform); + Qt::DescendingOrder, deviceTransform); return itemsAtPoint.isEmpty() ? 0 : itemsAtPoint.first(); } @@ -2127,7 +2127,7 @@ void QGraphicsScene::setSelectionArea(const QPainterPath &path, Qt::ItemSelectio bool changed = false; // Set all items in path to selected. - foreach (QGraphicsItem *item, items(path, mode, Qt::AscendingOrder, deviceTransform)) { + foreach (QGraphicsItem *item, items(path, mode, Qt::DescendingOrder, deviceTransform)) { if (item->flags() & QGraphicsItem::ItemIsSelectable) { if (!item->isSelected()) changed = true; @@ -4371,7 +4371,7 @@ void QGraphicsScenePrivate::drawItems(QPainter *painter, const QTransform *const if (viewTransform) exposedSceneRect = viewTransform->inverted().mapRect(exposedSceneRect); } - const QList tli = index->estimateTopLevelItems(exposedSceneRect, Qt::DescendingOrder); + const QList tli = index->estimateTopLevelItems(exposedSceneRect, Qt::AscendingOrder); for (int i = 0; i < tli.size(); ++i) drawSubtreeRecursive(tli.at(i), painter, viewTransform, exposedRegion, widget); } diff --git a/src/gui/graphicsview/qgraphicsscenebsptreeindex.cpp b/src/gui/graphicsview/qgraphicsscenebsptreeindex.cpp index 7c46144..e21183a 100644 --- a/src/gui/graphicsview/qgraphicsscenebsptreeindex.cpp +++ b/src/gui/graphicsview/qgraphicsscenebsptreeindex.cpp @@ -480,23 +480,23 @@ void QGraphicsSceneBspTreeIndexPrivate::sortItems(QList *itemLi return; if (onlyTopLevelItems) { - if (order == Qt::AscendingOrder) + if (order == Qt::DescendingOrder) qSort(itemList->begin(), itemList->end(), qt_closestLeaf); - else if (order == Qt::DescendingOrder) + else if (order == Qt::AscendingOrder) qSort(itemList->begin(), itemList->end(), qt_notclosestLeaf); return; } if (sortCacheEnabled) { - if (order == Qt::AscendingOrder) { + if (order == Qt::DescendingOrder) { qSort(itemList->begin(), itemList->end(), closestItemFirst_withCache); - } else if (order == Qt::DescendingOrder) { + } else if (order == Qt::AscendingOrder) { qSort(itemList->begin(), itemList->end(), closestItemLast_withCache); } } else { - if (order == Qt::AscendingOrder) { + if (order == Qt::DescendingOrder) { qSort(itemList->begin(), itemList->end(), closestItemFirst_withoutCache); - } else if (order == Qt::DescendingOrder) { + } else if (order == Qt::AscendingOrder) { qSort(itemList->begin(), itemList->end(), closestItemLast_withoutCache); } } @@ -605,7 +605,7 @@ QList QGraphicsSceneBspTreeIndex::estimateTopLevelItems(const Q } /*! - \fn QList QGraphicsSceneBspTreeIndex::items(Qt::SortOrder order = Qt::AscendingOrder) const; + \fn QList QGraphicsSceneBspTreeIndex::items(Qt::SortOrder order = Qt::DescendingOrder) const; Return all items in the BSP index and sort them using \a order. */ diff --git a/src/gui/graphicsview/qgraphicsscenebsptreeindex_p.h b/src/gui/graphicsview/qgraphicsscenebsptreeindex_p.h index cf85ba8..0a86bb7 100644 --- a/src/gui/graphicsview/qgraphicsscenebsptreeindex_p.h +++ b/src/gui/graphicsview/qgraphicsscenebsptreeindex_p.h @@ -81,7 +81,7 @@ public: QList estimateItems(const QRectF &rect, Qt::SortOrder order) const; QList estimateTopLevelItems(const QRectF &rect, Qt::SortOrder order) const; - QList items(Qt::SortOrder order = Qt::AscendingOrder) const; + QList items(Qt::SortOrder order = Qt::DescendingOrder) const; int bspTreeDepth(); void setBspTreeDepth(int depth); diff --git a/src/gui/graphicsview/qgraphicssceneindex.cpp b/src/gui/graphicsview/qgraphicssceneindex.cpp index e01ad10..3ea957f 100644 --- a/src/gui/graphicsview/qgraphicssceneindex.cpp +++ b/src/gui/graphicsview/qgraphicssceneindex.cpp @@ -542,7 +542,7 @@ QList QGraphicsSceneIndex::estimateTopLevelItems(const QRectF & Q_UNUSED(rect); QGraphicsScenePrivate *scened = d->scene->d_func(); scened->ensureSortedTopLevelItems(); - if (order == Qt::AscendingOrder) { + if (order == Qt::DescendingOrder) { QList sorted; for (int i = scened->topLevelItems.size() - 1; i >= 0; --i) sorted << scened->topLevelItems.at(i); @@ -552,7 +552,7 @@ QList QGraphicsSceneIndex::estimateTopLevelItems(const QRectF & } /*! - \fn QList QGraphicsSceneIndex::items(Qt::SortOrder order = Qt::AscendingOrder) const + \fn QList QGraphicsSceneIndex::items(Qt::SortOrder order = Qt::DescendingOrder) const This pure virtual function all items in the index and sort them using \a order. diff --git a/src/gui/graphicsview/qgraphicssceneindex_p.h b/src/gui/graphicsview/qgraphicssceneindex_p.h index ab7b38c..768c724 100644 --- a/src/gui/graphicsview/qgraphicssceneindex_p.h +++ b/src/gui/graphicsview/qgraphicssceneindex_p.h @@ -88,7 +88,7 @@ public: QGraphicsScene *scene() const; - virtual QList items(Qt::SortOrder order = Qt::AscendingOrder) const = 0; + virtual QList items(Qt::SortOrder order = Qt::DescendingOrder) const = 0; virtual QList items(const QPointF &pos, Qt::ItemSelectionMode mode, Qt::SortOrder order, const QTransform &deviceTransform = QTransform()) const; virtual QList items(const QRectF &rect, Qt::ItemSelectionMode mode, @@ -154,10 +154,10 @@ inline void QGraphicsSceneIndexPrivate::items_helper(const QRectF &rect, QGraphi Qt::ItemSelectionMode mode, Qt::SortOrder order) const { Q_Q(const QGraphicsSceneIndex); - const QList tli = q->estimateTopLevelItems(rect, Qt::DescendingOrder); + const QList tli = q->estimateTopLevelItems(rect, Qt::AscendingOrder); for (int i = 0; i < tli.size(); ++i) recursive_items_helper(tli.at(i), rect, intersector, items, viewTransform, mode, order); - if (order == Qt::AscendingOrder) { + if (order == Qt::DescendingOrder) { const int n = items->size(); for (int i = 0; i < n / 2; ++i) items->swap(i, n - i - 1); diff --git a/src/gui/graphicsview/qgraphicsscenelinearindex.cpp b/src/gui/graphicsview/qgraphicsscenelinearindex.cpp index 70fed64..d6faf05 100644 --- a/src/gui/graphicsview/qgraphicsscenelinearindex.cpp +++ b/src/gui/graphicsview/qgraphicsscenelinearindex.cpp @@ -62,7 +62,7 @@ */ /*! - \fn QList QGraphicsSceneLinearIndex::items(Qt::SortOrder order = Qt::AscendingOrder) const; + \fn QList QGraphicsSceneLinearIndex::items(Qt::SortOrder order = Qt::DescendingOrder) const; Return all items in the index and sort them using \a order. */ diff --git a/src/gui/graphicsview/qgraphicsscenelinearindex_p.h b/src/gui/graphicsview/qgraphicsscenelinearindex_p.h index 4c4aa9f..0aaee14 100644 --- a/src/gui/graphicsview/qgraphicsscenelinearindex_p.h +++ b/src/gui/graphicsview/qgraphicsscenelinearindex_p.h @@ -76,7 +76,7 @@ public: QGraphicsSceneLinearIndex(QGraphicsScene *scene = 0) : QGraphicsSceneIndex(scene) { } - QList items(Qt::SortOrder order = Qt::AscendingOrder) const + QList items(Qt::SortOrder order = Qt::DescendingOrder) const { Q_UNUSED(order); return m_items; } virtual QList estimateItems(const QRectF &rect, Qt::SortOrder order) const diff --git a/src/gui/graphicsview/qgraphicsview.cpp b/src/gui/graphicsview/qgraphicsview.cpp index b0829c5..98b2c9c 100644 --- a/src/gui/graphicsview/qgraphicsview.cpp +++ b/src/gui/graphicsview/qgraphicsview.cpp @@ -971,7 +971,7 @@ QList QGraphicsViewPrivate::findItems(const QRegion &exposedReg *allItems = true; // All items are guaranteed within the exposed region. - return scene->items(Qt::DescendingOrder); + return scene->items(Qt::AscendingOrder); } // Step 2) If the expose region is a simple rect and the view is only @@ -981,7 +981,7 @@ QList QGraphicsViewPrivate::findItems(const QRegion &exposedReg if (simpleRectLookup) { return scene->items(exposedRegionSceneBounds, Qt::IntersectsItemBoundingRect, - Qt::DescendingOrder, viewTransform); + Qt::AscendingOrder, viewTransform); } // If the region is complex or the view has a complex transform, adjust @@ -993,7 +993,7 @@ QList QGraphicsViewPrivate::findItems(const QRegion &exposedReg const QPainterPath exposedScenePath(q->mapToScene(qt_regionToPath(adjustedRegion))); return scene->items(exposedScenePath, Qt::IntersectsItemBoundingRect, - Qt::DescendingOrder, viewTransform); + Qt::AscendingOrder, viewTransform); } /*! @@ -2055,13 +2055,13 @@ QList QGraphicsView::items(const QPoint &pos) const QTransform xinv = viewportTransform().inverted(); return d->scene->items(xinv.mapRect(QRectF(pos.x(), pos.y(), 1, 1)), Qt::IntersectsItemShape, - Qt::AscendingOrder, + Qt::DescendingOrder, viewportTransform()); } // Use the polygon version return d->scene->items(mapToScene(pos.x(), pos.y(), 1, 1), Qt::IntersectsItemShape, - Qt::AscendingOrder, + Qt::DescendingOrder, viewportTransform()); } @@ -2089,7 +2089,7 @@ QList QGraphicsView::items(const QRect &rect, Qt::ItemSelection Q_D(const QGraphicsView); if (!d->scene) return QList(); - return d->scene->items(mapToScene(rect), mode, Qt::AscendingOrder, viewportTransform()); + return d->scene->items(mapToScene(rect), mode, Qt::DescendingOrder, viewportTransform()); } /*! @@ -2117,7 +2117,7 @@ QList QGraphicsView::items(const QPolygon &polygon, Qt::ItemSel Q_D(const QGraphicsView); if (!d->scene) return QList(); - return d->scene->items(mapToScene(polygon), mode, Qt::AscendingOrder, viewportTransform()); + return d->scene->items(mapToScene(polygon), mode, Qt::DescendingOrder, viewportTransform()); } /*! @@ -2137,7 +2137,7 @@ QList QGraphicsView::items(const QPainterPath &path, Qt::ItemSe Q_D(const QGraphicsView); if (!d->scene) return QList(); - return d->scene->items(mapToScene(path), mode, Qt::AscendingOrder, viewportTransform()); + return d->scene->items(mapToScene(path), mode, Qt::DescendingOrder, viewportTransform()); } /*! -- cgit v0.12 From b089f0e17dab094ce99dc8edd385cbef0bc212c4 Mon Sep 17 00:00:00 2001 From: Benjamin Poulain Date: Tue, 22 Sep 2009 17:51:47 +0200 Subject: Fix tst_QFileInfo::isHidden_data() with /bin on Mac OS X On Mac OS X, the directory /bin is hidden because it does not have the "Visible" attribute in the filesystem. --- tests/auto/qfileinfo/tst_qfileinfo.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/auto/qfileinfo/tst_qfileinfo.cpp b/tests/auto/qfileinfo/tst_qfileinfo.cpp index 71e38df..7c320ff 100644 --- a/tests/auto/qfileinfo/tst_qfileinfo.cpp +++ b/tests/auto/qfileinfo/tst_qfileinfo.cpp @@ -1049,7 +1049,10 @@ void tst_QFileInfo::isHidden_data() QTest::newRow("~/.qt/..") << QDir::homePath() + QString("/.qt/..") << false; #endif -#if !defined(Q_OS_WIN) && !defined(Q_OS_SYMBIAN) +#if defined(Q_OS_MAC) + // /bin has the hidden attribute on Mac OS X + QTest::newRow("/bin/") << QString::fromLatin1("/bin/") << true; +#elif !defined(Q_OS_WIN) && !defined(Q_OS_SYMBIAN) QTest::newRow("/bin/") << QString::fromLatin1("/bin/") << false; #endif -- cgit v0.12 From 58cc8cb5c86d2d51d0f647457e3677541c4a93c2 Mon Sep 17 00:00:00 2001 From: Daniel Molkentin Date: Fri, 18 Sep 2009 18:17:29 +0200 Subject: Docs: Fix spelling and reword docs about S60 specifics. Reviewed-By: TrustMe --- doc/src/howtos/appicon.qdoc | 9 +++++---- mkspecs/features/symbian/application_icon.prf | 5 +++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/doc/src/howtos/appicon.qdoc b/doc/src/howtos/appicon.qdoc index ba567b7..ece2dcf 100644 --- a/doc/src/howtos/appicon.qdoc +++ b/doc/src/howtos/appicon.qdoc @@ -215,12 +215,13 @@ \section1 Setting the Application Icon on S60 platforms - In order to set application icon for S60 application you need SVG-T icon. - How to create such SVG-T, please refer to + In order to set the application icon for S60 applications, you need + an SVG-T icon. For information on how to create SVG-T compliant icons, + please refer to \l{http://wiki.forum.nokia.com/index.php/How_to_create_application_icon(SVG)_in_S60_3rd_edition/} - Once you have icon in correct format and assuming you are using - \c qmake to generate your makefiles, you only need to add a single + Once the icon is available in the correct format and assuming you are + using \c qmake to generate your makefiles, you only need to add a single line to your \c .pro project file. For example, if the name of your icon file is \c{myapp.svg}, and your project file is \c{myapp.pro}, add this line to \c{myapp.pro}: diff --git a/mkspecs/features/symbian/application_icon.prf b/mkspecs/features/symbian/application_icon.prf index 97b99a5..b0c1bb1 100644 --- a/mkspecs/features/symbian/application_icon.prf +++ b/mkspecs/features/symbian/application_icon.prf @@ -6,7 +6,7 @@ contains( CONFIG, no_icon ) { symbian:RSS_RULES ="hidden = KAppIsHidden;" CONFIG -= no_icon } else { -# There is no sense to compile MIF icon is no_icon CONFIGS is set +# There is no point in compiling the MIF icon if no_icon CONFIGS is set !isEmpty(ICON) { !count(ICON, $$size(TRANSLATIONS)):!count(ICON, 1) { @@ -36,4 +36,5 @@ contains( CONFIG, no_icon ) { RSS_RULES.number_of_icons = $$size(ICON) RSS_RULES.icon_file = $$replace( APP_RESOURCE_DIR, /, \\\\ )\\\\$${TARGET.UID3}.mif } -} \ No newline at end of file +} + -- cgit v0.12 From c079a392306df4a273e511e7ce08d94d79319d36 Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Tue, 22 Sep 2009 18:06:22 +0200 Subject: Fix "make sis" target for -xplatform symbian-sbsv2 CFG_PATH evaluates as "udeb", not "UDEB" when building the debug-armv5 target. So changed the FLM to check for that. Also changed the variable redefinition to ifeq/else/endif. Reviewed-by: Iain --- mkspecs/symbian-sbsv2/flm/qt/qmake_store_build.flm | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mkspecs/symbian-sbsv2/flm/qt/qmake_store_build.flm b/mkspecs/symbian-sbsv2/flm/qt/qmake_store_build.flm index 0abc7c4..7fada1e 100644 --- a/mkspecs/symbian-sbsv2/flm/qt/qmake_store_build.flm +++ b/mkspecs/symbian-sbsv2/flm/qt/qmake_store_build.flm @@ -12,9 +12,10 @@ include $(FLMHOME)/metaflm.mk STORE_BUILD_TARGET:=$(call sanitise,TSTORE_BUILD_$(PLATFORM_PATH)_$(CFG_PATH)_$(EXTENSION_ROOT)) CACHE_FILENAME:=$(EXTENSION_ROOT)/.make.cache -VISUAL_CFG:=RELEASE -ifeq "$(CFG_PATH)" "UDEB" +ifeq "$(CFG_PATH)" "udeb" VISUAL_CFG:=DEBUG +else +VISUAL_CFG:=RELEASE endif define qmake_store_build -- cgit v0.12 From 2fafc136542a4aea51d1aee3e0d07374b1f52b41 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Tue, 22 Sep 2009 17:03:47 +0200 Subject: QPixMap::fromWinHICON compile fix for Windows CE Reviewed-by: thartman --- src/gui/image/qpixmap_win.cpp | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/gui/image/qpixmap_win.cpp b/src/gui/image/qpixmap_win.cpp index a9bcca2..87cb46c 100644 --- a/src/gui/image/qpixmap_win.cpp +++ b/src/gui/image/qpixmap_win.cpp @@ -393,6 +393,7 @@ QPixmap QPixmap::fromWinHICON(HICON icon) int w = iconinfo.xHotspot * 2; int h = iconinfo.yHotspot * 2; + const DWORD dwImageSize = w * h * 4; BITMAPINFO bmi; memset(&bmi, 0, sizeof(bmi)); @@ -402,44 +403,44 @@ QPixmap QPixmap::fromWinHICON(HICON icon) bmi.bmiHeader.biPlanes = 1; bmi.bmiHeader.biBitCount = 32; bmi.bmiHeader.biCompression = BI_RGB; - bmi.bmiHeader.biSizeImage = size*size*4; + bmi.bmiHeader.biSizeImage = dwImageSize; uchar* bits; HBITMAP winBitmap = CreateDIBSection(hdc, &bmi, DIB_RGB_COLORS, (void**) &bits, 0, 0); if (winBitmap ) - memset(bits, 0xff, size*size*4); + memset(bits, 0xff, dwImageSize); if (!winBitmap) { qWarning("QPixmap::fromWinHICON(), failed to CreateDIBSection()"); return QPixmap(); } HGDIOBJ oldhdc = (HBITMAP)SelectObject(hdc, winBitmap); - if (!DrawIconEx( hdc, 0, 0, icon, size, size, 0, 0, DI_NORMAL)) + if (!DrawIconEx( hdc, 0, 0, icon, w, h, 0, 0, DI_NORMAL)) qWarning("QPixmap::fromWinHICON(), failed to DrawIcon()"); uint mask = 0xff000000; // Create image and copy data into image. - QImage image(size, size, QImage::Format_ARGB32); + QImage image(w, h, QImage::Format_ARGB32); if (!image.isNull()) { // failed to alloc? - int bytes_per_line = size * sizeof(QRgb); - for (int y=0; y Date: Tue, 22 Sep 2009 18:10:07 +0200 Subject: fix QPixmap::fromWinHICON for Windows CE mobile On WinCE GetIconInfo returns a 0 hotspot for the system icons, thus we cannot use this value to determine width / height of the icon. Instead, we use the icon's bitmap to get this information. --- src/gui/image/qpixmap_win.cpp | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/src/gui/image/qpixmap_win.cpp b/src/gui/image/qpixmap_win.cpp index 87cb46c..1b61484 100644 --- a/src/gui/image/qpixmap_win.cpp +++ b/src/gui/image/qpixmap_win.cpp @@ -387,12 +387,29 @@ QPixmap QPixmap::fromWinHICON(HICON icon) ReleaseDC(0, screenDevice); ICONINFO iconinfo; - bool result = GetIconInfo(icon, &iconinfo); //x and y Hotspot describes the icon center + bool result = GetIconInfo(icon, &iconinfo); if (!result) qWarning("QPixmap::fromWinHICON(), failed to GetIconInfo()"); - int w = iconinfo.xHotspot * 2; - int h = iconinfo.yHotspot * 2; + int w = 0; + int h = 0; + if (!iconinfo.xHotspot || !iconinfo.yHotspot) { + // We could not retrieve the icon size via GetIconInfo, + // so we try again using the icon bitmap. + BITMAP bm; + int result = GetObject(iconinfo.hbmColor, sizeof(BITMAP), &bm); + if (!result) result = GetObject(iconinfo.hbmMask, sizeof(BITMAP), &bm); + if (!result) { + qWarning("QPixmap::fromWinHICON(), failed to retrieve icon size"); + return QPixmap(); + } + w = bm.bmWidth; + h = bm.bmHeight; + } else { + // x and y Hotspot describes the icon center + w = iconinfo.xHotspot * 2; + h = iconinfo.yHotspot * 2; + } const DWORD dwImageSize = w * h * 4; BITMAPINFO bmi; -- cgit v0.12 From a2a4e1c9fa5b3ffb151029735eb89e3708572928 Mon Sep 17 00:00:00 2001 From: Benjamin Poulain Date: Tue, 22 Sep 2009 18:21:48 +0200 Subject: Fix the test tst_QCoreApplication::sendEventsOnProcessEvents() The test is failing when Qt is compiled with Qt 3 support. Qt 3 support send events for the insertion of the new child. --- tests/auto/qcoreapplication/tst_qcoreapplication.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/auto/qcoreapplication/tst_qcoreapplication.cpp b/tests/auto/qcoreapplication/tst_qcoreapplication.cpp index 4b38044..c5f06e2 100644 --- a/tests/auto/qcoreapplication/tst_qcoreapplication.cpp +++ b/tests/auto/qcoreapplication/tst_qcoreapplication.cpp @@ -84,9 +84,7 @@ void tst_QCoreApplication::sendEventsOnProcessEvents() QCoreApplication::postEvent(&app, new QEvent(QEvent::Type(QEvent::User + 1))); QCoreApplication::processEvents(); - QList expected; - expected << QEvent::User + 1; - QCOMPARE(expected, spy.recordedEvents); + QVERIFY(spy.recordedEvents.contains(QEvent::User + 1)); } void tst_QCoreApplication::getSetCheck() -- cgit v0.12 From 074c697177ea699e55970f7678b558f335984782 Mon Sep 17 00:00:00 2001 From: Benjamin Poulain Date: Tue, 22 Sep 2009 18:34:10 +0200 Subject: Add a test for the first ::processEvents() on QApplication The test of ea0c0dfa64f5c614bfd728f323d9b6731ee4898c is not valid for the change introduced in that commit. QCoreApplication does not use the event loop of Cocoa. This is the same test in QApplication. --- tests/auto/qapplication/tst_qapplication.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/tests/auto/qapplication/tst_qapplication.cpp b/tests/auto/qapplication/tst_qapplication.cpp index 2ba5239..c53fca8 100644 --- a/tests/auto/qapplication/tst_qapplication.cpp +++ b/tests/auto/qapplication/tst_qapplication.cpp @@ -84,6 +84,7 @@ public slots: void init(); void cleanup(); private slots: + void sendEventsOnProcessEvents(); // this must be the first test void getSetCheck(); void staticSetup(); @@ -137,6 +138,32 @@ private slots: void touchEventPropagation(); }; +class EventSpy : public QObject +{ + Q_OBJECT + +public: + QList recordedEvents; + bool eventFilter(QObject *, QEvent *event) + { + recordedEvents.append(event->type()); + return false; + } +}; + +void tst_QApplication::sendEventsOnProcessEvents() +{ + int argc = 0; + QApplication app(argc, 0); + + EventSpy spy; + app.installEventFilter(&spy); + + QCoreApplication::postEvent(&app, new QEvent(QEvent::Type(QEvent::User + 1))); + QCoreApplication::processEvents(); + QVERIFY(spy.recordedEvents.contains(QEvent::User + 1)); +} + class MyInputContext : public QInputContext { public: -- cgit v0.12 From 0d8d7427c8cc0d9b47a81ca8343773b0481b87ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Tue, 22 Sep 2009 17:42:43 +0200 Subject: Fix QFileInfo autotest to run from a shadow build Also, don't depend on the existence of ~/.qt/ Reviewed-by: Olivier Goffart --- tests/auto/qfileinfo/qfileinfo.pro | 10 +++ tests/auto/qfileinfo/tst_qfileinfo.cpp | 115 +++++++++++++++++++++++---------- 2 files changed, 90 insertions(+), 35 deletions(-) diff --git a/tests/auto/qfileinfo/qfileinfo.pro b/tests/auto/qfileinfo/qfileinfo.pro index c3be825..93599f4 100644 --- a/tests/auto/qfileinfo/qfileinfo.pro +++ b/tests/auto/qfileinfo/qfileinfo.pro @@ -17,3 +17,13 @@ symbian { TARGET.CAPABILITY=AllFiles LIBS *= -lefsrv } + +# support for running test from shadow build directory +wince* { + DEFINES += SRCDIR=\\\"\\\" +} else:symbian { + # do not define SRCDIR at all +} else { + DEFINES += SRCDIR=\\\"$$PWD/\\\" +} + diff --git a/tests/auto/qfileinfo/tst_qfileinfo.cpp b/tests/auto/qfileinfo/tst_qfileinfo.cpp index 7c320ff..21edbcf 100644 --- a/tests/auto/qfileinfo/tst_qfileinfo.cpp +++ b/tests/auto/qfileinfo/tst_qfileinfo.cpp @@ -66,6 +66,10 @@ #include "../network-settings.h" #include +#if defined(Q_OS_SYMBIAN) +# define SRCDIR "" +#endif + //TESTED_CLASS= //TESTED_FILES= @@ -183,6 +187,12 @@ tst_QFileInfo::~tst_QFileInfo() #ifdef Q_OS_SYMBIAN QFile::remove("hidden.txt"); QFile::remove("nothidden.txt"); +#else + QFile::remove("tempfile.txt"); +#endif + +#if defined(Q_OS_UNIX) && !defined(Q_OS_SYMBIAN) + QDir().rmdir("./.hidden-directory"); #endif } @@ -254,7 +264,7 @@ void tst_QFileInfo::isFile_data() QTest::addColumn("expected"); QTest::newRow("data0") << QDir::currentPath() << false; - QTest::newRow("data1") << "tst_qfileinfo.cpp" << true; + QTest::newRow("data1") << SRCDIR "tst_qfileinfo.cpp" << true; QTest::newRow("data2") << ":/tst_qfileinfo/resources/" << false; QTest::newRow("data3") << ":/tst_qfileinfo/resources/file1" << true; QTest::newRow("data4") << ":/tst_qfileinfo/resources/afilethatshouldnotexist" << false; @@ -287,13 +297,13 @@ void tst_QFileInfo::isDir_data() QTest::addColumn("expected"); QTest::newRow("data0") << QDir::currentPath() << true; - QTest::newRow("data1") << "tst_qfileinfo.cpp" << false; + QTest::newRow("data1") << SRCDIR "tst_qfileinfo.cpp" << false; QTest::newRow("data2") << ":/tst_qfileinfo/resources/" << true; QTest::newRow("data3") << ":/tst_qfileinfo/resources/file1" << false; QTest::newRow("data4") << ":/tst_qfileinfo/resources/afilethatshouldnotexist" << false; - QTest::newRow("simple dir") << "resources" << true; - QTest::newRow("simple dir with slash") << "resources/" << true; + QTest::newRow("simple dir") << SRCDIR "resources" << true; + QTest::newRow("simple dir with slash") << SRCDIR "resources/" << true; QTest::newRow("broken link") << "brokenlink.lnk" << false; @@ -333,8 +343,8 @@ void tst_QFileInfo::isRoot_data() QTest::newRow("data4") << ":/tst_qfileinfo/resources/" << false; QTest::newRow("data5") << ":/" << true; - QTest::newRow("simple dir") << "resources" << false; - QTest::newRow("simple dir with slash") << "resources/" << false; + QTest::newRow("simple dir") << SRCDIR "resources" << false; + QTest::newRow("simple dir with slash") << SRCDIR "resources/" << false; #if (defined(Q_OS_WIN) && !defined(Q_OS_WINCE)) || defined(Q_OS_SYMBIAN) QTest::newRow("drive 1") << "c:" << false; QTest::newRow("drive 2") << "c:/" << true; @@ -365,20 +375,20 @@ void tst_QFileInfo::exists_data() QTest::addColumn("expected"); QTest::newRow("data0") << QDir::currentPath() << true; - QTest::newRow("data1") << "tst_qfileinfo.cpp" << true; + QTest::newRow("data1") << SRCDIR "tst_qfileinfo.cpp" << true; QTest::newRow("data2") << "/I/do_not_expect_this_path_to_exist/" << false; QTest::newRow("data3") << ":/tst_qfileinfo/resources/" << true; QTest::newRow("data4") << ":/tst_qfileinfo/resources/file1" << true; QTest::newRow("data5") << ":/I/do_not_expect_this_path_to_exist/" << false; - QTest::newRow("data6") << "resources/*" << false; - QTest::newRow("data7") << "resources/*.foo" << false; - QTest::newRow("data8") << "resources/*.ext1" << false; - QTest::newRow("data9") << "resources/file?.ext1" << false; + QTest::newRow("data6") << SRCDIR "resources/*" << false; + QTest::newRow("data7") << SRCDIR "resources/*.foo" << false; + QTest::newRow("data8") << SRCDIR "resources/*.ext1" << false; + QTest::newRow("data9") << SRCDIR "resources/file?.ext1" << false; QTest::newRow("data10") << "." << true; QTest::newRow("data11") << ". " << false; - QTest::newRow("simple dir") << "resources" << true; - QTest::newRow("simple dir with slash") << "resources/" << true; + QTest::newRow("simple dir") << SRCDIR "resources" << true; + QTest::newRow("simple dir with slash") << SRCDIR "resources/" << true; #if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) QTest::newRow("unc 1") << "//" + QtNetworkSettings::winServerName() << true; @@ -507,7 +517,7 @@ void tst_QFileInfo::canonicalFilePath() // test symlinks QFile::remove("link.lnk"); { - QFile file("tst_qfileinfo.cpp"); + QFile file(SRCDIR "tst_qfileinfo.cpp"); if (file.link("link.lnk")) { QFileInfo info1(file); QFileInfo info2("link.lnk"); @@ -521,16 +531,25 @@ void tst_QFileInfo::canonicalFilePath() QFile::remove(link); QFile file(QDir::currentPath()); if (file.link(link)) { - QFileInfo info1("tst_qfileinfo.cpp"); - QFileInfo info2(link + QDir::separator() + "tst_qfileinfo.cpp"); + QFile tempfile("tempfile.txt"); + tempfile.open(QIODevice::ReadWrite); + tempfile.write("This file is generated by the QFileInfo autotest."); + QVERIFY(tempfile.flush()); + tempfile.close(); + + QFileInfo info1("tempfile.txt"); + QFileInfo info2(link + QDir::separator() + "tempfile.txt"); - QVERIFY2(info1.exists(), "If this fails, one reason might be the test system has failed to copy the files."); - QVERIFY2(info2.exists(), "If this fails, one reason might be the test system has failed to copy the files."); + QVERIFY(info1.exists()); + QVERIFY(info2.exists()); QCOMPARE(info1.canonicalFilePath(), info2.canonicalFilePath()); QFileInfo info3(link + QDir::separator() + "link.lnk"); + QFileInfo info4(SRCDIR "tst_qfileinfo.cpp"); QVERIFY(!info3.canonicalFilePath().isEmpty()); - QCOMPARE(info1.canonicalFilePath(), info3.canonicalFilePath()); + QCOMPARE(info4.canonicalFilePath(), info3.canonicalFilePath()); + + tempfile.remove(); } } { @@ -743,7 +762,7 @@ void tst_QFileInfo::permission_data() QTest::addColumn("expected"); QTest::newRow("data0") << QCoreApplication::instance()->applicationFilePath() << int(QFile::ExeUser) << true; - QTest::newRow("data1") << "tst_qfileinfo.cpp" << int(QFile::ReadUser) << true; + QTest::newRow("data1") << SRCDIR "tst_qfileinfo.cpp" << int(QFile::ReadUser) << true; // QTest::newRow("data2") << "tst_qfileinfo.cpp" << int(QFile::WriteUser) << false; QTest::newRow("resource1") << ":/tst_qfileinfo/resources/file1.ext1" << int(QFile::ReadUser) << true; QTest::newRow("resource2") << ":/tst_qfileinfo/resources/file1.ext1" << int(QFile::WriteUser) << false; @@ -803,16 +822,25 @@ void tst_QFileInfo::compare_data() QTest::addColumn("file2"); QTest::addColumn("same"); - QTest::newRow("data0") << QString::fromLatin1("tst_qfileinfo.cpp") << QString::fromLatin1("tst_qfileinfo.cpp") << true; - QTest::newRow("data1") << QString::fromLatin1("tst_qfileinfo.cpp") << QString::fromLatin1("/tst_qfileinfo.cpp") << false; - QTest::newRow("data2") << QString::fromLatin1("tst_qfileinfo.cpp") - << QDir::currentPath() + QString::fromLatin1("/tst_qfileinfo.cpp") << true; - QTest::newRow("casesense1") << QString::fromLatin1("tst_qfileInfo.cpp") - << QDir::currentPath() + QString::fromLatin1("/tst_qfileinfo.cpp") + QTest::newRow("data0") + << QString::fromLatin1(SRCDIR "tst_qfileinfo.cpp") + << QString::fromLatin1(SRCDIR "tst_qfileinfo.cpp") + << true; + QTest::newRow("data1") + << QString::fromLatin1(SRCDIR "tst_qfileinfo.cpp") + << QString::fromLatin1("/tst_qfileinfo.cpp") + << false; + QTest::newRow("data2") + << QString::fromLatin1("tst_qfileinfo.cpp") + << QDir::currentPath() + QString::fromLatin1("/tst_qfileinfo.cpp") + << true; + QTest::newRow("casesense1") + << QString::fromLatin1(SRCDIR "tst_qfileInfo.cpp") + << QString::fromLatin1(SRCDIR "tst_qfileinfo.cpp") #if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN) - << true; + << true; #else - << false; + << false; #endif } @@ -994,7 +1022,7 @@ void tst_QFileInfo::isSymLink_data() QFile::remove("brokenlink.lnk"); QFile::remove("dummyfile"); - QFile file1("tst_qfileinfo.cpp"); + QFile file1(SRCDIR "tst_qfileinfo.cpp"); QVERIFY(file1.link("link.lnk")); QFile file2("dummyfile"); @@ -1006,8 +1034,8 @@ void tst_QFileInfo::isSymLink_data() QTest::addColumn("isSymLink"); QTest::addColumn("linkTarget"); - QTest::newRow("existent file") << "tst_qfileinfo.cpp" << false << ""; - QTest::newRow("link") << "link.lnk" << true << QFileInfo("tst_qfileinfo.cpp").absoluteFilePath(); + QTest::newRow("existent file") << SRCDIR "tst_qfileinfo.cpp" << false << ""; + QTest::newRow("link") << "link.lnk" << true << QFileInfo(SRCDIR "tst_qfileinfo.cpp").absoluteFilePath(); QTest::newRow("broken link") << "brokenlink.lnk" << true << QFileInfo("dummyfile").absoluteFilePath(); #if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) @@ -1044,9 +1072,18 @@ void tst_QFileInfo::isHidden_data() QTest::newRow("C:/RECYCLER/..") << QString::fromLatin1("C:/RECYCLER/..") << false; #endif #if defined(Q_OS_UNIX) && !defined(Q_OS_SYMBIAN) - QTest::newRow("~/.qt") << QDir::homePath() + QString("/.qt") << true; - QTest::newRow("~/.qt/.") << QDir::homePath() + QString("/.qt/.") << false; - QTest::newRow("~/.qt/..") << QDir::homePath() + QString("/.qt/..") << false; + + if (!QDir("./.hidden-directory").exists() + && !QDir().mkdir("./.hidden-directory")) + qWarning("Unable to create directory './.hidden-directory'. Some tests will fail."); + + QTest::newRow("./.hidden-directory") << QString("./.hidden-directory") << true; + QTest::newRow("./.hidden-directory/.") << QString("./.hidden-directory/.") << false; + QTest::newRow("./.hidden-directory/..") << QString("./.hidden-directory/..") << false; + + QTest::newRow("/path/to/.hidden-directory") << QDir::currentPath() + QString("/.hidden-directory") << true; + QTest::newRow("/path/to/.hidden-directory/.") << QDir::currentPath() + QString("/.hidden-directory/.") << false; + QTest::newRow("/path/to/.hidden-directory/..") << QDir::currentPath() + QString("/.hidden-directory/..") << false; #endif #if defined(Q_OS_MAC) @@ -1107,6 +1144,7 @@ void tst_QFileInfo::isHidden() QFETCH(QString, path); QFETCH(bool, isHidden); QFileInfo fi(path); + QCOMPARE(fi.isHidden(), isHidden); } @@ -1223,7 +1261,14 @@ void tst_QFileInfo::isWritable() QSKIP("Currently skipped on Symbian OS, but surely there is a writeable file somewhere???", SkipAll); #endif - QVERIFY(QFileInfo("tst_qfileinfo.cpp").isWritable()); + QFile tempfile("tempfile.txt"); + tempfile.open(QIODevice::WriteOnly); + tempfile.write("This file is generated by the QFileInfo autotest."); + tempfile.close(); + + QVERIFY(QFileInfo("tempfile.txt").isWritable()); + tempfile.remove(); + #ifdef Q_OS_WIN #ifdef Q_OS_WINCE QFileInfo fi("\\Windows\\wince.nls"); -- cgit v0.12 From 0691350e14632dea6c12a2d37e605dc0628b4ceb Mon Sep 17 00:00:00 2001 From: gunnar Date: Tue, 22 Sep 2009 07:34:51 +0200 Subject: Fixed crash in QFileSystemWatcher for addPath(nonExistingFile) Reviewed-by: Eskil --- src/corelib/io/qfilesystemwatcher_fsevents.cpp | 6 ++++++ tests/auto/qfilesystemwatcher/tst_qfilesystemwatcher.cpp | 10 ++++++++++ 2 files changed, 16 insertions(+) diff --git a/src/corelib/io/qfilesystemwatcher_fsevents.cpp b/src/corelib/io/qfilesystemwatcher_fsevents.cpp index f648016..be2125a 100644 --- a/src/corelib/io/qfilesystemwatcher_fsevents.cpp +++ b/src/corelib/io/qfilesystemwatcher_fsevents.cpp @@ -223,6 +223,11 @@ QStringList QFSEventsFileSystemWatcherEngine::addPaths(const QStringList &paths, } } } + + if (!pathsToWatch && failedToAdd.size() == paths.size()) { + return failedToAdd; + } + if (CFArrayGetCount(tmpArray) > 0) { if (pathsToWatch) { CFArrayAppendArray(tmpArray, pathsToWatch, CFRangeMake(0, CFArrayGetCount(pathsToWatch))); @@ -230,6 +235,7 @@ QStringList QFSEventsFileSystemWatcherEngine::addPaths(const QStringList &paths, } pathsToWatch = CFArrayCreateCopy(kCFAllocatorDefault, tmpArray); } + FSEventStreamContext context = { 0, this, 0, 0, 0 }; fsStream = FSEventStreamCreate(kCFAllocatorDefault, QFSEventsFileSystemWatcherEngine::fseventsCallback, diff --git a/tests/auto/qfilesystemwatcher/tst_qfilesystemwatcher.cpp b/tests/auto/qfilesystemwatcher/tst_qfilesystemwatcher.cpp index 9ab9d79..489a1ed 100644 --- a/tests/auto/qfilesystemwatcher/tst_qfilesystemwatcher.cpp +++ b/tests/auto/qfilesystemwatcher/tst_qfilesystemwatcher.cpp @@ -77,6 +77,8 @@ private slots: void watchFileAndItsDirectory_data() { basicTest_data(); } void watchFileAndItsDirectory(); + void nonExistingFile(); + void cleanup(); private: QStringList do_force_engines; @@ -525,5 +527,13 @@ void tst_QFileSystemWatcher::cleanup() QDir().rmdir("testDir"); } +void tst_QFileSystemWatcher::nonExistingFile() +{ + // Don't crash... + QFileSystemWatcher watcher; + watcher.addPath("file_that_does_not_exist.txt"); + QVERIFY(true); +} + QTEST_MAIN(tst_QFileSystemWatcher) #include "tst_qfilesystemwatcher.moc" -- cgit v0.12 From f5d6022f4ca4af32de2b683dfb9f41173e7c8934 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Tue, 22 Sep 2009 18:56:24 +0200 Subject: Stabilize more test --- tests/auto/q3table/tst_q3table.cpp | 2 ++ tests/auto/q3textbrowser/tst_q3textbrowser.cpp | 4 +--- tests/auto/qcombobox/tst_qcombobox.cpp | 3 +++ tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp | 6 +++--- .../auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp | 13 ++++--------- tests/auto/qgraphicsview/tst_qgraphicsview.cpp | 13 ++++++++----- 6 files changed, 21 insertions(+), 20 deletions(-) diff --git a/tests/auto/q3table/tst_q3table.cpp b/tests/auto/q3table/tst_q3table.cpp index 44b0edb..1fe4412 100644 --- a/tests/auto/q3table/tst_q3table.cpp +++ b/tests/auto/q3table/tst_q3table.cpp @@ -1201,6 +1201,7 @@ void tst_Q3Table::editCheck() EditCheckQ3Table table(10, 10, 0); table.show(); + QTest::qWaitForWindowShown(&table); table.setCurrentCell(0, 0); #ifdef WAITS QTest::qWait(50); @@ -1378,6 +1379,7 @@ void tst_Q3Table::dateTimeEdit() TimeTableItem *ti = new TimeTableItem(testWidget); testWidget->setItem(0, 0, ti); testWidget->show(); + QTest::qWaitForWindowShown(&testWidget); #ifdef WAITS QTest::qWait(50); #endif diff --git a/tests/auto/q3textbrowser/tst_q3textbrowser.cpp b/tests/auto/q3textbrowser/tst_q3textbrowser.cpp index fd67bb0..9a9f55c 100644 --- a/tests/auto/q3textbrowser/tst_q3textbrowser.cpp +++ b/tests/auto/q3textbrowser/tst_q3textbrowser.cpp @@ -84,9 +84,7 @@ void tst_Q3TextBrowser::initTestCase() testWidget->move(QApplication::desktop()->availableGeometry().topLeft()+QPoint(5, 5)); testWidget->show(); -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(testWidget); -#endif + QTest::qWaitForWindowShown(testWidget); qApp->processEvents(); } diff --git a/tests/auto/qcombobox/tst_qcombobox.cpp b/tests/auto/qcombobox/tst_qcombobox.cpp index 1b1eb1f..b549af6 100644 --- a/tests/auto/qcombobox/tst_qcombobox.cpp +++ b/tests/auto/qcombobox/tst_qcombobox.cpp @@ -1977,11 +1977,14 @@ void tst_QComboBox::task190351_layout() list->addItem(QLatin1String("list") + QString::number(i)); listCombo.show(); + QTest::qWaitForWindowShown(&listCombo); QTRY_VERIFY(listCombo.isVisible()); listCombo.setCurrentIndex(70); listCombo.showPopup(); QTRY_VERIFY(listCombo.view()); + QTest::qWaitForWindowShown(listCombo.view()); QTRY_VERIFY(listCombo.view()->isVisible()); + QApplication::processEvents(); #ifdef QT_BUILD_INTERNAL QFrame *container = qFindChild(&listCombo); diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp index 6f37b70..b0e4b9d 100644 --- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp @@ -6736,10 +6736,10 @@ void tst_QGraphicsItem::updateCachedItemAfterMove() scene.addItem(tester); QGraphicsView view(&scene); view.show(); -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(&view); -#endif + QTest::qWaitForWindowShown(&view); + QTest::qWait(125); + QTRY_VERIFY(tester->repaints > 0); tester->repaints = 0; // Move the item, should not cause repaints diff --git a/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp b/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp index 32b4420..a289257 100644 --- a/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp +++ b/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp @@ -1295,9 +1295,7 @@ void tst_QGraphicsProxyWidget::paintEvent() QGraphicsScene scene; QGraphicsView view(&scene); view.show(); -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(&view); -#endif + QTest::qWaitForWindowShown(&view); SubQGraphicsProxyWidget proxy; @@ -1306,9 +1304,8 @@ void tst_QGraphicsProxyWidget::paintEvent() //this bug prevents the widget from being updated w->show(); -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(w); -#endif + QTest::qWaitForWindowShown(w); + QTest::qWait(100); proxy.setWidget(w); @@ -2719,9 +2716,7 @@ void tst_QGraphicsProxyWidget::windowOpacity() QGraphicsProxyWidget *proxy = scene.addWidget(widget); proxy->setCacheMode(QGraphicsItem::ItemCoordinateCache); view.show(); -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(&view); -#endif + QTest::qWaitForWindowShown(&view); QApplication::sendPostedEvents(); QTest::qWait(100); diff --git a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp index 41f9660..ae00e34 100644 --- a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp +++ b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp @@ -2250,6 +2250,7 @@ void tst_QGraphicsView::viewportUpdateMode2() view.resize(200 + left + right, 200 + top + bottom); view.show(); QTest::qWaitForWindowShown(&view); + QTest::qWait(50); const QRect viewportRect = view.viewport()->rect(); QCOMPARE(viewportRect, QRect(0, 0, 200, 200)); @@ -2911,6 +2912,7 @@ void tst_QGraphicsView::task239729_noViewUpdate() view->show(); QTest::qWaitForWindowShown(view); + QTest::qWait(150); EventSpy spy(view->viewport(), QEvent::Paint); QCOMPARE(spy.count(), 0); @@ -2919,7 +2921,7 @@ void tst_QGraphicsView::task239729_noViewUpdate() QCOMPARE(spy.count(), 0); scene.update(); QTest::qWait(150); - QCOMPARE(spy.count(), 1); + QTRY_COMPARE(spy.count(), 1); delete view; } @@ -3342,7 +3344,7 @@ void tst_QGraphicsView::render() qApp->processEvents(); - QCOMPARE(r1->paints, 1); + QTRY_COMPARE(r1->paints, 1); QCOMPARE(r2->paints, 1); QCOMPARE(r3->paints, 1); QCOMPARE(r4->paints, 1); @@ -3429,14 +3431,15 @@ void tst_QGraphicsView::update() view.resize(200 + left + right, 200 + top + bottom); view.show(); QTest::qWaitForWindowShown(&view); - const QRect viewportRect = view.viewport()->rect(); - QCOMPARE(viewportRect, QRect(0, 0, 200, 200)); -#if defined QT_BUILD_INTERNAL QApplication::setActiveWindow(&view); QTest::qWait(50); QTRY_COMPARE(QApplication::activeWindow(), &view); + const QRect viewportRect = view.viewport()->rect(); + QCOMPARE(viewportRect, QRect(0, 0, 200, 200)); + +#if defined QT_BUILD_INTERNAL const bool intersects = updateRect.intersects(viewportRect); QGraphicsViewPrivate *viewPrivate = static_cast(qt_widget_private(&view)); QCOMPARE(viewPrivate->updateRect(updateRect), intersects); -- cgit v0.12 From adea8ea0dd70a0a33d07e9ada1d0823b5fc637ac Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Tue, 22 Sep 2009 19:19:51 +0200 Subject: Stabilize some tests --- tests/auto/qmenu/tst_qmenu.cpp | 1 + tests/auto/qprogressbar/tst_qprogressbar.cpp | 14 +++++++------- tests/auto/qwindowsurface/tst_qwindowsurface.cpp | 11 ++++------- 3 files changed, 12 insertions(+), 14 deletions(-) diff --git a/tests/auto/qmenu/tst_qmenu.cpp b/tests/auto/qmenu/tst_qmenu.cpp index eee5854..a5bac37 100644 --- a/tests/auto/qmenu/tst_qmenu.cpp +++ b/tests/auto/qmenu/tst_qmenu.cpp @@ -806,6 +806,7 @@ void tst_QMenu::task258920_mouseBorder() QAction *action = menu.addAction("test"); menu.popup(QApplication::desktop()->availableGeometry().center()); + QTest::qWaitForWindowShown(&menu); QTest::qWait(100); QRect actionRect = menu.actionGeometry(action); QTest::mouseMove(&menu, actionRect.center()); diff --git a/tests/auto/qprogressbar/tst_qprogressbar.cpp b/tests/auto/qprogressbar/tst_qprogressbar.cpp index 274c28e..ea9798b 100644 --- a/tests/auto/qprogressbar/tst_qprogressbar.cpp +++ b/tests/auto/qprogressbar/tst_qprogressbar.cpp @@ -167,11 +167,12 @@ void tst_QProgressBar::format() bar.setRange(0, 10); bar.setValue(1); bar.show(); + QTest::qWaitForWindowShown(&bar); - QTest::qWait(2000); + QTest::qWait(20); bar.repainted = false; bar.setFormat("%v of %m (%p%)"); - QTest::qWait(2000); + QTest::qWait(20); QVERIFY(bar.repainted); bar.repainted = false; bar.setFormat("%v of %m (%p%)"); @@ -197,15 +198,14 @@ void tst_QProgressBar::setValueRepaint() pbar.setMaximum(10); pbar.setFormat("%v"); pbar.show(); -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(&pbar); -#endif + QTest::qWaitForWindowShown(&pbar); + QApplication::processEvents(); for (int i = pbar.minimum(); i < pbar.maximum(); ++i) { pbar.repainted = false; pbar.setValue(i); - QTest::qWait(500); - QVERIFY(pbar.repainted); + QTest::qWait(50); + QTRY_VERIFY(pbar.repainted); } } diff --git a/tests/auto/qwindowsurface/tst_qwindowsurface.cpp b/tests/auto/qwindowsurface/tst_qwindowsurface.cpp index df87a42..2c5ba72 100644 --- a/tests/auto/qwindowsurface/tst_qwindowsurface.cpp +++ b/tests/auto/qwindowsurface/tst_qwindowsurface.cpp @@ -155,11 +155,10 @@ void tst_QWindowSurface::flushOutsidePaintEvent() // prevent custom styles from messing up the background w.setStyle(new QWindowsStyle); w.show(); + QTest::qWaitForWindowShown(&w); QApplication::processEvents(); -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(&w); -#elif defined(Q_WS_QWS) +#if defined(Q_WS_QWS) QApplication::sendPostedEvents(); //for the glib event loop #elif defined(Q_WS_S60) QTest::qWait(5000); @@ -189,9 +188,6 @@ void tst_QWindowSurface::flushOutsidePaintEvent() // the paintEvent() should overwrite the painted rectangle QApplication::processEvents(); -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(&w); -#endif #if defined(Q_WS_QWS) QSKIP("task 176755", SkipAll); @@ -232,8 +228,9 @@ void tst_QWindowSurface::grabWidget() babyWidget.show(); childWidget.show(); parentWidget.show(); + QTest::qWaitForWindowShown(&parentWidget); - QTest::qWait(200); + QTest::qWait(20); QPixmap parentPixmap = parentWidget.windowSurface()->grabWidget(&parentWidget); QPixmap childPixmap = childWidget.windowSurface()->grabWidget(&childWidget); -- cgit v0.12 From 1f67584c5260b0d9f275ed5f3a24e444168ec3eb Mon Sep 17 00:00:00 2001 From: Ariya Hidayat Date: Tue, 22 Sep 2009 19:49:39 +0200 Subject: Ray casting example: bypass alpha-blending for an easy speed-up. Reviewed-by: TrustMe --- demos/embedded/raycasting/raycasting.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/demos/embedded/raycasting/raycasting.cpp b/demos/embedded/raycasting/raycasting.cpp index e98dc35..3836dc1 100644 --- a/demos/embedded/raycasting/raycasting.cpp +++ b/demos/embedded/raycasting/raycasting.cpp @@ -254,6 +254,7 @@ protected: void paintEvent(QPaintEvent *event) { QPainter p(this); + p.setCompositionMode(QPainter::CompositionMode_Source); p.drawImage(event->rect(), buffer, event->rect()); } -- cgit v0.12 From 66da7e609e92fff2322c1ef42e4ac9132bc33fab Mon Sep 17 00:00:00 2001 From: Kent Hansen Date: Tue, 22 Sep 2009 20:01:43 +0200 Subject: don't crash in property access after script class has been set to 0 When the script class is set to 0, we need to remove the script object's delegate entirely, because the delegate requires a non-0 script class in order to be useful. Reviewed-by: Olivier Goffart --- src/script/api/qscriptvalue.cpp | 14 +++++++++----- src/script/bridge/qscriptclassobject.cpp | 1 + tests/auto/qscriptclass/tst_qscriptclass.cpp | 12 +++++++++++- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/src/script/api/qscriptvalue.cpp b/src/script/api/qscriptvalue.cpp index 6a6381e..2a33aea 100644 --- a/src/script/api/qscriptvalue.cpp +++ b/src/script/api/qscriptvalue.cpp @@ -2409,12 +2409,16 @@ void QScriptValue::setScriptClass(QScriptClass *scriptClass) return; } QScriptObject *scriptObject = static_cast(JSC::asObject(d->jscValue)); - QScriptObjectDelegate *delegate = scriptObject->delegate(); - if (!delegate || (delegate->type() != QScriptObjectDelegate::ClassObject)) { - delegate = new QScript::ClassObjectDelegate(scriptClass); - scriptObject->setDelegate(delegate); + if (!scriptClass) { + scriptObject->setDelegate(0); + } else { + QScriptObjectDelegate *delegate = scriptObject->delegate(); + if (!delegate || (delegate->type() != QScriptObjectDelegate::ClassObject)) { + delegate = new QScript::ClassObjectDelegate(scriptClass); + scriptObject->setDelegate(delegate); + } + static_cast(delegate)->setScriptClass(scriptClass); } - static_cast(delegate)->setScriptClass(scriptClass); } /*! diff --git a/src/script/bridge/qscriptclassobject.cpp b/src/script/bridge/qscriptclassobject.cpp index b57909f..c1e386b 100644 --- a/src/script/bridge/qscriptclassobject.cpp +++ b/src/script/bridge/qscriptclassobject.cpp @@ -77,6 +77,7 @@ QScriptClass *ClassObjectDelegate::scriptClass() const void ClassObjectDelegate::setScriptClass(QScriptClass *scriptClass) { + Q_ASSERT(scriptClass != 0); m_scriptClass = scriptClass; } diff --git a/tests/auto/qscriptclass/tst_qscriptclass.cpp b/tests/auto/qscriptclass/tst_qscriptclass.cpp index 71fcc79..608a134 100644 --- a/tests/auto/qscriptclass/tst_qscriptclass.cpp +++ b/tests/auto/qscriptclass/tst_qscriptclass.cpp @@ -625,6 +625,7 @@ void tst_QScriptClass::getAndSetProperty() QScriptValue obj2 = eng.newObject(&cls); QScriptString foo = eng.toStringHandle("foo"); QScriptString bar = eng.toStringHandle("bar"); + QScriptValue num(&eng, 123); // should behave just like normal for (int x = 0; x < 2; ++x) { @@ -644,7 +645,6 @@ void tst_QScriptClass::getAndSetProperty() // write property cls.clearReceivedArgs(); - QScriptValue num(&eng, 123); o.setProperty(s, num); QVERIFY(cls.lastQueryPropertyObject().strictlyEquals(o)); QVERIFY(cls.lastQueryPropertyName() == s); @@ -712,6 +712,16 @@ void tst_QScriptClass::getAndSetProperty() QVERIFY(cls.lastPropertyName() == foo2); QCOMPARE(cls.lastPropertyId(), foo2Id); } + + // remove script class; normal properties should remain + obj1.setScriptClass(0); + QCOMPARE(obj1.scriptClass(), (QScriptClass*)0); + QVERIFY(obj1.property(foo).equals(num)); + QVERIFY(obj1.property(bar).equals(num)); + obj1.setProperty(foo, QScriptValue()); + QVERIFY(!obj1.property(foo).isValid()); + obj1.setProperty(bar, QScriptValue()); + QVERIFY(!obj1.property(bar).isValid()); } void tst_QScriptClass::enumerate() -- cgit v0.12 From b7b21318c4edf10f5eaadd9481a58fd04f6947ea Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Tue, 22 Sep 2009 17:16:48 +0200 Subject: fix QApp::translate() calls Reviewed-By: Simon Hausmann --- src/3rdparty/webkit/WebCore/platform/qt/Localizations.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/3rdparty/webkit/WebCore/platform/qt/Localizations.cpp b/src/3rdparty/webkit/WebCore/platform/qt/Localizations.cpp index 0733617..977b284 100644 --- a/src/3rdparty/webkit/WebCore/platform/qt/Localizations.cpp +++ b/src/3rdparty/webkit/WebCore/platform/qt/Localizations.cpp @@ -444,7 +444,7 @@ String localizedMediaControlElementHelpText(const String& name) String localizedMediaTimeDescription(float time) { if (!isfinite(time)) - return QCoreApplication::translate("QWebPage," "Indefinite time", "Media time description"); + return QCoreApplication::translate("QWebPage", "Indefinite time", "Media time description"); int seconds = (int)fabsf(time); int days = seconds / (60 * 60 * 24); @@ -453,18 +453,18 @@ String localizedMediaTimeDescription(float time) seconds %= 60; if (days) { - return QCoreApplication::translate("QWebPage," "%1 days %2 hours %3 minutes %4 seconds", "Media time description").arg(days).arg(hours).arg(minutes).arg(seconds); + return QCoreApplication::translate("QWebPage", "%1 days %2 hours %3 minutes %4 seconds", "Media time description").arg(days).arg(hours).arg(minutes).arg(seconds); } if (hours) { - return QCoreApplication::translate("QWebPage," "%1 hours %2 minutes %3 seconds", "Media time description").arg(hours).arg(minutes).arg(seconds); + return QCoreApplication::translate("QWebPage", "%1 hours %2 minutes %3 seconds", "Media time description").arg(hours).arg(minutes).arg(seconds); } if (minutes) { - return QCoreApplication::translate("QWebPage," "%1 minutes %2 seconds", "Media time description").arg(minutes).arg(seconds); + return QCoreApplication::translate("QWebPage", "%1 minutes %2 seconds", "Media time description").arg(minutes).arg(seconds); } - return QCoreApplication::translate("QWebPage," "%1 seconds", "Media time description").arg(seconds); + return QCoreApplication::translate("QWebPage", "%1 seconds", "Media time description").arg(seconds); } #endif // ENABLE(VIDEO) -- cgit v0.12 From a4392f1d6869fcb86d8e91df5edf1fd2db197198 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Tue, 22 Sep 2009 18:31:18 +0200 Subject: add --sort-contexts option ok, so this is a feature ... a 4-line-one ... --- tools/linguist/lconvert/main.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/linguist/lconvert/main.cpp b/tools/linguist/lconvert/main.cpp index fb869ec..67553a0 100644 --- a/tools/linguist/lconvert/main.cpp +++ b/tools/linguist/lconvert/main.cpp @@ -103,6 +103,8 @@ static int usage(const QStringList &args) " Drop obsolete messages.\n\n" " --no-finished\n" " Drop finished messages.\n\n" + " --sort-contexts\n" + " Sort contexts in output TS file alphabetically.\n\n" " --locations {absolute|relative|none}\n" " Override how source code references are saved in TS files.\n" " Default is absolute.\n\n" @@ -201,6 +203,8 @@ int main(int argc, char *argv[]) noObsolete = true; } else if (args[i] == QLatin1String("-no-finished")) { noFinished = true; + } else if (args[i] == QLatin1String("-sort-contexts")) { + cd.m_sortContexts = true; } else if (args[i] == QLatin1String("-locations")) { if (++i >= args.size()) return usage(args); -- cgit v0.12 From 0873efff5197cb92bce378c67cd744753f809bae Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Tue, 22 Sep 2009 21:38:58 +0200 Subject: Try to stabilize and speedup the qwidget test The test goes in only almost 30seconds now. But i still have few failures Reviewed-by: Denis --- tests/auto/qwidget/tst_qwidget.cpp | 894 ++++++++++++++++--------------------- 1 file changed, 378 insertions(+), 516 deletions(-) diff --git a/tests/auto/qwidget/tst_qwidget.cpp b/tests/auto/qwidget/tst_qwidget.cpp index 04b7b39..6cfa23b 100644 --- a/tests/auto/qwidget/tst_qwidget.cpp +++ b/tests/auto/qwidget/tst_qwidget.cpp @@ -69,6 +69,9 @@ #include #include +#include "../../shared/util.h" + + #ifdef Q_WS_S60 #include // EEikStatusPaneUidTitle #include // CAknTitlePane @@ -637,9 +640,8 @@ void tst_QWidget::initTestCase() qApp->setMainWidget(testWidget); #endif testWidget->show(); -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(testWidget); -#endif + QTest::qWaitForWindowShown(testWidget); + QTest::qWait(50); } void tst_QWidget::cleanupTestCase() @@ -1755,14 +1757,14 @@ void tst_QWidget::setTabOrder() container.show(); container.activateWindow(); #ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(&container); + QTest::qWaitForWindowShown(&container); QTest::qWait(50); #endif qApp->setActiveWindow(&container); QTest::qWait(100); - QVERIFY(lastEdit->hasFocus()); + QTRY_VERIFY(lastEdit->hasFocus()); container.tab(); do { QVERIFY(comp[current]->focusProxy()->hasFocus()); @@ -2211,20 +2213,21 @@ void tst_QWidget::showMinimizedKeepsFocus() child2.setFocusPolicy(Qt::StrongFocus); window.show(); qApp->setActiveWindow(&window); + QTest::qWaitForWindowShown(&window); child2.setFocus(); - QTest::qWait(500); + QTest::qWait(50); - QCOMPARE(window.focusWidget(), &child2); - QCOMPARE(qApp->focusWidget(), &child2); + QTRY_COMPARE(window.focusWidget(), &child2); + QTRY_COMPARE(qApp->focusWidget(), &child2); window.showMinimized(); - QTest::qWait(100); - QVERIFY(window.isMinimized()); - QCOMPARE(window.focusWidget(), &child2); + QTest::qWait(10); + QTRY_VERIFY(window.isMinimized()); + QTRY_COMPARE(window.focusWidget(), &child2); window.showNormal(); - QTest::qWait(100); - QCOMPARE(window.focusWidget(), &child2); + QTest::qWait(10); + QTRY_COMPARE(window.focusWidget(), &child2); } //testing deletion of the focusWidget @@ -2234,10 +2237,11 @@ void tst_QWidget::showMinimizedKeepsFocus() child->setFocusPolicy(Qt::StrongFocus); window.show(); qApp->setActiveWindow(&window); + QTest::qWaitForWindowShown(&window); child->setFocus(); - QTest::qWait(500); - QCOMPARE(window.focusWidget(), child); - QCOMPARE(qApp->focusWidget(), child); + QTest::qWait(50); + QTRY_COMPARE(window.focusWidget(), child); + QTRY_COMPARE(qApp->focusWidget(), child); delete child; QCOMPARE(window.focusWidget(), static_cast(0)); @@ -2251,10 +2255,11 @@ void tst_QWidget::showMinimizedKeepsFocus() child->setFocusPolicy(Qt::StrongFocus); window.show(); qApp->setActiveWindow(&window); + QTest::qWaitForWindowShown(&window); child->setFocus(); - QTest::qWait(500); - QCOMPARE(window.focusWidget(), child); - QCOMPARE(qApp->focusWidget(), child); + QTest::qWait(50); + QTRY_COMPARE(window.focusWidget(), child); + QTRY_COMPARE(qApp->focusWidget(), child); child->setParent(0); QCOMPARE(window.focusWidget(), static_cast(0)); @@ -2268,10 +2273,11 @@ void tst_QWidget::showMinimizedKeepsFocus() child->setFocusPolicy(Qt::StrongFocus); window.show(); qApp->setActiveWindow(&window); + QTest::qWaitForWindowShown(&window); child->setFocus(); - QTest::qWait(1000); - QCOMPARE(window.focusWidget(), child); - QCOMPARE(qApp->focusWidget(), child); + QTest::qWait(10); + QTRY_COMPARE(window.focusWidget(), child); + QTRY_COMPARE(qApp->focusWidget(), child); child->setEnabled(false); QCOMPARE(window.focusWidget(), static_cast(0)); @@ -2287,10 +2293,11 @@ void tst_QWidget::showMinimizedKeepsFocus() child->setFocusPolicy(Qt::StrongFocus); window.show(); qApp->setActiveWindow(&window); + QTest::qWaitForWindowShown(&window); child->setFocus(); - QTest::qWait(1000); - QCOMPARE(window.focusWidget(), child); - QCOMPARE(qApp->focusWidget(), child); + QTest::qWait(10); + QTRY_COMPARE(window.focusWidget(), child); + QTRY_COMPARE(qApp->focusWidget(), child); child->clearFocus(); QCOMPARE(window.focusWidget(), static_cast(0)); @@ -2306,24 +2313,21 @@ void tst_QWidget::showMinimizedKeepsFocus() #ifdef Q_WS_QWS QEXPECT_FAIL("", "QWS does not implement showMinimized()", Continue); #endif - QCOMPARE(qApp->focusWidget(), static_cast(0)); + QTRY_COMPARE(qApp->focusWidget(), static_cast(0)); window.showNormal(); -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(&window); -#endif - QTest::qWait(300); + QTest::qWait(30); qApp->setActiveWindow(&window); #ifdef Q_WS_MAC if (!macHasAccessToWindowsServer()) QEXPECT_FAIL("", "When not having WindowServer access, we lose focus.", Continue); #endif - QCOMPARE(window.focusWidget(), firstchild); + QTRY_COMPARE(window.focusWidget(), firstchild); #ifdef Q_WS_MAC if (!macHasAccessToWindowsServer()) QEXPECT_FAIL("", "When not having WindowServer access, we lose focus.", Continue); #endif - QCOMPARE(qApp->focusWidget(), firstchild); + QTRY_COMPARE(qApp->focusWidget(), firstchild); } } @@ -2350,11 +2354,7 @@ void tst_QWidget::reparent() parent.show(); childTLW.show(); - -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(&parent); - qt_x11_wait_for_window_manager(&childTLW); -#endif + QTest::qWaitForWindowShown(&parent); #ifdef Q_OS_WINCE parent.move(50, 50); @@ -2370,14 +2370,13 @@ void tst_QWidget::reparent() child.show(); #ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(&child); // On X11, the window manager will apply NorthWestGravity rules to 'child', which // means the top-left corner of the window frame will be placed at 'childPos', // causing this test to fail #else QCOMPARE(child.geometry().topLeft(), childPos); #endif - QCOMPARE(childTLW.pos(), tlwPos); + QTRY_COMPARE(childTLW.pos(), tlwPos); #ifdef Q_WS_WIN QWidget childTLWChild(&childTLW); @@ -2502,7 +2501,8 @@ void tst_QWidget::normalGeometry() parent.setGeometry(100, 100, 200, 200); parent.show(); - QTestEventLoop::instance().enterLoop(1); + QTest::qWaitForWindowShown(&parent); + QApplication::processEvents(); QRect geom = parent.geometry(); // ### the window manager places the top-left corner at @@ -2513,83 +2513,83 @@ void tst_QWidget::normalGeometry() QCOMPARE(parent.normalGeometry(), geom); parent.setWindowState(parent.windowState() ^ Qt::WindowMaximized); - QTestEventLoop::instance().enterLoop(1); - QVERIFY(parent.windowState() & Qt::WindowMaximized); - QVERIFY(parent.geometry() != geom); - QCOMPARE(parent.normalGeometry(), geom); + QTest::qWait(10); + QTRY_VERIFY(parent.windowState() & Qt::WindowMaximized); + QTRY_VERIFY(parent.geometry() != geom); + QTRY_COMPARE(parent.normalGeometry(), geom); parent.setWindowState(parent.windowState() ^ Qt::WindowMaximized); - QTestEventLoop::instance().enterLoop(1); - QVERIFY(!(parent.windowState() & Qt::WindowMaximized)); - QCOMPARE(parent.geometry(), geom); - QCOMPARE(parent.normalGeometry(), geom); + QTest::qWait(10); + QTRY_VERIFY(!(parent.windowState() & Qt::WindowMaximized)); + QTRY_COMPARE(parent.geometry(), geom); + QTRY_COMPARE(parent.normalGeometry(), geom); parent.showMaximized(); - QTestEventLoop::instance().enterLoop(1); - QVERIFY(parent.windowState() & Qt::WindowMaximized); - QVERIFY(parent.geometry() != geom); + QTest::qWait(10); + QTRY_VERIFY(parent.windowState() & Qt::WindowMaximized); + QTRY_VERIFY(parent.geometry() != geom); QCOMPARE(parent.normalGeometry(), geom); parent.showNormal(); - QTestEventLoop::instance().enterLoop(1); - QVERIFY(!(parent.windowState() & Qt::WindowMaximized)); - QCOMPARE(parent.geometry(), geom); + QTest::qWait(10); + QTRY_VERIFY(!(parent.windowState() & Qt::WindowMaximized)); + QTRY_COMPARE(parent.geometry(), geom); QCOMPARE(parent.normalGeometry(), geom); parent.setWindowState(parent.windowState() ^ Qt::WindowMinimized); - QTestEventLoop::instance().enterLoop(1); + QTest::qWait(10); parent.setWindowState(parent.windowState() ^ Qt::WindowMaximized); - QTestEventLoop::instance().enterLoop(1); - QVERIFY(parent.windowState() & (Qt::WindowMinimized|Qt::WindowMaximized)); + QTest::qWait(10); + QTRY_VERIFY(parent.windowState() & (Qt::WindowMinimized|Qt::WindowMaximized)); // ### when minimized and maximized at the same time, the geometry // ### does *NOT* have to be the normal geometry, it could be the // ### maximized geometry. // QCOMPARE(parent.geometry(), geom); - QCOMPARE(parent.normalGeometry(), geom); + QTRY_COMPARE(parent.normalGeometry(), geom); parent.setWindowState(parent.windowState() ^ Qt::WindowMinimized); - QTestEventLoop::instance().enterLoop(1); - QVERIFY(!(parent.windowState() & Qt::WindowMinimized)); - QVERIFY(parent.windowState() & Qt::WindowMaximized); - QVERIFY(parent.geometry() != geom); - QCOMPARE(parent.normalGeometry(), geom); + QTest::qWait(10); + QTRY_VERIFY(!(parent.windowState() & Qt::WindowMinimized)); + QTRY_VERIFY(parent.windowState() & Qt::WindowMaximized); + QTRY_VERIFY(parent.geometry() != geom); + QTRY_COMPARE(parent.normalGeometry(), geom); parent.setWindowState(parent.windowState() ^ Qt::WindowMaximized); - QTestEventLoop::instance().enterLoop(1); - QVERIFY(!(parent.windowState() & Qt::WindowMaximized)); - QCOMPARE(parent.geometry(), geom); - QCOMPARE(parent.normalGeometry(), geom); + QTest::qWait(10); + QTRY_VERIFY(!(parent.windowState() & Qt::WindowMaximized)); + QTRY_COMPARE(parent.geometry(), geom); + QTRY_COMPARE(parent.normalGeometry(), geom); parent.setWindowState(parent.windowState() ^ Qt::WindowFullScreen); - QTestEventLoop::instance().enterLoop(1); - QVERIFY(parent.windowState() & Qt::WindowFullScreen); - QVERIFY(parent.geometry() != geom); - QCOMPARE(parent.normalGeometry(), geom); + QTest::qWait(10); + QTRY_VERIFY(parent.windowState() & Qt::WindowFullScreen); + QTRY_VERIFY(parent.geometry() != geom); + QTRY_COMPARE(parent.normalGeometry(), geom); parent.setWindowState(parent.windowState() ^ Qt::WindowFullScreen); - QTestEventLoop::instance().enterLoop(1); + QTest::qWait(10); QVERIFY(!(parent.windowState() & Qt::WindowFullScreen)); - QCOMPARE(parent.geometry(), geom); - QCOMPARE(parent.normalGeometry(), geom); + QTRY_COMPARE(parent.geometry(), geom); + QTRY_COMPARE(parent.normalGeometry(), geom); parent.showFullScreen(); - QTestEventLoop::instance().enterLoop(1); - QVERIFY(parent.windowState() & Qt::WindowFullScreen); - QVERIFY(parent.geometry() != geom); - QCOMPARE(parent.normalGeometry(), geom); + QTest::qWait(10); + QTRY_VERIFY(parent.windowState() & Qt::WindowFullScreen); + QTRY_VERIFY(parent.geometry() != geom); + QTRY_COMPARE(parent.normalGeometry(), geom); parent.showNormal(); - QTestEventLoop::instance().enterLoop(1); - QVERIFY(!(parent.windowState() & Qt::WindowFullScreen)); - QCOMPARE(parent.geometry(), geom); - QCOMPARE(parent.normalGeometry(), geom); + QTest::qWait(10); + QTRY_VERIFY(!(parent.windowState() & Qt::WindowFullScreen)); + QTRY_COMPARE(parent.geometry(), geom); + QTRY_COMPARE(parent.normalGeometry(), geom); parent.showNormal(); parent.setWindowState(Qt:: WindowFullScreen | Qt::WindowMaximized); parent.setWindowState(Qt::WindowMinimized | Qt:: WindowFullScreen | Qt::WindowMaximized); parent.setWindowState(Qt:: WindowFullScreen | Qt::WindowMaximized); - QTestEventLoop::instance().enterLoop(1); - QCOMPARE(parent.normalGeometry(), geom); + QTest::qWait(10); + QTRY_COMPARE(parent.normalGeometry(), geom); } @@ -2730,7 +2730,7 @@ void tst_QWidget::raise() #ifdef QT_MAC_USE_COCOA QSKIP("Cocoa has no Z-Order for views, we hack it, but it results in paint events.", SkipAll); #endif - QTest::qWait(1000); + QTest::qWait(10); QWidget *parent = new QWidget(0); QList allChildren; @@ -2751,10 +2751,8 @@ void tst_QWidget::raise() allChildren.append(child4); parent->show(); -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(parent); -#endif - QTest::qWait(500); + QTest::qWaitForWindowShown(parent); + QTest::qWait(10); QList list1; list1 << child1 << child2 << child3 << child4; @@ -2767,7 +2765,7 @@ void tst_QWidget::raise() QVERIFY(child->numPaintEvents == 0); } else { // show() issues multiple paint events on some window managers - QVERIFY(child->numPaintEvents >= expectedPaintEvents); + QTRY_VERIFY(child->numPaintEvents >= expectedPaintEvents); } QCOMPARE(child->numZOrderChangeEvents, 0); child->reset(); @@ -2775,12 +2773,12 @@ void tst_QWidget::raise() for (int i = 0; i < 5; ++i) child2->raise(); - QTest::qWait(500); + QTest::qWait(50); foreach (UpdateWidget *child, allChildren) { int expectedPaintEvents = child == child2 ? 1 : 0; int expectedZOrderChangeEvents = child == child2 ? 1 : 0; - QCOMPARE(child->numPaintEvents, expectedPaintEvents); + QTRY_COMPARE(child->numPaintEvents, expectedPaintEvents); QCOMPARE(child->numZOrderChangeEvents, expectedZOrderChangeEvents); child->reset(); } @@ -2794,16 +2792,14 @@ void tst_QWidget::raise() QWidget topLevel; parent->setParent(&topLevel); topLevel.show(); -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(&topLevel); -#endif - QTest::qWait(500); + QTest::qWaitForWindowShown(&topLevel); + QTest::qWait(50); UpdateWidget *onTop = new UpdateWidget(&topLevel); onTop->resize(topLevel.size()); onTop->setAutoFillBackground(true); onTop->show(); - QTest::qWait(500); + QTest::qWait(50); onTop->reset(); // Reset all the children. @@ -2812,7 +2808,7 @@ void tst_QWidget::raise() for (int i = 0; i < 5; ++i) child3->raise(); - QTest::qWait(500); + QTest::qWait(50); QCOMPARE(onTop->numPaintEvents, 0); QCOMPARE(onTop->numZOrderChangeEvents, 0); @@ -2824,7 +2820,7 @@ void tst_QWidget::raise() foreach (UpdateWidget *child, allChildren) { int expectedPaintEvents = 0; int expectedZOrderChangeEvents = child == child3 ? 1 : 0; - QCOMPARE(child->numPaintEvents, expectedPaintEvents); + QTRY_COMPARE(child->numPaintEvents, expectedPaintEvents); QCOMPARE(child->numZOrderChangeEvents, expectedZOrderChangeEvents); child->reset(); } @@ -2855,10 +2851,8 @@ void tst_QWidget::lower() allChildren.append(child4); parent->show(); -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(parent); -#endif - QTest::qWait(1000); + QTest::qWaitForWindowShown(parent); + QTest::qWait(100); QList list1; list1 << child1 << child2 << child3 << child4; @@ -2871,7 +2865,7 @@ void tst_QWidget::lower() QVERIFY(child->numPaintEvents == 0); } else { // show() issues multiple paint events on some window managers - QVERIFY(child->numPaintEvents >= expectedPaintEvents); + QTRY_VERIFY(child->numPaintEvents >= expectedPaintEvents); } QCOMPARE(child->numZOrderChangeEvents, 0); child->reset(); @@ -2880,13 +2874,13 @@ void tst_QWidget::lower() for (int i = 0; i < 5; ++i) child4->lower(); - QTest::qWait(1000); + QTest::qWait(100); foreach (UpdateWidget *child, allChildren) { int expectedPaintEvents = child == child3 ? 1 : 0; int expectedZOrderChangeEvents = child == child4 ? 1 : 0; - QCOMPARE(child->numZOrderChangeEvents, expectedZOrderChangeEvents); - QCOMPARE(child->numPaintEvents, expectedPaintEvents); + QTRY_COMPARE(child->numZOrderChangeEvents, expectedZOrderChangeEvents); + QTRY_COMPARE(child->numPaintEvents, expectedPaintEvents); child->reset(); } @@ -2902,7 +2896,7 @@ void tst_QWidget::stackUnder() #ifdef QT_MAC_USE_COCOA QSKIP("Cocoa has no Z-Order for views, we hack it, but it results in paint events.", SkipAll); #endif - QTest::qWait(1000); + QTest::qWait(10); QWidget *parent = new QWidget(0); QList allChildren; @@ -2923,10 +2917,8 @@ void tst_QWidget::stackUnder() allChildren.append(child4); parent->show(); -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(parent); -#endif - QTest::qWait(1000); + QTest::qWaitForWindowShown(parent); + QTest::qWait(10); #ifdef Q_WS_QWS QApplication::sendPostedEvents(); //glib workaround #endif @@ -2948,7 +2940,7 @@ void tst_QWidget::stackUnder() for (int i = 0; i < 5; ++i) child4->stackUnder(child2); - QTest::qWait(1000); + QTest::qWait(10); QList list2; list2 << child1 << child4 << child2 << child3; @@ -2957,14 +2949,14 @@ void tst_QWidget::stackUnder() foreach (UpdateWidget *child, allChildren) { int expectedPaintEvents = child == child3 ? 1 : 0; int expectedZOrderChangeEvents = child == child4 ? 1 : 0; - QCOMPARE(child->numPaintEvents, expectedPaintEvents); - QCOMPARE(child->numZOrderChangeEvents, expectedZOrderChangeEvents); + QTRY_COMPARE(child->numPaintEvents, expectedPaintEvents); + QTRY_COMPARE(child->numZOrderChangeEvents, expectedZOrderChangeEvents); child->reset(); } for (int i = 0; i < 5; ++i) child1->stackUnder(child3); - QTest::qWait(1000); + QTest::qWait(10); QList list3; list3 << child4 << child2 << child1 << child3; @@ -2983,7 +2975,7 @@ void tst_QWidget::stackUnder() } else { QCOMPARE(child->numPaintEvents, 0); } - QCOMPARE(child->numZOrderChangeEvents, expectedZOrderChangeEvents); + QTRY_COMPARE(child->numZOrderChangeEvents, expectedZOrderChangeEvents); child->reset(); } @@ -3079,12 +3071,10 @@ void tst_QWidget::saveRestoreGeometry() widget.move(position); widget.resize(size); widget.show(); -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(&widget); -#endif - QTest::qWait(100); + QTest::qWaitForWindowShown(&widget); + QTest::qWait(10); - QCOMPARE(widget.pos(), position); + QTRY_COMPARE(widget.pos(), position); QCOMPARE(widget.size(), size); savedGeometry = widget.saveGeometry(); } @@ -3108,12 +3098,10 @@ void tst_QWidget::saveRestoreGeometry() QVERIFY(widget.restoreGeometry(savedGeometry)); widget.show(); -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(&widget); -#endif - QTest::qWait(100); + QTest::qWaitForWindowShown(&widget); + QTest::qWait(10); - QCOMPARE(widget.pos(), position); + QTRY_COMPARE(widget.pos(), position); QCOMPARE(widget.size(), size); widget.show(); QCOMPARE(widget.pos(), position); @@ -3125,10 +3113,8 @@ void tst_QWidget::saveRestoreGeometry() widget.move(position); widget.resize(size); widget.show(); -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(&widget); -#endif - QTest::qWait(100); + QTest::qWaitForWindowShown(&widget); + QTest::qWait(10); QRect geom; @@ -3136,91 +3122,55 @@ void tst_QWidget::saveRestoreGeometry() savedGeometry = widget.saveGeometry(); geom = widget.geometry(); widget.setWindowState(widget.windowState() | Qt::WindowFullScreen); -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(&widget); -#endif - QTest::qWait(100); - QVERIFY((widget.windowState() & Qt::WindowFullScreen)); + QTest::qWait(10); + QTRY_VERIFY((widget.windowState() & Qt::WindowFullScreen)); QVERIFY(widget.restoreGeometry(savedGeometry)); -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(&widget); -#endif - QTest::qWait(100); - QCOMPARE(widget.geometry(), geom); + QTest::qWait(10); + QTRY_COMPARE(widget.geometry(), geom); QVERIFY(!(widget.windowState() & Qt::WindowFullScreen)); //Restore to full screen widget.setWindowState(widget.windowState() | Qt::WindowFullScreen); -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(&widget); -#endif - QTest::qWait(100); - QVERIFY((widget.windowState() & Qt::WindowFullScreen)); + QTest::qWait(10); + QTRY_VERIFY((widget.windowState() & Qt::WindowFullScreen)); savedGeometry = widget.saveGeometry(); geom = widget.geometry(); widget.setWindowState(widget.windowState() ^ Qt::WindowFullScreen); -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(&widget); -#endif - QTest::qWait(100); - QVERIFY(widget.restoreGeometry(savedGeometry)); -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(&widget); -#endif - QTest::qWait(100); - QCOMPARE(widget.geometry(), geom); + QTest::qWait(10); + QTRY_VERIFY(widget.restoreGeometry(savedGeometry)); + QTest::qWait(10); + QTRY_COMPARE(widget.geometry(), geom); QVERIFY((widget.windowState() & Qt::WindowFullScreen)); widget.setWindowState(widget.windowState() ^ Qt::WindowFullScreen); -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(&widget); -#endif - QTest::qWait(100); + QTest::qWait(10); //Restore from Maximised widget.move(position); widget.resize(size); -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(&widget); -#endif - QTest::qWait(100); + QTest::qWait(10); savedGeometry = widget.saveGeometry(); geom = widget.geometry(); widget.setWindowState(widget.windowState() | Qt::WindowMaximized); -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(&widget); -#endif - QTest::qWait(100); - QVERIFY((widget.windowState() & Qt::WindowMaximized)); + QTest::qWait(10); + QTRY_VERIFY((widget.windowState() & Qt::WindowMaximized)); QVERIFY(widget.geometry() != geom); QVERIFY(widget.restoreGeometry(savedGeometry)); -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(&widget); -#endif - QTest::qWait(100); + QTest::qWait(10); QCOMPARE(widget.geometry(), geom); QVERIFY(!(widget.windowState() & Qt::WindowMaximized)); //Restore to maximised widget.setWindowState(widget.windowState() | Qt::WindowMaximized); -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(&widget); -#endif - QTest::qWait(100); - QVERIFY((widget.windowState() & Qt::WindowMaximized)); + QTest::qWait(10); + QTRY_VERIFY((widget.windowState() & Qt::WindowMaximized)); geom = widget.geometry(); savedGeometry = widget.saveGeometry(); widget.setWindowState(widget.windowState() ^ Qt::WindowMaximized); -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(&widget); -#endif - QTest::qWait(100); - QVERIFY(widget.restoreGeometry(savedGeometry)); -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(&widget); -#endif - QTest::qWait(100); - QCOMPARE(widget.geometry(), geom); + QTest::qWait(10); + QTRY_VERIFY(widget.restoreGeometry(savedGeometry)); + QTest::qWait(10); + QTRY_COMPARE(widget.geometry(), geom); QVERIFY((widget.windowState() & Qt::WindowMaximized)); } } @@ -3277,9 +3227,7 @@ void tst_QWidget::restoreVersion1Geometry() QCOMPARE(widget.size(), expectedSize); } widget.show(); -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(&widget); -#endif + QTest::qWaitForWindowShown(&widget); QTest::qWait(100); if (expectedWindowState == Qt::WindowNoState) { @@ -3288,14 +3236,14 @@ void tst_QWidget::restoreVersion1Geometry() } widget.showNormal(); - QTest::qWait(1000); + QTest::qWait(10); if (expectedWindowState != Qt::WindowNoState) { // restoring from maximized or fullscreen, we can only restore to the normal geometry - QCOMPARE(widget.geometry(), expectedNormalGeometry); + QTRY_COMPARE(widget.geometry(), expectedNormalGeometry); } else { - QCOMPARE(widget.pos(), expectedPosition); - QCOMPARE(widget.size(), expectedSize); + QTRY_COMPARE(widget.pos(), expectedPosition); + QTRY_COMPARE(widget.size(), expectedSize); } #if 0 @@ -3336,32 +3284,28 @@ void tst_QWidget::widgetAt() w2->setGeometry(50,50,100,100); w2->setObjectName("w2"); w1->show(); -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(w1); -#endif + QTest::qWaitForWindowShown(w1); qApp->processEvents(); - QWidget *wr = QApplication::widgetAt(100, 100); - QVERIFY(wr); + QWidget *wr; + QTRY_VERIFY((wr = QApplication::widgetAt(100, 100))); QCOMPARE(wr->objectName(), QString("w1")); w2->show(); + QTest::qWaitForWindowShown(w2); qApp->processEvents(); qApp->processEvents(); qApp->processEvents(); - wr = QApplication::widgetAt(100, 100); - QVERIFY(wr); + QTRY_VERIFY((wr = QApplication::widgetAt(100, 100))); QCOMPARE(wr->objectName(), QString("w2")); w2->lower(); qApp->processEvents(); - wr = QApplication::widgetAt(100, 100); - QVERIFY(wr); + QTRY_VERIFY((wr = QApplication::widgetAt(100, 100))); QCOMPARE(wr->objectName(), QString("w1")); w2->raise(); qApp->processEvents(); - wr = QApplication::widgetAt(100, 100); - QVERIFY(wr); + QTRY_VERIFY((wr = QApplication::widgetAt(100, 100))); QCOMPARE(wr->objectName(), QString("w2")); @@ -3370,14 +3314,12 @@ void tst_QWidget::widgetAt() w3->setObjectName("w3"); w3->show(); qApp->processEvents(); - wr = QApplication::widgetAt(100,100); - QVERIFY(wr); + QTRY_VERIFY((wr = QApplication::widgetAt(100,100))); QCOMPARE(wr->objectName(), QString("w3")); w3->setAttribute(Qt::WA_TransparentForMouseEvents); qApp->processEvents(); - wr = QApplication::widgetAt(100, 100); - QVERIFY(wr); + QTRY_VERIFY((wr = QApplication::widgetAt(100, 100))); QCOMPARE(wr->objectName(), QString("w2")); QRegion rgn = QRect(QPoint(0,0), w2->size()); @@ -3385,15 +3327,15 @@ void tst_QWidget::widgetAt() rgn -= QRect(point, QSize(1,1)); w2->setMask(rgn); qApp->processEvents(); - QTest::qWait(1000); + QTest::qWait(10); #if defined(Q_OS_WINCE) QEXPECT_FAIL("", "Windows CE does only support rectangular regions", Continue); //See also task 147191 #endif #if defined(Q_OS_SYMBIAN) QEXPECT_FAIL("", "Symbian/S60 does only support rectangular regions", Continue); //See also task 147191 #endif - QCOMPARE(QApplication::widgetAt(100,100)->objectName(), w1->objectName()); - QCOMPARE(QApplication::widgetAt(101,101)->objectName(), w2->objectName()); + QTRY_COMPARE(QApplication::widgetAt(100,100)->objectName(), w1->objectName()); + QTRY_COMPARE(QApplication::widgetAt(101,101)->objectName(), w2->objectName()); QBitmap bitmap(w2->size()); QPainter p(&bitmap); @@ -3403,15 +3345,15 @@ void tst_QWidget::widgetAt() p.end(); w2->setMask(bitmap); qApp->processEvents(); - QTest::qWait(1000); + QTest::qWait(10); #if defined(Q_OS_WINCE) QEXPECT_FAIL("", "Windows CE does only support rectangular regions", Continue); //See also task 147191 #endif #if defined(Q_OS_SYMBIAN) QEXPECT_FAIL("", "Symbian/S60 does only support rectangular regions", Continue); //See also task 147191 #endif - QVERIFY(QApplication::widgetAt(100,100) == w1); - QVERIFY(QApplication::widgetAt(101,101) == w2); + QTRY_VERIFY(QApplication::widgetAt(100,100) == w1); + QTRY_VERIFY(QApplication::widgetAt(101,101) == w2); delete w2; delete w1; @@ -3655,12 +3597,13 @@ void tst_QWidget::windowModified() { QWidget widget(0); widget.show(); + QTest::qWaitForWindowShown(&widget); #ifndef Q_WS_MAC QTest::ignoreMessage(QtWarningMsg, "QWidget::setWindowModified: The window title does not contain a '[*]' placeholder"); #endif widget.setWindowTitle("Application Name"); - QTest::qWait(1000); - QCOMPARE(visibleWindowTitle(&widget), QString("Application Name")); + QTest::qWait(10); + QTRY_COMPARE(visibleWindowTitle(&widget), QString("Application Name")); #ifdef Q_WS_MAC widget.setWindowModified(true); @@ -3753,7 +3696,8 @@ void tst_QWidget::task110173() QTest::keyClick( &w, Qt::Key_Tab ); w.show(); - QTest::qWait(1000); + QTest::qWaitForWindowShown(&w); + QTest::qWait(200); } class Widget : public QWidget @@ -4090,70 +4034,70 @@ void tst_QWidget::optimizedResizeMove() parent.resize(400, 400); StaticWidget staticWidget(&parent); + staticWidget.gotPaintEvent = false; staticWidget.move(150, 150); staticWidget.resize(150, 150); parent.show(); -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(&parent); -#endif - QTest::qWait(200); + QTest::qWaitForWindowShown(&parent); + QTest::qWait(20); + QTRY_COMPARE(staticWidget.gotPaintEvent, true); staticWidget.gotPaintEvent = false; staticWidget.move(staticWidget.pos() + QPoint(10, 10)); - QTest::qWait(100); + QTest::qWait(20); QCOMPARE(staticWidget.gotPaintEvent, false); staticWidget.gotPaintEvent = false; staticWidget.move(staticWidget.pos() + QPoint(-10, -10)); - QTest::qWait(100); + QTest::qWait(20); QCOMPARE(staticWidget.gotPaintEvent, false); staticWidget.gotPaintEvent = false; staticWidget.move(staticWidget.pos() + QPoint(-10, 10)); - QTest::qWait(100); + QTest::qWait(20); QCOMPARE(staticWidget.gotPaintEvent, false); staticWidget.gotPaintEvent = false; staticWidget.resize(staticWidget.size() + QSize(10, 10)); - QTest::qWait(100); + QTest::qWait(20); QCOMPARE(staticWidget.gotPaintEvent, true); QCOMPARE(staticWidget.partial, true); staticWidget.gotPaintEvent = false; staticWidget.resize(staticWidget.size() + QSize(-10, -10)); - QTest::qWait(100); + QTest::qWait(20); QCOMPARE(staticWidget.gotPaintEvent, false); staticWidget.gotPaintEvent = false; staticWidget.resize(staticWidget.size() + QSize(10, -10)); - QTest::qWait(100); + QTest::qWait(20); QCOMPARE(staticWidget.gotPaintEvent, true); QCOMPARE(staticWidget.partial, true); staticWidget.gotPaintEvent = false; staticWidget.move(staticWidget.pos() + QPoint(10, 10)); staticWidget.resize(staticWidget.size() + QSize(-10, -10)); - QTest::qWait(100); + QTest::qWait(20); QCOMPARE(staticWidget.gotPaintEvent, false); staticWidget.gotPaintEvent = false; staticWidget.move(staticWidget.pos() + QPoint(10, 10)); staticWidget.resize(staticWidget.size() + QSize(10, 10)); - QTest::qWait(100); + QTest::qWait(20); QCOMPARE(staticWidget.gotPaintEvent, true); QCOMPARE(staticWidget.partial, true); staticWidget.gotPaintEvent = false; staticWidget.move(staticWidget.pos() + QPoint(-10, -10)); staticWidget.resize(staticWidget.size() + QSize(-10, -10)); - QTest::qWait(100); + QTest::qWait(20); QCOMPARE(staticWidget.gotPaintEvent, false); staticWidget.setAttribute(Qt::WA_StaticContents, false); staticWidget.gotPaintEvent = false; staticWidget.move(staticWidget.pos() + QPoint(-10, -10)); staticWidget.resize(staticWidget.size() + QSize(-10, -10)); - QTest::qWait(100); + QTest::qWait(20); QCOMPARE(staticWidget.gotPaintEvent, true); QCOMPARE(staticWidget.partial, false); staticWidget.setAttribute(Qt::WA_StaticContents, true); @@ -4161,7 +4105,7 @@ void tst_QWidget::optimizedResizeMove() staticWidget.setAttribute(Qt::WA_StaticContents, false); staticWidget.gotPaintEvent = false; staticWidget.move(staticWidget.pos() + QPoint(10, 10)); - QTest::qWait(100); + QTest::qWait(20); QCOMPARE(staticWidget.gotPaintEvent, false); staticWidget.setAttribute(Qt::WA_StaticContents, true); } @@ -4173,11 +4117,11 @@ void tst_QWidget::optimizedResize_topLevel() #endif StaticWidget topLevel; + topLevel.gotPaintEvent = false; topLevel.show(); -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(&topLevel); -#endif - QTest::qWait(100); + QTest::qWaitForWindowShown(&topLevel); + QTest::qWait(10); + QTRY_COMPARE(topLevel.gotPaintEvent, true); topLevel.gotPaintEvent = false; topLevel.partial = false; @@ -4198,16 +4142,13 @@ void tst_QWidget::optimizedResize_topLevel() true); #endif -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(&topLevel); -#endif QTest::qWait(100); // Expected update region: New rect - old rect. QRegion expectedUpdateRegion(topLevel.rect()); expectedUpdateRegion -= QRect(QPoint(), topLevel.size() - QSize(10, 10)); - QCOMPARE(topLevel.gotPaintEvent, true); + QTRY_COMPARE(topLevel.gotPaintEvent, true); QCOMPARE(topLevel.partial, true); QCOMPARE(topLevel.paintedRegion, expectedUpdateRegion); } @@ -4534,19 +4475,18 @@ void tst_QWidget::showHideEvent() void tst_QWidget::update() { - QTest::qWait(1000); // Wait for the initStuff to do it's stuff. + QTest::qWait(10); // Wait for the initStuff to do it's stuff. Q_CHECK_PAINTEVENTS UpdateWidget w; w.setGeometry(50, 50, 100, 100); w.show(); -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(&w); -#endif + QTest::qWaitForWindowShown(&w); + QApplication::processEvents(); QApplication::processEvents(); - QCOMPARE(w.numPaintEvents, 1); + QTRY_COMPARE(w.numPaintEvents, 1); QCOMPARE(w.visibleRegion(), QRegion(w.rect())); QCOMPARE(w.paintedRegion, w.visibleRegion()); @@ -4793,13 +4733,12 @@ void tst_QWidget::scroll() { UpdateWidget updateWidget; updateWidget.resize(500, 500); + updateWidget.reset(); updateWidget.show(); -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(&updateWidget); -#elif defined(Q_WS_QWS) + QTest::qWaitForWindowShown(&updateWidget); QTest::qWait(50); -#endif qApp->processEvents(); + QTRY_VERIFY(updateWidget.numPaintEvents > 0); { updateWidget.reset(); @@ -4974,49 +4913,45 @@ void tst_QWidget::setWindowGeometry() widget.setGeometry(rect); widget.show(); -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(&widget); -#endif - QTest::qWait(100); - QCOMPARE(widget.geometry(), rect); + QTest::qWaitForWindowShown(&widget); + QTest::qWait(20); + QTRY_COMPARE(widget.geometry(), rect); // setGeometry() while shown foreach (QRect r, rects) { widget.setGeometry(r); - QTest::qWait(100); - QCOMPARE(widget.geometry(), r); + QTest::qWait(10); + QTRY_COMPARE(widget.geometry(), r); } widget.setGeometry(rect); - QTest::qWait(100); - QCOMPARE(widget.geometry(), rect); + QTest::qWait(20); + QTRY_COMPARE(widget.geometry(), rect); // now hide widget.hide(); - QTest::qWait(100); - QCOMPARE(widget.geometry(), rect); + QTest::qWait(20); + QTRY_COMPARE(widget.geometry(), rect); // setGeometry() after hide() foreach (QRect r, rects) { widget.setGeometry(r); - QTest::qWait(100); - QCOMPARE(widget.geometry(), r); + QTest::qWait(10); + QTRY_COMPARE(widget.geometry(), r); } widget.setGeometry(rect); - QTest::qWait(100); - QCOMPARE(widget.geometry(), rect); + QTest::qWait(10); + QTRY_COMPARE(widget.geometry(), rect); // show() again, geometry() should still be the same widget.show(); -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(&widget); -#endif - QTest::qWait(100); - QCOMPARE(widget.geometry(), rect); + QTest::qWaitForWindowShown(&widget); + QTest::qWait(10); + QTRY_COMPARE(widget.geometry(), rect); // final hide(), again geometry() should be unchanged widget.hide(); - QTest::qWait(100); - QCOMPARE(widget.geometry(), rect); + QTest::qWait(10); + QTRY_COMPARE(widget.geometry(), rect); } { @@ -5026,50 +4961,46 @@ void tst_QWidget::setWindowGeometry() widget.setWindowFlags(Qt::WindowFlags(windowFlags)); widget.show(); -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(&widget); -#endif + QTest::qWaitForWindowShown(&widget); widget.setGeometry(rect); - QTest::qWait(100); - QCOMPARE(widget.geometry(), rect); + QTest::qWait(10); + QTRY_COMPARE(widget.geometry(), rect); // setGeometry() while shown foreach (QRect r, rects) { widget.setGeometry(r); - QTest::qWait(100); - QCOMPARE(widget.geometry(), r); + QTest::qWait(10); + QTRY_COMPARE(widget.geometry(), r); } widget.setGeometry(rect); - QTest::qWait(100); - QCOMPARE(widget.geometry(), rect); + QTest::qWait(10); + QTRY_COMPARE(widget.geometry(), rect); // now hide widget.hide(); - QTest::qWait(100); - QCOMPARE(widget.geometry(), rect); + QTest::qWait(10); + QTRY_COMPARE(widget.geometry(), rect); // setGeometry() after hide() foreach (QRect r, rects) { widget.setGeometry(r); - QTest::qWait(100); - QCOMPARE(widget.geometry(), r); + QTest::qWait(10); + QTRY_COMPARE(widget.geometry(), r); } widget.setGeometry(rect); - QTest::qWait(100); - QCOMPARE(widget.geometry(), rect); + QTest::qWait(10); + QTRY_COMPARE(widget.geometry(), rect); // show() again, geometry() should still be the same widget.show(); -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(&widget); -#endif - QTest::qWait(100); - QCOMPARE(widget.geometry(), rect); + QTest::qWaitForWindowShown(&widget); + QTest::qWait(10); + QTRY_COMPARE(widget.geometry(), rect); // final hide(), again geometry() should be unchanged widget.hide(); - QTest::qWait(100); - QCOMPARE(widget.geometry(), rect); + QTest::qWait(10); + QTRY_COMPARE(widget.geometry(), rect); } } @@ -5115,17 +5046,17 @@ void tst_QWidget::windowMoveResize() widget.move(rect.topLeft()); widget.resize(rect.size()); - QTest::qWait(100); - QCOMPARE(widget.pos(), rect.topLeft()); - QCOMPARE(widget.size(), rect.size()); + QTest::qWait(10); + QTRY_COMPARE(widget.pos(), rect.topLeft()); + QTRY_COMPARE(widget.size(), rect.size()); // move() without showing foreach (QRect r, rects) { widget.move(r.topLeft()); widget.resize(r.size()); - QTest::qWait(100); - QCOMPARE(widget.pos(), r.topLeft()); - QCOMPARE(widget.size(), r.size()); + QApplication::processEvents(); + QTRY_COMPARE(widget.pos(), r.topLeft()); + QTRY_COMPARE(widget.size(), r.size()); } } @@ -5138,17 +5069,15 @@ void tst_QWidget::windowMoveResize() widget.move(rect.topLeft()); widget.resize(rect.size()); widget.show(); -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(&widget); -#endif - QTest::qWait(100); + + QTest::qWait(10); #if defined(Q_WS_MAC) && !defined(QT_MAC_USE_COCOA) QEXPECT_FAIL("130,50 0x0, flags 0", "Showing a window with 0x0 size shifts it up.", Continue); #endif - QCOMPARE(widget.pos(), rect.topLeft()); - QCOMPARE(widget.size(), rect.size()); + QTRY_COMPARE(widget.pos(), rect.topLeft()); + QTRY_COMPARE(widget.size(), rect.size()); // move() while shown foreach (QRect r, rects) { @@ -5167,19 +5096,19 @@ void tst_QWidget::windowMoveResize() #endif widget.move(r.topLeft()); widget.resize(r.size()); - QTest::qWait(100); - QCOMPARE(widget.pos(), r.topLeft()); - QCOMPARE(widget.size(), r.size()); + QApplication::processEvents(); + QTRY_COMPARE(widget.pos(), r.topLeft()); + QTRY_COMPARE(widget.size(), r.size()); } widget.move(rect.topLeft()); widget.resize(rect.size()); - QTest::qWait(100); - QCOMPARE(widget.pos(), rect.topLeft()); - QCOMPARE(widget.size(), rect.size()); + QApplication::processEvents(); + QTRY_COMPARE(widget.pos(), rect.topLeft()); + QTRY_COMPARE(widget.size(), rect.size()); // now hide widget.hide(); - QTest::qWait(100); + QTest::qWait(10); #if defined (Q_WS_MAC) && defined(QT_MAC_USE_COCOA) QEXPECT_FAIL("130,100 0x200, flags 800", "Cocoa's Delegate sends a spurios move event when the window has a width of zero and non-zero height", @@ -5189,43 +5118,41 @@ void tst_QWidget::windowMoveResize() "Cocoa's Delegate sends a spurios move event when the window has a width of zero and non-zero height", Abort); #endif - QCOMPARE(widget.pos(), rect.topLeft()); - QCOMPARE(widget.size(), rect.size()); + QTRY_COMPARE(widget.pos(), rect.topLeft()); + QTRY_COMPARE(widget.size(), rect.size()); // move() after hide() foreach (QRect r, rects) { widget.move(r.topLeft()); widget.resize(r.size()); - QTest::qWait(1000); + QApplication::processEvents(); #if defined(Q_WS_MAC) && defined(QT_MAC_USE_COCOA) if (r.width() == 0 && r.height() > 0) { widget.move(r.topLeft()); widget.resize(r.size()); } #endif - QCOMPARE(widget.pos(), r.topLeft()); - QCOMPARE(widget.size(), r.size()); + QTRY_COMPARE(widget.pos(), r.topLeft()); + QTRY_COMPARE(widget.size(), r.size()); } widget.move(rect.topLeft()); widget.resize(rect.size()); - QTest::qWait(100); - QCOMPARE(widget.pos(), rect.topLeft()); - QCOMPARE(widget.size(), rect.size()); + QTest::qWait(10); + QTRY_COMPARE(widget.pos(), rect.topLeft()); + QTRY_COMPARE(widget.size(), rect.size()); // show() again, pos() should be the same widget.show(); -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(&widget); -#endif - QTest::qWait(100); - QCOMPARE(widget.pos(), rect.topLeft()); - QCOMPARE(widget.size(), rect.size()); + QTest::qWaitForWindowShown(&widget); + QApplication::processEvents(); + QTRY_COMPARE(widget.pos(), rect.topLeft()); + QTRY_COMPARE(widget.size(), rect.size()); // final hide(), again pos() should be unchanged widget.hide(); - QTest::qWait(100); - QCOMPARE(widget.pos(), rect.topLeft()); - QCOMPARE(widget.size(), rect.size()); + QApplication::processEvents(); + QTRY_COMPARE(widget.pos(), rect.topLeft()); + QTRY_COMPARE(widget.size(), rect.size()); } { @@ -5235,69 +5162,66 @@ void tst_QWidget::windowMoveResize() widget.setWindowFlags(Qt::WindowFlags(windowFlags)); widget.show(); -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(&widget); -#endif + QTest::qWaitForWindowShown(&widget); + QApplication::processEvents(); widget.move(rect.topLeft()); widget.resize(rect.size()); - QTest::qWait(100); - QCOMPARE(widget.pos(), rect.topLeft()); - QCOMPARE(widget.size(), rect.size()); + QApplication::processEvents(); + QTRY_COMPARE(widget.pos(), rect.topLeft()); + QTRY_COMPARE(widget.size(), rect.size()); // move() while shown foreach (QRect r, rects) { widget.move(r.topLeft()); widget.resize(r.size()); - QTest::qWait(100); - QCOMPARE(widget.pos(), r.topLeft()); - QCOMPARE(widget.size(), r.size()); + QApplication::processEvents(); + QTRY_COMPARE(widget.pos(), r.topLeft()); + QTRY_COMPARE(widget.size(), r.size()); } widget.move(rect.topLeft()); widget.resize(rect.size()); - QTest::qWait(100); - QCOMPARE(widget.pos(), rect.topLeft()); - QCOMPARE(widget.size(), rect.size()); + QApplication::processEvents(); + QTRY_COMPARE(widget.pos(), rect.topLeft()); + QTRY_COMPARE(widget.size(), rect.size()); // now hide widget.hide(); - QTest::qWait(100); - QCOMPARE(widget.pos(), rect.topLeft()); - QCOMPARE(widget.size(), rect.size()); + QApplication::processEvents(); + QTRY_COMPARE(widget.pos(), rect.topLeft()); + QTRY_COMPARE(widget.size(), rect.size()); // move() after hide() foreach (QRect r, rects) { widget.move(r.topLeft()); widget.resize(r.size()); - QTest::qWait(100); + QApplication::processEvents(); #if defined(Q_WS_MAC) && defined(QT_MAC_USE_COCOA) if (r.width() == 0 && r.height() > 0) { widget.move(r.topLeft()); widget.resize(r.size()); } #endif - QCOMPARE(widget.pos(), r.topLeft()); - QCOMPARE(widget.size(), r.size()); + QTRY_COMPARE(widget.pos(), r.topLeft()); + QTRY_COMPARE(widget.size(), r.size()); } widget.move(rect.topLeft()); widget.resize(rect.size()); - QTest::qWait(100); - QCOMPARE(widget.pos(), rect.topLeft()); - QCOMPARE(widget.size(), rect.size()); + QApplication::processEvents(); + QTRY_COMPARE(widget.pos(), rect.topLeft()); + QTRY_COMPARE(widget.size(), rect.size()); // show() again, pos() should be the same widget.show(); -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(&widget); -#endif - QTest::qWait(100); - QCOMPARE(widget.pos(), rect.topLeft()); - QCOMPARE(widget.size(), rect.size()); + QTest::qWaitForWindowShown(&widget); + QTest::qWait(10); + QTRY_COMPARE(widget.pos(), rect.topLeft()); + QTRY_COMPARE(widget.size(), rect.size()); // final hide(), again pos() should be unchanged widget.hide(); - QTest::qWait(100); - QCOMPARE(widget.pos(), rect.topLeft()); - QCOMPARE(widget.size(), rect.size()); + QTest::qWait(10); + QTRY_COMPARE(widget.pos(), rect.topLeft()); + QTRY_COMPARE(widget.size(), rect.size()); } } @@ -5335,6 +5259,7 @@ public: QCOMPARE(pixmap.size(), rect.size()); \ QPixmap expectedPixmap(pixmap); /* ensure equal formats */ \ expectedPixmap.fill(color); \ + QCOMPARE(pixmap.toImage().pixel(0,0), QColor(color).rgb()); \ QCOMPARE(pixmap, expectedPixmap); \ } \ } @@ -5368,7 +5293,8 @@ void tst_QWidget::moveChild() QPoint childOffset = child.mapToGlobal(QPoint()); parent.show(); - QTest::qWait(1000); + QTest::qWaitForWindowShown(&parent); + QTest::qWait(30); const QPoint tlwOffset = parent.geometry().topLeft(); #ifdef QT_MAC_USE_COCOA @@ -5389,7 +5315,7 @@ void tst_QWidget::moveChild() QPoint pos = child.pos() + offset; child.move(pos); - QTest::qWait(1000); + QTest::qWait(100); QCOMPARE(pos, child.pos()); QCOMPARE(parent.r, QRegion(oldGeometry) - child.geometry()); @@ -5411,10 +5337,8 @@ void tst_QWidget::showAndMoveChild() parent.resize(300, 300); parent.setPalette(Qt::red); parent.show(); -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(&parent); -#endif - QTest::qWait(200); + QTest::qWaitForWindowShown(&parent); + QTest::qWait(10); const QPoint tlwOffset = parent.geometry().topLeft(); QWidget child(&parent); @@ -5450,21 +5374,22 @@ void tst_QWidget::subtractOpaqueSiblings() tall->setGeometry(100, 30, 50, 100); w.show(); - QTest::qWait(1000); + QTest::qWaitForWindowShown(&w); + QTest::qWait(10); large->reset(); medium->reset(); tall->reset(); medium->update(); - QTest::qWait(1000); + QTest::qWait(10); // QWidgetPrivate::subtractOpaqueSiblings() should prevent parts of medium // to be repainted and tall from be repainted at all. - QCOMPARE(large->r, QRegion()); - QCOMPARE(tall->r, QRegion()); - QCOMPARE(medium->r.translated(medium->mapTo(&w, QPoint())), + QTRY_COMPARE(large->r, QRegion()); + QTRY_COMPARE(tall->r, QRegion()); + QTRY_COMPARE(medium->r.translated(medium->mapTo(&w, QPoint())), QRegion(medium->geometry().translated(large->pos())) - tall->geometry()); #endif @@ -5528,45 +5453,46 @@ void tst_QWidget::multipleToplevelFocusCheck() w1.resize(200, 200); w1.show(); + QTest::qWaitForWindowShown(&w1); w2.resize(200,200); w2.show(); + QTest::qWaitForWindowShown(&w2); - -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(&w1); - qt_x11_wait_for_window_manager(&w2); -#endif QTest::qWait(100); w1.activateWindow(); QApplication::setActiveWindow(&w1); QApplication::processEvents(); + QTRY_COMPARE(QApplication::activeWindow(), &w1); QTest::mouseDClick(&w1, Qt::LeftButton); - QCOMPARE(QApplication::focusWidget(), static_cast(w1.edit)); + QTRY_COMPARE(QApplication::focusWidget(), static_cast(w1.edit)); w2.activateWindow(); QApplication::setActiveWindow(&w2); QApplication::processEvents(); + QTRY_COMPARE(QApplication::activeWindow(), &w2); QTest::mouseClick(&w2, Qt::LeftButton); #ifdef Q_WS_QWS QEXPECT_FAIL("", "embedded toplevels take focus anyway", Continue); #endif - QCOMPARE(QApplication::focusWidget(), (QWidget *)0); + QTRY_COMPARE(QApplication::focusWidget(), (QWidget *)0); QTest::mouseDClick(&w2, Qt::LeftButton); - QCOMPARE(QApplication::focusWidget(), static_cast(w2.edit)); + QTRY_COMPARE(QApplication::focusWidget(), static_cast(w2.edit)); w1.activateWindow(); QApplication::setActiveWindow(&w1); QApplication::processEvents(); + QTRY_COMPARE(QApplication::activeWindow(), &w1); QTest::mouseDClick(&w1, Qt::LeftButton); - QCOMPARE(QApplication::focusWidget(), static_cast(w1.edit)); + QTRY_COMPARE(QApplication::focusWidget(), static_cast(w1.edit)); w2.activateWindow(); QApplication::setActiveWindow(&w2); QApplication::processEvents(); + QTRY_COMPARE(QApplication::activeWindow(), &w2); QTest::mouseClick(&w2, Qt::LeftButton); - QCOMPARE(QApplication::focusWidget(), (QWidget *)0); + QTRY_COMPARE(QApplication::focusWidget(), (QWidget *)0); } void tst_QWidget::setFocus() @@ -5643,15 +5569,15 @@ void tst_QWidget::setFocus() window.show(); #ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(testWidget); QApplication::setActiveWindow(&window); + QTest::qWaitForWindowShown(&window); #else window.activateWindow(); QApplication::processEvents(); #endif child1.setFocus(); - QVERIFY(child1.hasFocus()); + QTRY_VERIFY(child1.hasFocus()); QCOMPARE(window.focusWidget(), &child1); QCOMPARE(QApplication::focusWidget(), &child1); @@ -5667,8 +5593,8 @@ void tst_QWidget::setFocus() window.show(); #ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(testWidget); QApplication::setActiveWindow(&window); + QTest::qWaitForWindowShown(&window); #else window.activateWindow(); #endif @@ -5686,12 +5612,11 @@ void tst_QWidget::setFocus() child1.show(); #ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(&child1); QApplication::setActiveWindow(&child1); child1.activateWindow(); #endif QApplication::processEvents(); - QVERIFY(child1.hasFocus()); + QTRY_VERIFY(child1.hasFocus()); QCOMPARE(window.focusWidget(), &child1); QCOMPARE(QApplication::focusWidget(), &child1); @@ -5713,8 +5638,8 @@ void tst_QWidget::setFocus() window.show(); #ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(testWidget); QApplication::setActiveWindow(&window); + QTest::qWaitForWindowShown(&window); #else window.activateWindow(); #endif @@ -5926,10 +5851,8 @@ void tst_QWidget::setToolTip() frame->setToolTip(QLatin1String("TOOLTIP FRAME")); popup->setToolTip(QLatin1String("TOOLTIP POPUP")); popup->show(); -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(popup); -#endif - QTest::qWait(100); + QTest::qWaitForWindowShown(popup); + QTest::qWait(10); QTest::mouseMove(frame); QTest::qWait(900); // delay is 700 @@ -6439,21 +6362,16 @@ void tst_QWidget::render() f.setStyleStrategy(QFont::NoAntialias); source.setFont(f); source.show(); -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(&source); -#endif + QTest::qWaitForWindowShown(&source); // Render the entire source into target. RenderWidget target(&source); target.resize(source.size()); target.show(); -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(&target); -#endif qApp->processEvents(); qApp->sendPostedEvents(); - QTest::qWait(500); + QTest::qWait(100); QImage sourceImage = QPixmap::grabWidget(&source).toImage(); qApp->processEvents(); @@ -6481,9 +6399,7 @@ void tst_QWidget::render() // prevent custom styles window.setStyle(new QWindowsStyle); window.show(); -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(&window); -#endif + QTest::qWaitForWindowShown(&window); QWidget child(&window); child.resize(window.size()); child.show(); @@ -6500,9 +6416,7 @@ void tst_QWidget::render() // prevent custom styles widget.setStyle(new QWindowsStyle); widget.show(); -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(&widget); -#endif + QTest::qWaitForWindowShown(&widget); QImage image(widget.size(), QImage::Format_RGB32); image.fill(QColor(Qt::blue).rgb()); @@ -6556,16 +6470,12 @@ void tst_QWidget::renderInvisible() f.setStyleStrategy(QFont::NoAntialias); calendar->setFont(f); calendar->show(); -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(calendar); -#endif + QTest::qWaitForWindowShown(calendar); // Create a dummy focus widget to get rid of focus rect in reference image. QLineEdit dummyFocusWidget; dummyFocusWidget.show(); -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(&dummyFocusWidget); -#endif + QTest::qWaitForWindowShown(&dummyFocusWidget); qApp->processEvents(); // Create normal reference image. @@ -6580,9 +6490,6 @@ void tst_QWidget::renderInvisible() // Create resized reference image. const QSize calendarSizeResized = calendar->size() + QSize(50, 50); calendar->resize(calendarSizeResized); -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(&dummyFocusWidget); -#endif qApp->processEvents(); QImage referenceImageResized(calendarSizeResized, QImage::Format_ARGB32); calendar->render(&referenceImageResized); @@ -6593,9 +6500,6 @@ void tst_QWidget::renderInvisible() // Explicitly hide the calendar. calendar->hide(); -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(calendar); -#endif qApp->processEvents(); workaroundPaletteIssue(calendar); @@ -7459,10 +7363,8 @@ void tst_QWidget::repaintWhenChildDeleted() w.setGeometry(60, 60, 110, 110); #endif w.show(); - QTest::qWait(1000); -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(&w); -#endif + QTest::qWaitForWindowShown(&w); + QTest::qWait(30); QCOMPARE(w.r, QRegion(w.rect())); w.r = QRegion(); @@ -7500,11 +7402,9 @@ void tst_QWidget::hideOpaqueChildWhileHidden() child2.setGeometry(10, 10, 60, 60); w.show(); -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(&w); -#endif - QTest::qWait(1000); - QCOMPARE(child2.r, QRegion(child2.rect())); + QTest::qWaitForWindowShown(&w); + QTest::qWait(10); + QTRY_COMPARE(child2.r, QRegion(child2.rect())); child.r = QRegion(); child2.r = QRegion(); w.r = QRegion(); @@ -7531,33 +7431,25 @@ void tst_QWidget::updateWhileMinimized() // Filter out activation change and focus events to avoid update() calls in QWidget. widget.updateOnActivationChangeAndFocusIn = false; widget.show(); -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(&widget); -#endif - QTest::qWait(300); + QTest::qWaitForWindowShown(&widget); + QApplication::processEvents(); // Minimize window. widget.showMinimized(); -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(&widget); -#endif - QTest::qWait(300); + QTest::qWait(30); widget.reset(); // The widget is not visible on the screen (but isVisible() still returns true). // Make sure update requests are discarded until the widget is shown again. widget.update(0, 0, 50, 50); - QTest::qWait(100); + QTest::qWait(10); QCOMPARE(widget.numPaintEvents, 0); // Restore window. widget.showNormal(); -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(&widget); -#endif - QTest::qWait(300); - QCOMPARE(widget.numPaintEvents, 1); + QTest::qWait(30); + QTRY_COMPARE(widget.numPaintEvents, 1); QCOMPARE(widget.paintedRegion, QRegion(0, 0, 50, 50)); } @@ -8117,8 +8009,9 @@ void tst_QWidget::doubleRepaint() // Show: 1 repaint int expectedRepaints = 1; widget.show(); - QTest::qWait(1000); - QCOMPARE(widget.numPaintEvents, expectedRepaints); + QTest::qWaitForWindowShown(&widget); + QTest::qWait(10); + QTRY_COMPARE(widget.numPaintEvents, expectedRepaints); widget.numPaintEvents = 0; #ifndef Q_OS_WINCE //still no proper minimizing @@ -8128,13 +8021,14 @@ void tst_QWidget::doubleRepaint() // Hide: Should not trigger a repaint. widget.hide(); #endif - QTest::qWait(1000); + QTest::qWait(10); QCOMPARE(widget.numPaintEvents, 0); widget.numPaintEvents = 0; // Restore: Should not trigger a repaint. widget.showNormal(); - QTest::qWait(1000); + QTest::qWaitForWindowShown(&widget); + QTest::qWait(10); #ifndef Q_OS_WINCE QCOMPARE(widget.numPaintEvents, 0); #else @@ -8207,6 +8101,7 @@ public slots: void tst_QWidget::setMaskInResizeEvent() { UpdateWidget w; + w.reset(); w.resize(200, 200); w.setWindowFlags(Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint); w.raise(); @@ -8216,8 +8111,10 @@ void tst_QWidget::setMaskInResizeEvent() testWidget.setMask(QRegion(QRect(0,0,100,10))); testWidget.show(); w.show(); + QTest::qWaitForWindowShown(&w); + QTest::qWait(30); + QTRY_VERIFY(w.numPaintEvents > 0); - QTest::qWait(800); w.reset(); testWidget.paintedRegion = QRegion(); QTimer::singleShot(0, &testWidget, SLOT(resizeDown())); @@ -8231,9 +8128,9 @@ void tst_QWidget::setMaskInResizeEvent() testWidget.paintedRegion = QRegion(); // Now resize the widget again, but in the oposite direction QTimer::singleShot(0, &testWidget, SLOT(resizeUp())); - QTest::qWait(300); + QTest::qWait(100); - QCOMPARE(testWidget.paintedRegion, testWidget.mask()); + QTRY_COMPARE(testWidget.paintedRegion, testWidget.mask()); } class MoveInResizeWidget : public QWidget @@ -8268,14 +8165,11 @@ void tst_QWidget::moveInResizeEvent() MoveInResizeWidget testWidget; testWidget.setGeometry(50, 50, 200, 200); testWidget.show(); -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(&testWidget); -#endif - - QTest::qWait(500); + QTest::qWaitForWindowShown(&testWidget); + QTest::qWait(10); QRect expectedGeometry(100,100, 100, 100); - QCOMPARE(testWidget.geometry(), expectedGeometry); + QTRY_COMPARE(testWidget.geometry(), expectedGeometry); } @@ -8518,14 +8412,12 @@ void tst_QWidget::reparentStaticWidget() grandChild->resize(50, 50); grandChild->setAttribute(Qt::WA_StaticContents); window1.show(); + QTest::qWaitForWindowShown(&window1); QWidget window2; window2.show(); -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(&window1); - qt_x11_wait_for_window_manager(&window2); -#endif - QTest::qWait(200); + QTest::qWaitForWindowShown(&window2); + QTest::qWait(20); // Reparent into another top-level. child->setParent(&window2); @@ -8533,10 +8425,7 @@ void tst_QWidget::reparentStaticWidget() // Please don't crash. window1.resize(window1.size() + QSize(2, 2)); -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(&window1); -#endif - QTest::qWait(200); + QTest::qWait(20); // Make sure we move all static children even though // the reparented widget itself is non-static. @@ -8546,53 +8435,39 @@ void tst_QWidget::reparentStaticWidget() // Please don't crash. window2.resize(window2.size() + QSize(2, 2)); -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(&window2); -#endif - QTest::qWait(200); + QTest::qWait(20); child->setParent(0); child->show(); -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(child); -#endif + QTest::qWait(20); // Please don't crash. child->resize(child->size() + QSize(2, 2)); window2.resize(window2.size() + QSize(2, 2)); -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(child); - qt_x11_wait_for_window_manager(&window2); -#endif - QTest::qWait(200); + QTest::qWait(20); QWidget *siblingOfGrandChild = new QWidget(child); siblingOfGrandChild->show(); - QTest::qWait(200); + QTest::qWait(20); // Nothing should happen when reparenting within the same top-level. grandChild->setParent(siblingOfGrandChild); grandChild->show(); - QTest::qWait(200); + QTest::qWait(20); QWidget paintOnScreen; paintOnScreen.setAttribute(Qt::WA_PaintOnScreen); paintOnScreen.show(); -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(&paintOnScreen); -#endif - QTest::qWait(200); + QTest::qWaitForWindowShown(&paintOnScreen); + QTest::qWait(20); child->setParent(&paintOnScreen); child->show(); - QTest::qWait(200); + QTest::qWait(20); // Please don't crash. paintOnScreen.resize(paintOnScreen.size() + QSize(2, 2)); -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(&paintOnScreen); -#endif - QTest::qWait(200); + QTest::qWait(20); } #ifdef Q_WS_QWS @@ -8695,7 +8570,8 @@ void tst_QWidget::setClearAndResizeMask() UpdateWidget topLevel; topLevel.resize(150, 150); topLevel.show(); - QTest::qWait(400); + QTest::qWaitForWindowShown(&topLevel); + QTest::qWait(40); topLevel.reset(); @@ -8703,10 +8579,6 @@ void tst_QWidget::setClearAndResizeMask() const QRegion topLevelMask(0, 0, 100, 100, QRegion::Ellipse); topLevel.setMask(topLevelMask); QCOMPARE(topLevel.mask(), topLevelMask); -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(&topLevel); -#endif - QTest::qWait(400); #if defined(Q_WS_WIN) || defined(Q_WS_X11) // We don't control what's happening on other platforms. // and ensure that the top-level doesn't get any update. QCOMPARE(topLevel.numPaintEvents, 0); @@ -8717,15 +8589,12 @@ void tst_QWidget::setClearAndResizeMask() // Clear top-level mask topLevel.clearMask(); QCOMPARE(topLevel.mask(), QRegion()); -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(&topLevel); -#endif QTest::qWait(100); QRegion outsideOldMask(topLevel.rect()); outsideOldMask -= topLevelMask; #if defined(Q_WS_WIN) || defined(Q_WS_X11) // We don't control what's happening on other platforms. // and ensure that the top-level gets an update for the area outside the old mask. - QVERIFY(topLevel.numPaintEvents > 0); + QTRY_VERIFY(topLevel.numPaintEvents > 0); QCOMPARE(topLevel.paintedRegion, outsideOldMask); #endif @@ -8741,7 +8610,7 @@ void tst_QWidget::setClearAndResizeMask() // Mask child widget with a mask that is smaller than the rect const QRegion childMask(0, 0, 50, 50); child.setMask(childMask); - QCOMPARE(child.mask(), childMask); + QTRY_COMPARE(child.mask(), childMask); QTest::qWait(50); // and ensure that the child widget doesn't get any update. #ifdef Q_WS_MAC @@ -8751,7 +8620,7 @@ void tst_QWidget::setClearAndResizeMask() QCOMPARE(child.numPaintEvents, 0); #endif // and the parent widget gets an update for the newly exposed area. - QCOMPARE(topLevel.numPaintEvents, 1); + QTRY_COMPARE(topLevel.numPaintEvents, 1); QRegion expectedParentExpose(child.rect()); expectedParentExpose -= childMask; QCOMPARE(topLevel.paintedRegion, expectedParentExpose); @@ -8812,13 +8681,10 @@ void tst_QWidget::setClearAndResizeMask() resizeParent.setPalette(pal); resizeParent.show(); + QTest::qWaitForWindowShown(&resizeParent); // Disable the size grip on the Mac; otherwise it'll be included when grabbing the window. resizeParent.setFixedSize(resizeParent.size()); resizeChild.show(); -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(&resizeParent); -#endif - QTest::qWait(500); resizeChild.paintedRegion = QRegion(); QTimer::singleShot(100, &resizeChild, SLOT(shrinkMask())); @@ -9141,8 +9007,8 @@ void tst_QWidget::paintOutsidePaintEvent() child2.setAutoFillBackground(true); widget.show(); - qt_x11_wait_for_window_manager(&widget); - QTest::qWait(200); + QTest::qWaitForWindowShown(&widget); + QTest::qWait(20); const QPixmap before = QPixmap::grabWindow(widget.winId()); @@ -9200,13 +9066,11 @@ void tst_QWidget::toplevelLineEditFocus() QLineEdit w; w.show(); -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(&w); -#endif - QTest::qWait(200); + QTest::qWaitForWindowShown(&w); + QTest::qWait(20); - QCOMPARE(QApplication::activeWindow(), (QWidget*)&w); - QCOMPARE(QApplication::focusWidget(), (QWidget*)&w); + QTRY_COMPARE(QApplication::activeWindow(), (QWidget*)&w); + QTRY_COMPARE(QApplication::focusWidget(), (QWidget*)&w); } void tst_QWidget::focusWidget_task254563() @@ -9227,13 +9091,12 @@ void tst_QWidget::focusWidget_task254563() void tst_QWidget::destroyBackingStore() { UpdateWidget w; + w.reset(); w.show(); -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(&w); -#endif + QTest::qWaitForWindowShown(&w); QApplication::processEvents(); - + QTRY_VERIFY(w.numPaintEvents > 0); w.reset(); w.update(); delete qt_widget_private(&w)->topData()->backingStore; @@ -9274,11 +9137,10 @@ void tst_QWidget::rectOutsideCoordinatesLimit_task144779() bigWidget->setAutoFillBackground(true); main.show(); -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(&main); -#endif + QTest::qWaitForWindowShown(&main); + QTest::qWait(10); QCursor::setPos(main.pos()); //get the cursor out of the picture - QTest::qWait(100); + QTest::qWait(50); QPixmap pixmap = QPixmap::grabWindow(main.winId()); QPixmap correct(main.size()); -- cgit v0.12