From 384558d78a9a1bf1d8c8483036e32b616d7f275b Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Wed, 10 Dec 2014 13:50:09 +0100 Subject: Qt OpenGL is deprecated with 5.4. Show that in the docs as well MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Idadf24d5331443d2c947a633029c7d4ea2305caf Reviewed-by: Laszlo Agocs Reviewed-by: Topi Reiniö --- src/opengl/doc/src/qtopengl-index.qdoc | 5 ++--- src/opengl/doc/src/qtopengl-module.qdoc | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/opengl/doc/src/qtopengl-index.qdoc b/src/opengl/doc/src/qtopengl-index.qdoc index ff946c6e4e..3ba5b396ab 100644 --- a/src/opengl/doc/src/qtopengl-index.qdoc +++ b/src/opengl/doc/src/qtopengl-index.qdoc @@ -31,9 +31,8 @@ \brief The Qt OpenGL module offers classes that make it easy to use OpenGL in Qt applications. - \warning Apart from the \l{QGLWidget} class, this module should not be used - anymore for new code. Please use the corresponding OpenGL classes in - \l{Qt Gui}. + \warning This module should not be used anymore for new code. Please + use the corresponding OpenGL classes in \l{Qt Gui}. OpenGL is a standard API for rendering 3D graphics. OpenGL only deals with 3D rendering and provides little or no support for GUI diff --git a/src/opengl/doc/src/qtopengl-module.qdoc b/src/opengl/doc/src/qtopengl-module.qdoc index 8619f04a97..aec68e44c0 100644 --- a/src/opengl/doc/src/qtopengl-module.qdoc +++ b/src/opengl/doc/src/qtopengl-module.qdoc @@ -34,9 +34,8 @@ \brief The Qt OpenGL module offers classes that make it easy to use OpenGL in Qt applications. - \warning Apart from the \l{QGLWidget} class, this module should not be used - anymore for new code. Please use the corresponding OpenGL classes in - \l{Qt Gui}. + \warning This module should not be used anymore for new code. Please + use the corresponding OpenGL classes in \l{Qt Gui}. OpenGL is a standard API for rendering 3D graphics. OpenGL only deals with 3D rendering and provides little or no support for GUI -- cgit v1.2.3 From 15cc31c013afdefcb432bbeb94d10b4121c09e54 Mon Sep 17 00:00:00 2001 From: Dmitry Shachnev Date: Wed, 10 Dec 2014 20:28:29 +0300 Subject: QPlatformSystemTrayIcon: the timeout is in msecs, not secs What gets passed to this function is in milliseconds, not seconds (see QSystemTrayIconPrivate::showMessage_sys_qpa implementation), and the only currently existing implementation (in KDE frameworkintegration) expects milliseconds as well. Change-Id: I7a2c847530391aa73183704251c996664668a740 Reviewed-by: Sean Harmer Reviewed-by: Friedemann Kleint --- src/gui/kernel/qplatformsystemtrayicon.cpp | 4 ++-- src/gui/kernel/qplatformsystemtrayicon.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/gui/kernel/qplatformsystemtrayicon.cpp b/src/gui/kernel/qplatformsystemtrayicon.cpp index 7bc61e6e6e..ba1ccc379d 100644 --- a/src/gui/kernel/qplatformsystemtrayicon.cpp +++ b/src/gui/kernel/qplatformsystemtrayicon.cpp @@ -119,9 +119,9 @@ QPlatformSystemTrayIcon::~QPlatformSystemTrayIcon() /*! \fn void QPlatformSystemTrayIcon::showMessage(const QString &msg, const QString &title, - const QIcon &icon, MessageIcon iconType, int secs) + const QIcon &icon, MessageIcon iconType, int msecs) Shows a balloon message for the entry with the given \a title, message \a msg and \a icon for - the time specified in \a secs. \a iconType is used as a hint for the implementing platform. + the time specified in \a msecs. \a iconType is used as a hint for the implementing platform. \sa QSystemTrayIcon::showMessage() */ diff --git a/src/gui/kernel/qplatformsystemtrayicon.h b/src/gui/kernel/qplatformsystemtrayicon.h index 499b5fca17..1317708cd1 100644 --- a/src/gui/kernel/qplatformsystemtrayicon.h +++ b/src/gui/kernel/qplatformsystemtrayicon.h @@ -70,7 +70,7 @@ public: virtual void updateMenu(QPlatformMenu *menu) = 0; virtual QRect geometry() const = 0; virtual void showMessage(const QString &msg, const QString &title, - const QIcon &icon, MessageIcon iconType, int secs) = 0; + const QIcon &icon, MessageIcon iconType, int msecs) = 0; virtual bool isSystemTrayAvailable() const = 0; virtual bool supportsMessages() const = 0; -- cgit v1.2.3 From 9290383a1e6fdf13f5f2ffe4fbdafa2445e4db61 Mon Sep 17 00:00:00 2001 From: Topi Reinio Date: Wed, 17 Dec 2014 13:04:52 +0100 Subject: qdoc: Remove zero-width-space characters from function signatures The extra character was added in 5.4.0 to allow web browsers to break up long function signatures in a nice manner. However, not every browser supports it, and it causes problems in some code editors when copy-pasting the code. Change-Id: If6a52b92d683788c5e32f40bb8c280d76112723e Reviewed-by: Martin Smith --- src/tools/qdoc/cppcodemarker.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/qdoc/cppcodemarker.cpp b/src/tools/qdoc/cppcodemarker.cpp index 92b6ccca6a..3851ede16c 100644 --- a/src/tools/qdoc/cppcodemarker.cpp +++ b/src/tools/qdoc/cppcodemarker.cpp @@ -136,7 +136,7 @@ QString CppCodeMarker::markedUpSynopsis(const Node *node, if ((style == Detailed) && !node->parent()->name().isEmpty() && (node->type() != Node::Property) && !node->isQmlNode()) - name.prepend(taggedNode(node->parent()) + "::​"); + name.prepend(taggedNode(node->parent()) + "::"); switch (node->type()) { case Node::Namespace: -- cgit v1.2.3 From 8a075c405709eab9c08ed4230d795ca45eabd5a7 Mon Sep 17 00:00:00 2001 From: Alexander Volkov Date: Fri, 12 Dec 2014 14:37:36 +0300 Subject: xcb: Don't return 0 from QXcbKeyboard::possibleKeys MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It's possible to get 0 for baseQtKey in case Caps Lock is used as a layout switcher. So don't include this value in the result. Similar fix was in commit d904533acba1267431ca2c5f0d3e85cc59a20a26. Task-number: QTCREATORBUG-9589 Change-Id: I46fc91f9faf6fd0699f062a72fd2ca3187232f5a Reviewed-by: Jørgen Lind --- src/plugins/platforms/xcb/qxcbkeyboard.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/plugins/platforms/xcb/qxcbkeyboard.cpp b/src/plugins/platforms/xcb/qxcbkeyboard.cpp index 260fb46309..5fb745717b 100644 --- a/src/plugins/platforms/xcb/qxcbkeyboard.cpp +++ b/src/plugins/platforms/xcb/qxcbkeyboard.cpp @@ -957,7 +957,8 @@ QList QXcbKeyboard::possibleKeys(const QKeyEvent *event) const QList result; int baseQtKey = keysymToQtKey(sym, modifiers, lookupString(kb_state, keycode)); - result += (baseQtKey + modifiers); // The base key is _always_ valid, of course + if (baseQtKey) + result += (baseQtKey + modifiers); xkb_mod_index_t shiftMod = xkb_keymap_mod_get_index(xkb_keymap, "Shift"); xkb_mod_index_t altMod = xkb_keymap_mod_get_index(xkb_keymap, "Alt"); -- cgit v1.2.3 From 1acb774b2b11638ee40c8a96af659071926732f9 Mon Sep 17 00:00:00 2001 From: Rafael Roquetto Date: Wed, 17 Dec 2014 11:19:46 -0200 Subject: Remove unused code from QFontEngineFT. This method is not being called anywhere. Change-Id: Ia32e8b48d324e4848db666de4d274a260d22b06d Reviewed-by: Konstantin Ritt Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/gui/text/qfontengine_ft.cpp | 30 ------------------------------ src/gui/text/qfontengine_ft_p.h | 3 --- 2 files changed, 33 deletions(-) diff --git a/src/gui/text/qfontengine_ft.cpp b/src/gui/text/qfontengine_ft.cpp index 8b6c9a192c..792bfadb5e 100644 --- a/src/gui/text/qfontengine_ft.cpp +++ b/src/gui/text/qfontengine_ft.cpp @@ -1410,36 +1410,6 @@ QFontEngineFT::QGlyphSet *QFontEngineFT::loadTransformedGlyphSet(const QTransfor return gs; } -bool QFontEngineFT::loadGlyphs(QGlyphSet *gs, const glyph_t *glyphs, int num_glyphs, - const QFixedPoint *positions, - GlyphFormat format) -{ - FT_Face face = 0; - - for (int i = 0; i < num_glyphs; ++i) { - QFixed spp = subPixelPositionForX(positions[i].x); - Glyph *glyph = gs ? gs->getGlyph(glyphs[i], spp) : 0; - if (glyph == 0 || glyph->format != format) { - if (!face) { - face = lockFace(); - FT_Matrix m = matrix; - FT_Matrix_Multiply(&gs->transformationMatrix, &m); - FT_Set_Transform(face, &m, 0); - freetype->matrix = m; - } - if (!loadGlyph(gs, glyphs[i], spp, format)) { - unlockFace(); - return false; - } - } - } - - if (face) - unlockFace(); - - return true; -} - void QFontEngineFT::getUnscaledGlyph(glyph_t glyph, QPainterPath *path, glyph_metrics_t *metrics) { FT_Face face = lockFace(Unscaled); diff --git a/src/gui/text/qfontengine_ft_p.h b/src/gui/text/qfontengine_ft_p.h index 5b397e0034..383902c784 100644 --- a/src/gui/text/qfontengine_ft_p.h +++ b/src/gui/text/qfontengine_ft_p.h @@ -269,9 +269,6 @@ private: Glyph *loadGlyphFor(glyph_t g, QFixed subPixelPosition, GlyphFormat format, const QTransform &t); QGlyphSet *loadTransformedGlyphSet(const QTransform &matrix); - bool loadGlyphs(QGlyphSet *gs, const glyph_t *glyphs, int num_glyphs, - const QFixedPoint *positions, - GlyphFormat format = Format_Render); QFontEngineFT(const QFontDef &fd); virtual ~QFontEngineFT(); -- cgit v1.2.3 From 627afca13cf1b23489a1c61d1eb66cbdafff91bd Mon Sep 17 00:00:00 2001 From: Roger Maclean Date: Mon, 15 Dec 2014 17:17:43 -0500 Subject: QNX: Handle the case where screen returns a refresh rate of 0. Screen sometimes returns a refresh rate of 0. This has been observed on VMWare though it is unknown if this is always the case and whether it happens on other platforms as well. Returning a refresh rate of 0 causes animations to fail so we're better off returning a value that might be wrong than returning 0. Change-Id: I4846017bcb0d6bd52faad727df4ef6dac1a6250f Reviewed-by: Rafael Roquetto --- src/plugins/platforms/qnx/qqnxscreen.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/plugins/platforms/qnx/qqnxscreen.cpp b/src/plugins/platforms/qnx/qqnxscreen.cpp index f3f93e7f64..d42babb8ab 100644 --- a/src/plugins/platforms/qnx/qqnxscreen.cpp +++ b/src/plugins/platforms/qnx/qqnxscreen.cpp @@ -329,7 +329,8 @@ qreal QQnxScreen::refreshRate() const { screen_display_mode_t displayMode; int result = screen_get_display_property_pv(m_display, SCREEN_PROPERTY_MODE, reinterpret_cast(&displayMode)); - if (result != 0) { + // Screen shouldn't really return 0 but it does so default to 60 or things break. + if (result != 0 || displayMode.refresh == 0) { qWarning("QQnxScreen: Failed to query screen mode. Using default value of 60Hz"); return 60.0; } -- cgit v1.2.3 From c4bee2c47febb110946e6b80200fb269e6ea9f77 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Mon, 15 Dec 2014 16:14:36 +0100 Subject: Revert "Fix printing of semitransparent images to PDF" The patch was incorrect and caused semi-transparent images have inversed colors instead of fixing it. This reverts commit 624740cdcdd4abfb15bbbc8a8aa056c57712499f. Change-Id: I3f1fa17309fcb53995520843449aae972e0090b8 Reviewed-by: Andy Shaw --- src/gui/painting/qpdf.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/gui/painting/qpdf.cpp b/src/gui/painting/qpdf.cpp index 46d016de6b..473231b142 100644 --- a/src/gui/painting/qpdf.cpp +++ b/src/gui/painting/qpdf.cpp @@ -2083,10 +2083,8 @@ int QPdfEnginePrivate::writeImage(const QByteArray &data, int width, int height, } if (maskObject > 0) xprintf("/Mask %d 0 R\n", maskObject); - if (softMaskObject > 0) { + if (softMaskObject > 0) xprintf("/SMask %d 0 R\n", softMaskObject); - xprintf("/Decode [1 0 1 0 1 0]\n"); - } int lenobj = requestObject(); xprintf("/Length %d 0 R\n", lenobj); -- cgit v1.2.3 From f7716732a5d406a21fa0ca1bcc8607eb21ba4e54 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Tue, 9 Dec 2014 16:27:29 +0100 Subject: Remove direct linkage to dbus and qdbus It appears that there is no code in the plugin that actually uses dbus. Change-Id: I654cf0b8f5ecc018f2c6ae8701220f7496915a60 Reviewed-by: Thiago Macieira --- src/plugins/platforms/xcb/xcb-plugin.pro | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/plugins/platforms/xcb/xcb-plugin.pro b/src/plugins/platforms/xcb/xcb-plugin.pro index f14fcde73f..129076c916 100644 --- a/src/plugins/platforms/xcb/xcb-plugin.pro +++ b/src/plugins/platforms/xcb/xcb-plugin.pro @@ -99,11 +99,6 @@ QMAKE_CFLAGS += $$QMAKE_CFLAGS_XCB CONFIG += qpa/genericunixfontdatabase -contains(QT_CONFIG, dbus) { -QT += dbus -LIBS += -ldbus-1 -} - OTHER_FILES += xcb.json README contains(QT_CONFIG, xcb-qt) { -- cgit v1.2.3 From 622df95fee5ddea737ae3030dbae1286ffd4a454 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Thu, 18 Dec 2014 15:44:38 +0100 Subject: Prospective stabilization fix for tst_qwindow::positioning(default) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Our theory for the failure of framePosition() not having the expected value after setFramePosition towards the end of the test is that we try to call setFramePosition() while the getting-back-from-fullscreen-to-normal window animation is still running, at which point the compositor may just choose to ignore our move request. Similarly to when going fullscreen, also wait when coming back from it. Change-Id: Icfc92f277d96dccdfad772c4aac252b2a20c6196 Reviewed-by: Jørgen Lind --- tests/auto/gui/kernel/qwindow/tst_qwindow.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp index a5442968c6..61ba99c7de 100644 --- a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp +++ b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp @@ -298,6 +298,8 @@ void tst_QWindow::positioning() QTRY_VERIFY(window.received(QEvent::Resize) > 0); #endif + QTest::qWait(2000); + QTRY_COMPARE(originalPos, window.position()); QTRY_COMPARE(originalFramePos, window.framePosition()); QTRY_COMPARE(originalMargins, window.frameMargins()); -- cgit v1.2.3 From 0cd1ed0883e067edab24006b23fb1c663ba62041 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 17 Dec 2014 21:07:24 -0800 Subject: Fix running tst_qmessagehandler when QT_MESSAGE_PATTERN is set This test fails if the environment has the variable set. Change-Id: Ibd54ff3e6e22a885341898889088ac56e84282b1 Reviewed-by: David Faure Reviewed-by: Kai Koehne Reviewed-by: Olivier Goffart --- tests/auto/corelib/global/qlogging/tst_qlogging.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/auto/corelib/global/qlogging/tst_qlogging.cpp b/tests/auto/corelib/global/qlogging/tst_qlogging.cpp index 749c7da789..68b1fef71d 100644 --- a/tests/auto/corelib/global/qlogging/tst_qlogging.cpp +++ b/tests/auto/corelib/global/qlogging/tst_qlogging.cpp @@ -40,6 +40,9 @@ class tst_qmessagehandler : public QObject { Q_OBJECT +public: + tst_qmessagehandler(); + public slots: void initTestCase(); @@ -92,6 +95,12 @@ void customMsgHandler(QtMsgType type, const char *msg) s_message = QString::fromLocal8Bit(msg); } +tst_qmessagehandler::tst_qmessagehandler() +{ + // ensure it's unset, otherwise we'll have trouble + qputenv("QT_MESSAGE_PATTERN", ""); +} + void tst_qmessagehandler::initTestCase() { m_appDir = QFINDTESTDATA("app"); -- cgit v1.2.3 From 7fad14f4e23a5e4852f76e4493bab15c83a9e22f Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 17 Dec 2014 21:14:06 -0800 Subject: tst_qlogging: add tests for %{pid} and %{threadid} Since those are unpredictable, there's little we can match, besides the "0x" for the QThread pointer. For the PID, at least we can compare it to the value from QProcess. Change-Id: I89420306863b95c82be761baabd733a7f17eba5e Reviewed-by: David Faure Reviewed-by: Kai Koehne --- tests/auto/corelib/global/qlogging/tst_qlogging.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/auto/corelib/global/qlogging/tst_qlogging.cpp b/tests/auto/corelib/global/qlogging/tst_qlogging.cpp index 68b1fef71d..140b349c64 100644 --- a/tests/auto/corelib/global/qlogging/tst_qlogging.cpp +++ b/tests/auto/corelib/global/qlogging/tst_qlogging.cpp @@ -765,6 +765,12 @@ void tst_qmessagehandler::qMessagePattern_data() << "A DEBUG qDebug " << "A qWarning "); + QTest::newRow("pid") << "%{pid}: %{message}" + << true << QList(); // can't match anything, just test validity + QTest::newRow("threadid") << "ThreadId:%{threadid}: %{message}" + << true << (QList() + << "ThreadId:0x"); + // This test won't work when midnight is too close... wait a bit while (QTime::currentTime() > QTime(23, 59, 30)) QTest::qWait(10000); @@ -820,6 +826,7 @@ void tst_qmessagehandler::qMessagePattern() process.start(appExe); QVERIFY2(process.waitForStarted(), qPrintable( QString::fromLatin1("Could not start %1: %2").arg(appExe, process.errorString()))); + QByteArray pid = QByteArray::number(process.processId()); process.waitForFinished(); QByteArray output = process.readAllStandardError(); @@ -834,6 +841,8 @@ void tst_qmessagehandler::qMessagePattern() QVERIFY(output.contains(e)); } } + if (pattern.startsWith("%{pid}")) + QVERIFY2(output.startsWith('"' + pid), "PID: " + pid + "\noutput:\n" + output); #endif } -- cgit v1.2.3 From 2bd8443663676440dd03a699f8bbb42fb18cabb5 Mon Sep 17 00:00:00 2001 From: Alejandro Exojo Date: Fri, 12 Dec 2014 12:12:13 +0100 Subject: doc: Fix mistake in QProgressBar::orientation Reported on qt-interest: should say "true" instead of "false". Change-Id: Ic9d2608631679896179ae8601790847163a9224c Reviewed-by: Martin Smith Reviewed-by: Sze Howe Koh --- src/widgets/widgets/qprogressbar.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/widgets/widgets/qprogressbar.cpp b/src/widgets/widgets/qprogressbar.cpp index 5501247973..58aec8ee9a 100644 --- a/src/widgets/widgets/qprogressbar.cpp +++ b/src/widgets/widgets/qprogressbar.cpp @@ -525,7 +525,7 @@ Qt::Orientation QProgressBar::orientation() const \property QProgressBar::invertedAppearance \brief whether or not a progress bar shows its progress inverted - If this property is \c false, the progress bar grows in the other + If this property is \c true, the progress bar grows in the other direction (e.g. from right to left). By default, the progress bar is not inverted. -- cgit v1.2.3 From 7869ee5b9d74a9bcf1cff097fb93b108146f4df8 Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Wed, 10 Dec 2014 15:08:20 +0100 Subject: qdoc: Fixed broken TOC links to Reimplemented sections MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This update fixes some links in the table of contents on class reference pages. Links to sections of reimplemented functions did not work because the word 'reimplemented' was not included in the anchor. This update fixes that bug. Change-Id: Ifae972c45ebf6c81e865cfb36f645ea42d74cf55 Task-number: QTBUG-42237 Reviewed-by: Topi Reiniö --- src/tools/qdoc/htmlgenerator.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/tools/qdoc/htmlgenerator.cpp b/src/tools/qdoc/htmlgenerator.cpp index 0f5bf26e71..ced7e637b3 100644 --- a/src/tools/qdoc/htmlgenerator.cpp +++ b/src/tools/qdoc/htmlgenerator.cpp @@ -1226,11 +1226,10 @@ void HtmlGenerator::generateClassLikeNode(InnerNode* inner, CodeMarker* marker) } if (!s->reimpMembers.isEmpty()) { QString name = QString("Reimplemented ") + (*s).name; + QString ref = registerRef(name.toLower()); // out() << "
\n"; - out() << "" << divNavTop << "\n"; - out() << "

" << protectEnc(name) << "

\n"; + out() << "" << divNavTop << "\n"; + out() << "

" << protectEnc(name) << "

\n"; generateSection(s->reimpMembers, inner, marker, CodeMarker::Summary); } @@ -2221,7 +2220,7 @@ void HtmlGenerator::generateTableOfContents(const Node *node, else if (sections && (node->isClass() || node->isNamespace() || node->isQmlType())) { QList
::ConstIterator s = sections->constBegin(); while (s != sections->constEnd()) { - if (!s->members.isEmpty() || !s->reimpMembers.isEmpty()) { + if (!s->members.isEmpty()) { out() << "
  • " << (*s).name << "
  • \n"; } + if (!s->reimpMembers.isEmpty()) { + QString ref = QString("Reimplemented ") + (*s).pluralMember; + out() << "
  • " << QString("Reimplemented ") + (*s).name + << "
  • \n"; + } ++s; } out() << "
  • Date: Fri, 19 Dec 2014 00:18:07 +0100 Subject: MSVC: Restore 'public' accessibility of QMetaType member functions They were made 'private' as a side effect of a change enabling support of template friends for MSVC. However, accessibility is part of the MSVC's name mangling and thus BC was broken. [ChangeLog][Important Behavior Changes] Restored binary compatibility with Qt 5.3.2 on Windows when using MSVC 2012 or MSVC 2013. This means that Qt 5.4.1 is no longer binary compatible with Qt 5.4.0 when using either of those compilers. Change-Id: I18679aa15821a7365606dc80fdc8411641573820 Reviewed-by: Lars Knoll --- src/corelib/kernel/qmetatype.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/kernel/qmetatype.h b/src/corelib/kernel/qmetatype.h index af38589903..7a45e21253 100644 --- a/src/corelib/kernel/qmetatype.h +++ b/src/corelib/kernel/qmetatype.h @@ -640,7 +640,7 @@ private: static bool registerDebugStreamOperatorFunction(const QtPrivate::AbstractDebugStreamFunction *f, int type); #endif -#ifndef Q_NO_TEMPLATE_FRIENDS +#if !defined(Q_NO_TEMPLATE_FRIENDS) && !defined(Q_CC_MSVC) #ifndef Q_QDOC template friend bool qRegisterSequentialConverter(); -- cgit v1.2.3 From a07120d496c43d45792dc5ca92d93eea37f32cec Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Fri, 5 Dec 2014 10:22:28 +0100 Subject: Don't clear lineedit in non normal echo mode when validation is invalid This fixes a regression introduced with c09e9f71173a698670d6c728291ee24f53d50800 which caused the lineedit to clear the whole text when an invalid character was entered into a lineedit with an echo mode that was not Normal and a validator was set. Now if undo() is called directly then it will still clear the text as it is considered to be called as a user. Whereas the validation will take care of the invalid entry by using internalUndo() as before which avoids the clearing of the entire text. Task-number: QTBUG-29318 Change-Id: I5ff5777a75ab864de2217441b5f518f50646bd8f Reviewed-by: Friedemann Kleint Reviewed-by: Giuseppe D'Angelo --- src/widgets/widgets/qwidgetlinecontrol.cpp | 23 +++++++--- src/widgets/widgets/qwidgetlinecontrol_p.h | 2 +- .../widgets/widgets/qlineedit/tst_qlineedit.cpp | 51 ++++++++++++++++------ 3 files changed, 55 insertions(+), 21 deletions(-) diff --git a/src/widgets/widgets/qwidgetlinecontrol.cpp b/src/widgets/widgets/qwidgetlinecontrol.cpp index e6385ba390..7033eeea22 100644 --- a/src/widgets/widgets/qwidgetlinecontrol.cpp +++ b/src/widgets/widgets/qwidgetlinecontrol.cpp @@ -279,6 +279,23 @@ void QWidgetLineControl::clear() separate(); finishChange(priorState, /*update*/false, /*edited*/false); } +/*! + \internal + + Undoes the previous operation. +*/ + +void QWidgetLineControl::undo() +{ + // Undo works only for clearing the line when in any of password the modes + if (m_echoMode == QLineEdit::Normal) { + internalUndo(); + finishChange(-1, true); + } else { + cancelPasswordEchoTimer(); + clear(); + } +} /*! \internal @@ -1278,12 +1295,6 @@ void QWidgetLineControl::internalUndo(int until) cancelPasswordEchoTimer(); internalDeselect(); - // Undo works only for clearing the line when in any of password the modes - if (m_echoMode != QLineEdit::Normal) { - clear(); - return; - } - while (m_undoState && m_undoState > until) { Command& cmd = m_history[--m_undoState]; switch (cmd.type) { diff --git a/src/widgets/widgets/qwidgetlinecontrol_p.h b/src/widgets/widgets/qwidgetlinecontrol_p.h index f21d88177c..49d9413fc0 100644 --- a/src/widgets/widgets/qwidgetlinecontrol_p.h +++ b/src/widgets/widgets/qwidgetlinecontrol_p.h @@ -245,7 +245,7 @@ public: void insert(const QString &); void clear(); - void undo() { internalUndo(); finishChange(-1, true); } + void undo(); void redo() { internalRedo(); finishChange(); } void selectWordAtPos(int); diff --git a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp index bf4d1f2ebd..fec79326c8 100644 --- a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp +++ b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp @@ -2512,6 +2512,7 @@ void tst_QLineEdit::setValidator_QIntValidator_data() QTest::addColumn("expectedText"); QTest::addColumn("useKeys"); QTest::addColumn("is_valid"); + QTest::addColumn("echoMode"); for (int i=0; i<2; i++) { bool useKeys = false; @@ -2528,7 +2529,8 @@ void tst_QLineEdit::setValidator_QIntValidator_data() << QString("1") << QString("1") << bool(useKeys) - << bool(true); + << bool(true) + << uint(QLineEdit::Normal); QTest::newRow(QString(inputMode + "range [3,7] valid '3'").toLatin1()) << 3 @@ -2536,7 +2538,8 @@ void tst_QLineEdit::setValidator_QIntValidator_data() << QString("3") << QString("3") << bool(useKeys) - << bool(true); + << bool(true) + << uint(QLineEdit::Normal); QTest::newRow(QString(inputMode + "range [3,7] valid '7'").toLatin1()) << 3 @@ -2544,7 +2547,8 @@ void tst_QLineEdit::setValidator_QIntValidator_data() << QString("7") << QString("7") << bool(useKeys) - << bool(true); + << bool(true) + << uint(QLineEdit::Normal); QTest::newRow(QString(inputMode + "range [0,100] valid '9'").toLatin1()) << 0 @@ -2552,7 +2556,8 @@ void tst_QLineEdit::setValidator_QIntValidator_data() << QString("9") << QString("9") << bool(useKeys) - << bool(true); + << bool(true) + << uint(QLineEdit::Normal); QTest::newRow(QString(inputMode + "range [0,100] valid '12'").toLatin1()) << 0 @@ -2560,7 +2565,8 @@ void tst_QLineEdit::setValidator_QIntValidator_data() << QString("12") << QString("12") << bool(useKeys) - << bool(true); + << bool(true) + << uint(QLineEdit::Normal); QTest::newRow(QString(inputMode + "range [-100,100] valid '-12'").toLatin1()) << -100 @@ -2568,7 +2574,8 @@ void tst_QLineEdit::setValidator_QIntValidator_data() << QString("-12") << QString("-12") << bool(useKeys) - << bool(true); + << bool(true) + << uint(QLineEdit::Normal); // invalid data // characters not allowed in QIntValidator @@ -2578,7 +2585,8 @@ void tst_QLineEdit::setValidator_QIntValidator_data() << QString("a") << QString("") << bool(useKeys) - << bool(false); + << bool(false) + << uint(QLineEdit::Normal); QTest::newRow(QString(inputMode + "range [0,9] inv 'A'").toLatin1()) << 0 @@ -2586,7 +2594,8 @@ void tst_QLineEdit::setValidator_QIntValidator_data() << QString("A") << QString("") << bool(useKeys) - << bool(false); + << bool(false) + << uint(QLineEdit::Normal); // minus sign only allowed with a range on the negative side QTest::newRow(QString(inputMode + "range [0,100] inv '-'").toLatin1()) << 0 @@ -2594,36 +2603,48 @@ void tst_QLineEdit::setValidator_QIntValidator_data() << QString("-") << QString("") << bool(useKeys) - << bool(false); + << bool(false) + << uint(QLineEdit::Normal); QTest::newRow(QString(inputMode + "range [0,100] int '153'").toLatin1()) << 0 << 100 << QString("153") << QString(useKeys ? "15" : "") << bool(useKeys) - << bool(useKeys ? true : false); + << bool(useKeys ? true : false) + << uint(QLineEdit::Normal); QTest::newRow(QString(inputMode + "range [-100,100] int '-153'").toLatin1()) << -100 << 100 << QString("-153") << QString(useKeys ? "-15" : "") << bool(useKeys) - << bool(useKeys ? true : false); + << bool(useKeys ? true : false) + << uint(QLineEdit::Normal); QTest::newRow(QString(inputMode + "range [3,7] int '2'").toLatin1()) << 3 << 7 << QString("2") << QString("2") << bool(useKeys) - << bool(false); - + << bool(false) + << uint(QLineEdit::Normal); QTest::newRow(QString(inputMode + "range [3,7] int '8'").toLatin1()) << 3 << 7 << QString("8") << QString("") << bool(useKeys) - << bool(false); + << bool(false) + << uint(QLineEdit::Normal); + QTest::newRow(QString(inputMode + "range [0,99] inv 'a-a'").toLatin1()) + << 0 + << 99 + << QString("19a") + << QString(useKeys ? "19" : "") + << bool(useKeys) + << bool(useKeys ? true : false) + << uint(QLineEdit::Password); } } @@ -2635,9 +2656,11 @@ void tst_QLineEdit::setValidator_QIntValidator() QFETCH(QString, expectedText); QFETCH(bool, useKeys); QFETCH(bool, is_valid); + QFETCH(uint, echoMode); QIntValidator intValidator(mini, maxi, 0); QLineEdit *testWidget = ensureTestWidget(); + testWidget->setEchoMode((QLineEdit::EchoMode)echoMode); testWidget->setValidator(&intValidator); QVERIFY(testWidget->text().isEmpty()); //qDebug("1 input: '" + input + "' Exp: '" + expectedText + "'"); -- cgit v1.2.3 From 0fb839ac62fe9feb8700783270d03f1e9ccb3914 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Fri, 19 Dec 2014 10:36:46 +0100 Subject: Android: Fix QResourceEngine tests The test expects all the files to reside in the file system, both for loading the runtime resources and for comparisons. Since we can't deploy directly to the file system on Android, we go via qrc and extract the files on startup instead. Change-Id: I17ff8985cb17dbfc45f0fb692ca46558bb5c5cdc Reviewed-by: BogDan Vatra --- .../io/qresourceengine/android_testdata.qrc | 21 +++++++++ .../corelib/io/qresourceengine/qresourceengine.pro | 4 ++ .../io/qresourceengine/tst_qresourceengine.cpp | 54 ++++++++++++++++++---- 3 files changed, 71 insertions(+), 8 deletions(-) create mode 100644 tests/auto/corelib/io/qresourceengine/android_testdata.qrc diff --git a/tests/auto/corelib/io/qresourceengine/android_testdata.qrc b/tests/auto/corelib/io/qresourceengine/android_testdata.qrc new file mode 100644 index 0000000000..ad3389ac20 --- /dev/null +++ b/tests/auto/corelib/io/qresourceengine/android_testdata.qrc @@ -0,0 +1,21 @@ + + + runtime_resource.rcc + parentdir.txt + testqrc/blahblah.txt + testqrc/currentdir.txt + testqrc/currentdir2.txt + testqrc/search_file.txt + testqrc/aliasdir/aliasdir.txt + testqrc/aliasdir/compressme.txt + testqrc/otherdir/otherdir.txt + testqrc/searchpath1/search_file.txt + testqrc/searchpath2/search_file.txt + testqrc/subdir/subdir.txt + testqrc/test/test/test2.txt + testqrc/test/test/test1.txt + testqrc/test/german.txt + testqrc/test/testdir.txt + testqrc/test/testdir2.txt + + diff --git a/tests/auto/corelib/io/qresourceengine/qresourceengine.pro b/tests/auto/corelib/io/qresourceengine/qresourceengine.pro index b7606eb3fc..92d0952b89 100644 --- a/tests/auto/corelib/io/qresourceengine/qresourceengine.pro +++ b/tests/auto/corelib/io/qresourceengine/qresourceengine.pro @@ -16,3 +16,7 @@ TESTDATA += \ testqrc/* GENERATED_TESTDATA = $${runtime_resource.target} DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 + +android:!android-no-sdk { + RESOURCES += android_testdata.qrc +} diff --git a/tests/auto/corelib/io/qresourceengine/tst_qresourceengine.cpp b/tests/auto/corelib/io/qresourceengine/tst_qresourceengine.cpp index 20a5fa2786..5f8b79d2fc 100644 --- a/tests/auto/corelib/io/qresourceengine/tst_qresourceengine.cpp +++ b/tests/auto/corelib/io/qresourceengine/tst_qresourceengine.cpp @@ -40,7 +40,13 @@ class tst_QResourceEngine: public QObject Q_OBJECT public: - tst_QResourceEngine() : m_runtimeResourceRcc(QFINDTESTDATA("runtime_resource.rcc")) {} + tst_QResourceEngine() +#if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK) + : m_runtimeResourceRcc(QFileInfo(QStandardPaths::writableLocation(QStandardPaths::CacheLocation) + QStringLiteral("/runtime_resource.rcc")).absoluteFilePath()) +#else + : m_runtimeResourceRcc(QFINDTESTDATA("runtime_resource.rcc")) +#endif + {} private slots: void initTestCase(); @@ -62,6 +68,29 @@ private: void tst_QResourceEngine::initTestCase() { +#if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK) + QString sourcePath(QStringLiteral(":/android_testdata/")); + QString dataPath(QStandardPaths::writableLocation(QStandardPaths::CacheLocation)); + + QDirIterator it(sourcePath, QDirIterator::Subdirectories); + while (it.hasNext()) { + it.next(); + + QFileInfo fileInfo = it.fileInfo(); + if (!fileInfo.isDir()) { + QString destination(dataPath + QLatin1Char('/') + fileInfo.filePath().mid(sourcePath.length())); + QFileInfo destinationFileInfo(destination); + if (!destinationFileInfo.exists()) { + QVERIFY(QDir().mkpath(destinationFileInfo.path())); + QVERIFY(QFile::copy(fileInfo.filePath(), destination)); + QVERIFY(QFileInfo(destination).exists()); + } + } + } + + QVERIFY(QDir::setCurrent(dataPath)); +#endif + QVERIFY(!m_runtimeResourceRcc.isEmpty()); QVERIFY(QResource::registerResource(m_runtimeResourceRcc)); QVERIFY(QResource::registerResource(m_runtimeResourceRcc, "/secondary_root/")); @@ -85,16 +114,25 @@ void tst_QResourceEngine::checkStructure_data() QFileInfo info; + QStringList rootContents; + rootContents << QLatin1String("aliasdir") + << QLatin1String("otherdir") + << QLatin1String("qt-project.org") + << QLatin1String("runtime_resource") + << QLatin1String("searchpath1") + << QLatin1String("searchpath2") + << QLatin1String("secondary_root") + << QLatin1String("test") + << QLatin1String("withoutslashes"); + +#if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK) + rootContents.insert(1, QLatin1String("android_testdata")); +#endif + QTest::newRow("root dir") << QString(":/") << QString() << (QStringList() << "search_file.txt") - << (QStringList() << QLatin1String("aliasdir") << QLatin1String("otherdir") - << QLatin1String("qt-project.org") - << QLatin1String("runtime_resource") - << QLatin1String("searchpath1") << QLatin1String("searchpath2") - << QLatin1String("secondary_root") - << QLatin1String("test") - << QLatin1String("withoutslashes")) + << rootContents << QLocale::c() << qlonglong(0); -- cgit v1.2.3 From 678a2834989c6571e6fae531447f468d9e03970b Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Fri, 19 Dec 2014 10:51:13 +0100 Subject: Android: Fix QStandardPaths test QStandardPaths::writableLocation() is documented to return the empty string if no matching writable location can be determined. This is the case for e.g. FontsLocation and ApplicationsLocation on Android. We need to still accept this as a valid response. Change-Id: I2824e9dcfd41b1c24dbf3896b7ae9b5260e9accd Reviewed-by: David Faure Reviewed-by: BogDan Vatra --- tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp b/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp index a1732a0a79..21e020404b 100644 --- a/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp +++ b/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp @@ -472,7 +472,7 @@ void tst_qstandardpaths::testAllWritableLocations() QString loc = QStandardPaths::writableLocation(location); if (loc.size() > 1) // workaround for unlikely case of locations that return '/' QCOMPARE(loc.endsWith(QLatin1Char('/')), false); - QVERIFY(loc.contains(QLatin1Char('/'))); + QVERIFY(loc.isEmpty() || loc.contains(QLatin1Char('/'))); QVERIFY(!loc.contains(QLatin1Char('\\'))); } -- cgit v1.2.3 From 0655504015c4f1ac9d65fef85c3c0554d7d8fc93 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Fri, 19 Dec 2014 10:38:01 +0100 Subject: Also search current directory in QFINDTESTDATA On Android, none of the file system paths used for QFINDTESTDATA currently are suitable. We do have the possibility of putting test data in qrc, but in cases where the test is specifically testing access to the regular file system, we need a way to find files there as well. We add a fifth step when all other fail, which searches the current active directory for the data. Change-Id: I4f02f8530b5843eb282bd112ea03ed6a476593d6 Reviewed-by: BogDan Vatra --- src/testlib/qtestcase.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp index 24d563045b..2851f83427 100644 --- a/src/testlib/qtestcase.cpp +++ b/src/testlib/qtestcase.cpp @@ -2722,6 +2722,13 @@ QString QTest::qFindTestData(const QString& base, const char *file, int line, co found = candidate; } + // 5. Try current directory + if (found.isEmpty()) { + QString candidate = QString::fromLatin1("%1/%2").arg(QDir::currentPath()).arg(base); + if (QFileInfo(candidate).exists()) + found = candidate; + } + if (found.isEmpty()) { QTest::qWarn(qPrintable( QString::fromLatin1("testdata %1 could not be located!").arg(base)), -- cgit v1.2.3 From b6514cf30761b01b477edef67217a48a59268886 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 17 Dec 2014 11:16:45 +0100 Subject: Diaglib: Add helper functions for analyzing non-Latin strings. Add a functions to dump out texts character by character and as code. Task-number: QTBUG-43191 Change-Id: I1ac17f2485563f909b71bb1fbd1fd595d1d94223 Reviewed-by: Andy Shaw Reviewed-by: Shawn Rutledge Reviewed-by: Friedemann Kleint --- tests/manual/diaglib/README.txt | 11 + tests/manual/diaglib/diaglib.pri | 2 + tests/manual/diaglib/textdump.cpp | 451 ++++++++++++++++++++++++++++++++++++++ tests/manual/diaglib/textdump.h | 48 ++++ 4 files changed, 512 insertions(+) create mode 100644 tests/manual/diaglib/textdump.cpp create mode 100644 tests/manual/diaglib/textdump.h diff --git a/tests/manual/diaglib/README.txt b/tests/manual/diaglib/README.txt index 13387f5a2a..0fb226c750 100644 --- a/tests/manual/diaglib/README.txt +++ b/tests/manual/diaglib/README.txt @@ -12,6 +12,17 @@ code can be enlosed within #ifdef to work without it as well. All functions and classes are in the QtDiag namespace. +function dumpText() (textdump.h) + Returns a string containing the input text split up in characters + listing category, script, direction etc. + Useful for analyzing non-Latin text. + +function dumpTextAsCode() (textdump.h) + Returns a string containing a code snippet creating a QString + by appending the unicode value of character of the input. + This is useful for constructing non-Latin strings with purely ASCII + source code. + class EventFilter (eventfilter.h): An event filter that logs Qt events to qDebug() depending on configured categories (for example mouse, keyboard, etc). diff --git a/tests/manual/diaglib/diaglib.pri b/tests/manual/diaglib/diaglib.pri index e162d5f105..a1f1893f52 100644 --- a/tests/manual/diaglib/diaglib.pri +++ b/tests/manual/diaglib/diaglib.pri @@ -1,9 +1,11 @@ INCLUDEPATH += $$PWD SOURCES += \ + $$PWD/textdump.cpp \ $$PWD/eventfilter.cpp \ $$PWD/qwindowdump.cpp \ HEADERS += \ + $$PWD/textdump.h \ $$PWD/eventfilter.h \ $$PWD/qwindowdump.h \ $$PWD/nativewindowdump.h diff --git a/tests/manual/diaglib/textdump.cpp b/tests/manual/diaglib/textdump.cpp new file mode 100644 index 0000000000..7f08350874 --- /dev/null +++ b/tests/manual/diaglib/textdump.cpp @@ -0,0 +1,451 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL21$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "textdump.h" + +#include +#include + +namespace QtDiag { + +struct EnumLookup { + int value; + const char *description; +}; + +static const EnumLookup specialCharactersEnumLookup[] = +{ + {QChar::Null, "Null"}, +#if QT_VERSION >= 0x050000 + {QChar::Tabulation, "Tabulation"}, + {QChar::LineFeed, "LineFeed"}, + {QChar::CarriageReturn, "CarriageReturn"}, + {QChar::Space, "Space"}, +#endif + {QChar::Nbsp, "Nbsp"}, +#if QT_VERSION >= 0x050000 + {QChar::SoftHyphen, "SoftHyphen"}, +#endif + {QChar::ReplacementCharacter, "ReplacementCharacter"}, + {QChar::ObjectReplacementCharacter, "ObjectReplacementCharacter"}, + {QChar::ByteOrderMark, "ByteOrderMark"}, + {QChar::ByteOrderSwapped, "ByteOrderSwapped"}, + {QChar::ParagraphSeparator, "ParagraphSeparator"}, + {QChar::LineSeparator, "LineSeparator"}, +#if QT_VERSION >= 0x050000 + {QChar::LastValidCodePoint, "LastValidCodePoint"} +#endif +}; + +static const EnumLookup categoryEnumLookup[] = +{ + {QChar::Mark_NonSpacing, "Mark_NonSpacing"}, + {QChar::Mark_SpacingCombining, "Mark_SpacingCombining"}, + {QChar::Mark_Enclosing, "Mark_Enclosing"}, + + {QChar::Number_DecimalDigit, "Number_DecimalDigit"}, + {QChar::Number_Letter, "Number_Letter"}, + {QChar::Number_Other, "Number_Other"}, + + {QChar::Separator_Space, "Separator_Space"}, + {QChar::Separator_Line, "Separator_Line"}, + {QChar::Separator_Paragraph, "Separator_Paragraph"}, + + {QChar::Other_Control, "Other_Control"}, + {QChar::Other_Format, "Other_Format"}, + {QChar::Other_Surrogate, "Other_Surrogate"}, + {QChar::Other_PrivateUse, "Other_PrivateUse"}, + {QChar::Other_NotAssigned, "Other_NotAssigned"}, + + {QChar::Letter_Uppercase, "Letter_Uppercase"}, + {QChar::Letter_Lowercase, "Letter_Lowercase"}, + {QChar::Letter_Titlecase, "Letter_Titlecase"}, + {QChar::Letter_Modifier, "Letter_Modifier"}, + {QChar::Letter_Other, "Letter_Other"}, + + {QChar::Punctuation_Connector, "Punctuation_Connector"}, + {QChar::Punctuation_Dash, "Punctuation_Dash"}, + {QChar::Punctuation_Open, "Punctuation_Open"}, + {QChar::Punctuation_Close, "Punctuation_Close"}, + {QChar::Punctuation_InitialQuote, "Punctuation_InitialQuote"}, + {QChar::Punctuation_FinalQuote, "Punctuation_FinalQuote"}, + {QChar::Punctuation_Other, "Punctuation_Other"}, + + {QChar::Symbol_Math, "Symbol_Math"}, + {QChar::Symbol_Currency, "Symbol_Currency"}, + {QChar::Symbol_Modifier, "Symbol_Modifier"}, + {QChar::Symbol_Other, "Symbol_Other"}, +}; + +#if QT_VERSION >= 0x050100 + +static const EnumLookup scriptEnumLookup[] = +{ + {QChar::Script_Unknown, "Script_Unknown"}, + {QChar::Script_Inherited, "Script_Inherited"}, + {QChar::Script_Common, "Script_Common"}, + + {QChar::Script_Latin, "Script_Latin"}, + {QChar::Script_Greek, "Script_Greek"}, + {QChar::Script_Cyrillic, "Script_Cyrillic"}, + {QChar::Script_Armenian, "Script_Armenian"}, + {QChar::Script_Hebrew, "Script_Hebrew"}, + {QChar::Script_Arabic, "Script_Arabic"}, + {QChar::Script_Syriac, "Script_Syriac"}, + {QChar::Script_Thaana, "Script_Thaana"}, + {QChar::Script_Devanagari, "Script_Devanagari"}, + {QChar::Script_Bengali, "Script_Bengali"}, + {QChar::Script_Gurmukhi, "Script_Gurmukhi"}, + {QChar::Script_Gujarati, "Script_Gujarati"}, + {QChar::Script_Oriya, "Script_Oriya"}, + {QChar::Script_Tamil, "Script_Tamil"}, + {QChar::Script_Telugu, "Script_Telugu"}, + {QChar::Script_Kannada, "Script_Kannada"}, + {QChar::Script_Malayalam, "Script_Malayalam"}, + {QChar::Script_Sinhala, "Script_Sinhala"}, + {QChar::Script_Thai, "Script_Thai"}, + {QChar::Script_Lao, "Script_Lao"}, + {QChar::Script_Tibetan, "Script_Tibetan"}, + {QChar::Script_Myanmar, "Script_Myanmar"}, + {QChar::Script_Georgian, "Script_Georgian"}, + {QChar::Script_Hangul, "Script_Hangul"}, + {QChar::Script_Ethiopic, "Script_Ethiopic"}, + {QChar::Script_Cherokee, "Script_Cherokee"}, + {QChar::Script_CanadianAboriginal, "Script_CanadianAboriginal"}, + {QChar::Script_Ogham, "Script_Ogham"}, + {QChar::Script_Runic, "Script_Runic"}, + {QChar::Script_Khmer, "Script_Khmer"}, + {QChar::Script_Mongolian, "Script_Mongolian"}, + {QChar::Script_Hiragana, "Script_Hiragana"}, + {QChar::Script_Katakana, "Script_Katakana"}, + {QChar::Script_Bopomofo, "Script_Bopomofo"}, + {QChar::Script_Han, "Script_Han"}, + {QChar::Script_Yi, "Script_Yi"}, + {QChar::Script_OldItalic, "Script_OldItalic"}, + {QChar::Script_Gothic, "Script_Gothic"}, + {QChar::Script_Deseret, "Script_Deseret"}, + {QChar::Script_Tagalog, "Script_Tagalog"}, + {QChar::Script_Hanunoo, "Script_Hanunoo"}, + {QChar::Script_Buhid, "Script_Buhid"}, + {QChar::Script_Tagbanwa, "Script_Tagbanwa"}, + {QChar::Script_Coptic, "Script_Coptic"}, + + {QChar::Script_Limbu, "Script_Limbu"}, + {QChar::Script_TaiLe, "Script_TaiLe"}, + {QChar::Script_LinearB, "Script_LinearB"}, + {QChar::Script_Ugaritic, "Script_Ugaritic"}, + {QChar::Script_Shavian, "Script_Shavian"}, + {QChar::Script_Osmanya, "Script_Osmanya"}, + {QChar::Script_Cypriot, "Script_Cypriot"}, + {QChar::Script_Braille, "Script_Braille"}, + + {QChar::Script_Buginese, "Script_Buginese"}, + {QChar::Script_NewTaiLue, "Script_NewTaiLue"}, + {QChar::Script_Glagolitic, "Script_Glagolitic"}, + {QChar::Script_Tifinagh, "Script_Tifinagh"}, + {QChar::Script_SylotiNagri, "Script_SylotiNagri"}, + {QChar::Script_OldPersian, "Script_OldPersian"}, + {QChar::Script_Kharoshthi, "Script_Kharoshthi"}, + + {QChar::Script_Balinese, "Script_Balinese"}, + {QChar::Script_Cuneiform, "Script_Cuneiform"}, + {QChar::Script_Phoenician, "Script_Phoenician"}, + {QChar::Script_PhagsPa, "Script_PhagsPa"}, + {QChar::Script_Nko, "Script_Nko"}, + + {QChar::Script_Sundanese, "Script_Sundanese"}, + {QChar::Script_Lepcha, "Script_Lepcha"}, + {QChar::Script_OlChiki, "Script_OlChiki"}, + {QChar::Script_Vai, "Script_Vai"}, + {QChar::Script_Saurashtra, "Script_Saurashtra"}, + {QChar::Script_KayahLi, "Script_KayahLi"}, + {QChar::Script_Rejang, "Script_Rejang"}, + {QChar::Script_Lycian, "Script_Lycian"}, + {QChar::Script_Carian, "Script_Carian"}, + {QChar::Script_Lydian, "Script_Lydian"}, + {QChar::Script_Cham, "Script_Cham"}, + + {QChar::Script_TaiTham, "Script_TaiTham"}, + {QChar::Script_TaiViet, "Script_TaiViet"}, + {QChar::Script_Avestan, "Script_Avestan"}, + {QChar::Script_EgyptianHieroglyphs, "Script_EgyptianHieroglyphs"}, + {QChar::Script_Samaritan, "Script_Samaritan"}, + {QChar::Script_Lisu, "Script_Lisu"}, + {QChar::Script_Bamum, "Script_Bamum"}, + {QChar::Script_Javanese, "Script_Javanese"}, + {QChar::Script_MeeteiMayek, "Script_MeeteiMayek"}, + {QChar::Script_ImperialAramaic, "Script_ImperialAramaic"}, + {QChar::Script_OldSouthArabian, "Script_OldSouthArabian"}, + {QChar::Script_InscriptionalParthian, "Script_InscriptionalParthian"}, + {QChar::Script_InscriptionalPahlavi, "Script_InscriptionalPahlavi"}, + {QChar::Script_OldTurkic, "Script_OldTurkic"}, + {QChar::Script_Kaithi, "Script_Kaithi"}, + + {QChar::Script_Batak, "Script_Batak"}, + {QChar::Script_Brahmi, "Script_Brahmi"}, + {QChar::Script_Mandaic, "Script_Mandaic"}, + + {QChar::Script_Chakma, "Script_Chakma"}, + {QChar::Script_MeroiticCursive, "Script_MeroiticCursive"}, + {QChar::Script_MeroiticHieroglyphs, "Script_MeroiticHieroglyphs"}, + {QChar::Script_Miao, "Script_Miao"}, + {QChar::Script_Sharada, "Script_Sharada"}, + {QChar::Script_SoraSompeng, "Script_SoraSompeng"}, + {QChar::Script_Takri, "Script_Takri"}, +}; + +#endif // Qt 5.1 + +static const EnumLookup directionEnumLookup[] = +{ + {QChar::DirL, "DirL"}, + {QChar::DirR, "DirR"}, + {QChar::DirEN, "DirEN"}, + {QChar::DirES, "DirES"}, + {QChar::DirET, "DirET"}, + {QChar::DirAN, "DirAN"}, + {QChar::DirCS, "DirCS"}, + {QChar::DirB, "DirB"}, + {QChar::DirS, "DirS"}, + {QChar::DirWS, "DirWS"}, + {QChar::DirON, "DirON"}, + {QChar::DirLRE, "DirLRE"}, + {QChar::DirLRO, "DirLRO"}, + {QChar::DirAL, "DirAL"}, + {QChar::DirRLE, "DirRLE"}, + {QChar::DirRLO, "DirRLO"}, + {QChar::DirPDF, "DirPDF"}, + {QChar::DirNSM, "DirNSM"}, + {QChar::DirBN, "DirBN"}, +#if QT_VERSION >= 0x050000 + {QChar::DirLRI, "DirLRI"}, + {QChar::DirRLI, "DirRLI"}, + {QChar::DirFSI, "DirFSI"}, + {QChar::DirPDI, "DirPDI"}, +#endif +}; + +static const EnumLookup decompositionEnumLookup[] = +{ + {QChar::NoDecomposition, "NoDecomposition"}, + {QChar::Canonical, "Canonical"}, + {QChar::Font, "Font"}, + {QChar::NoBreak, "NoBreak"}, + {QChar::Initial, "Initial"}, + {QChar::Medial, "Medial"}, + {QChar::Final, "Final"}, + {QChar::Isolated, "Isolated"}, + {QChar::Circle, "Circle"}, + {QChar::Super, "Super"}, + {QChar::Sub, "Sub"}, + {QChar::Vertical, "Vertical"}, + {QChar::Wide, "Wide"}, + {QChar::Narrow, "Narrow"}, + {QChar::Small, "Small"}, + {QChar::Square, "Square"}, + {QChar::Compat, "Compat"}, + {QChar::Fraction, "Fraction"}, +}; + +#if QT_VERSION >= 0x050000 + +static const EnumLookup joiningTypeEnumLookup[] = +{ + {QChar::Joining_None, "Joining_None"}, + {QChar::Joining_Causing, "Joining_Causing"}, + {QChar::Joining_Dual, "Joining_Dual"}, + {QChar::Joining_Right, "Joining_Right"}, + {QChar::Joining_Left, "Joining_Left"}, + {QChar::Joining_Transparent, "Joining_Transparent"} +}; + +#endif // Qt 5 + +static const EnumLookup combiningClassEnumLookup[] = +{ + {QChar::Combining_BelowLeftAttached, "Combining_BelowLeftAttached"}, + {QChar::Combining_BelowAttached, "Combining_BelowAttached"}, + {QChar::Combining_BelowRightAttached, "Combining_BelowRightAttached"}, + {QChar::Combining_LeftAttached, "Combining_LeftAttached"}, + {QChar::Combining_RightAttached, "Combining_RightAttached"}, + {QChar::Combining_AboveLeftAttached, "Combining_AboveLeftAttached"}, + {QChar::Combining_AboveAttached, "Combining_AboveAttached"}, + {QChar::Combining_AboveRightAttached, "Combining_AboveRightAttached"}, + + {QChar::Combining_BelowLeft, "Combining_BelowLeft"}, + {QChar::Combining_Below, "Combining_Below"}, + {QChar::Combining_BelowRight, "Combining_BelowRight"}, + {QChar::Combining_Left, "Combining_Left"}, + {QChar::Combining_Right, "Combining_Right"}, + {QChar::Combining_AboveLeft, "Combining_AboveLeft"}, + {QChar::Combining_Above, "Combining_Above"}, + {QChar::Combining_AboveRight, "Combining_AboveRight"}, + + {QChar::Combining_DoubleBelow, "Combining_DoubleBelow"}, + {QChar::Combining_DoubleAbove, "Combining_DoubleAbove"}, + {QChar::Combining_IotaSubscript, "Combining_IotaSubscript"}, +}; + +static const EnumLookup unicodeVersionEnumLookup[] = +{ + {QChar::Unicode_Unassigned, "Unicode_Unassigned"}, + {QChar::Unicode_1_1, "Unicode_1_1"}, + {QChar::Unicode_2_0, "Unicode_2_0"}, + {QChar::Unicode_2_1_2, "Unicode_2_1_2"}, + {QChar::Unicode_3_0, "Unicode_3_0"}, + {QChar::Unicode_3_1, "Unicode_3_1"}, + {QChar::Unicode_3_2, "Unicode_3_2"}, + {QChar::Unicode_4_0, "Unicode_4_0"}, + {QChar::Unicode_4_1, "Unicode_4_1"}, + {QChar::Unicode_5_0, "Unicode_5_0"}, +#if QT_VERSION >= 0x050000 + {QChar::Unicode_5_1, "Unicode_5_1"}, + {QChar::Unicode_5_2, "Unicode_5_2"}, + {QChar::Unicode_6_0, "Unicode_6_0"}, + {QChar::Unicode_6_1, "Unicode_6_1"}, + {QChar::Unicode_6_2, "Unicode_6_2"}, + {QChar::Unicode_6_3, "Unicode_6_3"}, +#endif // Qt 5 +}; + +static const EnumLookup *enumLookup(int v, const EnumLookup *array, size_t size) +{ + const EnumLookup *end = array + size; + for (const EnumLookup *p = array; p < end; ++p) { + if (p->value == v) + return p; + } + return 0; +} + +static const char *enumName(int v, const EnumLookup *array, size_t size) +{ + const EnumLookup *e = enumLookup(v, array, size); + return e ? e->description : ""; +} + +// Context struct storing the parameters of the last character, only the parameters +// that change will be output. +struct FormattingContext +{ + FormattingContext() : category(-1), direction(-1), joiningType(-1) + , decompositionTag(-1), script(-1), unicodeVersion(-1) {} + + int category; + int direction; + int joiningType; + int decompositionTag; + int script; + int unicodeVersion; +}; + +static void formatCharacter(QTextStream &str, const QChar &qc, FormattingContext &context) +{ + const ushort unicode = qc.unicode(); + str << "U+" << qSetFieldWidth(4) << qSetPadChar('0') << uppercasedigits << hex << unicode + << dec << qSetFieldWidth(0) << ' '; + + const EnumLookup *specialChar = enumLookup(unicode, specialCharactersEnumLookup, sizeof(specialCharactersEnumLookup) / sizeof(EnumLookup)); + if (specialChar) + str << specialChar->description; + else + str << "'" << qc << '\''; + + const int category = qc.category(); + if (category != context.category) { + str << " category=" + << enumName(category, categoryEnumLookup, sizeof(categoryEnumLookup) / sizeof(EnumLookup)); + context.category = category; + } +#if QT_VERSION >= 0x050100 + const int script = qc.script(); + if (script != context.script) { + str << " script=" + << enumName(script, scriptEnumLookup, sizeof(scriptEnumLookup) / sizeof(EnumLookup)) + << '(' << script << ')'; + context.script = script; + } +#endif // Qt 5 + const int direction = qc.direction(); + if (direction != context.direction) { + str << " direction=" + << enumName(direction, directionEnumLookup, sizeof(directionEnumLookup) / sizeof(EnumLookup)); + context.direction = direction; + } +#if QT_VERSION >= 0x050000 + const int joiningType = qc.joiningType(); + if (joiningType != context.joiningType) { + str << " joiningType=" + << enumName(joiningType, joiningTypeEnumLookup, sizeof(joiningTypeEnumLookup) / sizeof(EnumLookup)); + context.joiningType = joiningType; + } +#endif // Qt 5QWidget + const int decompositionTag = qc.decompositionTag(); + if (decompositionTag != context.decompositionTag) { + str << " decomposition=" + << enumName(decompositionTag, decompositionEnumLookup, sizeof(decompositionEnumLookup) / sizeof(EnumLookup)); + context.decompositionTag = decompositionTag; + } + const int unicodeVersion = qc.unicodeVersion(); + if (unicodeVersion != context.unicodeVersion) { + str << " version=" + << enumName(unicodeVersion, unicodeVersionEnumLookup, sizeof(unicodeVersionEnumLookup) / sizeof(EnumLookup)); + context.unicodeVersion = unicodeVersion; + } +} + +QString dumpText(const QString &text) +{ + QString result; + QTextStream str(&result); + FormattingContext context; + for (int i = 0; i < text.size(); ++i) { + str << '#' << (i + 1) << ' '; + formatCharacter(str, text.at(i), context); + str << '\n'; + } + return result; +} + +QString dumpTextAsCode(const QString &text) +{ + QString result; + QTextStream str(&result); + str << " QString result;\n" << hex << showbase; + for (int i = 0; i < text.size(); ++i) + str << " result += QChar(" << text.at(i).unicode() << ");\n"; + str << '\n'; + return result; +} + +} // namespace QtDiag diff --git a/tests/manual/diaglib/textdump.h b/tests/manual/diaglib/textdump.h new file mode 100644 index 0000000000..596c57de50 --- /dev/null +++ b/tests/manual/diaglib/textdump.h @@ -0,0 +1,48 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL21$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef TEXTDUMP_H +#define TEXTDUMP_H + +#include + +QT_FORWARD_DECLARE_CLASS(QString) + +namespace QtDiag { + +QString dumpText(const QString &text); +QString dumpTextAsCode(const QString &text); + +} // namespace QtDiag + +#endif // TEXTDUMP_H -- cgit v1.2.3 From 1c1cce67fa1d03a49cdfb6f1ca378b182925ffdb Mon Sep 17 00:00:00 2001 From: Pavel Krebs Date: Fri, 5 Dec 2014 15:39:48 +0100 Subject: QScrollBar: emit valueChanged once even if a slot takes too much time Put also processing of control activation into initial timer check for possibly pending mouse release event. [ChangeLog][QtWidgets][QScrollBar] Fixed a bug where the valueChanged() signal was emitted twice if a connected slot took too much time. Task-number: QTBUG-42871 Change-Id: I7bad5279ef84463a033b55256d241d4445374081 Reviewed-by: Giuseppe D'Angelo --- src/widgets/widgets/qscrollbar.cpp | 7 ++-- .../widgets/widgets/qscrollbar/tst_qscrollbar.cpp | 40 ++++++++++++++++++++++ 2 files changed, 44 insertions(+), 3 deletions(-) diff --git a/src/widgets/widgets/qscrollbar.cpp b/src/widgets/widgets/qscrollbar.cpp index 5851020379..c2d2117e20 100644 --- a/src/widgets/widgets/qscrollbar.cpp +++ b/src/widgets/widgets/qscrollbar.cpp @@ -593,13 +593,14 @@ void QScrollBar::mousePressEvent(QMouseEvent *e) d->clickOffset = sliderLength / 2; } const int initialDelay = 500; // default threshold - d->activateControl(d->pressedControl, initialDelay); QElapsedTimer time; time.start(); + d->activateControl(d->pressedControl, initialDelay); repaint(style()->subControlRect(QStyle::CC_ScrollBar, &opt, d->pressedControl, this)); if (time.elapsed() >= initialDelay && d->repeatActionTimer.isActive()) { - // It took more than 500ms (the initial timer delay) to process the repaint(), we - // therefore need to restart the timer in case we have a pending mouse release event; + // It took more than 500ms (the initial timer delay) to process + // the control activation and repaint(), we therefore need + // to restart the timer in case we have a pending mouse release event; // otherwise we'll get a timer event right before the release event, // causing the repeat action to be invoked twice on a single mouse click. // 50ms is the default repeat time (see activateControl/setRepeatAction). diff --git a/tests/auto/widgets/widgets/qscrollbar/tst_qscrollbar.cpp b/tests/auto/widgets/widgets/qscrollbar/tst_qscrollbar.cpp index cb0383c398..008d3b2435 100644 --- a/tests/auto/widgets/widgets/qscrollbar/tst_qscrollbar.cpp +++ b/tests/auto/widgets/widgets/qscrollbar/tst_qscrollbar.cpp @@ -58,6 +58,7 @@ private slots: #ifndef QT_NO_WHEELEVENT void QTBUG_27308(); #endif + void QTBUG_42871(); }; class SingleStepTestScrollBar : public QScrollBar { @@ -169,5 +170,44 @@ void tst_QScrollBar::QTBUG_27308() } #endif +class QTBUG_42871_Handler : public QObject { + Q_OBJECT +public: + int updatesCount; + QTBUG_42871_Handler() : QObject(), updatesCount(0) {} +public slots: + void valueUpdated(int) { ++updatesCount; QTest::qSleep(600); } +}; + +void tst_QScrollBar::QTBUG_42871() +{ + QTBUG_42871_Handler myHandler; + QScrollBar scrollBarWidget(Qt::Vertical); + bool connection = connect(&scrollBarWidget, SIGNAL(valueChanged(int)), &myHandler, SLOT(valueUpdated(int))); + QVERIFY(connection); + scrollBarWidget.resize(100, scrollBarWidget.height()); + centerOnScreen(&scrollBarWidget); + scrollBarWidget.show(); + QTest::qWaitForWindowExposed(&scrollBarWidget); + QSignalSpy spy(&scrollBarWidget, SIGNAL(actionTriggered(int))); + QVERIFY(spy.isValid()); + QCOMPARE(myHandler.updatesCount, 0); + QCOMPARE(spy.count(), 0); + + // Simulate a mouse click on the "scroll down button". + const QPoint pressPoint(scrollBarWidget.width() / 2, scrollBarWidget.height() - 10); + const QPoint globalPressPoint = scrollBarWidget.mapToGlobal(pressPoint); + QMouseEvent mousePressEvent(QEvent::MouseButtonPress, pressPoint, globalPressPoint, + Qt::LeftButton, Qt::LeftButton, 0); + QApplication::sendEvent(&scrollBarWidget, &mousePressEvent); + QTest::qWait(1); + QMouseEvent mouseReleaseEvent(QEvent::MouseButtonRelease, pressPoint, globalPressPoint, + Qt::LeftButton, Qt::LeftButton, 0); + QApplication::sendEvent(&scrollBarWidget, &mouseReleaseEvent); + // Check that the action was triggered once. + QCOMPARE(myHandler.updatesCount, 1); + QCOMPARE(spy.count(), 1); +} + QTEST_MAIN(tst_QScrollBar) #include "tst_qscrollbar.moc" -- cgit v1.2.3 From 80d0075588aa94e011a394967fb21d8bb0c84781 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 16 Dec 2014 16:22:10 -0800 Subject: Fix QThread::idealThreadCount on Unix if sysconf or sysctl fails The BSD4 code (including OS X) calls sysctl and if that fails, it sets cores to -1. Similarly, the generic Unix code calls sysconf() and assigns the returned value to cores, but sysconf can return -1 on failure. Change-Id: I9e521d366e9c42f36c2ba20a37e7a74539ddb8f4 Reviewed-by: Oswald Buddenhagen --- src/corelib/thread/qthread_unix.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/corelib/thread/qthread_unix.cpp b/src/corelib/thread/qthread_unix.cpp index 5df50311ef..9a14503584 100644 --- a/src/corelib/thread/qthread_unix.cpp +++ b/src/corelib/thread/qthread_unix.cpp @@ -450,7 +450,8 @@ int QThread::idealThreadCount() Q_DECL_NOTHROW // the rest: Linux, Solaris, AIX, Tru64 cores = (int)sysconf(_SC_NPROCESSORS_ONLN); #endif - + if (cores == -1) + return 1; return cores; } -- cgit v1.2.3 From c70658d301e274c3aaa1fb6cebe2a5e56db12779 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 16 Dec 2014 14:24:55 -0800 Subject: Make sure we don't try to ask QByteArray to allocate too much QFile::readAll could be asked to read a file that is over 1 GB in size and thus cause an assertion: ASSERT failure in qAllocMore: "Requested size is too large!", ... The idea behind the existing code was correct, but the value was wrong. It prevented overflow of the integer size request, but didn't prevent overflowing the storage size. Change-Id: I072e6e419f47b639454f3fd96deb0f88d03e960c Reviewed-by: Martin Smith --- src/corelib/io/qiodevice.cpp | 2 +- src/corelib/tools/qbytearray.cpp | 11 ++++++++++- src/corelib/tools/qbytearray.h | 3 +++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/corelib/io/qiodevice.cpp b/src/corelib/io/qiodevice.cpp index 0709a93bad..72ec6ff403 100644 --- a/src/corelib/io/qiodevice.cpp +++ b/src/corelib/io/qiodevice.cpp @@ -1025,7 +1025,7 @@ QByteArray QIODevice::readAll() } else { // Read it all in one go. // If resize fails, don't read anything. - if (readBytes + theSize - d->pos > INT_MAX) + if (quint64(readBytes + theSize - d->pos) > QByteArray::MaxSize) return QByteArray(); result.resize(int(readBytes + theSize - d->pos)); readBytes += read(result.data() + readBytes, result.size() - readBytes); diff --git a/src/corelib/tools/qbytearray.cpp b/src/corelib/tools/qbytearray.cpp index 6ac442d27b..d8b2efbef3 100644 --- a/src/corelib/tools/qbytearray.cpp +++ b/src/corelib/tools/qbytearray.cpp @@ -63,7 +63,7 @@ int qFindByteArray( int qAllocMore(int alloc, int extra) Q_DECL_NOTHROW { Q_ASSERT(alloc >= 0 && extra >= 0); - Q_ASSERT_X(alloc < (1 << 30) - extra, "qAllocMore", "Requested size is too large!"); + Q_ASSERT_X(uint(alloc) < QByteArray::MaxSize, "qAllocMore", "Requested size is too large!"); unsigned nalloc = qNextPowerOfTwo(alloc + extra); @@ -776,6 +776,15 @@ static inline char qToLower(char c) \sa QString, QBitArray */ +/*! + \variable QByteArray::MaxSize + \internal + \since 5.4 + + The maximum size of a QByteArray, in bytes. Also applies to a the maximum + storage size of QString and QVector, though not the number of elements. +*/ + /*! \enum QByteArray::Base64Option \since 5.2 diff --git a/src/corelib/tools/qbytearray.h b/src/corelib/tools/qbytearray.h index f13b1c16cd..3bcc7b1f2a 100644 --- a/src/corelib/tools/qbytearray.h +++ b/src/corelib/tools/qbytearray.h @@ -173,6 +173,9 @@ private: typedef QTypedArrayData Data; public: + // undocumented: + static const quint64 MaxSize = (1 << 30) - sizeof(Data); + enum Base64Option { Base64Encoding = 0, Base64UrlEncoding = 1, -- cgit v1.2.3 From a31b75b766b87d0210ed174f587aee33ad639f9b Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 3 Dec 2014 14:11:47 -0800 Subject: Use the GCC and Clang __builtin_bswap intrinsics in qbswap MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Glibc will use the intrinsics for 32- and 64-bit, but didn't for 16-bit (probably because GCC didn't document it until version 4.8), so this commit will make us access the intrinsics directly the intrisincs for all type sizes. Additionally, this will get us access to the compiler intrisics even without Glibc, such as when building against uclibc or Bionic. Another benefit is that both Clang and ICC will use the MOVBE instruction on Atom and Haswell architectures. Change-Id: I39d1891f479887d719d69ebe4ac92ac9bfeda8af Reviewed-by: Jędrzej Nowacki --- mkspecs/features/qt_common.prf | 3 --- src/corelib/global/qendian.h | 26 +++++++++++++------------- 2 files changed, 13 insertions(+), 16 deletions(-) diff --git a/mkspecs/features/qt_common.prf b/mkspecs/features/qt_common.prf index af9d6cae67..eb65e73079 100644 --- a/mkspecs/features/qt_common.prf +++ b/mkspecs/features/qt_common.prf @@ -50,9 +50,6 @@ warnings_are_errors:warning_clean { reg_ver = $${QT_CLANG_MAJOR_VERSION}.$${QT_CLANG_MINOR_VERSION} contains(apple_ver, "4\\.[012]|5\\.[01]")|contains(reg_ver, "3\\.[34]") { QMAKE_CXXFLAGS_WARN_ON += -Werror -Wno-error=\\$${LITERAL_HASH}warnings -Wno-error=deprecated-declarations $$WERROR - - # glibc's bswap_XX macros use the "register" keyword - linux:equals(reg_ver, "3.4"): QMAKE_CXXFLAGS_WARN_ON += -Wno-error=deprecated-register } } else:intel_icc:linux { # Intel CC 13.0 - 15.0, on Linux only diff --git a/src/corelib/global/qendian.h b/src/corelib/global/qendian.h index 136581167c..7c643f7592 100644 --- a/src/corelib/global/qendian.h +++ b/src/corelib/global/qendian.h @@ -40,10 +40,6 @@ #include #include -#ifdef __GLIBC__ -#include -#endif - QT_BEGIN_NAMESPACE @@ -276,18 +272,16 @@ template <> inline qint8 qFromBigEndian(const uchar *src) */ template T qbswap(T source); -#ifdef __GLIBC__ +// GCC 4.3 implemented all the intrinsics, but the 16-bit one only got implemented in 4.8; +// Clang 2.6 implemented the 32- and 64-bit but waited until 3.2 to implement the 16-bit one +#if (defined(Q_CC_GNU) && Q_CC_GNU >= 403) || (defined(Q_CC_CLANG) && Q_CC_CLANG >= 206) template <> inline quint64 qbswap(quint64 source) { - return bswap_64(source); + return __builtin_bswap64(source); } template <> inline quint32 qbswap(quint32 source) { - return bswap_32(source); -} -template <> inline quint16 qbswap(quint16 source) -{ - return bswap_16(source); + return __builtin_bswap32(source); } #else template <> inline quint64 qbswap(quint64 source) @@ -311,14 +305,20 @@ template <> inline quint32 qbswap(quint32 source) | ((source & 0x00ff0000) >> 8) | ((source & 0xff000000) >> 24); } - +#endif // GCC & Clang intrinsics +#if (defined(Q_CC_GNU) && Q_CC_GNU >= 408) || (defined(Q_CC_CLANG) && Q_CC_CLANG >= 302) +template <> inline quint16 qbswap(quint16 source) +{ + return __builtin_bswap16(source); +} +#else template <> inline quint16 qbswap(quint16 source) { return quint16( 0 | ((source & 0x00ff) << 8) | ((source & 0xff00) >> 8) ); } -#endif // __GLIBC__ +#endif // GCC & Clang intrinsics // signed specializations template <> inline qint64 qbswap(qint64 source) -- cgit v1.2.3 From 741dd3da33920dd1c2e4485d85f7693d394798ce Mon Sep 17 00:00:00 2001 From: Jeongmin Kim Date: Tue, 11 Nov 2014 08:49:25 +0900 Subject: QNetworkDiskCache: Do not store set-cookie headers of the response in disk cache. The cookies may contain sensitive information. so we should not store cookies in disk cache. Task-number: QTBUG-42546 Change-Id: I6331bdd766445af41f55bfaf0e9132b75dd7957f Reviewed-by: Jeongmin Kim Reviewed-by: Thiago Macieira --- src/network/access/qnetworkreplyhttpimpl.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/network/access/qnetworkreplyhttpimpl.cpp b/src/network/access/qnetworkreplyhttpimpl.cpp index 836b3c3fa4..4ce7303dbb 100644 --- a/src/network/access/qnetworkreplyhttpimpl.cpp +++ b/src/network/access/qnetworkreplyhttpimpl.cpp @@ -1399,6 +1399,9 @@ QNetworkCacheMetaData QNetworkReplyHttpImplPrivate::fetchCacheMetaData(const QNe if (hop_by_hop) continue; + if (header == "set-cookie") + continue; + // for 4.6.0, we were planning to not store the date header in the // cached resource; through that we planned to reduce the number // of writes to disk when using a QNetworkDiskCache (i.e. don't -- cgit v1.2.3 From 91ae988b5c7ce8d9cf9af2d5f2460e91617dc95e Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 11 Dec 2014 17:38:48 -0800 Subject: Remove unnecessary adding of test rows in the QtDBus type benchmark No need to loop twice to add the "native" entries, since they are added by the helper function anyway. Change-Id: I9caabc6fc4973a90b483840815769b1351947a89 Reviewed-by: Friedemann Kleint --- tests/benchmarks/dbus/qdbustype/main.cpp | 35 ++++++++++++++------------------ 1 file changed, 15 insertions(+), 20 deletions(-) diff --git a/tests/benchmarks/dbus/qdbustype/main.cpp b/tests/benchmarks/dbus/qdbustype/main.cpp index b37a6930e2..b405df99d5 100644 --- a/tests/benchmarks/dbus/qdbustype/main.cpp +++ b/tests/benchmarks/dbus/qdbustype/main.cpp @@ -57,29 +57,24 @@ void tst_QDBusType::benchmarkSignature_data() QTest::addColumn("data"); QTest::addColumn("useNative"); - for (int loopCount = 0; loopCount < 2; ++loopCount) { - bool useNative = loopCount; - QByteArray prefix = useNative ? "native-" : ""; + benchmarkAddRow("single-invalid", "~"); + benchmarkAddRow("single-invalid-array", "a~"); + benchmarkAddRow("single-invalid-struct", "(.)"); - benchmarkAddRow("single-invalid", "~"); - benchmarkAddRow("single-invalid-array", "a~"); - benchmarkAddRow("single-invalid-struct", "(.)"); + benchmarkAddRow("single-char", "b"); + benchmarkAddRow("single-array", "as"); + benchmarkAddRow("single-simplestruct", "(y)"); + benchmarkAddRow("single-simpledict", "a{sv}"); + benchmarkAddRow("single-complexdict", "a{s(aya{io})}"); - benchmarkAddRow("single-char", "b"); - benchmarkAddRow("single-array", "as"); - benchmarkAddRow("single-simplestruct", "(y)"); - benchmarkAddRow("single-simpledict", "a{sv}"); - benchmarkAddRow("single-complexdict", "a{s(aya{io})}"); + benchmarkAddRow("multiple-char", "ssg"); + benchmarkAddRow("multiple-arrays", "asasay"); - benchmarkAddRow("multiple-char", "ssg"); - benchmarkAddRow("multiple-arrays", "asasay"); - - benchmarkAddRow("struct-missingclose", "(ayyyy"); - benchmarkAddRow("longstruct", "(yyyyyyayasy)"); - benchmarkAddRow("invalid-longstruct", "(yyyyyyayas.y)"); - benchmarkAddRow("complexstruct", "(y(aasay)oga{sv})"); - benchmarkAddRow("multiple-simple-structs", "(y)(y)(y)"); - } + benchmarkAddRow("struct-missingclose", "(ayyyy"); + benchmarkAddRow("longstruct", "(yyyyyyayasy)"); + benchmarkAddRow("invalid-longstruct", "(yyyyyyayas.y)"); + benchmarkAddRow("complexstruct", "(y(aasay)oga{sv})"); + benchmarkAddRow("multiple-simple-structs", "(y)(y)(y)"); } void tst_QDBusType::benchmarkSignature() -- cgit v1.2.3 From d1d3c36e876464a9bae42565f086ded268ab5118 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 17 Dec 2014 20:24:04 -0800 Subject: Simplify use of __has_include in qlogging.cpp Easier to just #define it to 0 Change-Id: Ife99fdca6564077762fa67c6d7a5becaf48655d8 Reviewed-by: Olivier Goffart --- src/corelib/global/qlogging.cpp | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/src/corelib/global/qlogging.cpp b/src/corelib/global/qlogging.cpp index 0271573445..50d35a6d84 100644 --- a/src/corelib/global/qlogging.cpp +++ b/src/corelib/global/qlogging.cpp @@ -72,20 +72,17 @@ # include "private/qcore_unix_p.h" #endif -#if !defined QT_NO_REGULAREXPRESSION && !defined(QT_BOOTSTRAPPED) -#ifdef __has_include -#if __has_include() && __has_include() -#define QLOGGING_HAVE_BACKTRACE -#endif -#elif defined(__GLIBCXX__) && defined(__GLIBC__) // (because older version of gcc don't have __has_include) -#define QLOGGING_HAVE_BACKTRACE +#ifndef __has_include +# define __has_include(x) 0 #endif -#ifdef QLOGGING_HAVE_BACKTRACE -#include -#include -#include -#endif +#if !defined QT_NO_REGULAREXPRESSION && !defined(QT_BOOTSTRAPPED) +# if (defined(__GLIBC__) && defined(__GLIBCXX__)) || (__has_include() && __has_include()) +# define QLOGGING_HAVE_BACKTRACE +# include +# include +# include +# endif #endif #include -- cgit v1.2.3 From cfab93418689db9a6702af7a60b7d45fc4b63898 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 11 Dec 2014 13:43:14 -0800 Subject: Fix loading of the dbus-1 DLL built by MinGW on Windows QLibrary does not append the version suffix on Windows by itself, since there's no established practice on how to do this. The MinGW builds of dbus-1 call it "libdbus-1-3.dll", so we need append the suffix ourselves. Unfortunately, other names like "dbus-1.dll" have been seen in the wild, so we need to try both basenames (Windows doesn't prepend the "lib" prefix). Both basenames work on Unix, so give "libdbus-1" on Unix since that will result in one fewer stat. Change-Id: I92506df5fd30c7674216568406bf86b25bf646b8 Reviewed-by: Simon Hausmann --- src/dbus/qdbus_symbols.cpp | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/src/dbus/qdbus_symbols.cpp b/src/dbus/qdbus_symbols.cpp index 8c642c8887..e475a23f48 100644 --- a/src/dbus/qdbus_symbols.cpp +++ b/src/dbus/qdbus_symbols.cpp @@ -84,14 +84,29 @@ bool qdbus_loadLibDBus() triedToLoadLibrary = true; static int majorversions[] = { 3, 2, -1 }; + const QString baseNames[] = { +#ifdef Q_OS_WIN + QStringLiteral("dbus-1"), +#endif + QStringLiteral("libdbus-1") + }; + lib->unload(); - lib->setFileName(QLatin1String("dbus-1")); for (uint i = 0; i < sizeof(majorversions) / sizeof(majorversions[0]); ++i) { - lib->setFileNameAndVersion(lib->fileName(), majorversions[i]); - if (lib->load() && lib->resolve("dbus_connection_open_private")) - return true; + for (uint j = 0; j < sizeof(baseNames) / sizeof(baseNames[0]); ++j) { +#ifdef Q_OS_WIN + QString suffix; + if (majorversions[i] != -1) + suffix = QString::number(- majorversions[i]); // negative so it prepends the dash + lib->setFileName(baseNames[j] + suffix); +#else + lib->setFileNameAndVersion(baseNames[j], majorversions[i]); +#endif + if (lib->load() && lib->resolve("dbus_connection_open_private")) + return true; - lib->unload(); + lib->unload(); + } } delete lib; -- cgit v1.2.3 From 9434162eda4d0ffe5f5f8571ff7330a71df0d0e2 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 11 Dec 2014 18:13:10 -0800 Subject: tst_qdbusconnection_no_bus: Fix build on Windows There's no setenv, so use qputenv instead. Change-Id: I357ff6d0e3d67e199661a9d87c720fc4e0131755 Reviewed-by: Simon Hausmann --- tests/auto/dbus/qdbusconnection_no_bus/tst_qdbusconnection_no_bus.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/auto/dbus/qdbusconnection_no_bus/tst_qdbusconnection_no_bus.cpp b/tests/auto/dbus/qdbusconnection_no_bus/tst_qdbusconnection_no_bus.cpp index 2c5ca71990..3d7e477f47 100644 --- a/tests/auto/dbus/qdbusconnection_no_bus/tst_qdbusconnection_no_bus.cpp +++ b/tests/auto/dbus/qdbusconnection_no_bus/tst_qdbusconnection_no_bus.cpp @@ -51,8 +51,8 @@ class tst_QDBusConnectionNoBus : public QObject public: tst_QDBusConnectionNoBus() { - ::setenv("DBUS_SESSION_BUS_ADDRESS", "unix:abstract=/tmp/does_not_exist", 1); - ::setenv("QT_SIMULATE_DBUS_LIBFAIL", "1", 1); + qputenv("DBUS_SESSION_BUS_ADDRESS", "unix:abstract=/tmp/does_not_exist"); + qputenv("QT_SIMULATE_DBUS_LIBFAIL", "1"); } private slots: -- cgit v1.2.3 From 7b6ab50c68e771ecbd350b58890fae0e58330e9f Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 11 Dec 2014 14:37:11 -0800 Subject: Remove the hardcoding of Unix socket paths for QtDBus This allows the tests to be run on Windows too by using TCP socket connections instead of requiring Unix sockets. The tests shouldn't have hardcoded the path, which came from QDBusServer anyway. Now the tests simply defer to QDBusServer. This is a slight behavior change for Windows, but not one that should matter since anyone who was using the default constructor resulted in a QDBusServer that failed to listen. [ChangeLog][QtDBus][QDBusServer] Fixed a bug that made QDBusServer's default constructor try to bind to a Unix socket on non-Unix systems. Now QDBusServer will attempt to bind to a TCP socket instead. Change-Id: I2a126019671c2d90257e739ed3aff7938d1fe946 Reviewed-by: Friedemann Kleint Reviewed-by: Simon Hausmann --- src/dbus/qdbusserver.cpp | 12 +++++++++--- .../dbus/qdbusabstractadaptor/qmyserver/qmyserver.cpp | 4 ++-- .../auto/dbus/qdbusabstractinterface/qpinger/qpinger.cpp | 4 ++-- tests/auto/dbus/qdbusconnection/tst_qdbusconnection.cpp | 15 ++++++--------- tests/auto/dbus/qdbusinterface/qmyserver/qmyserver.cpp | 4 ++-- 5 files changed, 21 insertions(+), 18 deletions(-) diff --git a/src/dbus/qdbusserver.cpp b/src/dbus/qdbusserver.cpp index f2f4872aa0..54b38ee848 100644 --- a/src/dbus/qdbusserver.cpp +++ b/src/dbus/qdbusserver.cpp @@ -72,12 +72,18 @@ QDBusServer::QDBusServer(const QString &address, QObject *parent) /*! Constructs a QDBusServer with the given \a parent. The server will listen - for connections in \c {/tmp}. + for connections in \c {/tmp} (on Unix systems) or on a TCP port bound to + localhost (elsewhere). */ QDBusServer::QDBusServer(QObject *parent) : QObject(parent) { - const QString address = QLatin1String("unix:tmpdir=/tmp"); +#ifdef Q_OS_UNIX + // Use Unix sockets on Unix systems only + static const char address[] = "unix:tmpdir=/tmp"; +#else + static const char address[] = "tcp:"; +#endif if (!qdbus_loadLibDBus()) { d = 0; @@ -89,7 +95,7 @@ QDBusServer::QDBusServer(QObject *parent) this, SIGNAL(newConnection(QDBusConnection))); QDBusErrorInternal error; - d->setServer(q_dbus_server_listen(address.toUtf8().constData(), error), error); + d->setServer(q_dbus_server_listen(address, error), error); } /*! diff --git a/tests/auto/dbus/qdbusabstractadaptor/qmyserver/qmyserver.cpp b/tests/auto/dbus/qdbusabstractadaptor/qmyserver/qmyserver.cpp index b4c16c6fa3..b0b9889e70 100644 --- a/tests/auto/dbus/qdbusabstractadaptor/qmyserver/qmyserver.cpp +++ b/tests/auto/dbus/qdbusabstractadaptor/qmyserver/qmyserver.cpp @@ -50,8 +50,8 @@ class MyServer : public QDBusServer Q_CLASSINFO("D-Bus Interface", "org.qtproject.autotests.qmyserver") public: - MyServer(QString addr = "unix:tmpdir=/tmp", QObject* parent = 0) - : QDBusServer(addr, parent), + MyServer(QObject* parent = 0) + : QDBusServer(parent), m_conn("none"), obj(NULL) { diff --git a/tests/auto/dbus/qdbusabstractinterface/qpinger/qpinger.cpp b/tests/auto/dbus/qdbusabstractinterface/qpinger/qpinger.cpp index 6be61ec9e0..7466526c99 100644 --- a/tests/auto/dbus/qdbusabstractinterface/qpinger/qpinger.cpp +++ b/tests/auto/dbus/qdbusabstractinterface/qpinger/qpinger.cpp @@ -43,8 +43,8 @@ class PingerServer : public QDBusServer Q_OBJECT Q_CLASSINFO("D-Bus Interface", "org.qtproject.autotests.qpinger") public: - PingerServer(QString addr = "unix:tmpdir=/tmp", QObject* parent = 0) - : QDBusServer(addr, parent), + PingerServer(QObject* parent = 0) + : QDBusServer(parent), m_conn("none") { connect(this, SIGNAL(newConnection(QDBusConnection)), SLOT(handleConnection(QDBusConnection))); diff --git a/tests/auto/dbus/qdbusconnection/tst_qdbusconnection.cpp b/tests/auto/dbus/qdbusconnection/tst_qdbusconnection.cpp index c8d1184226..7e6e742e28 100644 --- a/tests/auto/dbus/qdbusconnection/tst_qdbusconnection.cpp +++ b/tests/auto/dbus/qdbusconnection/tst_qdbusconnection.cpp @@ -296,7 +296,7 @@ void tst_QDBusConnection::connectToPeer() QVERIFY(con.lastError().isValid()); } - QDBusServer server("unix:tmpdir=/tmp", 0); + QDBusServer server; { QDBusConnection con = QDBusConnection::connectToPeer( @@ -381,9 +381,7 @@ class MyServer : public QDBusServer { Q_OBJECT public: - MyServer(QString path, QString addr, QObject* parent) : QDBusServer(addr, parent), - m_path(path), - m_connections() + MyServer(QString path) : m_path(path), m_connections() { connect(this, SIGNAL(newConnection(QDBusConnection)), SLOT(handleConnection(QDBusConnection))); } @@ -446,7 +444,7 @@ void tst_QDBusConnection::registerObjectPeer() { QFETCH(QString, path); - MyServer server(path, "unix:tmpdir=/tmp", 0); + MyServer server(path); QDBusConnection::connectToPeer(server.address(), "beforeFoo"); @@ -594,8 +592,7 @@ class MyServer2 : public QDBusServer { Q_OBJECT public: - MyServer2(QString addr, QObject* parent) : QDBusServer(addr, parent), - m_conn("none") + MyServer2() : m_conn("none") { connect(this, SIGNAL(newConnection(QDBusConnection)), SLOT(handleConnection(QDBusConnection))); } @@ -620,7 +617,7 @@ private: void tst_QDBusConnection::registerObjectPeer2() { - MyServer2 server("unix:tmpdir=/tmp", 0); + MyServer2 server; QDBusConnection con = QDBusConnection::connectToPeer(server.address(), "foo"); QCoreApplication::processEvents(); QVERIFY(con.isConnected()); @@ -775,7 +772,7 @@ void tst_QDBusConnection::registerQObjectChildren() void tst_QDBusConnection::registerQObjectChildrenPeer() { - MyServer2 server("unix:tmpdir=/tmp", 0); + MyServer2 server; QDBusConnection con = QDBusConnection::connectToPeer(server.address(), "foo"); QCoreApplication::processEvents(); QVERIFY(con.isConnected()); diff --git a/tests/auto/dbus/qdbusinterface/qmyserver/qmyserver.cpp b/tests/auto/dbus/qdbusinterface/qmyserver/qmyserver.cpp index df131f13f6..cb7296e7d2 100644 --- a/tests/auto/dbus/qdbusinterface/qmyserver/qmyserver.cpp +++ b/tests/auto/dbus/qdbusinterface/qmyserver/qmyserver.cpp @@ -48,8 +48,8 @@ class MyServer : public QDBusServer Q_CLASSINFO("D-Bus Interface", "org.qtproject.autotests.qmyserver") public: - MyServer(QString addr = "unix:tmpdir=/tmp", QObject* parent = 0) - : QDBusServer(addr, parent), + MyServer(QObject* parent = 0) + : QDBusServer(parent), m_conn("none") { connect(this, SIGNAL(newConnection(QDBusConnection)), SLOT(handleConnection(QDBusConnection))); -- cgit v1.2.3 From 91fe8129fa54847b8d4146672d561349633aea79 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 11 Dec 2014 14:39:22 -0800 Subject: Autotest: Make the peer executables report error if they failed QDBusServer::address() will return an empty QString, which caused the tests to fail later with no apparent reason. Change-Id: I86f448dfc67a6cdb27ecda2d490f335766cfaf4f Reviewed-by: Friedemann Kleint Reviewed-by: Simon Hausmann --- tests/auto/dbus/qdbusabstractadaptor/qmyserver/qmyserver.cpp | 4 +++- tests/auto/dbus/qdbusabstractinterface/qpinger/qpinger.cpp | 4 +++- tests/auto/dbus/qdbusinterface/qmyserver/qmyserver.cpp | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/tests/auto/dbus/qdbusabstractadaptor/qmyserver/qmyserver.cpp b/tests/auto/dbus/qdbusabstractadaptor/qmyserver/qmyserver.cpp index b0b9889e70..b4a79fa754 100644 --- a/tests/auto/dbus/qdbusabstractadaptor/qmyserver/qmyserver.cpp +++ b/tests/auto/dbus/qdbusabstractadaptor/qmyserver/qmyserver.cpp @@ -44,7 +44,7 @@ QString valueSpy; Q_DECLARE_METATYPE(QDBusConnection::RegisterOptions) -class MyServer : public QDBusServer +class MyServer : public QDBusServer, protected QDBusContext { Q_OBJECT Q_CLASSINFO("D-Bus Interface", "org.qtproject.autotests.qmyserver") @@ -67,6 +67,8 @@ public: public slots: QString address() const { + if (!QDBusServer::isConnected()) + sendErrorReply(QDBusServer::lastError().name(), QDBusServer::lastError().message()); return QDBusServer::address(); } diff --git a/tests/auto/dbus/qdbusabstractinterface/qpinger/qpinger.cpp b/tests/auto/dbus/qdbusabstractinterface/qpinger/qpinger.cpp index 7466526c99..49291abf92 100644 --- a/tests/auto/dbus/qdbusabstractinterface/qpinger/qpinger.cpp +++ b/tests/auto/dbus/qdbusabstractinterface/qpinger/qpinger.cpp @@ -38,7 +38,7 @@ static const char serviceName[] = "org.qtproject.autotests.qpinger"; static const char objectPath[] = "/org/qtproject/qpinger"; //static const char *interfaceName = serviceName; -class PingerServer : public QDBusServer +class PingerServer : public QDBusServer, protected QDBusContext { Q_OBJECT Q_CLASSINFO("D-Bus Interface", "org.qtproject.autotests.qpinger") @@ -54,6 +54,8 @@ public: public slots: QString address() const { + if (!QDBusServer::isConnected()) + sendErrorReply(QDBusServer::lastError().name(), QDBusServer::lastError().message()); return QDBusServer::address(); } diff --git a/tests/auto/dbus/qdbusinterface/qmyserver/qmyserver.cpp b/tests/auto/dbus/qdbusinterface/qmyserver/qmyserver.cpp index cb7296e7d2..4aacbdc5a2 100644 --- a/tests/auto/dbus/qdbusinterface/qmyserver/qmyserver.cpp +++ b/tests/auto/dbus/qdbusinterface/qmyserver/qmyserver.cpp @@ -42,7 +42,7 @@ static const char objectPath[] = "/org/qtproject/qmyserver"; int MyObject::callCount = 0; QVariantList MyObject::callArgs; -class MyServer : public QDBusServer +class MyServer : public QDBusServer, protected QDBusContext { Q_OBJECT Q_CLASSINFO("D-Bus Interface", "org.qtproject.autotests.qmyserver") @@ -58,6 +58,8 @@ public: public slots: QString address() const { + if (!QDBusServer::isConnected()) + sendErrorReply(QDBusServer::lastError().name(), QDBusServer::lastError().message()); return QDBusServer::address(); } -- cgit v1.2.3 From 3148d0c7b403af1bd74a2082cdde61e6974b38c1 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 11 Dec 2014 15:51:01 -0800 Subject: Don't kill the subprocess in tst_qdbusabstractinterface Rohan was right in e88f9a92b7ab05ea9bc25083de7dee1b67dd673e to stabilize the test and reset the state, but killing the subprocess is overkill. All we need is to reset the state in both applications, which includes disconnecting and reconnecting to the peer, to discard any sent but not yet received messages. Change-Id: Ie01392e6e63bd70ef8345217d3fc641ed63c7aba Reviewed-by: Simon Hausmann --- .../tst_qdbusabstractinterface.cpp | 42 +++++++++++++--------- 1 file changed, 25 insertions(+), 17 deletions(-) diff --git a/tests/auto/dbus/qdbusabstractinterface/tst_qdbusabstractinterface.cpp b/tests/auto/dbus/qdbusabstractinterface/tst_qdbusabstractinterface.cpp index 904c1be88f..3ea2d939d9 100644 --- a/tests/auto/dbus/qdbusabstractinterface/tst_qdbusabstractinterface.cpp +++ b/tests/auto/dbus/qdbusabstractinterface/tst_qdbusabstractinterface.cpp @@ -51,6 +51,7 @@ class tst_QDBusAbstractInterface: public QObject { Q_OBJECT Interface targetObj; + QString peerAddress; Pinger getPinger(QString service = "", const QString &path = "/") { @@ -81,6 +82,7 @@ public: private slots: void initTestCase(); + void cleanupTestCase(); void init(); void cleanup(); @@ -223,12 +225,6 @@ void tst_QDBusAbstractInterface::initTestCase() QDBusConnection con = QDBusConnection::sessionBus(); QVERIFY(con.isConnected()); con.registerObject("/", &targetObj, QDBusConnection::ExportScriptableContents); -} - -void tst_QDBusAbstractInterface::init() -{ - QDBusConnection con = QDBusConnection::sessionBus(); - QVERIFY(con.isConnected()); // verify service isn't registered by something else // (e.g. a left over qpinger from a previous test run) @@ -249,10 +245,29 @@ void tst_QDBusAbstractInterface::init() QDBusMessage req = QDBusMessage::createMethodCall(serviceName, objectPath, interfaceName, "address"); QDBusMessage rpl = con.call(req); QVERIFY(rpl.type() == QDBusMessage::ReplyMessage); - QString address = rpl.arguments().at(0).toString(); + peerAddress = rpl.arguments().at(0).toString(); +} + +void tst_QDBusAbstractInterface::cleanupTestCase() +{ + // Kill peer, resetting the object exported by a separate process + proc.terminate(); + QVERIFY(proc.waitForFinished() || proc.state() == QProcess::NotRunning); + + // Wait until the service is certainly not registered + QDBusConnection con = QDBusConnection::sessionBus(); + if (con.isConnected()) { + QTRY_VERIFY(!con.interface()->isServiceRegistered(serviceName)); + } +} + +void tst_QDBusAbstractInterface::init() +{ + QDBusConnection con = QDBusConnection::sessionBus(); + QVERIFY(con.isConnected()); // connect to peer server - QDBusConnection peercon = QDBusConnection::connectToPeer(address, "peer"); + QDBusConnection peercon = QDBusConnection::connectToPeer(peerAddress, "peer"); QVERIFY(peercon.isConnected()); QDBusMessage req2 = QDBusMessage::createMethodCall(serviceName, objectPath, interfaceName, "isConnected"); @@ -265,20 +280,13 @@ void tst_QDBusAbstractInterface::cleanup() { QDBusConnection::disconnectFromPeer("peer"); - // Kill peer, resetting the object exported by a separate process - proc.terminate(); - QVERIFY(proc.waitForFinished() || proc.state() == QProcess::NotRunning); - // Reset the object exported by this process targetObj.m_stringProp = QString(); targetObj.m_variantProp = QDBusVariant(); targetObj.m_complexProp = RegisteredType(); - // Wait until the service is certainly not registered - QDBusConnection con = QDBusConnection::sessionBus(); - if (con.isConnected()) { - QTRY_VERIFY(!con.interface()->isServiceRegistered(serviceName)); - } + QDBusMessage resetCall = QDBusMessage::createMethodCall(serviceName, objectPath, interfaceName, "reset"); + QVERIFY(QDBusConnection::sessionBus().call(resetCall).type() == QDBusMessage::ReplyMessage); } void tst_QDBusAbstractInterface::makeVoidCall() -- cgit v1.2.3 From 36314ae75f2f13b6c93252dc2c93592bc0624296 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 11 Dec 2014 17:42:49 -0800 Subject: Fix handling of subprocesses for QtDBus unit tests on Windows The executables are not in the same dir as on Unix, so we need to use QFINDTESTDATA to find them. The DESTDIR setting prevents qmake from placing the executables in a "debug/" subdir. Change-Id: I1d6d10e6f6f109f55fd9809dcf83da0386f38772 Reviewed-by: Simon Hausmann --- .../dbus/qdbusabstractadaptor/qmyserver/qmyserver.pro | 1 + tests/auto/dbus/qdbusabstractadaptor/test/test.pro | 1 + .../qdbusabstractadaptor/tst_qdbusabstractadaptor.cpp | 13 +++++++------ .../dbus/qdbusabstractinterface/qpinger/qpinger.pro | 1 + tests/auto/dbus/qdbusabstractinterface/test/test.pro | 1 + .../tst_qdbusabstractinterface.cpp | 17 +++++++++++------ tests/auto/dbus/qdbusinterface/qmyserver/qmyserver.pro | 1 + tests/auto/dbus/qdbusinterface/test/test.pro | 1 + tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp | 14 +++++++------- tests/auto/dbus/qdbusmarshall/qpong/qpong.pro | 1 + tests/auto/dbus/qdbusmarshall/test/test.pro | 1 + tests/auto/dbus/qdbusmarshall/tst_qdbusmarshall.cpp | 8 +++++--- .../benchmarks/dbus/qdbusperformance/server/server.pro | 1 + .../dbus/qdbusperformance/tst_qdbusperformance.cpp | 7 ++++--- 14 files changed, 43 insertions(+), 25 deletions(-) diff --git a/tests/auto/dbus/qdbusabstractadaptor/qmyserver/qmyserver.pro b/tests/auto/dbus/qdbusabstractadaptor/qmyserver/qmyserver.pro index dc480fc88c..ddafd528ee 100644 --- a/tests/auto/dbus/qdbusabstractadaptor/qmyserver/qmyserver.pro +++ b/tests/auto/dbus/qdbusabstractadaptor/qmyserver/qmyserver.pro @@ -1,6 +1,7 @@ SOURCES = qmyserver.cpp HEADERS = ../myobject.h TARGET = qmyserver +DESTDIR = ./ QT = core dbus CONFIG -= app_bundle DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/dbus/qdbusabstractadaptor/test/test.pro b/tests/auto/dbus/qdbusabstractadaptor/test/test.pro index 0e4dc91128..3d8f885437 100644 --- a/tests/auto/dbus/qdbusabstractadaptor/test/test.pro +++ b/tests/auto/dbus/qdbusabstractadaptor/test/test.pro @@ -2,6 +2,7 @@ CONFIG += testcase SOURCES += ../tst_qdbusabstractadaptor.cpp HEADERS += ../myobject.h TARGET = ../tst_qdbusabstractadaptor +DESTDIR = ./ QT = core core-private dbus testlib DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/dbus/qdbusabstractadaptor/tst_qdbusabstractadaptor.cpp b/tests/auto/dbus/qdbusabstractadaptor/tst_qdbusabstractadaptor.cpp index 9fe6bc790e..2fdba4f7e1 100644 --- a/tests/auto/dbus/qdbusabstractadaptor/tst_qdbusabstractadaptor.cpp +++ b/tests/auto/dbus/qdbusabstractadaptor/tst_qdbusabstractadaptor.cpp @@ -491,12 +491,13 @@ void tst_QDBusAbstractAdaptor::initTestCase() commonInit(); // start peer server - #ifdef Q_OS_WIN - proc.start("qmyserver"); - #else - proc.start("./qmyserver/qmyserver"); - #endif - QVERIFY(proc.waitForStarted()); +#ifdef Q_OS_WIN +# define EXE ".exe" +#else +# define EXE "" +#endif + proc.start(QFINDTESTDATA("qmyserver/qmyserver" EXE)); + QVERIFY2(proc.waitForStarted(), qPrintable(proc.errorString())); WaitForQMyServer w; QVERIFY(w.ok()); diff --git a/tests/auto/dbus/qdbusabstractinterface/qpinger/qpinger.pro b/tests/auto/dbus/qdbusabstractinterface/qpinger/qpinger.pro index 5001ec2cd2..957b47e413 100644 --- a/tests/auto/dbus/qdbusabstractinterface/qpinger/qpinger.pro +++ b/tests/auto/dbus/qdbusabstractinterface/qpinger/qpinger.pro @@ -1,6 +1,7 @@ SOURCES = qpinger.cpp ../interface.cpp HEADERS = ../interface.h TARGET = qpinger +DESTDIR = ./ CONFIG -= app_bundle CONFIG += console QT = core dbus diff --git a/tests/auto/dbus/qdbusabstractinterface/test/test.pro b/tests/auto/dbus/qdbusabstractinterface/test/test.pro index 223c94866c..afd101455e 100644 --- a/tests/auto/dbus/qdbusabstractinterface/test/test.pro +++ b/tests/auto/dbus/qdbusabstractinterface/test/test.pro @@ -3,6 +3,7 @@ SOURCES += ../tst_qdbusabstractinterface.cpp ../interface.cpp HEADERS += ../interface.h TARGET = ../tst_qdbusabstractinterface +DESTDIR = ./ QT = core testlib QT += dbus diff --git a/tests/auto/dbus/qdbusabstractinterface/tst_qdbusabstractinterface.cpp b/tests/auto/dbus/qdbusabstractinterface/tst_qdbusabstractinterface.cpp index 3ea2d939d9..6ab5e5ff61 100644 --- a/tests/auto/dbus/qdbusabstractinterface/tst_qdbusabstractinterface.cpp +++ b/tests/auto/dbus/qdbusabstractinterface/tst_qdbusabstractinterface.cpp @@ -231,12 +231,13 @@ void tst_QDBusAbstractInterface::initTestCase() QVERIFY(!con.interface()->isServiceRegistered(serviceName)); // start peer server - #ifdef Q_OS_WIN - proc.start("qpinger"); - #else - proc.start("./qpinger/qpinger"); - #endif - QVERIFY(proc.waitForStarted()); +#ifdef Q_OS_WIN +# define EXE ".exe" +#else +# define EXE "" +#endif + proc.start(QFINDTESTDATA("qpinger/qpinger" EXE)); + QVERIFY2(proc.waitForStarted(), qPrintable(proc.errorString())); // verify service is now registered QTRY_VERIFY(con.interface()->isServiceRegistered(serviceName)); @@ -251,7 +252,11 @@ void tst_QDBusAbstractInterface::initTestCase() void tst_QDBusAbstractInterface::cleanupTestCase() { // Kill peer, resetting the object exported by a separate process +#ifdef Q_OS_WIN + proc.kill(); // non-GUI processes don't respond to QProcess::terminate() +#else proc.terminate(); +#endif QVERIFY(proc.waitForFinished() || proc.state() == QProcess::NotRunning); // Wait until the service is certainly not registered diff --git a/tests/auto/dbus/qdbusinterface/qmyserver/qmyserver.pro b/tests/auto/dbus/qdbusinterface/qmyserver/qmyserver.pro index dc480fc88c..ddafd528ee 100644 --- a/tests/auto/dbus/qdbusinterface/qmyserver/qmyserver.pro +++ b/tests/auto/dbus/qdbusinterface/qmyserver/qmyserver.pro @@ -1,6 +1,7 @@ SOURCES = qmyserver.cpp HEADERS = ../myobject.h TARGET = qmyserver +DESTDIR = ./ QT = core dbus CONFIG -= app_bundle DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/dbus/qdbusinterface/test/test.pro b/tests/auto/dbus/qdbusinterface/test/test.pro index ba70273aab..70e631de9c 100644 --- a/tests/auto/dbus/qdbusinterface/test/test.pro +++ b/tests/auto/dbus/qdbusinterface/test/test.pro @@ -2,6 +2,7 @@ CONFIG += testcase SOURCES += ../tst_qdbusinterface.cpp HEADERS += ../myobject.h TARGET = ../tst_qdbusinterface +DESTDIR = ./ QT = core core-private dbus testlib DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp b/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp index e66b1134d4..81e3aa3292 100644 --- a/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp +++ b/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp @@ -266,13 +266,13 @@ void tst_QDBusInterface::initTestCase() | QDBusConnection::ExportAllSlots | QDBusConnection::ExportAllInvokables); - // start peer server - #ifdef Q_OS_WIN - proc.start("qmyserver"); - #else - proc.start("./qmyserver/qmyserver"); - #endif - QVERIFY(proc.waitForStarted()); +#ifdef Q_OS_WIN +# define EXE ".exe" +#else +# define EXE "" +#endif + proc.start(QFINDTESTDATA("qmyserver/qmyserver" EXE)); + QVERIFY2(proc.waitForStarted(), qPrintable(proc.errorString())); WaitForQMyServer w; QVERIFY(w.ok()); diff --git a/tests/auto/dbus/qdbusmarshall/qpong/qpong.pro b/tests/auto/dbus/qdbusmarshall/qpong/qpong.pro index ffc538f2ab..a4c5efba85 100644 --- a/tests/auto/dbus/qdbusmarshall/qpong/qpong.pro +++ b/tests/auto/dbus/qdbusmarshall/qpong/qpong.pro @@ -1,5 +1,6 @@ SOURCES = qpong.cpp TARGET = qpong +DESTDIR = ./ QT = core dbus CONFIG -= app_bundle CONFIG += console diff --git a/tests/auto/dbus/qdbusmarshall/test/test.pro b/tests/auto/dbus/qdbusmarshall/test/test.pro index 5c67bfc624..658cc52fde 100644 --- a/tests/auto/dbus/qdbusmarshall/test/test.pro +++ b/tests/auto/dbus/qdbusmarshall/test/test.pro @@ -1,6 +1,7 @@ CONFIG += testcase SOURCES += ../tst_qdbusmarshall.cpp TARGET = ../tst_qdbusmarshall +DESTDIR = ./ QT = core-private dbus-private testlib diff --git a/tests/auto/dbus/qdbusmarshall/tst_qdbusmarshall.cpp b/tests/auto/dbus/qdbusmarshall/tst_qdbusmarshall.cpp index 972205566a..0d9fba3e1f 100644 --- a/tests/auto/dbus/qdbusmarshall/tst_qdbusmarshall.cpp +++ b/tests/auto/dbus/qdbusmarshall/tst_qdbusmarshall.cpp @@ -130,13 +130,15 @@ void tst_QDBusMarshall::initTestCase() commonInit(); QDBusConnection con = QDBusConnection::sessionBus(); fileDescriptorPassing = con.connectionCapabilities() & QDBusConnection::UnixFileDescriptorPassing; + #ifdef Q_OS_WIN - proc.start("qpong"); +# define EXE ".exe" #else - proc.start("./qpong/qpong"); +# define EXE "" #endif + proc.start(QFINDTESTDATA("qpong/qpong" EXE)); if (!QDBusConnection::sessionBus().interface()->isServiceRegistered(serviceName)) { - QVERIFY(proc.waitForStarted()); + QVERIFY2(proc.waitForStarted(), qPrintable(proc.errorString())); QVERIFY(con.isConnected()); con.connect("org.freedesktop.DBus", QString(), "org.freedesktop.DBus", "NameOwnerChanged", diff --git a/tests/benchmarks/dbus/qdbusperformance/server/server.pro b/tests/benchmarks/dbus/qdbusperformance/server/server.pro index b38623b099..c913e90afb 100644 --- a/tests/benchmarks/dbus/qdbusperformance/server/server.pro +++ b/tests/benchmarks/dbus/qdbusperformance/server/server.pro @@ -1,6 +1,7 @@ SOURCES = server.cpp HEADERS = ../serverobject.h TARGET = server +DESTDIR = . QT += dbus QT -= gui DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/benchmarks/dbus/qdbusperformance/tst_qdbusperformance.cpp b/tests/benchmarks/dbus/qdbusperformance/tst_qdbusperformance.cpp index 5b3be02c33..eff69fe24d 100644 --- a/tests/benchmarks/dbus/qdbusperformance/tst_qdbusperformance.cpp +++ b/tests/benchmarks/dbus/qdbusperformance/tst_qdbusperformance.cpp @@ -80,11 +80,12 @@ void tst_QDBusPerformance::initTestCase() &QTestEventLoop::instance(), SLOT(exitLoop())); #ifdef Q_OS_WIN - proc.start("server"); +# define EXE ".exe" #else - proc.start("./server/server"); +# define EXE "" #endif - QVERIFY(proc.waitForStarted()); + proc.start(QFINDTESTDATA("server/server" EXE)); + QVERIFY2(proc.waitForStarted(), qPrintable(proc.errorString())); QTestEventLoop::instance().enterLoop(5); QVERIFY(con.interface()->isServiceRegistered(serviceName)); -- cgit v1.2.3 From d55db285fc4ae0a978591213c294f53ab879cd40 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 11 Dec 2014 17:50:01 -0800 Subject: Autotest: Fix a race condition in launching the QtDBus sub-processes Wait for the subprocess to print "ready" before assuming that it is ready to receive calls. waitForStarted() will return as soon as the child is running, but it may not have registered on D-Bus yet. This also solves the synchronization problem more elegantly than how tst_qdbusmarshall.cpp was trying to do it. Change-Id: I548dfba2677cc5a34ba50f4310c4d5baa98093b2 Reviewed-by: Simon Hausmann --- .../dbus/qdbusabstractadaptor/qmyserver/qmyserver.cpp | 1 + .../qdbusabstractadaptor/tst_qdbusabstractadaptor.cpp | 1 + .../auto/dbus/qdbusabstractinterface/qpinger/qpinger.cpp | 1 + .../tst_qdbusabstractinterface.cpp | 1 + tests/auto/dbus/qdbusinterface/qmyserver/qmyserver.cpp | 1 + tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp | 1 + tests/auto/dbus/qdbusmarshall/qpong/qpong.cpp | 1 + tests/auto/dbus/qdbusmarshall/tst_qdbusmarshall.cpp | 16 ++-------------- tests/benchmarks/dbus/qdbusperformance/server/server.cpp | 1 + .../dbus/qdbusperformance/tst_qdbusperformance.cpp | 1 + 10 files changed, 11 insertions(+), 14 deletions(-) diff --git a/tests/auto/dbus/qdbusabstractadaptor/qmyserver/qmyserver.cpp b/tests/auto/dbus/qdbusabstractadaptor/qmyserver/qmyserver.cpp index b4a79fa754..c680d93dab 100644 --- a/tests/auto/dbus/qdbusabstractadaptor/qmyserver/qmyserver.cpp +++ b/tests/auto/dbus/qdbusabstractadaptor/qmyserver/qmyserver.cpp @@ -163,6 +163,7 @@ int main(int argc, char *argv[]) con.registerObject(objectPath, &server, QDBusConnection::ExportAllSlots); printf("ready.\n"); + fflush(stdout); return app.exec(); } diff --git a/tests/auto/dbus/qdbusabstractadaptor/tst_qdbusabstractadaptor.cpp b/tests/auto/dbus/qdbusabstractadaptor/tst_qdbusabstractadaptor.cpp index 2fdba4f7e1..971c939aad 100644 --- a/tests/auto/dbus/qdbusabstractadaptor/tst_qdbusabstractadaptor.cpp +++ b/tests/auto/dbus/qdbusabstractadaptor/tst_qdbusabstractadaptor.cpp @@ -498,6 +498,7 @@ void tst_QDBusAbstractAdaptor::initTestCase() #endif proc.start(QFINDTESTDATA("qmyserver/qmyserver" EXE)); QVERIFY2(proc.waitForStarted(), qPrintable(proc.errorString())); + QVERIFY(proc.waitForReadyRead()); WaitForQMyServer w; QVERIFY(w.ok()); diff --git a/tests/auto/dbus/qdbusabstractinterface/qpinger/qpinger.cpp b/tests/auto/dbus/qdbusabstractinterface/qpinger/qpinger.cpp index 49291abf92..49462d388c 100644 --- a/tests/auto/dbus/qdbusabstractinterface/qpinger/qpinger.cpp +++ b/tests/auto/dbus/qdbusabstractinterface/qpinger/qpinger.cpp @@ -118,6 +118,7 @@ int main(int argc, char *argv[]) con.registerObject(objectPath, &server, QDBusConnection::ExportAllSlots); printf("ready.\n"); + fflush(stdout); return app.exec(); } diff --git a/tests/auto/dbus/qdbusabstractinterface/tst_qdbusabstractinterface.cpp b/tests/auto/dbus/qdbusabstractinterface/tst_qdbusabstractinterface.cpp index 6ab5e5ff61..0cb29d121b 100644 --- a/tests/auto/dbus/qdbusabstractinterface/tst_qdbusabstractinterface.cpp +++ b/tests/auto/dbus/qdbusabstractinterface/tst_qdbusabstractinterface.cpp @@ -238,6 +238,7 @@ void tst_QDBusAbstractInterface::initTestCase() #endif proc.start(QFINDTESTDATA("qpinger/qpinger" EXE)); QVERIFY2(proc.waitForStarted(), qPrintable(proc.errorString())); + QVERIFY(proc.waitForReadyRead()); // verify service is now registered QTRY_VERIFY(con.interface()->isServiceRegistered(serviceName)); diff --git a/tests/auto/dbus/qdbusinterface/qmyserver/qmyserver.cpp b/tests/auto/dbus/qdbusinterface/qmyserver/qmyserver.cpp index 4aacbdc5a2..7a22fe90ad 100644 --- a/tests/auto/dbus/qdbusinterface/qmyserver/qmyserver.cpp +++ b/tests/auto/dbus/qdbusinterface/qmyserver/qmyserver.cpp @@ -142,6 +142,7 @@ int main(int argc, char *argv[]) con.registerObject(objectPath, &server, QDBusConnection::ExportAllSlots); printf("ready.\n"); + fflush(stdout); return app.exec(); } diff --git a/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp b/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp index 81e3aa3292..04992c9f28 100644 --- a/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp +++ b/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp @@ -273,6 +273,7 @@ void tst_QDBusInterface::initTestCase() #endif proc.start(QFINDTESTDATA("qmyserver/qmyserver" EXE)); QVERIFY2(proc.waitForStarted(), qPrintable(proc.errorString())); + QVERIFY(proc.waitForReadyRead()); WaitForQMyServer w; QVERIFY(w.ok()); diff --git a/tests/auto/dbus/qdbusmarshall/qpong/qpong.cpp b/tests/auto/dbus/qdbusmarshall/qpong/qpong.cpp index 5476dd7f8e..bb8aab3d21 100644 --- a/tests/auto/dbus/qdbusmarshall/qpong/qpong.cpp +++ b/tests/auto/dbus/qdbusmarshall/qpong/qpong.cpp @@ -66,6 +66,7 @@ int main(int argc, char *argv[]) con.registerObject(objectPath, &pong, QDBusConnection::ExportAllSlots); printf("ready.\n"); + fflush(stdout); return app.exec(); } diff --git a/tests/auto/dbus/qdbusmarshall/tst_qdbusmarshall.cpp b/tests/auto/dbus/qdbusmarshall/tst_qdbusmarshall.cpp index 0d9fba3e1f..4d12522a68 100644 --- a/tests/auto/dbus/qdbusmarshall/tst_qdbusmarshall.cpp +++ b/tests/auto/dbus/qdbusmarshall/tst_qdbusmarshall.cpp @@ -137,20 +137,8 @@ void tst_QDBusMarshall::initTestCase() # define EXE "" #endif proc.start(QFINDTESTDATA("qpong/qpong" EXE)); - if (!QDBusConnection::sessionBus().interface()->isServiceRegistered(serviceName)) { - QVERIFY2(proc.waitForStarted(), qPrintable(proc.errorString())); - - QVERIFY(con.isConnected()); - con.connect("org.freedesktop.DBus", QString(), "org.freedesktop.DBus", "NameOwnerChanged", - QStringList() << serviceName << QString(""), QString(), - &QTestEventLoop::instance(), SLOT(exitLoop())); - QTestEventLoop::instance().enterLoop(2); - QVERIFY(!QTestEventLoop::instance().timeout()); - QVERIFY(QDBusConnection::sessionBus().interface()->isServiceRegistered(serviceName)); - con.disconnect("org.freedesktop.DBus", QString(), "org.freedesktop.DBus", "NameOwnerChanged", - QStringList() << serviceName << QString(""), QString(), - &QTestEventLoop::instance(), SLOT(exitLoop())); - } + QVERIFY2(proc.waitForStarted(), qPrintable(proc.errorString())); + QVERIFY(proc.waitForReadyRead()); } void tst_QDBusMarshall::cleanupTestCase() diff --git a/tests/benchmarks/dbus/qdbusperformance/server/server.cpp b/tests/benchmarks/dbus/qdbusperformance/server/server.cpp index 12ae6ec6fb..6ee13b5c71 100644 --- a/tests/benchmarks/dbus/qdbusperformance/server/server.cpp +++ b/tests/benchmarks/dbus/qdbusperformance/server/server.cpp @@ -51,6 +51,7 @@ int main(int argc, char *argv[]) ServerObject obj(objectPath, con); printf("ready.\n"); + fflush(stdout); return app.exec(); } diff --git a/tests/benchmarks/dbus/qdbusperformance/tst_qdbusperformance.cpp b/tests/benchmarks/dbus/qdbusperformance/tst_qdbusperformance.cpp index eff69fe24d..4bc3c94cd0 100644 --- a/tests/benchmarks/dbus/qdbusperformance/tst_qdbusperformance.cpp +++ b/tests/benchmarks/dbus/qdbusperformance/tst_qdbusperformance.cpp @@ -86,6 +86,7 @@ void tst_QDBusPerformance::initTestCase() #endif proc.start(QFINDTESTDATA("server/server" EXE)); QVERIFY2(proc.waitForStarted(), qPrintable(proc.errorString())); + QVERIFY(proc.waitForReadyRead()); QTestEventLoop::instance().enterLoop(5); QVERIFY(con.interface()->isServiceRegistered(serviceName)); -- cgit v1.2.3 From 36132addd1dd7592dd0948e61399c2263e68b6e7 Mon Sep 17 00:00:00 2001 From: BogDan Vatra Date: Fri, 19 Dec 2014 10:55:23 +0200 Subject: Remove old test script & project. Change-Id: Ia31959228e188a3f9d2fe3a95c7381a3f4e5d1fb Reviewed-by: Eskil Abrahamsen Blomfeldt --- tests/auto/android/AndroidManifest.xml | 37 -- tests/auto/android/res/layout/main.xml | 12 - tests/auto/android/res/values/libs.xml | 21 - tests/auto/android/res/values/strings.xml | 4 - tests/auto/android/runtests.pl | 367 ---------------- .../src/org/qtproject/qt5/android/QtActivity.java | 330 --------------- .../qtproject/qt5/android/QtInputConnection.java | 209 --------- .../src/org/qtproject/qt5/android/QtNative.java | 471 --------------------- .../src/org/qtproject/qt5/android/QtSurface.java | 163 ------- 9 files changed, 1614 deletions(-) delete mode 100644 tests/auto/android/AndroidManifest.xml delete mode 100644 tests/auto/android/res/layout/main.xml delete mode 100644 tests/auto/android/res/values/libs.xml delete mode 100644 tests/auto/android/res/values/strings.xml delete mode 100755 tests/auto/android/runtests.pl delete mode 100644 tests/auto/android/src/org/qtproject/qt5/android/QtActivity.java delete mode 100644 tests/auto/android/src/org/qtproject/qt5/android/QtInputConnection.java delete mode 100644 tests/auto/android/src/org/qtproject/qt5/android/QtNative.java delete mode 100644 tests/auto/android/src/org/qtproject/qt5/android/QtSurface.java diff --git a/tests/auto/android/AndroidManifest.xml b/tests/auto/android/AndroidManifest.xml deleted file mode 100644 index bd1e0afc68..0000000000 --- a/tests/auto/android/AndroidManifest.xml +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/auto/android/res/layout/main.xml b/tests/auto/android/res/layout/main.xml deleted file mode 100644 index 7fe6bbac67..0000000000 --- a/tests/auto/android/res/layout/main.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - diff --git a/tests/auto/android/res/values/libs.xml b/tests/auto/android/res/values/libs.xml deleted file mode 100644 index 43f1d4aff4..0000000000 --- a/tests/auto/android/res/values/libs.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - gnustl_shared - Qt5Core - Qt5Gui - Qt5Widgets - Qt5Test - Qt5OpenGL - Qt5Network - Qt5Script - Qt5Sql - Qt5Xml - Qt5ScriptTools - Qt5Svg - Qt5XmlPatterns - Qt5Declarative - Qt5WebKit - - - diff --git a/tests/auto/android/res/values/strings.xml b/tests/auto/android/res/values/strings.xml deleted file mode 100644 index faf61040b5..0000000000 --- a/tests/auto/android/res/values/strings.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - Quadruplor - diff --git a/tests/auto/android/runtests.pl b/tests/auto/android/runtests.pl deleted file mode 100755 index 30bf78f0b7..0000000000 --- a/tests/auto/android/runtests.pl +++ /dev/null @@ -1,367 +0,0 @@ -#!/usr/bin/perl -w -############################################################################# -## -## Copyright (C) 2012-2013 BogDan Vatra -## Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). -## Contact: http://www.qt-project.org/legal -## -## This file is part of the test suite of the Qt Toolkit. -## -## $QT_BEGIN_LICENSE:LGPL21$ -## Commercial License Usage -## Licensees holding valid commercial Qt licenses may use this file in -## accordance with the commercial license agreement provided with the -## Software or, alternatively, in accordance with the terms contained in -## a written agreement between you and Digia. For licensing terms and -## conditions see http://qt.digia.com/licensing. For further information -## use the contact form at http://qt.digia.com/contact-us. -## -## GNU Lesser General Public License Usage -## Alternatively, this file may be used under the terms of the GNU Lesser -## General Public License version 2.1 or version 3 as published by the Free -## Software Foundation and appearing in the file LICENSE.LGPLv21 and -## LICENSE.LGPLv3 included in the packaging of this file. Please review the -## following information to ensure the GNU Lesser General Public License -## requirements will be met: https://www.gnu.org/licenses/lgpl.html and -## http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -## -## In addition, as a special exception, Digia gives you certain additional -## rights. These rights are described in the Digia Qt LGPL Exception -## version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -## -## $QT_END_LICENSE$ -## -############################################################################# - -use Cwd; -use Cwd 'abs_path'; -use File::Basename; -use File::Temp 'tempdir'; -use File::Path 'remove_tree'; -use Getopt::Long; -use Pod::Usage; - -### default options -my @stack = cwd; -my $device_serial=""; # "-s device_serial"; -my $packageName="org.qtproject.qt5.android.tests"; -my $intentName="$packageName/org.qtproject.qt5.android.QtActivity"; -my $jobs = 4; -my $testsubset = ""; -my $man = 0; -my $help = 0; -my $make_clean = 0; -my $deploy_qt = 0; -my $time_out=400; -my $android_sdk_dir = "$ENV{'ANDROID_SDK_ROOT'}"; -my $android_ndk_dir = "$ENV{'ANDROID_NDK_ROOT'}"; -my $ant_tool = `which ant`; -chomp $ant_tool; -my $strip_tool=""; -my $readelf_tool=""; -GetOptions('h|help' => \$help - , man => \$man - , 's|serial=s' => \$device_serial - , 't|test=s' => \$testsubset - , 'c|clean' => \$make_clean - , 'd|deploy' => \$deploy_qt - , 'j|jobs=i' => \$jobs - , 'sdk=s' => \$android_sdk_dir - , 'ndk=s' => \$android_ndk_dir - , 'ant=s' => \$ant_tool - , 'strip=s' => \$strip_tool - , 'readelf=s' => \$readelf_tool - , 'testcase=s' => \$testcase - ) or pod2usage(2); -pod2usage(1) if $help; -pod2usage(-verbose => 2) if $man; - -my $adb_tool="$android_sdk_dir/platform-tools/adb"; -system("$adb_tool devices") == 0 or die "No device found, please plug/start at least one device/emulator\n"; # make sure we have at least on device attached - -$device_serial = "-s $device_serial" if ($device_serial); -$testsubset="/$testsubset" if ($testsubset); - -$strip_tool="$android_ndk_dir/toolchains/arm-linux-androideabi-4.7/prebuilt/linux-x86/bin/arm-linux-androideabi-strip" unless($strip_tool); -$readelf_tool="$android_ndk_dir/toolchains/arm-linux-androideabi-4.7/prebuilt/linux-x86/bin/arm-linux-androideabi-readelf" unless($readelf_tool); -$readelf_tool="$readelf_tool -d -w "; - -sub dir -{ -# print "@stack\n"; -} - -sub pushd ($) -{ - unless ( chdir $_[0] ) - { - warn "Error: $!\n"; - return; - } - unshift @stack, cwd; - dir; -} - -sub popd () -{ - @stack > 1 and shift @stack; - chdir $stack[0]; - dir; -} - - -sub waitForProcess -{ - my $process=shift; - my $action=shift; - my $timeout=shift; - my $sleepPeriod=shift; - $sleepPeriod=1 if !defined($sleepPeriod); - print "Waiting for $process ".$timeout*$sleepPeriod." seconds to"; - print $action?" start...\n":" die...\n"; - while ($timeout--) - { - my $output = `$adb_tool $device_serial shell ps 2>&1`; # get current processes - #FIXME check why $output is not matching m/.*S $process\n/ or m/.*S $process$/ (eol) - my $res=($output =~ m/.*S $process/)?1:0; # check the procress - if ($action == $res) - { - print "... succeed\n"; - return 1; - } - sleep($sleepPeriod); - print "timeount in ".$timeout*$sleepPeriod." seconds\n" - } - print "... failed\n"; - return 0; -} - -my $src_dir_qt=abs_path(dirname($0)."/../../.."); -my $quadruplor_dir="$src_dir_qt/tests/auto/android"; -my $qmake_path="$src_dir_qt/bin/qmake"; -my $tests_dir="$src_dir_qt/tests$testsubset"; -my $temp_dir=tempdir(CLEANUP => 1); -my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); -my $output_dir=$stack[0]."/".(1900+$year)."-$mon-$mday-$hour:$min"; -mkdir($output_dir); -my $sdk_api=0; -my $output = `$adb_tool $device_serial shell getprop`; # get device properties -if ($output =~ m/.*\[ro.build.version.sdk\]: \[(\d+)\]/) -{ - $sdk_api=int($1); - $sdk_api=5 if ($sdk_api>5 && $sdk_api<8); - $sdk_api=9 if ($sdk_api>9); -} - -sub reinstallQuadruplor -{ - pushd($quadruplor_dir); - system("$android_sdk_dir/tools/android update project -p . -t android-10")==0 or die "Can't update project ...\n"; - system("$ant_tool uninstall clean debug install")==0 or die "Can't install Quadruplor\n"; - system("$adb_tool $device_serial shell am start -n $intentName"); # create application folders - waitForProcess($packageName,1,10); - waitForProcess($packageName,0,20); - popd(); -} -sub killProcess -{ - reinstallQuadruplor; -# #### it seems I'm too idiot to use perl regexp -# my $process=shift; -# my $output = `$adb_tool $device_serial shell ps 2>&1`; # get current processes -# $output =~ s/\r//g; # replace all "\r" with "" -# chomp($output); -# print $output; -# if ($output =~ m/^.*_\d+\s+(\d+).*S $process/) # check the procress -# { -# print("Killing $process PID:$1\n"); -# system("$adb_tool $device_serial shell kill $1"); -# waitForProcess($process,0,20); -# } -# else -# { -# print("Can't kill the process $process\n"); -# } -} - - -sub startTest -{ - my $libs = shift; - my $mainLib = shift; - my $openGL = ((shift)?"true":"false"); - system("$adb_tool $device_serial shell am start -n $intentName --ez needsOpenGl $openGL --es extra_libs \"$libs\" --es lib_name \"$mainLib\""); # start intent - #wait to start - return 0 unless(waitForProcess($packageName,1,10)); - #wait to stop - unless(waitForProcess($packageName,0,$time_out,5)) - { - killProcess($packageName); - return 1; - } - my $output_file = shift; - system("$adb_tool $device_serial pull /data/data/$packageName/app_files/output.xml $output_dir/$output_file"); - return 1; -} - -sub needsOpenGl -{ - my $app=$readelf_tool.shift.' |grep -e "^.*(NEEDED).*Shared library: \[libQtOpenGL\.so\]$"'; - my $res=`$app`; - chomp $res; - return $res; -} - -########### delpoy qt libs ########### -if ($deploy_qt) -{ - - pushd($src_dir_qt); - mkdir("$temp_dir/lib"); - my @libs=`find lib -name *.so`; # libs must be handled diferently - foreach (@libs) - { - chomp; - print ("cp -L $_ $temp_dir/lib\n"); - system("cp -L $_ $temp_dir/lib"); - } - system("cp -L $android_ndk_dir/sources/cxx-stl/gnu-libstdc++/4.7/libs/armeabi-v7a/libgnustl_shared.so $temp_dir/lib"); - system("cp -a plugins $temp_dir"); - system("cp -a imports $temp_dir"); - system("cp -a qml $temp_dir"); - pushd($temp_dir); - system("find -name *.so | xargs $strip_tool --strip-unneeded"); - popd; - system("$adb_tool $device_serial shell rm -r /data/local/tmp/qt"); # remove old qt libs - system("$adb_tool $device_serial push $temp_dir /data/local/tmp/qt"); # copy newer qt libs - popd; -} - -########### build & install quadruplor ########### -reinstallQuadruplor; - -########### build qt tests and benchmarks ########### -pushd($tests_dir); -print "Building $tests_dir \n"; -system("make distclean") if ($make_clean); -system("$qmake_path CONFIG-=QTDIR_build -r") == 0 or die "Can't run qmake\n"; #exec qmake -system("make -j$jobs") == 0 or warn "Can't build all tests\n"; #exec make - -my $testsFiles = ""; -if ($testcase) { - $testsFiles=`find . -name libtst_$testcase.so`; # only tests -} else { - $testsFiles=`find . -name libtst_*.so`; # only tests -} - -foreach (split("\n",$testsFiles)) -{ - chomp; #remove white spaces - pushd(abs_path(dirname($_))); # cd to application dir - system("make INSTALL_ROOT=$temp_dir install"); # install the application to temp dir - system("$adb_tool $device_serial shell rm -r /data/data/$packageName/app_files/*"); # remove old data - system("$adb_tool $device_serial push $temp_dir /data/data/$packageName/app_files"); # copy - my $application=basename(cwd); - my $output_name=dirname($_); - $output_name =~ s/\.//; # remove first "." character - $output_name =~ s/\///; # remove first "/" character - $output_name =~ s/\//_/g; # replace all "/" with "_" - $output_name=$application unless($output_name); - $time_out=5*60/5; # 5 minutes time out for a normal test - if (-e "$temp_dir/libtst_bench_$application.so") - { - $time_out=5*60/5; # 10 minutes for a benchmark - $application = "bench_$application"; - } - - if (-e "$temp_dir/libtst_$application.so") - { - if (needsOpenGl("$temp_dir/libtst_$application.so")) - { - startTest("/data/local/tmp/qt/plugins/platforms/android/libqtforandroidGL.so", "/data/data/$packageName/app_files/libtst_$application.so", 1 - , "$output_name.xml") or warn "Can't run $application ...\n"; - } - else - { - startTest("/data/local/tmp/qt/plugins/platforms/android/libqtforandroid.so", "/data/data/$packageName/app_files/libtst_$application.so", 0 - , "$output_name.xml") or warn "Can't run $application stopping tests ...\n"; - } - } - else - { #ups this test application doesn't respect name convention - warn "$application test application doesn't respect name convention please fix it !\n"; - } - popd(); - remove_tree( $temp_dir, {keep_root => 1} ); -} -popd(); - -__END__ - -=head1 NAME - -Script to run all qt tests/benchmarks to an android device/emulator - -=head1 SYNOPSIS - -runtests.pl [options] - -=head1 OPTIONS - -=over 8 - -=item B<-s --serial = serial> - -Device serial number. May be empty if only one device is attached. - -=item B<-t --test = test_subset> - -Tests subset (e.g. benchmarks, auto, auto/qbuffer, etc.). - -=item B<-d --deploy> - -Deploy current qt libs. - -=item B<-c --clean> - -Clean tests before building them. - -=item B<-j --jobs = number> - -Make jobs when building tests. - -=item B<--sdk = sdk_path> - -Android SDK path. - -=item B<--ndk = ndk_path> - -Android NDK path. - -=item B<--ant = ant_tool_path> - -Ant tool path. - -=item B<--strip = strip_tool_path> - -Android strip tool path, used to deploy qt libs. - -=item B<--readelf = readelf_tool_path> - -Android readelf tool path, used to check if a test application uses qt OpenGL. - -=item B<-h --help> - -Print a brief help message and exits. - -=item B<--man> - -Prints the manual page and exits. - -=back - -=head1 DESCRIPTION - -B will run all qt tests/benchmarks to an android device/emulator. - -=cut diff --git a/tests/auto/android/src/org/qtproject/qt5/android/QtActivity.java b/tests/auto/android/src/org/qtproject/qt5/android/QtActivity.java deleted file mode 100644 index ed190fdc1b..0000000000 --- a/tests/auto/android/src/org/qtproject/qt5/android/QtActivity.java +++ /dev/null @@ -1,330 +0,0 @@ -/* - Copyright (c) 2012, BogDan Vatra - Contact: http://www.qt-project.org/legal - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - 1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -package org.qtproject.qt5.android; - -import java.io.File; -import java.util.ArrayList; -import java.util.Iterator; - -import org.qtproject.qt5.android.tests.R; - -import android.app.Activity; -import android.content.Context; -import android.content.res.Configuration; -import android.graphics.Rect; -import android.os.Bundle; -import android.text.method.MetaKeyKeyListener; -import android.util.DisplayMetrics; -import android.util.Log; -import android.view.KeyCharacterMap; -import android.view.KeyEvent; -import android.view.Menu; -import android.view.MenuItem; -import android.view.Window; -import android.view.WindowManager; -import android.view.inputmethod.InputMethodManager; - -public class QtActivity extends Activity { - private int m_id =- 1; - private boolean softwareKeyboardIsVisible = false; - private long m_metaState; - private int m_lastChar = 0; - private boolean m_fullScreen = false; - private boolean m_started = false; - private QtSurface m_surface = null; - private boolean m_usesGL = false; - private void loadQtLibs(String[] libs, String environment, String params, String mainLib, String nativeLibDir) throws Exception - { - QtNative.loadQtLibraries(libs); - // start application - - final String envPaths = "NECESSITAS_API_LEVEL=2\tHOME=" + getDir("files", MODE_WORLD_WRITEABLE | MODE_WORLD_READABLE).getAbsolutePath() + - "\tTMPDIR=" + getDir("files", MODE_WORLD_WRITEABLE | MODE_WORLD_READABLE).getAbsolutePath() + - "\tCACHE_PATH=" + getDir("files", MODE_WORLD_WRITEABLE | MODE_WORLD_READABLE).getAbsolutePath(); - if (environment != null && environment.length() > 0) - environment = envPaths + "\t" + environment; - else - environment = envPaths; - - try { - Thread.sleep(5000); - } catch (InterruptedException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - QtNative.startApplication(params, environment, mainLib, nativeLibDir); - m_surface.applicationStarted(m_usesGL); - m_started = true; - } - - private boolean m_quitApp = true; - private Process m_debuggerProcess = null; // debugger process - - private void startApp(final boolean firstStart) - { - try { - String qtLibs[] = getResources().getStringArray(R.array.qt_libs); - ArrayList libraryList = new ArrayList(); - for (int i = 0; i < qtLibs.length; i++) - libraryList.add("/data/local/tmp/qt/lib/lib" + qtLibs[i] + ".so"); - - String mainLib = null; - String nativeLibDir = null; - if (getIntent().getExtras() != null) { - if (getIntent().getExtras().containsKey("extra_libs")) { - String extra_libs = getIntent().getExtras().getString("extra_libs"); - for (String lib : extra_libs.split(":")) - libraryList.add(lib); - } - if (getIntent().getExtras().containsKey("lib_name")) { - mainLib = getIntent().getExtras().getString("lib_name"); - libraryList.add(mainLib); - int slash = mainLib.lastIndexOf("/"); - if (slash >= 0) { - nativeLibDir = mainLib.substring(0, slash+1); - mainLib = mainLib.substring(slash+1+3, mainLib.length()-3); //remove lib and .so - } else { - nativeLibDir = ""; - } - } - - if (getIntent().getExtras().containsKey("needsOpenGl")) - m_usesGL = getIntent().getExtras().getBoolean("needsOpenGl"); - } else { - try { - Thread.sleep(5000); - } catch (InterruptedException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - finish(); - System.exit(0); - } - String[] libs = new String[libraryList.size()]; - libs = libraryList.toArray(libs); - loadQtLibs(libs - ,"QT_QPA_EGLFS_HIDECURSOR=1\tQML2_IMPORT_PATH=/data/local/tmp/qt/qml\tQML_IMPORT_PATH=/data/local/tmp/qt/imports\tQT_PLUGIN_PATH=/data/local/tmp/qt/plugins" - , "-xml\t-silent\t-o\toutput.xml", mainLib, nativeLibDir); - } catch (Exception e) { - Log.e(QtNative.QtTAG, "Can't create main activity", e); - } - } - - @Override - public void onCreate(Bundle savedInstanceState) - { - super.onCreate(savedInstanceState); - getDir("files", MODE_WORLD_WRITEABLE | MODE_WORLD_READABLE); - requestWindowFeature(Window.FEATURE_NO_TITLE); - m_quitApp = true; - QtNative.setMainActivity(this); - if (null == getLastNonConfigurationInstance()) { - DisplayMetrics metrics = new DisplayMetrics(); - getWindowManager().getDefaultDisplay().getMetrics(metrics); - QtNative.setApplicationDisplayMetrics(metrics.widthPixels, metrics.heightPixels, - metrics.widthPixels, metrics.heightPixels, - metrics.xdpi, metrics.ydpi); - } - m_surface = new QtSurface(this, m_id); - setContentView(m_surface); - if (null == getLastNonConfigurationInstance()) - startApp(true); - } - - public QtSurface getQtSurface() - { - return m_surface; - } - - @Override - public Object onRetainNonConfigurationInstance() - { - super.onRetainNonConfigurationInstance(); - m_quitApp = false; - return true; - } - - @Override - protected void onDestroy() - { - QtNative.setMainActivity(null); - super.onDestroy(); - if (m_quitApp) { - Log.i(QtNative.QtTAG, "onDestroy"); - if (m_debuggerProcess != null) - m_debuggerProcess.destroy(); - System.exit(0);// FIXME remove it or find a better way - } - QtNative.setMainActivity(null); - } - - @Override - protected void onResume() - { - // fire all lostActions - synchronized (QtNative.m_mainActivityMutex) { - Iterator itr = QtNative.getLostActions().iterator(); - while (itr.hasNext()) - runOnUiThread(itr.next()); - if (m_started) { - QtNative.clearLostActions(); - QtNative.updateWindow(); - } - } - super.onResume(); - } - - public void redrawWindow(int left, int top, int right, int bottom) - { - m_surface.drawBitmap(new Rect(left, top, right, bottom)); - } - - public void setFullScreen(boolean enterFullScreen) - { - if (m_fullScreen == enterFullScreen) - return; - if (m_fullScreen = enterFullScreen) - getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); - else - getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); - } - - @Override - protected void onSaveInstanceState(Bundle outState) - { - super.onSaveInstanceState(outState); - outState.putBoolean("FullScreen", m_fullScreen); - outState.putBoolean("Started", m_started); - } - - @Override - protected void onRestoreInstanceState(Bundle savedInstanceState) - { - super.onRestoreInstanceState(savedInstanceState); - setFullScreen(savedInstanceState.getBoolean("FullScreen")); - m_started = savedInstanceState.getBoolean("Started"); - if (m_started) - m_surface.applicationStarted(true); - } - - public void showSoftwareKeyboard() - { - softwareKeyboardIsVisible = true; - InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE); - imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY); - } - - public void resetSoftwareKeyboard() - { - } - - public void hideSoftwareKeyboard() - { - if (softwareKeyboardIsVisible) { - InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE); - imm.toggleSoftInput(0, 0); - } - softwareKeyboardIsVisible = false; - } - - @Override - public boolean dispatchKeyEvent(KeyEvent event) - { - if (m_started && event.getAction() == KeyEvent.ACTION_MULTIPLE && - event.getCharacters() != null && - event.getCharacters().length() == 1 && - event.getKeyCode() == 0) { - Log.i(QtNative.QtTAG, "dispatchKeyEvent at MULTIPLE with one character: " + event.getCharacters()); - QtNative.keyDown(0, event.getCharacters().charAt(0), event.getMetaState()); - QtNative.keyUp(0, event.getCharacters().charAt(0), event.getMetaState()); - } - - return super.dispatchKeyEvent(event); - } - - @Override - public boolean onKeyDown(int keyCode, KeyEvent event) - { - if (!m_started) - return false; - m_metaState = MetaKeyKeyListener.handleKeyDown(m_metaState, keyCode, event); - int c = event.getUnicodeChar(MetaKeyKeyListener.getMetaState(m_metaState)); - int lc = c; - m_metaState = MetaKeyKeyListener.adjustMetaAfterKeypress(m_metaState); - - if ((c & KeyCharacterMap.COMBINING_ACCENT) != 0) { - c = c & KeyCharacterMap.COMBINING_ACCENT_MASK; - int composed = KeyEvent.getDeadChar(m_lastChar, c); - c = composed; - } - m_lastChar = lc; - if (keyCode != KeyEvent.KEYCODE_BACK) - QtNative.keyDown(keyCode, c, event.getMetaState()); - return true; - } - - @Override - public boolean onKeyUp(int keyCode, KeyEvent event) - { - if (!m_started) - return false; - m_metaState = MetaKeyKeyListener.handleKeyUp(m_metaState, keyCode, event); - QtNative.keyUp(keyCode, event.getUnicodeChar(), event.getMetaState()); - return true; - } - - public void onConfigurationChanged(Configuration newConfig) { - super.onConfigurationChanged(newConfig); - } - -/* public boolean onCreateOptionsMenu(Menu menu) - { - QtNative.createOptionsMenu(menu); - try { - return onPrepareOptionsMenu(menu); - } catch (Exception e) { - e.printStackTrace(); - return false; - } - } - - public boolean onPrepareOptionsMenu(Menu menu) - { - QtNative.prepareOptionsMenu(menu); - try { - return (Boolean) onPrepareOptionsMenu(menu); - } catch (Exception e) { - e.printStackTrace(); - return false; - } - } - - public boolean onOptionsItemSelected(MenuItem item) - { - return QtNative.optionsItemSelected(item.getGroupId(), item.getItemId()); - }*/ -} diff --git a/tests/auto/android/src/org/qtproject/qt5/android/QtInputConnection.java b/tests/auto/android/src/org/qtproject/qt5/android/QtInputConnection.java deleted file mode 100644 index e69a03061b..0000000000 --- a/tests/auto/android/src/org/qtproject/qt5/android/QtInputConnection.java +++ /dev/null @@ -1,209 +0,0 @@ -/* - Copyright (c) 2012, BogDan Vatra - Contact: http://www.qt-project.org/legal - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - 1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -package org.qtproject.qt5.android; - -import android.content.Context; -import android.content.Intent; -import android.text.Editable; -import android.text.InputFilter; -import android.util.Log; -import android.view.KeyEvent; -import android.view.View; -import android.view.inputmethod.BaseInputConnection; -import android.view.inputmethod.CompletionInfo; -import android.view.inputmethod.ExtractedText; -import android.view.inputmethod.ExtractedTextRequest; -import android.view.inputmethod.InputMethodManager; - -class QtExtractedText -{ - public int partialEndOffset; - public int partialStartOffset; - public int selectionEnd; - public int selectionStart; - public int startOffset; - public String text; -} - -class QtNativeInputConnection -{ - static native boolean commitText(String text, int newCursorPosition); - static native boolean commitCompletion(String text, int position); - static native boolean deleteSurroundingText(int leftLength, int rightLength); - static native boolean finishComposingText(); - static native int getCursorCapsMode(int reqModes); - static native QtExtractedText getExtractedText(int hintMaxChars, int hintMaxLines, int flags); - static native String getSelectedText(int flags); - static native String getTextAfterCursor(int length, int flags); - static native String getTextBeforeCursor(int length, int flags); - static native boolean setComposingText(String text, int newCursorPosition); - static native boolean setSelection(int start, int end); - static native boolean selectAll(); - static native boolean cut(); - static native boolean copy(); - static native boolean copyURL(); - static native boolean paste(); -} - -public class QtInputConnection extends BaseInputConnection -{ - private static final int ID_SELECT_ALL = android.R.id.selectAll; - private static final int ID_START_SELECTING_TEXT = android.R.id.startSelectingText; - private static final int ID_STOP_SELECTING_TEXT = android.R.id.stopSelectingText; - private static final int ID_CUT = android.R.id.cut; - private static final int ID_COPY = android.R.id.copy; - private static final int ID_PASTE = android.R.id.paste; - private static final int ID_COPY_URL = android.R.id.copyUrl; - private static final int ID_SWITCH_INPUT_METHOD = android.R.id.switchInputMethod; - private static final int ID_ADD_TO_DICTIONARY = android.R.id.addToDictionary; - View m_view; - - public QtInputConnection(View targetView) - { - super(targetView, true); - m_view = targetView; - } - - @Override - public boolean beginBatchEdit() - { - return true; - } - - @Override - public boolean endBatchEdit() - { - return true; - } - - @Override - public boolean commitCompletion(CompletionInfo text) - { - return QtNativeInputConnection.commitCompletion(text.getText().toString(), text.getPosition()); - } - - @Override - public boolean commitText(CharSequence text, int newCursorPosition) - { - return QtNativeInputConnection.commitText(text.toString(), newCursorPosition); - } - - @Override - public boolean deleteSurroundingText(int leftLength, int rightLength) - { - return QtNativeInputConnection.deleteSurroundingText(leftLength, rightLength); - } - - @Override - public boolean finishComposingText() - { - return QtNativeInputConnection.finishComposingText(); - } - - @Override - public int getCursorCapsMode(int reqModes) - { - return QtNativeInputConnection.getCursorCapsMode(reqModes); - } - - @Override - public ExtractedText getExtractedText(ExtractedTextRequest request, int flags) - { - QtExtractedText qExtractedText = QtNativeInputConnection.getExtractedText(request.hintMaxChars, request.hintMaxLines, flags); - ExtractedText extractedText = new ExtractedText(); - extractedText.partialEndOffset = qExtractedText.partialEndOffset; - extractedText.partialStartOffset = qExtractedText.partialStartOffset; - extractedText.selectionEnd = qExtractedText.selectionEnd; - extractedText.selectionStart = qExtractedText.selectionStart; - extractedText.startOffset = qExtractedText.startOffset; - extractedText.text = qExtractedText.text; - return extractedText; - } - - public CharSequence getSelectedText(int flags) - { - return QtNativeInputConnection.getSelectedText(flags); - } - - @Override - public CharSequence getTextAfterCursor(int length, int flags) - { - return QtNativeInputConnection.getTextAfterCursor(length, flags); - } - - @Override - public CharSequence getTextBeforeCursor(int length, int flags) - { - return QtNativeInputConnection.getTextBeforeCursor(length, flags); - } - - @Override - public boolean performContextMenuAction(int id) - { - switch (id) { - case ID_SELECT_ALL: - return QtNativeInputConnection.selectAll(); - case ID_COPY: - return QtNativeInputConnection.copy(); - case ID_COPY_URL: - return QtNativeInputConnection.copyURL(); - case ID_CUT: - return QtNativeInputConnection.cut(); - case ID_PASTE: - return QtNativeInputConnection.paste(); - - case ID_SWITCH_INPUT_METHOD: - InputMethodManager imm = (InputMethodManager)m_view.getContext().getSystemService(Context.INPUT_METHOD_SERVICE); - if (imm != null) { - imm.showInputMethodPicker(); - } - return true; - - case ID_ADD_TO_DICTIONARY: -// TODO -// String word = m_editable.subSequence(0, m_editable.length()).toString(); -// if (word != null) { -// Intent i = new Intent("com.android.settings.USER_DICTIONARY_INSERT"); -// i.putExtra("word", word); -// i.setFlags(i.getFlags() | Intent.FLAG_ACTIVITY_NEW_TASK); -// m_view.getContext().startActivity(i); -// } - return true; - } - return super.performContextMenuAction(id); - } - - @Override - public boolean setComposingText(CharSequence text, int newCursorPosition) { - return QtNativeInputConnection.setComposingText(text.toString(), newCursorPosition); - } - - @Override - public boolean setSelection(int start, int end) { - return QtNativeInputConnection.setSelection(start, end); - } -} diff --git a/tests/auto/android/src/org/qtproject/qt5/android/QtNative.java b/tests/auto/android/src/org/qtproject/qt5/android/QtNative.java deleted file mode 100644 index a61543d31a..0000000000 --- a/tests/auto/android/src/org/qtproject/qt5/android/QtNative.java +++ /dev/null @@ -1,471 +0,0 @@ -/* - Copyright (c) 2012, BogDan Vatra - Contact: http://www.qt-project.org/legal - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - 1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -package org.qtproject.qt5.android; - -import java.io.File; -import java.util.ArrayList; - -import android.app.Activity; -import android.app.Application; -import android.content.Intent; -import android.net.Uri; -import android.util.Log; -import android.view.ContextMenu; -import android.view.Menu; -import android.view.MotionEvent; - -public class QtNative extends Application -{ - private static QtActivity m_mainActivity = null; - private static QtSurface m_mainView = null; - public static Object m_mainActivityMutex = new Object(); // mutex used to synchronize runnable operations - - public static final String QtTAG = "Qt JAVA"; // string used for Log.x - private static ArrayList m_lostActions = new ArrayList(); // a list containing all actions which could not be performed (e.g. the main activity is destroyed, etc.) - private static boolean m_started = false; - private static int m_displayMetricsScreenWidthPixels = 0; - private static int m_displayMetricsScreenHeightPixels = 0; - private static int m_displayMetricsDesktopWidthPixels = 0; - private static int m_displayMetricsDesktopHeightPixels = 0; - private static double m_displayMetricsXDpi = .0; - private static double m_displayMetricsYDpi = .0; - private static int m_oldx, m_oldy; - private static final int m_moveThreshold = 0; - - public static ClassLoader classLoader() - { - return m_mainActivity.getClassLoader(); - } - - public static Activity activity() - { - return m_mainActivity; - } - - public static QtSurface mainView() - { - return m_mainView; - } - - public static void openURL(String url) - { - Uri uri = Uri.parse(url); - Intent intent = new Intent(Intent.ACTION_VIEW, uri); - activity().startActivity(intent); - } - - // this method loads full path libs - public static void loadQtLibraries(String[] libraries) - { - if (libraries == null) - return; - - for (int i = 0; i < libraries.length; i++) { - try { - File f = new File(libraries[i]); - if (f.exists()) - System.load(libraries[i]); - } catch (SecurityException e) { - Log.i(QtTAG, "Can't load '" + libraries[i] + "'", e); - } catch (Exception e) { - Log.i(QtTAG, "Can't load '" + libraries[i] + "'", e); - } - } - } - - // this method loads bundled libs by name. - public static void loadBundledLibraries(String[] libraries) - { - for (int i = 0; i < libraries.length; i++) { - try { - System.loadLibrary(libraries[i]); - } catch (UnsatisfiedLinkError e) { - Log.i(QtTAG, "Can't load '" + libraries[i] + "'", e); - } catch (SecurityException e) { - Log.i(QtTAG, "Can't load '" + libraries[i] + "'", e); - } catch (Exception e) { - Log.i(QtTAG, "Can't load '" + libraries[i] + "'", e); - } - } - } - - public static void setMainActivity(QtActivity qtMainActivity) - { - synchronized (m_mainActivityMutex) { - m_mainActivity = qtMainActivity; - } - } - public static void setMainView(QtSurface qtSurface) - { - synchronized (m_mainActivityMutex) { - m_mainView = qtSurface; - } - } - - static public ArrayList getLostActions() - { - return m_lostActions; - } - - static public void clearLostActions() - { - m_lostActions.clear(); - } - - private static boolean runAction(Runnable action) - { - synchronized (m_mainActivityMutex) { - if (m_mainActivity == null) - m_lostActions.add(action); - else - m_mainActivity.runOnUiThread(action); - return m_mainActivity != null; - } - } - - public static boolean startApplication(String params, String environment, String mainLibrary, String nativeLibraryDir) throws Exception - { - File f = new File(nativeLibraryDir+"lib"+mainLibrary+".so"); - if (!f.exists()) - throw new Exception("Can't find main library '" + mainLibrary + "'"); - - if (params == null) - params = "-platform\tandroid"; - - boolean res = false; - synchronized (m_mainActivityMutex) { - res = startQtAndroidPlugin(); - setDisplayMetrics(m_displayMetricsScreenWidthPixels, - m_displayMetricsScreenHeightPixels, - m_displayMetricsDesktopWidthPixels, - m_displayMetricsDesktopHeightPixels, - m_displayMetricsXDpi, - m_displayMetricsYDpi, - 1.0); - startQtApplication(f.getAbsolutePath()+"\t"+params, environment); - m_started = true; - } - return res; - } - - public static void setApplicationDisplayMetrics(int screenWidthPixels, - int screenHeightPixels, int desktopWidthPixels, - int desktopHeightPixels, double XDpi, double YDpi) - { - /* Fix buggy dpi report */ - if (XDpi < android.util.DisplayMetrics.DENSITY_LOW) - XDpi = android.util.DisplayMetrics.DENSITY_LOW; - if (YDpi < android.util.DisplayMetrics.DENSITY_LOW) - YDpi = android.util.DisplayMetrics.DENSITY_LOW; - - synchronized (m_mainActivityMutex) { - if (m_started) { - setDisplayMetrics(screenWidthPixels, screenHeightPixels, desktopWidthPixels, desktopHeightPixels, XDpi, YDpi, 1.0); - } else { - m_displayMetricsScreenWidthPixels = screenWidthPixels; - m_displayMetricsScreenHeightPixels = screenHeightPixels; - m_displayMetricsDesktopWidthPixels = desktopWidthPixels; - m_displayMetricsDesktopHeightPixels = desktopHeightPixels; - m_displayMetricsXDpi = XDpi; - m_displayMetricsYDpi = YDpi; - } - } - } - - public static void pauseApplication() - { - synchronized (m_mainActivityMutex) { - if (m_started) - pauseQtApp(); - } - } - - public static void resumeApplication() - { - synchronized (m_mainActivityMutex) { - if (m_started) { - resumeQtApp(); - updateWindow(); - } - } - } - // application methods - public static native void startQtApplication(String params, String env); - public static native void pauseQtApp(); - public static native void resumeQtApp(); - public static native boolean startQtAndroidPlugin(); - public static native void quitQtAndroidPlugin(); - public static native void terminateQt(); - // application methods - - private static void quitApp() - { - m_mainActivity.finish(); - } - - private static void redrawSurface(final int left, final int top, final int right, final int bottom ) - { - runAction(new Runnable() { - @Override - public void run() { - m_mainActivity.redrawWindow(left, top, right, bottom); - } - }); - } - - @Override - public void onTerminate() - { - if (m_started) - terminateQt(); - super.onTerminate(); - } - - - static public void sendTouchEvent(MotionEvent event, int id) - { - switch (event.getAction()) { - case MotionEvent.ACTION_UP: - mouseUp(id,(int) event.getX(), (int) event.getY()); - break; - - case MotionEvent.ACTION_DOWN: - mouseDown(id,(int) event.getX(), (int) event.getY()); - m_oldx = (int) event.getX(); - m_oldy = (int) event.getY(); - break; - - case MotionEvent.ACTION_MOVE: - int dx = (int) (event.getX() - m_oldx); - int dy = (int) (event.getY() - m_oldy); - if (Math.abs(dx) > m_moveThreshold || Math.abs(dy) > m_moveThreshold) { - mouseMove(id,(int) event.getX(), (int) event.getY()); - m_oldx = (int) event.getX(); - m_oldy = (int) event.getY(); - } - break; - } - } - - static public void sendTrackballEvent(MotionEvent event, int id) - { - switch (event.getAction()) { - case MotionEvent.ACTION_UP: - mouseUp(id, (int) event.getX(), (int) event.getY()); - break; - - case MotionEvent.ACTION_DOWN: - mouseDown(id, (int) event.getX(), (int) event.getY()); - m_oldx = (int) event.getX(); - m_oldy = (int) event.getY(); - break; - - case MotionEvent.ACTION_MOVE: - int dx = (int) (event.getX() - m_oldx); - int dy = (int) (event.getY() - m_oldy); - if (Math.abs(dx) > 5 || Math.abs(dy) > 5) { - mouseMove(id, (int) event.getX(), (int) event.getY()); - m_oldx = (int) event.getX(); - m_oldy = (int) event.getY(); - } - break; - } - } - - private static void updateSelection(final int selStart, final int selEnd, final int candidatesStart, final int candidatesEnd) - { - } - - private static void showSoftwareKeyboard(final int x, final int y - , final int width, final int height - , final int inputHints ) - { - runAction(new Runnable() { - @Override - public void run() { - m_mainActivity.showSoftwareKeyboard(); - } - }); - } - - private static void resetSoftwareKeyboard() - { - runAction(new Runnable() { - @Override - public void run() { - m_mainActivity.resetSoftwareKeyboard(); - } - }); - } - - private static void hideSoftwareKeyboard() - { - runAction(new Runnable() { - @Override - public void run() { - m_mainActivity.hideSoftwareKeyboard(); - } - }); - } - - private static boolean isSoftwareKeyboardVisible() - { - return false; - } - - private static void setFullScreen(final boolean fullScreen) - { - runAction(new Runnable() { - @Override - public void run() { - m_mainActivity.setFullScreen(fullScreen); - updateWindow(); - } - }); - } - - private static void registerClipboardManager() - { - } - - private static void setClipboardText(String text) - { - } - - private static boolean hasClipboardText() - { - return false; - } - - private static String getClipboardText() - { - return "Qt"; - } - - private static void openContextMenu() - { - } - - private static void closeContextMenu() - { - } - - private static void resetOptionsMenu() - { - } - - // screen methods - public static native void setDisplayMetrics(int screenWidthPixels, - int screenHeightPixels, - int desktopWidthPixels, - int desktopHeightPixels, - double XDpi, - double YDpi, - double scaledDensity); - public static native void handleOrientationChanged(int newOrientation); - // screen methods - - private static void showOptionsMenu() - { - runAction(new Runnable() { - @Override - public void run() { - if (m_mainActivity != null) - m_mainActivity.openOptionsMenu(); - } - }); - } - - private static void hideOptionsMenu() - { - runAction(new Runnable() { - @Override - public void run() { - if (m_mainActivity != null) - m_mainActivity.closeOptionsMenu(); - } - }); - } - - private static void showContextMenu() - { - runAction(new Runnable() { - @Override - public void run() { - if (m_mainActivity != null) - m_mainActivity.openContextMenu(m_mainView); - } - }); - } - - private static void hideContextMenu() - { - runAction(new Runnable() { - @Override - public void run() { - if (m_mainActivity != null) - m_mainActivity.closeContextMenu(); - } - }); - } - - // pointer methods - public static native void mouseDown(int winId, int x, int y); - public static native void mouseUp(int winId, int x, int y); - public static native void mouseMove(int winId, int x, int y); - public static native void touchBegin(int winId); - public static native void touchAdd(int winId, int pointerId, int action, boolean primary, int x, int y, float size, float pressure); - public static native void touchEnd(int winId, int action); - public static native void longPress(int winId, int x, int y); - // pointer methods - - // keyboard methods - public static native void keyDown(int key, int unicode, int modifier); - public static native void keyUp(int key, int unicode, int modifier); - // keyboard methods - - // surface methods - public static native void destroySurface(); - public static native void setSurface(Object surface); - public static native void lockSurface(); - public static native void unlockSurface(); - // surface methods - - // window methods - public static native void updateWindow(); - // window methods - - // menu methods - public static native boolean onPrepareOptionsMenu(Menu menu); - public static native boolean onOptionsItemSelected(int itemId, boolean checked); - public static native void onOptionsMenuClosed(Menu menu); - - public static native void onCreateContextMenu(ContextMenu menu); - public static native boolean onContextItemSelected(int itemId, boolean checked); - public static native void onContextMenuClosed(Menu menu); - // menu methods -} diff --git a/tests/auto/android/src/org/qtproject/qt5/android/QtSurface.java b/tests/auto/android/src/org/qtproject/qt5/android/QtSurface.java deleted file mode 100644 index 7e7db031ec..0000000000 --- a/tests/auto/android/src/org/qtproject/qt5/android/QtSurface.java +++ /dev/null @@ -1,163 +0,0 @@ -/* - Copyright (c) 2012, BogDan Vatra - Contact: http://www.qt-project.org/legal - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - 1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -package org.qtproject.qt5.android; - -import android.app.Activity; -import android.content.Context; -import android.graphics.Bitmap; -import android.graphics.Canvas; -import android.graphics.PixelFormat; -import android.graphics.Rect; -import android.util.DisplayMetrics; -import android.util.Log; -import android.view.MotionEvent; -import android.view.SurfaceHolder; -import android.view.SurfaceView; - -public class QtSurface extends SurfaceView implements SurfaceHolder.Callback -{ - private Bitmap m_bitmap=null; - private boolean m_started = false; - private boolean m_usesGL = false; - public QtSurface(Context context, int id) - { - super(context); - setFocusable(true); - getHolder().addCallback(this); - getHolder().setType(SurfaceHolder.SURFACE_TYPE_GPU); - setId(id); - } - - public void applicationStarted(boolean usesGL) - { - m_started = true; - m_usesGL = usesGL; - if (getWidth() < 1 || getHeight() < 1) - return; - if (m_usesGL) { - QtNative.setSurface(getHolder().getSurface()); - } else { - QtNative.lockSurface(); - QtNative.setSurface(null); - m_bitmap=Bitmap.createBitmap(getWidth(), getHeight(), Bitmap.Config.RGB_565); - QtNative.setSurface(m_bitmap); - QtNative.unlockSurface(); - } - } - - @Override - public void surfaceCreated(SurfaceHolder holder) - { - DisplayMetrics metrics = new DisplayMetrics(); - ((Activity) getContext()).getWindowManager().getDefaultDisplay().getMetrics(metrics); - QtNative.setApplicationDisplayMetrics(metrics.widthPixels, - metrics.heightPixels, getWidth(), getHeight(), metrics.xdpi, metrics.ydpi); - - if (m_usesGL) - holder.setFormat(PixelFormat.RGBA_8888); - else - holder.setFormat(PixelFormat.RGB_565); - } - - @Override - public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) - { - Log.i(QtNative.QtTAG,"surfaceChanged: "+width+","+height); - if (width < 1 || height < 1) - return; - - DisplayMetrics metrics = new DisplayMetrics(); - ((Activity) getContext()).getWindowManager().getDefaultDisplay().getMetrics(metrics); - QtNative.setApplicationDisplayMetrics(metrics.widthPixels, - metrics.heightPixels, width, height, metrics.xdpi, metrics.ydpi); - - if (!m_started) - return; - - if (m_usesGL) { - QtNative.setSurface(holder.getSurface()); - } else { - QtNative.lockSurface(); - QtNative.setSurface(null); - m_bitmap=Bitmap.createBitmap(width, height, Bitmap.Config.RGB_565); - QtNative.setSurface(m_bitmap); - QtNative.unlockSurface(); - QtNative.updateWindow(); - } - } - - @Override - public void surfaceDestroyed(SurfaceHolder holder) - { - Log.i(QtNative.QtTAG,"surfaceDestroyed "); - if (m_usesGL) { - QtNative.destroySurface(); - } else { - if (!m_started) - return; - - QtNative.lockSurface(); - QtNative.setSurface(null); - QtNative.unlockSurface(); - } - } - - public void drawBitmap(Rect rect) - { - if (!m_started) - return; - QtNative.lockSurface(); - if (null != m_bitmap) { - try { - Canvas cv=getHolder().lockCanvas(rect); - cv.drawBitmap(m_bitmap, rect, rect, null); - getHolder().unlockCanvasAndPost(cv); - } catch (Exception e) { - Log.e(QtNative.QtTAG, "Can't create main activity", e); - } - } - QtNative.unlockSurface(); - } - - @Override - public boolean onTouchEvent(MotionEvent event) - { - if (!m_started) - return false; - QtNative.sendTouchEvent(event, getId()); - return true; - } - - @Override - public boolean onTrackballEvent(MotionEvent event) - { - if (!m_started) - return false; - QtNative.sendTrackballEvent(event, getId()); - return true; - } -} -- cgit v1.2.3 From 81d116595c64d62dec701214579d094c5e0d51e5 Mon Sep 17 00:00:00 2001 From: Laszlo Papp Date: Sat, 13 Dec 2014 13:09:11 +0000 Subject: Mention the c++14 CONFIG option in the qmake variable reference Change-Id: Iaad18c39925c07b9bf068c02f2cda5d7f06fd38f Reviewed-by: Alejandro Exojo Piqueras Reviewed-by: Olivier Goffart --- qmake/doc/src/qmake-manual.qdoc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/qmake/doc/src/qmake-manual.qdoc b/qmake/doc/src/qmake-manual.qdoc index 7bfd7c66ab..202df7e03c 100644 --- a/qmake/doc/src/qmake-manual.qdoc +++ b/qmake/doc/src/qmake-manual.qdoc @@ -917,6 +917,9 @@ \row \li c++11 \li C++11 support is enabled. This option has no effect if the compiler does not support C++11. By default, support is disabled. + \row \li c++14 \li C++14 support is enabled. This option has no effect if + the compiler does not support C++14. + By default, support is disabled. \endtable When you use the \c debug_and_release option (which is the default under -- cgit v1.2.3 From 2073057bde383ae62540c11d47498cc774181d38 Mon Sep 17 00:00:00 2001 From: BogDan Vatra Date: Fri, 19 Dec 2014 14:42:12 +0200 Subject: Android: Fix json test. Add test data to resources. Change-Id: Ib8a5688e7caab8434b8f0676f53a2a79ec94b264 Reviewed-by: Eskil Abrahamsen Blomfeldt --- tests/auto/corelib/json/json.pro | 5 +++-- tests/auto/corelib/json/json.qrc | 9 +++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 tests/auto/corelib/json/json.qrc diff --git a/tests/auto/corelib/json/json.pro b/tests/auto/corelib/json/json.pro index 25d740f5b9..237e20685a 100644 --- a/tests/auto/corelib/json/json.pro +++ b/tests/auto/corelib/json/json.pro @@ -1,10 +1,11 @@ -TARGET = tst_qtjson +TARGET = tst_json QT = core testlib CONFIG -= app_bundle CONFIG += testcase CONFIG += parallel_test -TESTDATA += test.json test.bjson test3.json test2.json +!android:TESTDATA += test.json test.bjson test3.json test2.json + else:RESOURCES += json.qrc SOURCES += tst_qtjson.cpp DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/corelib/json/json.qrc b/tests/auto/corelib/json/json.qrc new file mode 100644 index 0000000000..eb122a1779 --- /dev/null +++ b/tests/auto/corelib/json/json.qrc @@ -0,0 +1,9 @@ + + + bom.json + test2.json + test3.json + test.json + test.bjson + + -- cgit v1.2.3 From daa5679c8ef9ff80fb10b6bfe8570d3755e6cd29 Mon Sep 17 00:00:00 2001 From: BogDan Vatra Date: Fri, 19 Dec 2014 16:12:37 +0200 Subject: Android: Fix qicon test. We must add all test data to resources. Change-Id: I7f9e7650156b174b7c16270d86b78e9408dff254 Reviewed-by: Eskil Abrahamsen Blomfeldt --- tests/auto/gui/image/qicon/tst_qicon.qrc | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/auto/gui/image/qicon/tst_qicon.qrc b/tests/auto/gui/image/qicon/tst_qicon.qrc index 469a0a21b4..dc11a87ddd 100644 --- a/tests/auto/gui/image/qicon/tst_qicon.qrc +++ b/tests/auto/gui/image/qicon/tst_qicon.qrc @@ -1,5 +1,6 @@ +tst_qicon.cpp image.png rect.png ./icons/testtheme/16x16/actions/appointment-new.png -- cgit v1.2.3 From 4cea71eebec6d178ca53a3124ee923c82d475ace Mon Sep 17 00:00:00 2001 From: BogDan Vatra Date: Fri, 19 Dec 2014 15:47:21 +0200 Subject: Android: Fix qmovie test. We must add all test data to resources. Change-Id: Ic12f8fce9afb965aff32e7141516c8d223e64491 Reviewed-by: Eskil Abrahamsen Blomfeldt --- tests/auto/gui/image/qmovie/resources.qrc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/auto/gui/image/qmovie/resources.qrc b/tests/auto/gui/image/qmovie/resources.qrc index ce459a0e7e..077f6ff004 100644 --- a/tests/auto/gui/image/qmovie/resources.qrc +++ b/tests/auto/gui/image/qmovie/resources.qrc @@ -1,5 +1,7 @@ + animations/comicsecard.gif animations/corrupt.gif + animations/trolltech.gif -- cgit v1.2.3 From 49517ac1dc450b3fe85a2522a191fe5bb2e902d0 Mon Sep 17 00:00:00 2001 From: BogDan Vatra Date: Fri, 19 Dec 2014 16:11:01 +0200 Subject: Android: Fix qicoimageformat test. Add all test data to resources. Change-Id: Id42a4c033b75409f65cb4d56ebf1161336b93832 Reviewed-by: Eskil Abrahamsen Blomfeldt --- .../auto/gui/image/qicoimageformat/qicoimageformat.pro | 1 + .../auto/gui/image/qicoimageformat/qicoimageformat.qrc | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 tests/auto/gui/image/qicoimageformat/qicoimageformat.qrc diff --git a/tests/auto/gui/image/qicoimageformat/qicoimageformat.pro b/tests/auto/gui/image/qicoimageformat/qicoimageformat.pro index 83af3960a6..a58336e511 100644 --- a/tests/auto/gui/image/qicoimageformat/qicoimageformat.pro +++ b/tests/auto/gui/image/qicoimageformat/qicoimageformat.pro @@ -14,3 +14,4 @@ wince*: { DEPLOYMENT += addPlugins } TESTDATA += icons/* +android:RESOURCES+=qicoimageformat.qrc diff --git a/tests/auto/gui/image/qicoimageformat/qicoimageformat.qrc b/tests/auto/gui/image/qicoimageformat/qicoimageformat.qrc new file mode 100644 index 0000000000..1e0ee8aa8c --- /dev/null +++ b/tests/auto/gui/image/qicoimageformat/qicoimageformat.qrc @@ -0,0 +1,18 @@ + + + icons/invalid/35floppy.ico + icons/valid/35FLOPPY.ICO + icons/valid/abcardWindow.ico + icons/valid/AddPerfMon.ico + icons/valid/App.ico + icons/valid/Obj_N2_Internal_Mem.ico + icons/valid/Qt.ico + icons/valid/semitransparent.ico + icons/valid/Status_Play.ico + icons/valid/TIMER01.ICO + icons/valid/trolltechlogo_tiny.ico + icons/valid/WORLD.ico + icons/valid/WORLDH.ico + icons/valid/yellow.cur + + -- cgit v1.2.3 From 999321fecb9223bcadc702674ca83d8f84bd3886 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Thu, 18 Dec 2014 10:20:03 +0100 Subject: Android: Stabilize QPauseAnimation test This will arbitrarily fail at certain points. Adjusting the timeouts helps, but it's very unpredictable, so it's better to do what we do on Windows and just expect-fail the results that we get. Change-Id: Ie6033c73539c2dd69115b06096919e173f097367 Reviewed-by: Friedemann Kleint Reviewed-by: BogDan Vatra --- .../qpauseanimation/tst_qpauseanimation.cpp | 72 ++++++++++++---------- 1 file changed, 38 insertions(+), 34 deletions(-) diff --git a/tests/auto/corelib/animation/qpauseanimation/tst_qpauseanimation.cpp b/tests/auto/corelib/animation/qpauseanimation/tst_qpauseanimation.cpp index a966f557f5..1b7f28bbfa 100644 --- a/tests/auto/corelib/animation/qpauseanimation/tst_qpauseanimation.cpp +++ b/tests/auto/corelib/animation/qpauseanimation/tst_qpauseanimation.cpp @@ -39,8 +39,12 @@ #include -#ifdef Q_OS_WIN -static const char winTimerError[] = "On windows, consistent timing is not working properly due to bad timer resolution"; +#if defined(Q_OS_WIN) || defined(Q_OS_ANDROID) +# define BAD_TIMER_RESOLUTION +#endif + +#ifdef BAD_TIMER_RESOLUTION +static const char timerError[] = "On this platform, consistent timing is not working properly due to bad timer resolution"; #endif class TestablePauseAnimation : public QPauseAnimation @@ -140,17 +144,17 @@ void tst_QPauseAnimation::noTimerUpdates() animation.start(); QTest::qWait(animation.totalDuration() + 100); -#ifdef Q_OS_WIN +#ifdef BAD_TIMER_RESOLUTION if (animation.state() != QAbstractAnimation::Stopped) - QEXPECT_FAIL("", winTimerError, Abort); + QEXPECT_FAIL("", timerError, Abort); #endif QVERIFY(animation.state() == QAbstractAnimation::Stopped); const int expectedLoopCount = 1 + loopCount; -#ifdef Q_OS_WIN +#ifdef BAD_TIMER_RESOLUTION if (animation.m_updateCurrentTimeCount != expectedLoopCount) - QEXPECT_FAIL("", winTimerError, Abort); + QEXPECT_FAIL("", timerError, Abort); #endif QCOMPARE(animation.m_updateCurrentTimeCount, expectedLoopCount); } @@ -169,41 +173,41 @@ void tst_QPauseAnimation::multiplePauseAnimations() animation2.start(); QTest::qWait(animation.totalDuration() + 100); -#ifdef Q_OS_WIN +#ifdef BAD_TIMER_RESOLUTION if (animation.state() != QAbstractAnimation::Stopped) - QEXPECT_FAIL("", winTimerError, Abort); + QEXPECT_FAIL("", timerError, Abort); #endif QVERIFY(animation.state() == QAbstractAnimation::Stopped); -#ifdef Q_OS_WIN +#ifdef BAD_TIMER_RESOLUTION if (animation2.state() != QAbstractAnimation::Running) - QEXPECT_FAIL("", winTimerError, Abort); + QEXPECT_FAIL("", timerError, Abort); #endif QVERIFY(animation2.state() == QAbstractAnimation::Running); -#ifdef Q_OS_WIN +#ifdef BAD_TIMER_RESOLUTION if (animation.m_updateCurrentTimeCount != 2) - QEXPECT_FAIL("", winTimerError, Abort); + QEXPECT_FAIL("", timerError, Abort); #endif QCOMPARE(animation.m_updateCurrentTimeCount, 2); -#ifdef Q_OS_WIN +#ifdef BAD_TIMER_RESOLUTION if (animation2.m_updateCurrentTimeCount != 2) - QEXPECT_FAIL("", winTimerError, Abort); + QEXPECT_FAIL("", timerError, Abort); #endif QCOMPARE(animation2.m_updateCurrentTimeCount, 2); QTest::qWait(550); -#ifdef Q_OS_WIN +#ifdef BAD_TIMER_RESOLUTION if (animation2.state() != QAbstractAnimation::Stopped) - QEXPECT_FAIL("", winTimerError, Abort); + QEXPECT_FAIL("", timerError, Abort); #endif QVERIFY(animation2.state() == QAbstractAnimation::Stopped); -#ifdef Q_OS_WIN +#ifdef BAD_TIMER_RESOLUTION if (animation2.m_updateCurrentTimeCount != 3) - QEXPECT_FAIL("", winTimerError, Abort); + QEXPECT_FAIL("", timerError, Abort); #endif QCOMPARE(animation2.m_updateCurrentTimeCount, 3); } @@ -232,9 +236,9 @@ void tst_QPauseAnimation::pauseAndPropertyAnimations() QTest::qWait(animation.totalDuration() + 100); -#ifdef Q_OS_WIN +#ifdef BAD_TIMER_RESOLUTION if (animation.state() != QAbstractAnimation::Stopped) - QEXPECT_FAIL("", winTimerError, Abort); + QEXPECT_FAIL("", timerError, Abort); #endif QVERIFY(animation.state() == QAbstractAnimation::Stopped); QVERIFY(pause.state() == QAbstractAnimation::Stopped); @@ -253,9 +257,9 @@ void tst_QPauseAnimation::pauseResume() animation.start(); QTRY_COMPARE(animation.state(), QAbstractAnimation::Stopped); -#ifdef Q_OS_WIN +#ifdef BAD_TIMER_RESOLUTION if (animation.m_updateCurrentTimeCount < 3) - QEXPECT_FAIL("", winTimerError, Abort); + QEXPECT_FAIL("", timerError, Abort); #endif QVERIFY2(animation.m_updateCurrentTimeCount >= 3, qPrintable( QString::fromLatin1("animation.m_updateCurrentTimeCount = %1").arg(animation.m_updateCurrentTimeCount))); @@ -408,39 +412,39 @@ void tst_QPauseAnimation::multipleSequentialGroups() // measure... QTest::qWait(group.totalDuration() + 500); -#ifdef Q_OS_WIN +#ifdef BAD_TIMER_RESOLUTION if (group.state() != QAbstractAnimation::Stopped) - QEXPECT_FAIL("", winTimerError, Abort); + QEXPECT_FAIL("", timerError, Abort); #endif QVERIFY(group.state() == QAbstractAnimation::Stopped); -#ifdef Q_OS_WIN +#ifdef BAD_TIMER_RESOLUTION if (subgroup1.state() != QAbstractAnimation::Stopped) - QEXPECT_FAIL("", winTimerError, Abort); + QEXPECT_FAIL("", timerError, Abort); #endif QVERIFY(subgroup1.state() == QAbstractAnimation::Stopped); -#ifdef Q_OS_WIN +#ifdef BAD_TIMER_RESOLUTION if (subgroup2.state() != QAbstractAnimation::Stopped) - QEXPECT_FAIL("", winTimerError, Abort); + QEXPECT_FAIL("", timerError, Abort); #endif QVERIFY(subgroup2.state() == QAbstractAnimation::Stopped); -#ifdef Q_OS_WIN +#ifdef BAD_TIMER_RESOLUTION if (subgroup3.state() != QAbstractAnimation::Stopped) - QEXPECT_FAIL("", winTimerError, Abort); + QEXPECT_FAIL("", timerError, Abort); #endif QVERIFY(subgroup3.state() == QAbstractAnimation::Stopped); -#ifdef Q_OS_WIN +#ifdef BAD_TIMER_RESOLUTION if (subgroup4.state() != QAbstractAnimation::Stopped) - QEXPECT_FAIL("", winTimerError, Abort); + QEXPECT_FAIL("", timerError, Abort); #endif QVERIFY(subgroup4.state() == QAbstractAnimation::Stopped); -#ifdef Q_OS_WIN +#ifdef BAD_TIMER_RESOLUTION if (pause5.m_updateCurrentTimeCount != 4) - QEXPECT_FAIL("", winTimerError, Abort); + QEXPECT_FAIL("", timerError, Abort); #endif QCOMPARE(pause5.m_updateCurrentTimeCount, 4); } -- cgit v1.2.3 From 0b16f425652c0e804ddac9cbca2d0063cfdad55e Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Thu, 18 Dec 2014 11:58:27 +0100 Subject: Android: Fix QDir tests There's no way to install files automatically into the file system on Android, so to test QDir on the file system, we have to bundle the files in qrc and then copy them into the file system on startup. This adds some complexity, but at least it will detect regressions. We also need to make sure the current directory is the same as the data path, since the test assumes this, and /usr/ does not exist on Android, so we have to use a different path to find the root path. Change-Id: I18d79b5ed99a0afff573beb30c61745c403f8991 Reviewed-by: BogDan Vatra --- tests/auto/corelib/io/qdir/android_testdata.qrc | 44 +++++++++++++++++++++++++ tests/auto/corelib/io/qdir/qdir.pro | 4 +++ tests/auto/corelib/io/qdir/tst_qdir.cpp | 29 ++++++++++++++++ 3 files changed, 77 insertions(+) create mode 100644 tests/auto/corelib/io/qdir/android_testdata.qrc diff --git a/tests/auto/corelib/io/qdir/android_testdata.qrc b/tests/auto/corelib/io/qdir/android_testdata.qrc new file mode 100644 index 0000000000..52cf4da330 --- /dev/null +++ b/tests/auto/corelib/io/qdir/android_testdata.qrc @@ -0,0 +1,44 @@ + + + tst_qdir.cpp + entrylist/file + entrylist/directory/dummy + searchdir/subdir1/picker.png + searchdir/subdir2/picker.png + testData/empty + testdir/dir/tmp/empty + testdir/dir/qdir.pro + testdir/dir/qrc_qdir.cpp + testdir/dir/tst_qdir.cpp + testdir/spaces/foo. bar + testdir/spaces/foo.bar + types/a + types/a.a + types/a.b + types/a.c + types/b + types/b.a + types/b.b + types/b.c + types/c + types/c.a + types/c.b + types/c.c + types/d/dummy + types/d.a/dummy + types/d.c/dummy + types/d.b/dummy + types/e/dummy + types/e.a/dummy + types/e.c/dummy + types/f/dummy + types/f.a/dummy + types/f.b/dummy + types/f.c/dummy + types/e.b/dummy + resources/entryList/file1.data + resources/entryList/file2.data + resources/entryList/file3.data + resources/entryList/file4.nothing + + diff --git a/tests/auto/corelib/io/qdir/qdir.pro b/tests/auto/corelib/io/qdir/qdir.pro index e2b25866df..d3e954bd32 100644 --- a/tests/auto/corelib/io/qdir/qdir.pro +++ b/tests/auto/corelib/io/qdir/qdir.pro @@ -6,3 +6,7 @@ RESOURCES += qdir.qrc TESTDATA += testdir testData searchdir resources entrylist types tst_qdir.cpp DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 + +android:!android-no-sdk { + RESOURCES += android_testdata.qrc +} diff --git a/tests/auto/corelib/io/qdir/tst_qdir.cpp b/tests/auto/corelib/io/qdir/tst_qdir.cpp index 49e3264617..484130f163 100644 --- a/tests/auto/corelib/io/qdir/tst_qdir.cpp +++ b/tests/auto/corelib/io/qdir/tst_qdir.cpp @@ -214,8 +214,35 @@ private: Q_DECLARE_METATYPE(tst_QDir::UncHandling) tst_QDir::tst_QDir() +#if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK) + : m_dataPath(QStandardPaths::writableLocation(QStandardPaths::CacheLocation)) +#else : m_dataPath(QFileInfo(QFINDTESTDATA("testData")).absolutePath()) +#endif { +#if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK) + QString resourceSourcePath = QStringLiteral(":/android_testdata/"); + QDirIterator it(resourceSourcePath, QDirIterator::Subdirectories); + while (it.hasNext()) { + it.next(); + + QFileInfo fileInfo = it.fileInfo(); + + if (!fileInfo.isDir()) { + QString destination = m_dataPath + QLatin1Char('/') + fileInfo.filePath().mid(resourceSourcePath.length()); + QFileInfo destinationFileInfo(destination); + if (!destinationFileInfo.exists()) { + QDir().mkpath(destinationFileInfo.path()); + if (!QFile::copy(fileInfo.filePath(), destination)) + qWarning("Failed to copy %s", qPrintable(fileInfo.filePath())); + } + } + + } + + if (!QDir::setCurrent(m_dataPath)) + qWarning("Couldn't set current path to %s", qPrintable(m_dataPath)); +#endif } void tst_QDir::init() @@ -2028,6 +2055,8 @@ void tst_QDir::equalityOperator_data() //need a path in the root directory that is unlikely to be a symbolic link. #if defined (Q_OS_WIN) QString pathinroot("c:/windows/.."); +#elif defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK) + QString pathinroot("/system/.."); #else QString pathinroot("/usr/.."); #endif -- cgit v1.2.3 From 0dd7bd0c7ab8383c5aa739e69a3e2bb317c4b19f Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Thu, 18 Dec 2014 12:32:13 +0100 Subject: Android: Fix QDirIterator tests This test requires that the resources are also available in the file system. Since it's not possible to deploy directly to the file system using Android, we extract the files on startup instead. Change-Id: I1d1fe7d62c4c618a89713e3a7d1903e42bfb10b8 Reviewed-by: BogDan Vatra --- .../corelib/io/qdiriterator/tst_qdiriterator.cpp | 26 ++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/tests/auto/corelib/io/qdiriterator/tst_qdiriterator.cpp b/tests/auto/corelib/io/qdiriterator/tst_qdiriterator.cpp index fa6a1978ca..cdece2f8c7 100644 --- a/tests/auto/corelib/io/qdiriterator/tst_qdiriterator.cpp +++ b/tests/auto/corelib/io/qdiriterator/tst_qdiriterator.cpp @@ -119,8 +119,34 @@ private slots: void tst_QDirIterator::initTestCase() { +#if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK) + QString testdata_dir = QStandardPaths::writableLocation(QStandardPaths::CacheLocation); + QString resourceSourcePath = QStringLiteral(":/"); + QDirIterator it(resourceSourcePath, QDirIterator::Subdirectories); + while (it.hasNext()) { + it.next(); + + QFileInfo fileInfo = it.fileInfo(); + + if (!fileInfo.isDir()) { + QString destination = testdata_dir + QLatin1Char('/') + fileInfo.filePath().mid(resourceSourcePath.length()); + QFileInfo destinationFileInfo(destination); + if (!destinationFileInfo.exists()) { + QDir().mkpath(destinationFileInfo.path()); + if (!QFile::copy(fileInfo.filePath(), destination)) + qWarning("Failed to copy %s", qPrintable(fileInfo.filePath())); + } + } + + } + + testdata_dir += QStringLiteral("/entrylist"); +#else + // chdir into testdata directory, then find testdata by relative paths. QString testdata_dir = QFileInfo(QFINDTESTDATA("entrylist")).absolutePath(); +#endif + QVERIFY2(QDir::setCurrent(testdata_dir), qPrintable("Could not chdir to " + testdata_dir)); QFile::remove("entrylist/entrylist1.lnk"); -- cgit v1.2.3 From 5681ae74e35b861b03a51cc5f9dbcbadef45b24c Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Thu, 18 Dec 2014 13:05:22 +0100 Subject: Android: Fix QFileInfo tests Since there's no way to deploy files directly to the file file system on Android, we put them in a qrc file and extract them on startup. Change-Id: I6a42aa5e0372bfd9fb2f7ccfea964c9c3c2e45d8 Reviewed-by: BogDan Vatra --- .../auto/corelib/io/qfileinfo/android_testdata.qrc | 8 +++++++ tests/auto/corelib/io/qfileinfo/qfileinfo.pro | 4 ++++ tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp | 25 +++++++++++++++++++++- 3 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 tests/auto/corelib/io/qfileinfo/android_testdata.qrc diff --git a/tests/auto/corelib/io/qfileinfo/android_testdata.qrc b/tests/auto/corelib/io/qfileinfo/android_testdata.qrc new file mode 100644 index 0000000000..ce545cc21c --- /dev/null +++ b/tests/auto/corelib/io/qfileinfo/android_testdata.qrc @@ -0,0 +1,8 @@ + + + resources/file1 + resources/file1.ext1 + resources/file1.ext1.ext2 + tst_qfileinfo.cpp + + diff --git a/tests/auto/corelib/io/qfileinfo/qfileinfo.pro b/tests/auto/corelib/io/qfileinfo/qfileinfo.pro index 64d289bc3c..3fd58b4958 100644 --- a/tests/auto/corelib/io/qfileinfo/qfileinfo.pro +++ b/tests/auto/corelib/io/qfileinfo/qfileinfo.pro @@ -8,3 +8,7 @@ TESTDATA += qfileinfo.qrc qfileinfo.pro tst_qfileinfo.cpp resources/file1 resour win32*:!wince*:!winrt:LIBS += -ladvapi32 -lnetapi32 DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 + +android:!android-no-sdk: { + RESOURCES += android_testdata.qrc +} diff --git a/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp b/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp index 22d5da8e68..d187133674 100644 --- a/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp +++ b/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp @@ -272,9 +272,32 @@ private: void tst_QFileInfo::initTestCase() { +#if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK) + QString dataPath = QStandardPaths::writableLocation(QStandardPaths::CacheLocation); + QString resourceSourcePath = QStringLiteral(":/android_testdata"); + QDirIterator it(resourceSourcePath, QDirIterator::Subdirectories); + while (it.hasNext()) { + it.next(); + + QFileInfo fileInfo = it.fileInfo(); + if (!fileInfo.isDir()) { + QString destination = dataPath + QLatin1Char('/') + fileInfo.filePath().mid(resourceSourcePath.length()); + QFileInfo destinationFileInfo(destination); + if (!destinationFileInfo.exists()) { + QDir().mkpath(destinationFileInfo.path()); + if (!QFile::copy(fileInfo.filePath(), destination)) + qWarning("Failed to copy %s", qPrintable(fileInfo.filePath())); + } + } + } + m_sourceFile = dataPath + QStringLiteral("/tst_qfileinfo.cpp"); + m_resourcesDir = dataPath + QStringLiteral("/resources"); +#else m_sourceFile = QFINDTESTDATA("tst_qfileinfo.cpp"); - QVERIFY(!m_sourceFile.isEmpty()); m_resourcesDir = QFINDTESTDATA("resources"); +#endif + + QVERIFY(!m_sourceFile.isEmpty()); QVERIFY(!m_resourcesDir.isEmpty()); QVERIFY(m_dir.isValid()); QVERIFY(QDir::setCurrent(m_dir.path())); -- cgit v1.2.3 From 616ac8e59c3ac5d743b766859a23f6fc8e6c0a11 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Thu, 18 Dec 2014 13:05:57 +0100 Subject: Android: Fix test failure for test QFileInfo::lastRead() This test may not be possible on Android, since the file system can be mounted with noatime or relatime which means read access will not be registered. Change-Id: I40f587e1a1f131ee06f0e3700e908ccaa19c83ce Reviewed-by: BogDan Vatra --- tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp b/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp index d187133674..5b67fd2af5 100644 --- a/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp +++ b/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp @@ -1160,7 +1160,11 @@ void tst_QFileInfo::fileTimes() QEXPECT_FAIL("simple", "WinCE only stores date of access data, not the time", Continue); #elif defined(Q_OS_QNX) QEXPECT_FAIL("", "QNX uses the noatime filesystem option", Continue); +#elif defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK) + if (fileInfo.lastRead() <= beforeRead) + QEXPECT_FAIL("", "Android may use relatime or noatime on mounts", Continue); #endif + QVERIFY(fileInfo.lastRead() > beforeRead); QVERIFY(fileInfo.lastModified() > beforeWrite); QVERIFY(fileInfo.lastModified() < beforeRead); -- cgit v1.2.3 From e511d9b9dddcf4390939a36be12e9c7d6365b0e7 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Thu, 18 Dec 2014 13:58:39 +0100 Subject: Android: Fix QFileSystemWatcher test failures Some of the tests expect QDir::homePath() and QDir::currentPath() to be different, so we just set the current path to something other than QDir::homePath(). Change-Id: Ib048d323f4745369821765230b995a73b8a97145 Reviewed-by: BogDan Vatra --- tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp b/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp index 4f648a62d6..0a952e9452 100644 --- a/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp +++ b/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp @@ -87,6 +87,10 @@ tst_QFileSystemWatcher::tst_QFileSystemWatcher() m_tempDirPattern += QLatin1Char('/'); m_tempDirPattern += QStringLiteral("tst_qfilesystemwatcherXXXXXX"); #endif // QT_NO_FILESYSTEMWATCHER + +#if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK) + QDir::setCurrent(QStandardPaths::writableLocation(QStandardPaths::CacheLocation)); +#endif } #ifndef QT_NO_FILESYSTEMWATCHER -- cgit v1.2.3 From ae55d3ea27f1007c7b46f655a64ff64fab9e83a5 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Thu, 18 Dec 2014 14:16:16 +0100 Subject: Android: Fix QIODevice tests Test requires that tst_qiodevice.cpp is available on file system, but since we're not able to deploy directly to the file system on Android and since we want to actually test file system access, we bundle it in qrc and copy it out during initialization. Change-Id: Ida2b5bf6f1dcd43bc740a2b9380352bab5eb6c62 Reviewed-by: BogDan Vatra --- tests/auto/corelib/io/qiodevice/android_testdata.qrc | 5 +++++ tests/auto/corelib/io/qiodevice/qiodevice.pro | 5 +++++ tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp | 4 ++++ 3 files changed, 14 insertions(+) create mode 100644 tests/auto/corelib/io/qiodevice/android_testdata.qrc diff --git a/tests/auto/corelib/io/qiodevice/android_testdata.qrc b/tests/auto/corelib/io/qiodevice/android_testdata.qrc new file mode 100644 index 0000000000..fa4b3d11da --- /dev/null +++ b/tests/auto/corelib/io/qiodevice/android_testdata.qrc @@ -0,0 +1,5 @@ + + + tst_qiodevice.cpp + + diff --git a/tests/auto/corelib/io/qiodevice/qiodevice.pro b/tests/auto/corelib/io/qiodevice/qiodevice.pro index 9103ff2152..9fd70fb177 100644 --- a/tests/auto/corelib/io/qiodevice/qiodevice.pro +++ b/tests/auto/corelib/io/qiodevice/qiodevice.pro @@ -6,3 +6,8 @@ SOURCES = tst_qiodevice.cpp TESTDATA += tst_qiodevice.cpp MOC_DIR=tmp DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 + +android:!android-no-sdk: { + RESOURCES += \ + android_testdata.qrc +} diff --git a/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp b/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp index dec440a6d5..d94893c767 100644 --- a/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp +++ b/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp @@ -62,6 +62,10 @@ private slots: void tst_QIODevice::initTestCase() { +#if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK) + QVERIFY(QFileInfo(QStringLiteral("./tst_qiodevice.cpp")).exists() + || QFile::copy(QStringLiteral(":/tst_qiodevice.cpp"), QStringLiteral("./tst_qiodevice.cpp"))); +#endif } // Testing get/set functions -- cgit v1.2.3 From 4fec0dca877855488d0eeb8ce5d0d682497ad1e3 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Thu, 18 Dec 2014 14:23:25 +0100 Subject: Android: Disable QLockFile test This test requires building a console application first, deploying this as part of the APK and then being able to execute the bundled file from the main application. Since IPC is a limited use case on Android, we just skip this test instead. Change-Id: Ie68e495ff64b69e7027924291a411b5de0e2da76 Reviewed-by: BogDan Vatra --- tests/auto/corelib/io/qlockfile/tst_qlockfile.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/auto/corelib/io/qlockfile/tst_qlockfile.cpp b/tests/auto/corelib/io/qlockfile/tst_qlockfile.cpp index 1790676028..77bef94550 100644 --- a/tests/auto/corelib/io/qlockfile/tst_qlockfile.cpp +++ b/tests/auto/corelib/io/qlockfile/tst_qlockfile.cpp @@ -66,7 +66,9 @@ public: void tst_QLockFile::initTestCase() { -#ifdef QT_NO_PROCESS +#if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK) + QSKIP("This test requires deploying and running external console applications"); +#elif defined(QT_NO_PROCESS) QSKIP("This test requires QProcess support"); #else // chdir to our testdata path and execute helper apps relative to that. -- cgit v1.2.3 From 4bee095069273ae27606a3f5b79f3aed4a94cee3 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Thu, 18 Dec 2014 14:33:07 +0100 Subject: Android: Fix QLoggingRegistry test The qtlogging.ini file needs to be detectable by QFINDTESTDATA, so we put it in a qrc file on Android. Change-Id: I5fb0217098c56f2b2e99ab8d1642c4a7904b18d1 Reviewed-by: BogDan Vatra --- tests/auto/corelib/io/qloggingregistry/android_testdata.qrc | 5 +++++ tests/auto/corelib/io/qloggingregistry/qloggingregistry.pro | 5 +++++ 2 files changed, 10 insertions(+) create mode 100644 tests/auto/corelib/io/qloggingregistry/android_testdata.qrc diff --git a/tests/auto/corelib/io/qloggingregistry/android_testdata.qrc b/tests/auto/corelib/io/qloggingregistry/android_testdata.qrc new file mode 100644 index 0000000000..7563fb9630 --- /dev/null +++ b/tests/auto/corelib/io/qloggingregistry/android_testdata.qrc @@ -0,0 +1,5 @@ + + + qtlogging.ini + + diff --git a/tests/auto/corelib/io/qloggingregistry/qloggingregistry.pro b/tests/auto/corelib/io/qloggingregistry/qloggingregistry.pro index c6c4caace3..6be5fb1067 100644 --- a/tests/auto/corelib/io/qloggingregistry/qloggingregistry.pro +++ b/tests/auto/corelib/io/qloggingregistry/qloggingregistry.pro @@ -6,3 +6,8 @@ QT = core core-private testlib SOURCES += tst_qloggingregistry.cpp OTHER_FILES += qtlogging.ini + +android:!android-no-sdk: { + RESOURCES += \ + android_testdata.qrc +} -- cgit v1.2.3 From 244da85d3b391d72a3b7880f5c334f6c89a1af77 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Fri, 19 Dec 2014 13:08:35 +0100 Subject: Android: Fix QTemporaryDir/File::nonWritableCurrentDir() tests The /home path doesn't exist on Android, so it doesn't work as a non-writable current dir. Instead we use /data on Android. Change-Id: Ib779f60822da1bef421a16a00c1030245a8c5b90 Reviewed-by: BogDan Vatra --- tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp | 4 ++++ tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp b/tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp index 3e11ba0717..a68a1185b8 100644 --- a/tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp +++ b/tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp @@ -237,7 +237,11 @@ void tst_QTemporaryDir::nonWritableCurrentDir() }; ChdirOnReturn cor(QDir::currentPath()); +#if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK) + QDir::setCurrent("/data"); +#else QDir::setCurrent("/home"); +#endif // QTemporaryDir("tempXXXXXX") is probably a bad idea in any app // where the current dir could anything... QTemporaryDir dir("tempXXXXXX"); diff --git a/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp b/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp index b3fa47e586..a08a0ae777 100644 --- a/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp +++ b/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp @@ -269,7 +269,12 @@ void tst_QTemporaryFile::nonWritableCurrentDir() }; ChdirOnReturn cor(QDir::currentPath()); +#if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK) + QDir::setCurrent("/data"); +#else QDir::setCurrent("/home"); +#endif + // QTemporaryFile("tempXXXXXX") is probably a bad idea in any app // where the current dir could anything... QTemporaryFile file("tempXXXXXX"); -- cgit v1.2.3 From c0853825551ec34f4052e8a86f1c47be7fb5b1d7 Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov Date: Mon, 22 Dec 2014 09:15:06 +0100 Subject: Revert "OS X: rename special menu items instead of duplicating" This reverts commit 8c538d10da618add00aba1acbc8d8dc2f24445b4. This patch, unfortunately, do not combine well with another problematic code producing, as a result, a serious regression. While the proper/better fix in Cocoa menu not found, I'm reverting this patch. Change-Id: I1ff03dbe12805da447cb3cfe3e2f231528bf1a16 Task-number: QTBUG-43471 Reviewed-by: Gabriel de Dietrich --- src/plugins/platforms/cocoa/qcocoamenu.mm | 9 ++------- src/plugins/platforms/cocoa/qcocoamenuitem.mm | 11 ++++------- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/src/plugins/platforms/cocoa/qcocoamenu.mm b/src/plugins/platforms/cocoa/qcocoamenu.mm index d849389907..736e02a3ca 100644 --- a/src/plugins/platforms/cocoa/qcocoamenu.mm +++ b/src/plugins/platforms/cocoa/qcocoamenu.mm @@ -366,14 +366,9 @@ void QCocoaMenu::syncMenuItem(QPlatformMenuItem *menuItem) } bool wasMerged = cocoaItem->isMerged(); - NSMenu *oldMenu = m_nativeMenu; - if (wasMerged) { - QPlatformMenuItem::MenuRole role = cocoaItem->effectiveRole(); - if (role >= QPlatformMenuItem::ApplicationSpecificRole && role < QPlatformMenuItem::CutRole) - oldMenu = [getMenuLoader() applicationMenu]; - } - + NSMenu *oldMenu = wasMerged ? [getMenuLoader() applicationMenu] : m_nativeMenu; NSMenuItem *oldItem = [oldMenu itemWithTag:(NSInteger) cocoaItem]; + if (cocoaItem->sync() != oldItem) { // native item was changed for some reason if (oldItem) { diff --git a/src/plugins/platforms/cocoa/qcocoamenuitem.mm b/src/plugins/platforms/cocoa/qcocoamenuitem.mm index 251fe9485c..470788b6bf 100644 --- a/src/plugins/platforms/cocoa/qcocoamenuitem.mm +++ b/src/plugins/platforms/cocoa/qcocoamenuitem.mm @@ -256,8 +256,8 @@ NSMenuItem *QCocoaMenuItem::sync() if (depth == 3 || !menubar) break; // Menu item too deep in the hierarchy, or not connected to any menubar - MenuRole newDetectedRole = detectMenuRole(m_text); - switch (newDetectedRole) { + m_detectedRole = detectMenuRole(m_text); + switch (m_detectedRole) { case QPlatformMenuItem::AboutRole: if (m_text.indexOf(QRegExp(QString::fromLatin1("qt$"), Qt::CaseInsensitive)) == -1) mergeItem = [loader aboutMenuItem]; @@ -271,15 +271,12 @@ NSMenuItem *QCocoaMenuItem::sync() mergeItem = [loader quitMenuItem]; break; default: - if (newDetectedRole >= CutRole && newDetectedRole < RoleCount && menubar) - mergeItem = menubar->itemForRole(newDetectedRole); + if (m_detectedRole >= CutRole && m_detectedRole < RoleCount && menubar) + mergeItem = menubar->itemForRole(m_detectedRole); if (!m_text.isEmpty()) m_textSynced = true; break; } - - m_detectedRole = newDetectedRole; - break; } -- cgit v1.2.3 From 66a8be268142d4f3272f54093299087289f530b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9rgio=20Martins?= Date: Sat, 20 Dec 2014 23:04:58 +0000 Subject: QColorDialog: Fix a few layouting issues. Fixes combo-boxes being too big and some alignment issues that were not present in Qt4. See screenshot in JIRA task. Tested with QT_SMALL_COLORDIALOG too. Task-number: QTBUG-43501 Change-Id: I2aefb64be1c5f3c4894149d85e1a12c9c0cc3d62 Reviewed-by: Giuseppe D'Angelo --- src/widgets/dialogs/qcolordialog.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/widgets/dialogs/qcolordialog.cpp b/src/widgets/dialogs/qcolordialog.cpp index ee3ece2d77..f04e5b9ea6 100644 --- a/src/widgets/dialogs/qcolordialog.cpp +++ b/src/widgets/dialogs/qcolordialog.cpp @@ -972,6 +972,7 @@ private: QColorShowLabel *lab; bool rgbOriginal; QColorDialog *colorDialog; + QGridLayout *gl; friend class QColorDialog; friend class QColorDialogPrivate; @@ -1099,7 +1100,7 @@ QColorShower::QColorShower(QColorDialog *parent) curCol = qRgb(255, 255, 255); curQColor = Qt::white; - QGridLayout *gl = new QGridLayout(this); + gl = new QGridLayout(this); gl->setMargin(gl->spacing()); lab = new QColorShowLabel(this); @@ -1277,10 +1278,16 @@ QColorShower::QColorShower(QColorDialog *parent) #else htEd->setReadOnly(true); #endif + htEd->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Fixed); lblHtml->setAlignment(Qt::AlignRight|Qt::AlignVCenter); +#if defined(QT_SMALL_COLORDIALOG) + gl->addWidget(lblHtml, 5, 0); + gl->addWidget(htEd, 5, 1, 1, /*colspan=*/ 2); +#else gl->addWidget(lblHtml, 5, 1); - gl->addWidget(htEd, 5, 2); + gl->addWidget(htEd, 5, 2, 1, /*colspan=*/ 3); +#endif connect(hEd, SIGNAL(valueChanged(int)), this, SLOT(hsvEd())); connect(sEd, SIGNAL(valueChanged(int)), this, SLOT(hsvEd())); @@ -1742,7 +1749,9 @@ void QColorDialogPrivate::initWidgets() lp->hide(); #else lp->setFixedWidth(20); + pickLay->addSpacing(10); pickLay->addWidget(lp); + pickLay->addStretch(); #endif QObject::connect(cp, SIGNAL(newCol(int,int)), lp, SLOT(setCol(int,int))); @@ -1751,6 +1760,7 @@ void QColorDialogPrivate::initWidgets() rightLay->addStretch(); cs = new QColorShower(q); + pickLay->setMargin(cs->gl->margin()); QObject::connect(cs, SIGNAL(newCol(QRgb)), q, SLOT(_q_newColorTypedIn(QRgb))); QObject::connect(cs, SIGNAL(currentColorChanged(QColor)), q, SIGNAL(currentColorChanged(QColor))); @@ -1760,6 +1770,7 @@ void QColorDialogPrivate::initWidgets() topLay->addWidget(cs); #else rightLay->addWidget(cs); + leftLay->addSpacing(cs->gl->margin()); #endif buttons = new QDialogButtonBox(q); -- cgit v1.2.3 From 2b7204c0a9d2af07e956c02113c779924ca0c188 Mon Sep 17 00:00:00 2001 From: Alexander Volkov Date: Thu, 18 Dec 2014 14:21:52 +0300 Subject: Doc: Describe the enum item QStyle::PE_FrameStatusBar as obsolete Change-Id: Ibda864d2b037bd8b2484b8642423ae1bca218021 Reviewed-by: Martin Smith --- src/widgets/styles/qstyle.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/widgets/styles/qstyle.cpp b/src/widgets/styles/qstyle.cpp index ba5bd717b6..6072842fc9 100644 --- a/src/widgets/styles/qstyle.cpp +++ b/src/widgets/styles/qstyle.cpp @@ -627,7 +627,7 @@ void QStyle::drawItemPixmap(QPainter *painter, const QRect &rect, int alignment, indicator or button bevel. \omitvalue PE_IndicatorViewItemCheck - \value PE_FrameStatusBar Frame + \value PE_FrameStatusBar Obsolete. Use PE_FrameStatusBarItem instead. \value PE_PanelButtonCommand Button used to initiate an action, for example, a QPushButton. -- cgit v1.2.3 From c63bb90ac7224927b56197d80252c79d01ff3b6f Mon Sep 17 00:00:00 2001 From: Aleix Pol Date: Mon, 22 Dec 2014 16:34:54 +0100 Subject: Fix typo in Qt5CoreMacros.cmake According to the documentation, the argument is called COPYONLY instead of COPY_ONLY. Fixes warning and ensures it works properly. Change-Id: I643f5ea808aaaf94c3ee666ec39485e84ed38df1 Reviewed-by: Vishesh Handa Reviewed-by: Milian Wolff --- src/corelib/Qt5CoreMacros.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/Qt5CoreMacros.cmake b/src/corelib/Qt5CoreMacros.cmake index 88710bc55e..9c81754302 100644 --- a/src/corelib/Qt5CoreMacros.cmake +++ b/src/corelib/Qt5CoreMacros.cmake @@ -221,7 +221,7 @@ function(QT5_ADD_RESOURCES outfiles ) # let's make a configured file and add it as a dependency so cmake is run # again when dependencies need to be recomputed. qt5_make_output_file("${infile}" "" "qrc.depends" out_depends) - configure_file("${infile}" "${out_depends}" COPY_ONLY) + configure_file("${infile}" "${out_depends}" COPYONLY) else() # The .qrc file does not exist (yet). Let's add a dependency and hope # that it will be generated later -- cgit v1.2.3 From 13972476ad2c3178fe89f2d96f398de10394c6f6 Mon Sep 17 00:00:00 2001 From: Dmitry Shachnev Date: Mon, 22 Dec 2014 13:44:45 +0300 Subject: qstorageinfo_unix.cpp: Fix build on BSD and other unices MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Include statvfs.h on all non-Linux and non-Solaris systems. * Fix type of stat_buf structure on BSD. Change-Id: I6336503082fafd7f6108cf95c079bdd329d2ea0f Reviewed-by: Gabriel de Dietrich Reviewed-by: Lisandro Damián Nicanor Pérez Meyer Reviewed-by: Allan Sandfeld Jensen Reviewed-by: Shawn Rutledge --- src/corelib/io/qstorageinfo_unix.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/corelib/io/qstorageinfo_unix.cpp b/src/corelib/io/qstorageinfo_unix.cpp index e82737c51c..857464f578 100644 --- a/src/corelib/io/qstorageinfo_unix.cpp +++ b/src/corelib/io/qstorageinfo_unix.cpp @@ -52,17 +52,18 @@ #if defined(Q_OS_BSD4) # include +# include #elif defined(Q_OS_ANDROID) # include # include # include -#elif defined(Q_OS_QNX) -# include #elif defined(Q_OS_LINUX) # include # include #elif defined(Q_OS_SOLARIS) # include +#else +# include #endif #if defined(Q_OS_BSD4) @@ -118,7 +119,7 @@ public: inline QByteArray device() const; private: #if defined(Q_OS_BSD4) - statfs *stat_buf; + struct statfs *stat_buf; int entryCount; int currentIndex; #elif defined(Q_OS_SOLARIS) -- cgit v1.2.3 From 033318f7a747ee2630542bed37df7e3fc10a0fb1 Mon Sep 17 00:00:00 2001 From: Jason Haslam Date: Fri, 21 Nov 2014 14:33:59 -0700 Subject: Check for valid receiver before sending gesture events. Gesture events sent to a disappearing tooltip can crash. This can most easily be seen by scrolling over a tooltip on OSX with a magic mouse middle scroll gesture. Task-number: QTBUG-42826 Change-Id: Id5510895f63297ca157e3d24a3f4e3a6034586e8 Reviewed-by: Andy Shaw Reviewed-by: Shawn Rutledge Reviewed-by: Laszlo Agocs --- src/gui/kernel/qguiapplication.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index e3f4794e6d..dc5501eaf5 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -2168,6 +2168,9 @@ void QGuiApplicationPrivate::processTabletLeaveProximityEvent(QWindowSystemInter #ifndef QT_NO_GESTURES void QGuiApplicationPrivate::processGestureEvent(QWindowSystemInterfacePrivate::GestureEvent *e) { + if (e->window.isNull()) + return; + QNativeGestureEvent ev(e->type, e->pos, e->pos, e->globalPos, e->realValue, e->sequenceId, e->intValue); ev.setTimestamp(e->timestamp); QGuiApplication::sendSpontaneousEvent(e->window, &ev); -- cgit v1.2.3 From 0920e00932b2686b59247633ea01669fcc398f9c Mon Sep 17 00:00:00 2001 From: Joni Poikelin Date: Mon, 22 Dec 2014 10:00:54 +0200 Subject: Check screen before changing cursor Task-number: QTBUG-43508 Change-Id: I6b525cab2a3958f4e3528ed8102d07984f152e60 Reviewed-by: Shawn Rutledge --- src/gui/kernel/qwindow.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp index c5d88b198b..a4b5376b6f 100644 --- a/src/gui/kernel/qwindow.cpp +++ b/src/gui/kernel/qwindow.cpp @@ -2393,7 +2393,8 @@ void QWindowPrivate::setCursor(const QCursor *newCursor) hasCursor = false; } // Only attempt to set cursor and emit signal if there is an actual platform cursor - if (q->screen()->handle()->cursor()) { + QScreen* screen = q->screen(); + if (screen && screen->handle()->cursor()) { applyCursor(); QEvent event(QEvent::CursorChange); QGuiApplication::sendEvent(q, &event); -- cgit v1.2.3 From a8714548d18884f3dc90cb51b251bc1f612db6e2 Mon Sep 17 00:00:00 2001 From: Nico Vertriest Date: Wed, 17 Dec 2014 15:20:29 +0100 Subject: Doc: corrected broken links qtbase MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Task-number: QTBUG-43115 Change-Id: Ib441326083294a6d59d75510142b1481f7b0bc35 Reviewed-by: Topi Reiniö Reviewed-by: Martin Smith --- src/dbus/doc/src/qtdbus-module.qdoc | 4 ++-- src/gui/image/qimage.cpp | 2 +- src/gui/kernel/qevent.cpp | 2 -- src/gui/kernel/qopenglcontext.cpp | 12 +++++------- src/gui/kernel/qstylehints.cpp | 2 +- src/sql/doc/src/sql-driver.qdoc | 5 ++--- 6 files changed, 11 insertions(+), 16 deletions(-) diff --git a/src/dbus/doc/src/qtdbus-module.qdoc b/src/dbus/doc/src/qtdbus-module.qdoc index ac9cac428b..cd9365aac8 100644 --- a/src/dbus/doc/src/qtdbus-module.qdoc +++ b/src/dbus/doc/src/qtdbus-module.qdoc @@ -29,7 +29,7 @@ \module QtDBus \title Qt D-Bus C++ Classes \brief The Qt D-Bus module is a Unix-only library that you can use - to perform Inter-Process Communication using the \l{D-Bus} protocol. + to perform Inter-Process Communication using the \l{Qt D-Bus}{D-Bus} protocol. \ingroup modules \qtvariable dbus @@ -61,6 +61,6 @@ directory. When installing Qt from source, this module is built when Qt's tools are built. - See the \l {D-Bus} page for detailed information on + See the \l {Qt D-Bus}{D-Bus} page for detailed information on how to use this module. */ diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp index ea23954a49..887a7c29eb 100644 --- a/src/gui/image/qimage.cpp +++ b/src/gui/image/qimage.cpp @@ -314,7 +314,7 @@ bool QImageData::checkForAlphaPixels() const sharing}. QImage objects can also be streamed and compared. \note If you would like to load QImage objects in a static build of Qt, - refer to the \l{How To Create Qt Plugins#Static Plugins}{Plugin HowTo}. + refer to the \l{How To Create Qt Plugins}{Plugin HowTo}. \warning Painting on a QImage with the format QImage::Format_Indexed8 is not supported. diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp index a8c34a8871..60e7b97f12 100644 --- a/src/gui/kernel/qevent.cpp +++ b/src/gui/kernel/qevent.cpp @@ -283,7 +283,6 @@ QMouseEvent::~QMouseEvent() \sa Qt::MouseEventSource \sa QGraphicsSceneMouseEvent::source() - \sa QGraphicsSceneMouseEvent::setSource() */ Qt::MouseEventSource QMouseEvent::source() const { @@ -299,7 +298,6 @@ Qt::MouseEventSource QMouseEvent::source() const \sa Qt::MouseEventFlag \sa QGraphicsSceneMouseEvent::flags() - \sa QGraphicsSceneMouseEvent::setFlags() */ Qt::MouseEventFlags QMouseEvent::flags() const { diff --git a/src/gui/kernel/qopenglcontext.cpp b/src/gui/kernel/qopenglcontext.cpp index c01e1c95dd..5918f30660 100644 --- a/src/gui/kernel/qopenglcontext.cpp +++ b/src/gui/kernel/qopenglcontext.cpp @@ -519,7 +519,7 @@ void QOpenGLContext::setScreen(QScreen *screen) value type. These classes can be found in the QtPlatformHeaders module. When create() is called with native handles set, the handles' ownership are - not taken, meaning that destroy() will not destroy the native context. + not taken, meaning that \c destroy() will not destroy the native context. \note Some frameworks track the current context and surfaces internally. Making the adopted QOpenGLContext current via Qt will have no effect on such @@ -583,9 +583,9 @@ QVariant QOpenGLContext::nativeHandle() const be used with makeCurrent(), swapBuffers(), etc. \note If the context is already created, this function will first call - destroy(), and then create a new OpenGL context. + \c destroy(), and then create a new OpenGL context. - \sa makeCurrent(), destroy(), format() + \sa makeCurrent(), format() */ bool QOpenGLContext::create() { @@ -613,7 +613,7 @@ bool QOpenGLContext::create() destroying the underlying platform context frees any state associated with the context. - After destroy() has been called, you must call create() if you wish to + After \c destroy() has been called, you must call create() if you wish to use the context again. \note This implicitly calls doneCurrent() if the context is current. @@ -658,10 +658,8 @@ void QOpenGLContext::destroy() /*! Destroys the QOpenGLContext object. - This implicitly calls destroy(), so if this is the current context for the + This implicitly calls \c destroy(), so if this is the current context for the thread, doneCurrent() is also called. - - \sa destroy() */ QOpenGLContext::~QOpenGLContext() { diff --git a/src/gui/kernel/qstylehints.cpp b/src/gui/kernel/qstylehints.cpp index 65a710c3f7..125e59aa5f 100644 --- a/src/gui/kernel/qstylehints.cpp +++ b/src/gui/kernel/qstylehints.cpp @@ -88,7 +88,7 @@ public: Access to these parameters are useful when implementing custom user interface components, in that they allow the components to exhibit the same behaviour and feel as other components. - \sa QGuiApplication::styleHints(), QPlatformTheme + \sa QGuiApplication::styleHints() */ QStyleHints::QStyleHints() : QObject(*new QStyleHintsPrivate(), 0) diff --git a/src/sql/doc/src/sql-driver.qdoc b/src/sql/doc/src/sql-driver.qdoc index 71d2fb4f85..e2ffdaea2c 100644 --- a/src/sql/doc/src/sql-driver.qdoc +++ b/src/sql/doc/src/sql-driver.qdoc @@ -713,9 +713,8 @@ \snippet code/doc_src_sql-driver.cpp 31 - the problem is usually that the plugin had the wrong \l{Deploying - Plugins#The Build Key}{build key}. This might require removing an - entry from the \l{Deploying Plugins#The Plugin Cache} {plugin cache}. + the problem is usually that the plugin had the wrong build key. + This might require removing an entry from the plugin cache. \target development \section1 How to Write Your Own Database Driver -- cgit v1.2.3 From 7f34bee8493bce5b690f864a1c5da4493ce8e409 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 19 Dec 2014 22:41:50 -0800 Subject: Fix include headers for qsslcertificate_qt.cpp The order is: 1) own header 2) own private header, if any 3) other headers Commit f17d7a124f0fa817a7e1a2dda6f48098432c0dc0 broke the order. Change-Id: I7225024691db91fd936a057accdad65bacb3f979 Reviewed-by: Richard J. Moore --- src/network/ssl/qsslcertificate_qt.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/network/ssl/qsslcertificate_qt.cpp b/src/network/ssl/qsslcertificate_qt.cpp index cf99e77314..c560c5af87 100644 --- a/src/network/ssl/qsslcertificate_qt.cpp +++ b/src/network/ssl/qsslcertificate_qt.cpp @@ -39,10 +39,10 @@ ** ****************************************************************************/ - -#include "qssl_p.h" #include "qsslcertificate.h" #include "qsslcertificate_p.h" + +#include "qssl_p.h" #include "qsslkey.h" #include "qsslkey_p.h" #include "qsslcertificateextension.h" -- cgit v1.2.3 From c013104b0417626077f52f4d2216381382b2d9bd Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 18 Dec 2014 17:19:19 -0800 Subject: Temporarily disable the QtDBus tests if the session bus isn't available This is a temporary measure while the Qt CI system is updated to have the correct D-Bus configuration. Once it is fixed, this commit should be reverted, so that we don't run into the situation in which the tests aren't getting run on some configurations and we never know about it. Change-Id: I7192d4d95a60dcb63acfa6cc90bfdc58592b0664 Reviewed-by: Alex Blasche --- tests/auto/auto.pro | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro index a9aecc9448..01952aac3c 100644 --- a/tests/auto/auto.pro +++ b/tests/auto/auto.pro @@ -24,9 +24,18 @@ ios: SUBDIRS = corelib gui wince*: SUBDIRS -= printsupport cross_compile: SUBDIRS -= tools !qtHaveModule(opengl): SUBDIRS -= opengl -!unix|embedded|!qtHaveModule(dbus): SUBDIRS -= dbus !qtHaveModule(gui): SUBDIRS -= gui cmake !qtHaveModule(widgets): SUBDIRS -= widgets !qtHaveModule(printsupport): SUBDIRS -= printsupport !qtHaveModule(concurrent): SUBDIRS -= concurrent !qtHaveModule(network): SUBDIRS -= network + +# Disable the QtDBus tests if we can't connect to the session bus +qtHaveModule(dbus) { + !system("dbus-send --type=signal / local.AutotestCheck.Hello"): { + warning("QtDBus is enabled but session bus is not available. Please check the installation.") + SUBDIRS -= dbus + } +} else { + SUBDIRS -= dbus +} -- cgit v1.2.3 From ceeb032de6b9e9256f96ce033512529523ea64b1 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Mon, 22 Dec 2014 16:49:41 +0100 Subject: QRawFont: improve the thread-safety checks 384388f2 introduced some checks, and used an assignment in an assert; that sets off compiler warnings about expressions with side effects into an assertion. Hence, that code needs to be reworked a bit. Unfortunately, there's no single define we can use to know if assertions are enabled or not in Qt, so simply use QT_NO_DEBUG to enable/disable those checks. The actual "thread" data member is kept around to avoid break ABI depending on debugging flags. Change-Id: I8b07e7ff6f81359d6b0653a1d9cc2b720541d1b9 Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/gui/text/qrawfont_p.h | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/gui/text/qrawfont_p.h b/src/gui/text/qrawfont_p.h index 9b0846de9a..96ba3fd026 100644 --- a/src/gui/text/qrawfont_p.h +++ b/src/gui/text/qrawfont_p.h @@ -70,14 +70,18 @@ public: , hintingPreference(other.hintingPreference) , thread(other.thread) { +#ifndef QT_NO_DEBUG Q_ASSERT(fontEngine == 0 || thread == QThread::currentThread()); +#endif if (fontEngine != 0) fontEngine->ref.ref(); } ~QRawFontPrivate() { +#ifndef QT_NO_DEBUG Q_ASSERT(ref.load() == 0); +#endif cleanUp(); } @@ -89,27 +93,36 @@ public: inline bool isValid() const { +#ifndef QT_NO_DEBUG Q_ASSERT(fontEngine == 0 || thread == QThread::currentThread()); +#endif return fontEngine != 0; } inline void setFontEngine(QFontEngine *engine) { +#ifndef QT_NO_DEBUG Q_ASSERT(fontEngine == 0 || thread == QThread::currentThread()); +#endif if (fontEngine == engine) return; if (fontEngine != 0) { if (!fontEngine->ref.deref()) delete fontEngine; +#ifndef QT_NO_DEBUG thread = 0; +#endif } fontEngine = engine; if (fontEngine != 0) { fontEngine->ref.ref(); - Q_ASSERT(thread = QThread::currentThread()); // set only if assertions enabled +#ifndef QT_NO_DEBUG + thread = QThread::currentThread(); + Q_ASSERT(thread); +#endif } } -- cgit v1.2.3 From 8815a75ef0adbdce0f1ff311222302286c2033aa Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Tue, 23 Dec 2014 13:03:27 +0100 Subject: Remove a memory leak in the custom sort filter model example Change-Id: Ie14f07bc2ee2215da2a81a75d816d4763fac085f Reviewed-by: Olivier Goffart --- .../itemviews/customsortfiltermodel/mysortfilterproxymodel.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/examples/widgets/itemviews/customsortfiltermodel/mysortfilterproxymodel.cpp b/examples/widgets/itemviews/customsortfiltermodel/mysortfilterproxymodel.cpp index af4d8b477b..70af51cd1e 100644 --- a/examples/widgets/itemviews/customsortfiltermodel/mysortfilterproxymodel.cpp +++ b/examples/widgets/itemviews/customsortfiltermodel/mysortfilterproxymodel.cpp @@ -91,15 +91,15 @@ bool MySortFilterProxyModel::lessThan(const QModelIndex &left, if (leftData.type() == QVariant::DateTime) { return leftData.toDateTime() < rightData.toDateTime(); } else { - QRegExp *emailPattern = new QRegExp("([\\w\\.]*@[\\w\\.]*)"); + static QRegExp emailPattern("[\\w\\.]*@[\\w\\.]*)"); QString leftString = leftData.toString(); - if(left.column() == 1 && emailPattern->indexIn(leftString) != -1) - leftString = emailPattern->cap(1); + if(left.column() == 1 && emailPattern.indexIn(leftString) != -1) + leftString = emailPattern.cap(1); QString rightString = rightData.toString(); - if(right.column() == 1 && emailPattern->indexIn(rightString) != -1) - rightString = emailPattern->cap(1); + if(right.column() == 1 && emailPattern.indexIn(rightString) != -1) + rightString = emailPattern.cap(1); return QString::localeAwareCompare(leftString, rightString) < 0; } -- cgit v1.2.3 From a0cec542207d42d95b2e6fb836f47823f9bd4625 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 23 Dec 2014 15:48:40 -0200 Subject: Autotest: Disable multicast testing with proxies It doesn't make sense because there is no command to ask the proxy server to join a multicast group. At best, we could write a datagram via proxy without joining, but we definitely can't receive. Change-Id: Icc6b54572a053fb7821dfca1f4111f2046ff8686 Reviewed-by: Richard J. Moore --- tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp b/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp index eda24abcd9..b2338d2ce5 100644 --- a/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp +++ b/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp @@ -1259,16 +1259,7 @@ void tst_QUdpSocket::multicast() QSKIP("system doesn't support ipv6!"); if (setProxy) { // UDP multicast does not work with proxies - if ( -#ifndef Q_OS_WIN - //windows native socket engine binds 0.0.0.0 instead of the requested multicast address - (bindAddress.protocol() == QAbstractSocket::IPv4Protocol && (bindAddress.toIPv4Address() & 0xffff0000) == 0xefff0000) || -#endif - bindAddress.protocol() == QAbstractSocket::IPv6Protocol) { - // proxy cannot bind to IPv6 or multicast addresses - bindResult = false; - } - joinResult = false; + return; } QUdpSocket receiver; -- cgit v1.2.3 From 7a303ff55f3c9ee962506c5cf24b1fd432aa44fa Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 23 Dec 2014 10:26:28 -0200 Subject: Suppress silly shell warning during qmake of qtcpsocket.pro If you don't have /etc/lsb-release, you'd get sh: line 0: [: =: unary operator expected Change-Id: Idb5c79f799879e4d32cd640ef74fb388227f831e Reviewed-by: Richard J. Moore --- tests/auto/network/socket/qtcpsocket/qtcpsocket.pro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/auto/network/socket/qtcpsocket/qtcpsocket.pro b/tests/auto/network/socket/qtcpsocket/qtcpsocket.pro index a7b9f6126e..cdab37bd07 100644 --- a/tests/auto/network/socket/qtcpsocket/qtcpsocket.pro +++ b/tests/auto/network/socket/qtcpsocket/qtcpsocket.pro @@ -4,6 +4,6 @@ TEMPLATE = subdirs !wince*: SUBDIRS = test stressTest wince*|vxworks* : SUBDIRS = test -linux-*:system(". /etc/lsb-release && [ $DISTRIB_CODENAME = oneiric ]"):DEFINES+=UBUNTU_ONEIRIC +linux-*:system(". /etc/lsb-release && [ "$DISTRIB_CODENAME" = oneiric ]"):DEFINES+=UBUNTU_ONEIRIC requires(contains(QT_CONFIG,private_tests)) -- cgit v1.2.3 From 68d8d27fadafdd28e87fb8090b4770d44f888803 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 23 Dec 2014 12:52:59 -0200 Subject: Don't try to send broadcasts over IPv6 IPv6 has no such thing, so don't try to bind to an IPv6 address to send broadcasts (even though that works) and it's a poor idea to bind to IPv6 to receive broadcasts. Moreover, skip any IPv6 network addresses (broadcast() is invalid). Change-Id: I2829b042c000158565adfd92db682f37d67dacae Reviewed-by: Richard J. Moore --- tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp b/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp index b2338d2ce5..c2276a2126 100644 --- a/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp +++ b/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp @@ -282,8 +282,11 @@ void tst_QUdpSocket::broadcasting() foreach (QNetworkInterface iface, QNetworkInterface::allInterfaces()) { if ((iface.flags() & QNetworkInterface::CanBroadcast) && iface.flags() & QNetworkInterface::IsUp) { - for (int i=0;i Date: Tue, 23 Dec 2014 13:10:27 -0200 Subject: Stabilize tst_QUdpSocket::broadcasting Sending 100*8 packets of each type of message is WAY overkill. That's a stress test without limiting. My Linux system starts reporting EAGAIN on the socket, so reduce the amount of data sent. Change-Id: I153f44cf3b91d37526dac580b400114cc80b1769 Reviewed-by: Richard J. Moore --- tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp b/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp index c2276a2126..0a56807a7f 100644 --- a/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp +++ b/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp @@ -308,7 +308,7 @@ void tst_QUdpSocket::broadcasting() #endif broadcastSocket.bind(QHostAddress(QHostAddress::AnyIPv4), 0); - for (int j = 0; j < 100; ++j) { + for (int j = 0; j < 10; ++j) { for (int k = 0; k < 4; k++) { broadcastSocket.writeDatagram(message[i], strlen(message[i]), QHostAddress::Broadcast, 5000); -- cgit v1.2.3 From 23ba824b7d358abd9354f7b88f67265fae4c7eff Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 23 Dec 2014 15:22:42 -0200 Subject: Fix silly mistake: 0 is a valid file descriptor Change-Id: I60baa01f0ef9419a73535c761c4722c5abd6f26e Reviewed-by: Richard J. Moore --- src/network/socket/qhttpsocketengine.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/network/socket/qhttpsocketengine.cpp b/src/network/socket/qhttpsocketengine.cpp index b754e98b19..b929ee088e 100644 --- a/src/network/socket/qhttpsocketengine.cpp +++ b/src/network/socket/qhttpsocketengine.cpp @@ -116,7 +116,7 @@ void QHttpSocketEngine::setProxy(const QNetworkProxy &proxy) qintptr QHttpSocketEngine::socketDescriptor() const { Q_D(const QHttpSocketEngine); - return d->socket ? d->socket->socketDescriptor() : 0; + return d->socket ? d->socket->socketDescriptor() : -1; } bool QHttpSocketEngine::isValid() const -- cgit v1.2.3 From dec81ad2dac347ae380f405eb2a58d0a4d0abad4 Mon Sep 17 00:00:00 2001 From: Roger Maclean Date: Tue, 9 Dec 2014 11:44:50 -0500 Subject: QNX: Revert the change to give higher precision timers. The previous change (SHA 82c2118c) to provide better than 1ms accuracy for timers on QNX is not safe. According to the docs, ClockCycles is not guaranteed to return consistent information if called from different CPUs. While this can be addressed by locking the thread to a single CPU, you wouldn't want to do that here. On some systems (e.g. BB10) the behavior is extremely bad since ClockCycles only has 32 bits of precision. This results in overflows in the calculations making short timers run very slowly (16ms timers were around 1s). Also ClockCycles wraps in under three minutes causing even more problems. I've talked to the kernel developers and there is currently nothing that will give you better than 1ms accuracy. An individual program could use ClockCycles to calculate more accurate times if they want. It's not clear to me what benefit one would get with increased accuracy. Unless I've missed something, these times are only used to calculate timeouts for calls such as select. These timeouts will themselves have the same resolution as clock_gettime provides so the increased accuracy would appear to be for naught. Change-Id: Ia38b154ca41949becbd0b8558a9ff4ddd5e01a43 Reviewed-by: Thiago Macieira Reviewed-by: Bernd Weimer Reviewed-by: Oswald Buddenhagen Reviewed-by: Rafael Roquetto --- src/corelib/tools/qelapsedtimer_unix.cpp | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/src/corelib/tools/qelapsedtimer_unix.cpp b/src/corelib/tools/qelapsedtimer_unix.cpp index 9dd5df0266..d29447fa03 100644 --- a/src/corelib/tools/qelapsedtimer_unix.cpp +++ b/src/corelib/tools/qelapsedtimer_unix.cpp @@ -37,10 +37,6 @@ #include "qelapsedtimer.h" #if defined(Q_OS_VXWORKS) #include "qfunctions_vxworks.h" -#elif defined(Q_OS_QNX) -#include -#include -#include #else #include #include @@ -88,18 +84,7 @@ QT_BEGIN_NAMESPACE * see http://pubs.opengroup.org/onlinepubs/9699919799/functions/clock_getres.html */ -#if defined(Q_OS_QNX) -static inline void qt_clock_gettime(clockid_t clock, struct timespec *ts) -{ - // The standard POSIX clock calls only have 1ms accuracy on QNX. To get - // higher accuracy, this platform-specific function must be used instead - quint64 cycles_per_sec = SYSPAGE_ENTRY(qtime)->cycles_per_sec; - quint64 cycles = ClockCycles(); - ts->tv_sec = cycles / cycles_per_sec; - quint64 mod = cycles % cycles_per_sec; - ts->tv_nsec = mod * Q_INT64_C(1000000000) / cycles_per_sec; -} -#elif !defined(CLOCK_REALTIME) +#if !defined(CLOCK_REALTIME) # define CLOCK_REALTIME 0 static inline void qt_clock_gettime(int, struct timespec *ts) { -- cgit v1.2.3 From 11b282d58121ec63316ec11da0af10023b593549 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Tue, 23 Dec 2014 12:55:23 +0100 Subject: Glib config test: fix compiler warnings Remove warnings: "assigned but not used" and "uninitialized usage". Change-Id: I247e1de020e78c35787b8e1e30421174ac232fd5 Reviewed-by: Thiago Macieira --- config.tests/unix/glib/glib.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/config.tests/unix/glib/glib.cpp b/config.tests/unix/glib/glib.cpp index 692e3173fa..f8abc824c6 100644 --- a/config.tests/unix/glib/glib.cpp +++ b/config.tests/unix/glib/glib.cpp @@ -39,10 +39,11 @@ int main(int, char **) { GMainContext *context; GSource *source; - GPollFD *pollfd; + GPollFD *pollfd = NULL; if (!g_thread_supported()) g_thread_init(NULL); context = g_main_context_default(); + (void)context; source = g_source_new(0, 0); g_source_add_poll(source, pollfd); return 0; -- cgit v1.2.3 From 14c5f149cdbec51df297d4849ba4eb98fb47fbe2 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 23 Dec 2014 15:34:24 -0200 Subject: Fix tst_QUdpSocket::multicastLeaveAfterClose With IPv6, you cannot bind to a multicast address. You need to bind to a local address only. The previous tests either checked this or didn't check the result of bind(). Change-Id: Ief70887d8988fc1bc4394cf6ff34b5d560e5748e Reviewed-by: Richard J. Moore --- tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp b/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp index 0a56807a7f..a49f284938 100644 --- a/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp +++ b/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp @@ -1163,8 +1163,8 @@ void tst_QUdpSocket::multicastJoinBeforeBind() void tst_QUdpSocket::multicastLeaveAfterClose_data() { QTest::addColumn("groupAddress"); - QTest::newRow("valid ipv4 group address") << QHostAddress("239.255.118.62"); - QTest::newRow("valid ipv6 group address") << QHostAddress("FF01::114"); + QTest::newRow("ipv4") << QHostAddress("239.255.118.62"); + QTest::newRow("ipv6") << QHostAddress("FF01::114"); } void tst_QUdpSocket::multicastLeaveAfterClose() @@ -1180,7 +1180,10 @@ void tst_QUdpSocket::multicastLeaveAfterClose() #ifdef FORCE_SESSION udpSocket.setProperty("_q_networksession", QVariant::fromValue(networkSession)); #endif - QVERIFY2(udpSocket.bind(groupAddress, 0), + QHostAddress bindAddress = QHostAddress::AnyIPv4; + if (groupAddress.protocol() == QAbstractSocket::IPv6Protocol) + bindAddress = QHostAddress::AnyIPv6; + QVERIFY2(udpSocket.bind(bindAddress, 0), qPrintable(udpSocket.errorString())); QVERIFY2(udpSocket.joinMulticastGroup(groupAddress), qPrintable(udpSocket.errorString())); -- cgit v1.2.3 From 98a7497d74b24e71bd39adb41f6043f6fe23a9dd Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 23 Dec 2014 15:46:52 -0200 Subject: Silence warning in tst_QUdpSocket::multicast for Any+IPv4 QUdpSocket doesn't support binding to QHostAddress::Any and then joining an IPv4 multicat group since QHostAddress::Any is really an IPv6 socket with v6only = false. The test did check this case, but failed to ignore the warning. Change-Id: I62d782408319a6e566e0ff1a6081b706ac1f669c Reviewed-by: Richard J. Moore --- src/network/socket/qnativesocketengine.cpp | 4 ++-- tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp | 8 +++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/network/socket/qnativesocketengine.cpp b/src/network/socket/qnativesocketengine.cpp index c19815034d..e7113c8c5e 100644 --- a/src/network/socket/qnativesocketengine.cpp +++ b/src/network/socket/qnativesocketengine.cpp @@ -641,8 +641,8 @@ bool QNativeSocketEngine::joinMulticastGroup(const QHostAddress &groupAddress, if (groupAddress.protocol() == QAbstractSocket::IPv4Protocol && (d->socketProtocol == QAbstractSocket::IPv6Protocol || d->socketProtocol == QAbstractSocket::AnyIPProtocol)) { - qWarning("QAbstractSocket: cannot bind to QHostAddress::Any (or an IPv6 address) and join an IPv4 multicast group"); - qWarning("QAbstractSocket: bind to QHostAddress::AnyIPv4 instead if you want to do this"); + qWarning("QAbstractSocket: cannot bind to QHostAddress::Any (or an IPv6 address) and join an IPv4 multicast group;" + " bind to QHostAddress::AnyIPv4 instead if you want to do this"); return false; } diff --git a/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp b/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp index a49f284938..4b7ace8685 100644 --- a/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp +++ b/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp @@ -1249,7 +1249,7 @@ void tst_QUdpSocket::multicast_data() QTest::newRow("same bind, group ipv4 address") << groupAddress << true << groupAddress << true; QTest::newRow("valid bind, group ipv6 address") << any6Address << true << group6Address << true; QTest::newRow("valid bind, invalid group ipv6 address") << any6Address << true << any6Address << false; - QTest::newRow("same bind, group ipv6 address") << group6Address << true << group6Address << true; + QTest::newRow("same bind, group ipv6 address") << group6Address << false << group6Address << false; QTest::newRow("dual bind, group ipv4 address") << dualAddress << true << groupAddress << false; QTest::newRow("dual bind, group ipv6 address") << dualAddress << true << group6Address << true; } @@ -1279,6 +1279,12 @@ void tst_QUdpSocket::multicast() if (!bindResult) return; + if (bindAddress == QHostAddress::Any && groupAddress.protocol() == QAbstractSocket::IPv4Protocol) { + QCOMPARE(joinResult, false); + QTest::ignoreMessage(QtWarningMsg, + "QAbstractSocket: cannot bind to QHostAddress::Any (or an IPv6 address) and join an IPv4 multicast group;" + " bind to QHostAddress::AnyIPv4 instead if you want to do this"); + } QVERIFY2(receiver.joinMulticastGroup(groupAddress) == joinResult, qPrintable(receiver.errorString())); if (!joinResult) -- cgit v1.2.3 From 9a0c4fc479b2f46f569890a2821e56b2943efac5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9rgio=20Martins?= Date: Tue, 2 Dec 2014 11:37:32 +0000 Subject: Fix win32-g++ build due to -Werror qwindowsprintdevice.cpp:182:85: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare] && DeviceCapabilities((LPWSTR)m_id.utf16(), NULL, DC_PAPERSIZE, NULL, NULL) == paperCount MinGW DeviceCapabilities is returning an int, although microsoft documents it as returning DWORD. Change-Id: I3acd76dde0b8b83f8a785ec84e3413115c847cb2 Reviewed-by: Friedemann Kleint Reviewed-by: Thiago Macieira --- src/plugins/printsupport/windows/qwindowsprintdevice.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/plugins/printsupport/windows/qwindowsprintdevice.cpp b/src/plugins/printsupport/windows/qwindowsprintdevice.cpp index a0a549da6f..c349655b1e 100644 --- a/src/plugins/printsupport/windows/qwindowsprintdevice.cpp +++ b/src/plugins/printsupport/windows/qwindowsprintdevice.cpp @@ -39,6 +39,10 @@ # define DC_COLLATE 22 #endif +#if defined (Q_CC_MINGW) +# pragma GCC diagnostic ignored "-Wsign-compare" +#endif + QT_BEGIN_NAMESPACE #ifndef QT_NO_PRINTER -- cgit v1.2.3 From 62e751842143168ceaa607f7b8635ed5938df48f Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 24 Dec 2014 14:08:33 -0200 Subject: Report QHostAddress::Any explicitly in qDebug() With toString(), it was printing "0.0.0.0", which is the same as QHostAddress::AnyIPv4, making it difficult to tell the two apart. Change-Id: I4668ec3337c25ddfdc2fa3bbacc83b9d34316b1f Reviewed-by: Richard J. Moore --- src/network/kernel/qhostaddress.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/network/kernel/qhostaddress.cpp b/src/network/kernel/qhostaddress.cpp index cf24438f0c..10fdf2f97d 100644 --- a/src/network/kernel/qhostaddress.cpp +++ b/src/network/kernel/qhostaddress.cpp @@ -1024,7 +1024,10 @@ bool QHostAddress::isLoopback() const #ifndef QT_NO_DEBUG_STREAM QDebug operator<<(QDebug d, const QHostAddress &address) { - d.maybeSpace() << "QHostAddress(" << address.toString() << ')'; + if (address == QHostAddress::Any) + d.maybeSpace() << "QHostAddress(QHostAddress::Any)"; + else + d.maybeSpace() << "QHostAddress(" << address.toString() << ')'; return d.space(); } #endif -- cgit v1.2.3 From c290ee69f28e8b4534e9a04dc623c7f5a946274b Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 23 Dec 2014 15:39:16 -0200 Subject: Fix silly QSKIP for IPv6 in tst_QUdpSocket::multicast It was unconditional. Someone forgot to check for IPv6 support before skipping IPv6 tests. Change-Id: I7b11528ad02560f0db9defde3c64f76f48a6c1f8 Reviewed-by: Richard J. Moore --- tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp b/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp index 4b7ace8685..aad591b410 100644 --- a/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp +++ b/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp @@ -1261,7 +1261,7 @@ void tst_QUdpSocket::multicast() QFETCH(bool, bindResult); QFETCH(QHostAddress, groupAddress); QFETCH(bool, joinResult); - if (groupAddress.protocol() == QAbstractSocket::IPv6Protocol) + if (groupAddress.protocol() == QAbstractSocket::IPv6Protocol && !QtNetworkSettings::hasIPv6()) QSKIP("system doesn't support ipv6!"); if (setProxy) { // UDP multicast does not work with proxies -- cgit v1.2.3 From 9a70b67b5a8e022fa91883a177c79c6da872fe4c Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 24 Dec 2014 12:18:04 -0200 Subject: Don't hardcode port numbers in tst_QUdpSocket wherever possible On my Mac Mini, port 5000 is in use, which means the broadcasting test fails. Change-Id: Ifb0883263e277f388342430349ea7315d42f324a Reviewed-by: Richard J. Moore --- .../network/socket/qudpsocket/tst_qudpsocket.cpp | 25 +++++++++++++--------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp b/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp index aad591b410..2ab27c3473 100644 --- a/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp +++ b/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp @@ -296,7 +296,8 @@ void tst_QUdpSocket::broadcasting() #ifdef FORCE_SESSION serverSocket.setProperty("_q_networksession", QVariant::fromValue(networkSession)); #endif - QVERIFY2(serverSocket.bind(QHostAddress::AnyIPv4, 5000), serverSocket.errorString().toLatin1().constData()); + QVERIFY2(serverSocket.bind(QHostAddress(QHostAddress::AnyIPv4), 0), serverSocket.errorString().toLatin1().constData()); + quint16 serverPort = serverSocket.localPort(); QCOMPARE(serverSocket.state(), QUdpSocket::BoundState); @@ -311,9 +312,9 @@ void tst_QUdpSocket::broadcasting() for (int j = 0; j < 10; ++j) { for (int k = 0; k < 4; k++) { broadcastSocket.writeDatagram(message[i], strlen(message[i]), - QHostAddress::Broadcast, 5000); + QHostAddress::Broadcast, serverPort); foreach (QHostAddress addr, broadcastAddresses) - broadcastSocket.writeDatagram(message[i], strlen(message[i]), addr, 5000); + broadcastSocket.writeDatagram(message[i], strlen(message[i]), addr, serverPort); } QTestEventLoop::instance().enterLoop(15); if (QTestEventLoop::instance().timeout()) { @@ -422,13 +423,18 @@ void tst_QUdpSocket::ipv6Loop() paul.setProperty("_q_networksession", QVariant::fromValue(networkSession)); #endif - quint16 peterPort = 28124; - quint16 paulPort = 28123; + quint16 peterPort; + quint16 paulPort; - if (!peter.bind(QHostAddress::LocalHostIPv6, peterPort)) { - QCOMPARE(peter.error(), QUdpSocket::UnsupportedSocketOperationError); - } else { - QVERIFY(paul.bind(QHostAddress::LocalHostIPv6, paulPort)); + if (!peter.bind(QHostAddress(QHostAddress::LocalHostIPv6), 0)) { + QCOMPARE(peter.error(), QUdpSocket::UnsupportedSocketOperationError); + return; + } + + QVERIFY(paul.bind(QHostAddress(QHostAddress::LocalHostIPv6), 0)); + + peterPort = peter.localPort(); + paulPort = paul.localPort(); QCOMPARE(peter.writeDatagram(peterMessage.data(), peterMessage.length(), QHostAddress("::1"), paulPort), qint64(peterMessage.length())); @@ -454,7 +460,6 @@ void tst_QUdpSocket::ipv6Loop() QCOMPARE(QByteArray(peterBuffer, paulMessage.length()), paulMessage); QCOMPARE(QByteArray(paulBuffer, peterMessage.length()), peterMessage); - } } void tst_QUdpSocket::dualStack() -- cgit v1.2.3 From 1196f691120d77ab3be55f21824aba645210fb8c Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 24 Dec 2014 11:53:45 -0200 Subject: tst_QUdpSocket: Fix inverted logic in getting a non-"any" address We want to use "localhost" if the server's address is "any", as some OS can't send datagrams to "any" (e.g., OS X and FreeBSD). Change-Id: I1004bc2282e7f930cdb7ed394aa9f4b5a1cfcf82 Reviewed-by: Richard J. Moore --- .../network/socket/qudpsocket/tst_qudpsocket.cpp | 41 ++++++++++------------ 1 file changed, 18 insertions(+), 23 deletions(-) diff --git a/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp b/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp index 2ab27c3473..60ac54856c 100644 --- a/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp +++ b/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp @@ -127,6 +127,17 @@ private: #endif }; +static QHostAddress makeNonAny(const QHostAddress &address, QHostAddress::SpecialAddress preferForAny = QHostAddress::LocalHost) +{ + if (address == QHostAddress::Any) + return preferForAny; + if (address == QHostAddress::AnyIPv4) + return QHostAddress::LocalHost; + if (address == QHostAddress::AnyIPv6) + return QHostAddress::LocalHostIPv6; + return address; +} + tst_QUdpSocket::tst_QUdpSocket() { } @@ -236,10 +247,7 @@ void tst_QUdpSocket::unconnectedServerAndClientTest() const char *message[] = {"Yo mista", "Yo", "Wassap"}; - QHostAddress serverAddress = QHostAddress::LocalHost; - if (!(serverSocket.localAddress() == QHostAddress::AnyIPv4 || serverSocket.localAddress() == QHostAddress::AnyIPv6)) - serverAddress = serverSocket.localAddress(); - + QHostAddress serverAddress = makeNonAny(serverSocket.localAddress()); for (int i = 0; i < 3; ++i) { QUdpSocket clientSocket; #ifdef FORCE_SESSION @@ -375,12 +383,8 @@ void tst_QUdpSocket::loop() QVERIFY2(peter.bind(), peter.errorString().toLatin1().constData()); QVERIFY2(paul.bind(), paul.errorString().toLatin1().constData()); - QHostAddress peterAddress = QHostAddress::LocalHost; - if (!(peter.localAddress() == QHostAddress::AnyIPv4 || peter.localAddress() == QHostAddress::AnyIPv6)) - peterAddress = peter.localAddress(); - QHostAddress pualAddress = QHostAddress::LocalHost; - if (!(paul.localAddress() == QHostAddress::AnyIPv4 || paul.localAddress() == QHostAddress::AnyIPv6)) - pualAddress = paul.localAddress(); + QHostAddress peterAddress = makeNonAny(peter.localAddress()); + QHostAddress pualAddress = makeNonAny(paul.localAddress()); QCOMPARE(peter.writeDatagram(peterMessage.data(), peterMessage.length(), pualAddress, paul.localPort()), qint64(peterMessage.length())); @@ -624,7 +628,7 @@ void tst_QUdpSocket::readLine() #endif QVERIFY2(socket1.bind(), socket1.errorString().toLatin1().constData()); - socket2.connectToHost("127.0.0.1", socket1.localPort()); + socket2.connectToHost(makeNonAny(socket1.localAddress()), socket1.localPort()); QVERIFY(socket2.waitForConnected(5000)); } @@ -638,10 +642,7 @@ void tst_QUdpSocket::pendingDatagramSize() #endif QVERIFY2(server.bind(), server.errorString().toLatin1().constData()); - QHostAddress serverAddress = QHostAddress::LocalHost; - if (!(server.localAddress() == QHostAddress::AnyIPv4 || server.localAddress() == QHostAddress::AnyIPv6)) - serverAddress = server.localAddress(); - + QHostAddress serverAddress = makeNonAny(server.localAddress()); QUdpSocket client; #ifdef FORCE_SESSION client.setProperty("_q_networksession", QVariant::fromValue(networkSession)); @@ -689,10 +690,7 @@ void tst_QUdpSocket::writeDatagram() #endif QVERIFY2(server.bind(), server.errorString().toLatin1().constData()); - QHostAddress serverAddress = QHostAddress::LocalHost; - if (!(server.localAddress() == QHostAddress::AnyIPv4 || server.localAddress() == QHostAddress::AnyIPv6)) - serverAddress = server.localAddress(); - + QHostAddress serverAddress = makeNonAny(server.localAddress()); QUdpSocket client; #ifdef FORCE_SESSION client.setProperty("_q_networksession", QVariant::fromValue(networkSession)); @@ -739,10 +737,7 @@ void tst_QUdpSocket::performance() #endif QVERIFY2(server.bind(), server.errorString().toLatin1().constData()); - QHostAddress serverAddress = QHostAddress::LocalHost; - if (!(server.localAddress() == QHostAddress::AnyIPv4 || server.localAddress() == QHostAddress::AnyIPv6)) - serverAddress = server.localAddress(); - + QHostAddress serverAddress = makeNonAny(server.localAddress()); QUdpSocket client; #ifdef FORCE_SESSION client.setProperty("_q_networksession", QVariant::fromValue(networkSession)); -- cgit v1.2.3