From 0cc37b6e60f96a0c7e442786e3e941ed5cacfeed Mon Sep 17 00:00:00 2001 From: Topi Reinio Date: Fri, 13 Feb 2015 10:37:35 +0100 Subject: [PATCH 01/10] qdoc: Clear the list of output files during generator init QDoc keeps a list of files it generates (or copies) to the output directory, for writing it to a .qhp file later on. In single-exec mode, QDoc processes several qdocconf files without deleting the generator in between. Therefore, we need to clear the list of files whenever the generator is initialized, to avoid duplicating the filenames across multiple .qhp files. Change-Id: Ibc2a6b171466aa1db6cfe3da9a820d5ba2845004 Reviewed-by: Martin Smith --- src/tools/qdoc/generator.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/tools/qdoc/generator.cpp b/src/tools/qdoc/generator.cpp index b2ce094871..587a7bc7ab 100644 --- a/src/tools/qdoc/generator.cpp +++ b/src/tools/qdoc/generator.cpp @@ -1516,6 +1516,7 @@ void Generator::initialize(const Config &config) if (config.getBool(QString("HTML.nosubdirs"))) resetUseOutputSubdirs(); + outFileNames_.clear(); outputFormats = config.getOutputFormats(); redirectDocumentationToDevNull_ = config.getBool(CONFIG_REDIRECTDOCUMENTATIONTODEVNULL); if (!outputFormats.isEmpty()) { From 1748b7e7d2f619dc32df7ccbd3aa24316aa63c82 Mon Sep 17 00:00:00 2001 From: "Richard J. Moore" Date: Sun, 8 Feb 2015 16:33:30 +0000 Subject: [PATCH 02/10] Use d2i_DHparams instead of poking around inside the DH struct. This change is a step closer to working with openssl 1.2 which makes this struct opaque. Change-Id: I3897142657edc0fa4053142b6ef743c2b00c013e Reviewed-by: Peter Hartmann --- src/network/ssl/qsslcontext_openssl.cpp | 49 ++++--------------- .../ssl/qsslsocket_openssl_symbols.cpp | 2 + .../ssl/qsslsocket_openssl_symbols_p.h | 2 + 3 files changed, 13 insertions(+), 40 deletions(-) diff --git a/src/network/ssl/qsslcontext_openssl.cpp b/src/network/ssl/qsslcontext_openssl.cpp index f91af9db74..f30f77d206 100644 --- a/src/network/ssl/qsslcontext_openssl.cpp +++ b/src/network/ssl/qsslcontext_openssl.cpp @@ -49,49 +49,18 @@ QT_BEGIN_NAMESPACE extern int q_X509Callback(int ok, X509_STORE_CTX *ctx); extern QString getErrorsFromOpenSsl(); -// Default DH params -// 1024-bit MODP Group with 160-bit Prime Order Subgroup -// From RFC 5114 -static unsigned const char dh1024_p[]={ - 0xB1,0x0B,0x8F,0x96,0xA0,0x80,0xE0,0x1D,0xDE,0x92,0xDE,0x5E, - 0xAE,0x5D,0x54,0xEC,0x52,0xC9,0x9F,0xBC,0xFB,0x06,0xA3,0xC6, - 0x9A,0x6A,0x9D,0xCA,0x52,0xD2,0x3B,0x61,0x60,0x73,0xE2,0x86, - 0x75,0xA2,0x3D,0x18,0x98,0x38,0xEF,0x1E,0x2E,0xE6,0x52,0xC0, - 0x13,0xEC,0xB4,0xAE,0xA9,0x06,0x11,0x23,0x24,0x97,0x5C,0x3C, - 0xD4,0x9B,0x83,0xBF,0xAC,0xCB,0xDD,0x7D,0x90,0xC4,0xBD,0x70, - 0x98,0x48,0x8E,0x9C,0x21,0x9A,0x73,0x72,0x4E,0xFF,0xD6,0xFA, - 0xE5,0x64,0x47,0x38,0xFA,0xA3,0x1A,0x4F,0xF5,0x5B,0xCC,0xC0, - 0xA1,0x51,0xAF,0x5F,0x0D,0xC8,0xB4,0xBD,0x45,0xBF,0x37,0xDF, - 0x36,0x5C,0x1A,0x65,0xE6,0x8C,0xFD,0xA7,0x6D,0x4D,0xA7,0x08, - 0xDF,0x1F,0xB2,0xBC,0x2E,0x4A,0x43,0x71 -}; - -static unsigned const char dh1024_g[]={ - 0xA4,0xD1,0xCB,0xD5,0xC3,0xFD,0x34,0x12,0x67,0x65,0xA4,0x42, - 0xEF,0xB9,0x99,0x05,0xF8,0x10,0x4D,0xD2,0x58,0xAC,0x50,0x7F, - 0xD6,0x40,0x6C,0xFF,0x14,0x26,0x6D,0x31,0x26,0x6F,0xEA,0x1E, - 0x5C,0x41,0x56,0x4B,0x77,0x7E,0x69,0x0F,0x55,0x04,0xF2,0x13, - 0x16,0x02,0x17,0xB4,0xB0,0x1B,0x88,0x6A,0x5E,0x91,0x54,0x7F, - 0x9E,0x27,0x49,0xF4,0xD7,0xFB,0xD7,0xD3,0xB9,0xA9,0x2E,0xE1, - 0x90,0x9D,0x0D,0x22,0x63,0xF8,0x0A,0x76,0xA6,0xA2,0x4C,0x08, - 0x7A,0x09,0x1F,0x53,0x1D,0xBF,0x0A,0x01,0x69,0xB6,0xA2,0x8A, - 0xD6,0x62,0xA4,0xD1,0x8E,0x73,0xAF,0xA3,0x2D,0x77,0x9D,0x59, - 0x18,0xD0,0x8B,0xC8,0x85,0x8F,0x4D,0xCE,0xF9,0x7C,0x2A,0x24, - 0x85,0x5E,0x6E,0xEB,0x22,0xB3,0xB2,0xE5 -}; - static DH *get_dh1024() { - DH *dh = q_DH_new(); - if (!dh) - return 0; + // Default DH params + // 1024-bit MODP Group + // From RFC 2409 + QByteArray params = QByteArray::fromBase64( + QByteArrayLiteral("MIGHAoGBAP//////////yQ/aoiFowjTExmKLgNwc0SkCTgiKZ8x0Agu+pjsTmyJR" \ + "Sgh5jjQE3e+VGbPNOkMbMCsKbfJfFDdP4TVtbVHCReSFtXZiXn7G9ExC6aY37WsL" \ + "/1y29Aa37e44a/taiZ+lrp8kEXxLH+ZJKGZR7OZTgf//////////AgEC")); - dh->p = q_BN_bin2bn(dh1024_p, sizeof(dh1024_p), 0); - dh->g = q_BN_bin2bn(dh1024_g, sizeof(dh1024_g), 0); - if (!dh->p || !dh->g) { - q_DH_free(dh); - return 0; - } + const char *ptr = params.constData(); + DH *dh = q_d2i_DHparams(NULL, (unsigned char **)(&ptr), params.length()); return dh; } diff --git a/src/network/ssl/qsslsocket_openssl_symbols.cpp b/src/network/ssl/qsslsocket_openssl_symbols.cpp index 135e9e5b6d..7d29e25e33 100644 --- a/src/network/ssl/qsslsocket_openssl_symbols.cpp +++ b/src/network/ssl/qsslsocket_openssl_symbols.cpp @@ -399,6 +399,7 @@ DEFINEFUNC3(void, SSL_get0_next_proto_negotiated, const SSL *s, s, #endif // OPENSSL_VERSION_NUMBER >= 0x1000100fL ... DEFINEFUNC(DH *, DH_new, DUMMYARG, DUMMYARG, return 0, return) DEFINEFUNC(void, DH_free, DH *dh, dh, return, DUMMYARG) +DEFINEFUNC3(DH *, d2i_DHparams, DH**a, a, unsigned char **pp, pp, long length, length, return 0, return); DEFINEFUNC3(BIGNUM *, BN_bin2bn, const unsigned char *s, s, int len, len, BIGNUM *ret, ret, return 0, return) #ifndef OPENSSL_NO_EC DEFINEFUNC(EC_KEY *, EC_KEY_dup, const EC_KEY *ec, ec, return 0, return) @@ -946,6 +947,7 @@ bool q_resolveOpenSslSymbols() #endif // OPENSSL_VERSION_NUMBER >= 0x1000100fL ... RESOLVEFUNC(DH_new) RESOLVEFUNC(DH_free) + RESOLVEFUNC(d2i_DHparams) RESOLVEFUNC(BN_bin2bn) #ifndef OPENSSL_NO_EC RESOLVEFUNC(EC_KEY_dup) diff --git a/src/network/ssl/qsslsocket_openssl_symbols_p.h b/src/network/ssl/qsslsocket_openssl_symbols_p.h index 4f3296fafa..aedd477b39 100644 --- a/src/network/ssl/qsslsocket_openssl_symbols_p.h +++ b/src/network/ssl/qsslsocket_openssl_symbols_p.h @@ -440,6 +440,8 @@ STACK_OF(X509) *q_X509_STORE_CTX_get_chain(X509_STORE_CTX *ctx); // Diffie-Hellman support DH *q_DH_new(); void q_DH_free(DH *dh); +DH *q_d2i_DHparams(DH **a, unsigned char **pp, long length); + BIGNUM *q_BN_bin2bn(const unsigned char *s, int len, BIGNUM *ret); #define q_SSL_CTX_set_tmp_dh(ctx, dh) q_SSL_CTX_ctrl((ctx), SSL_CTRL_SET_TMP_DH, 0, (char *)dh) From effc6b4cd15aefa1bef30c27f0458390735fafb5 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Thu, 12 Feb 2015 15:28:12 +0100 Subject: [PATCH 03/10] Add widget support for requestUpdate() and improve its docs and tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We must do something when requestUpdate() is called on a QWidgetWindow. The semantics of UpdateRequest for QWindow and QWidget are unfortunately different: for widgets an UpdateRequest means "sync the backing store". For QWindow it also involves marking as dirty. Change-Id: Idf40b3fc0873652dc081edeb12c96b3007a126ef Reviewed-by: Morten Johan Sørvig Reviewed-by: Jørgen Lind --- src/gui/kernel/qwindow.cpp | 13 ++++++---- src/widgets/kernel/qwidgetwindow.cpp | 12 +++++++++- tests/auto/gui/kernel/qwindow/tst_qwindow.cpp | 20 ++++++++++++++++ .../qopenglwidget/tst_qopenglwidget.cpp | 24 +++++++++++++++++++ 4 files changed, 64 insertions(+), 5 deletions(-) diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp index 1fbb67fb8a..4a88988322 100644 --- a/src/gui/kernel/qwindow.cpp +++ b/src/gui/kernel/qwindow.cpp @@ -2078,11 +2078,16 @@ void QWindowPrivate::deliverUpdateRequest() Calling this function multiple times will result in a single event being delivered to the window. - Subclasses of QWindow should reimplement QWindow::event(), intercept - the event and call the application's rendering code, then call the - base class implementation. -*/ + Subclasses of QWindow should reimplement event(), intercept the event and + call the application's rendering code, then call the base class + implementation. + \note The subclass' reimplementation of event() must invoke the base class + implementation, unless it is absolutely sure that the event does not need to + be handled by the base class. For example, the default implementation of + this function relies on QEvent::Timer events. Filtering them away would + therefore break the delivery of the update events. +*/ void QWindow::requestUpdate() { Q_D(QWindow); diff --git a/src/widgets/kernel/qwidgetwindow.cpp b/src/widgets/kernel/qwidgetwindow.cpp index 11dfe8a6d5..6c7dc070d5 100644 --- a/src/widgets/kernel/qwidgetwindow.cpp +++ b/src/widgets/kernel/qwidgetwindow.cpp @@ -292,11 +292,21 @@ bool QWidgetWindow::event(QEvent *event) case QEvent::WindowBlocked: qt_button_down = 0; break; + + case QEvent::UpdateRequest: + // This is not the same as an UpdateRequest for a QWidget. That just + // syncs the backing store while here we also must mark as dirty. + m_widget->repaint(); + return true; + default: break; } - return m_widget->event(event) || QWindow::event(event); + if (m_widget->event(event) && event->type() != QEvent::Timer) + return true; + + return QWindow::event(event); } QPointer qt_last_mouse_receiver = 0; diff --git a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp index e542c85218..89490525c9 100644 --- a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp +++ b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp @@ -91,6 +91,7 @@ private slots: void modalWindowModallity(); void modalWindowPosition(); void windowsTransientChildren(); + void requestUpdate(); void initTestCase(); void cleanup(); @@ -1666,6 +1667,25 @@ void tst_QWindow::windowsTransientChildren() QVERIFY(isNativeWindowVisible(&child)); // Real children should be visible. } +void tst_QWindow::requestUpdate() +{ + QRect geometry(m_availableTopLeft + QPoint(80, 80), m_testWindowSize); + + Window window; + window.setGeometry(geometry); + window.show(); + QCoreApplication::processEvents(); + QTRY_VERIFY(window.isExposed()); + + QVERIFY(window.received(QEvent::UpdateRequest) == 0); + + window.requestUpdate(); + QTRY_VERIFY(window.received(QEvent::UpdateRequest) == 1); + + window.requestUpdate(); + QTRY_VERIFY(window.received(QEvent::UpdateRequest) == 2); +} + #include QTEST_MAIN(tst_QWindow) diff --git a/tests/auto/widgets/widgets/qopenglwidget/tst_qopenglwidget.cpp b/tests/auto/widgets/widgets/qopenglwidget/tst_qopenglwidget.cpp index ade70b0eec..0c0c50ac64 100644 --- a/tests/auto/widgets/widgets/qopenglwidget/tst_qopenglwidget.cpp +++ b/tests/auto/widgets/widgets/qopenglwidget/tst_qopenglwidget.cpp @@ -55,6 +55,7 @@ private slots: void reparentToAlreadyCreated(); void reparentToNotYetCreated(); void asViewport(); + void requestUpdate(); }; void tst_QOpenGLWidget::create() @@ -305,6 +306,29 @@ void tst_QOpenGLWidget::asViewport() QVERIFY(view->paintCount() == 0); } +class PaintCountWidget : public QOpenGLWidget +{ +public: + PaintCountWidget() : m_count(0) { } + void reset() { m_count = 0; } + void paintGL() Q_DECL_OVERRIDE { ++m_count; } + int m_count; +}; + +void tst_QOpenGLWidget::requestUpdate() +{ + PaintCountWidget w; + w.resize(640, 480); + w.show(); + QTest::qWaitForWindowExposed(&w); + + w.reset(); + QCOMPARE(w.m_count, 0); + + w.windowHandle()->requestUpdate(); + QTRY_VERIFY(w.m_count > 0); +} + QTEST_MAIN(tst_QOpenGLWidget) #include "tst_qopenglwidget.moc" From 478f319df95321a1569f8f3c1ce1fe0847abfbbd Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Mon, 16 Feb 2015 08:52:36 +0100 Subject: [PATCH 04/10] LocalSocket: Do not return early in waitForReadyRead Do not return early on Windows if bytes are still in the buffer. This is not in line with the behavior on other platforms, and also breaks apps where the caller knows that the bytes available are insufficient. [ChangeLog][Network][QLocalSocket] On Windows, waitForReadyRead now always waits for more data, even if bytes are still in the buffer. Task-number: QTBUG-16688 Change-Id: I1425a5780c7707295374934a6b5446ff8e148cc8 Reviewed-by: Oswald Buddenhagen --- src/network/socket/qlocalsocket_win.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/network/socket/qlocalsocket_win.cpp b/src/network/socket/qlocalsocket_win.cpp index 423ea99d04..ae39f78fe8 100644 --- a/src/network/socket/qlocalsocket_win.cpp +++ b/src/network/socket/qlocalsocket_win.cpp @@ -405,9 +405,6 @@ bool QLocalSocket::waitForReadyRead(int msecs) { Q_D(QLocalSocket); - if (bytesAvailable() > 0) - return true; - if (d->state != QLocalSocket::ConnectedState) return false; From 710cb8e2fc421b2ae752dd533f4d2eb9c4521f28 Mon Sep 17 00:00:00 2001 From: Yoann Lopes Date: Fri, 13 Feb 2015 16:41:58 +0100 Subject: [PATCH 05/10] Add configure option and tests for GStreamer. Qt Multimedia can be compiled with either GStreamer 0.10 or 1.0. 0.10 takes precedence over 1.0 if both are available (1.0 will be used by default in Qt 5.6). Auto-detection can be overridden with -gstreamer . Change-Id: I74d58d2c146c842902375b4d1e5e6e96d32addac Reviewed-by: Oswald Buddenhagen --- config.tests/unix/gstreamer/gstreamer.cpp | 42 ++++++++++++++ config.tests/unix/gstreamer/gstreamer.pro | 22 ++++++++ configure | 69 ++++++++++++++++++++++- 3 files changed, 132 insertions(+), 1 deletion(-) create mode 100644 config.tests/unix/gstreamer/gstreamer.cpp create mode 100644 config.tests/unix/gstreamer/gstreamer.pro diff --git a/config.tests/unix/gstreamer/gstreamer.cpp b/config.tests/unix/gstreamer/gstreamer.cpp new file mode 100644 index 0000000000..cc61498787 --- /dev/null +++ b/config.tests/unix/gstreamer/gstreamer.cpp @@ -0,0 +1,42 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part 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 The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/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. +** +** As a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#define GST_USE_UNSTABLE_API + +#include + +int main(int, char**) +{ + gst_is_initialized(); + return 0; +} diff --git a/config.tests/unix/gstreamer/gstreamer.pro b/config.tests/unix/gstreamer/gstreamer.pro new file mode 100644 index 0000000000..a5e158fa21 --- /dev/null +++ b/config.tests/unix/gstreamer/gstreamer.pro @@ -0,0 +1,22 @@ +SOURCES += gstreamer.cpp + +CONFIG += link_pkgconfig + +gst-0.10 { + PKGCONFIG_PRIVATE += \ + gstreamer-0.10 \ + gstreamer-base-0.10 \ + gstreamer-audio-0.10 \ + gstreamer-video-0.10 \ + gstreamer-pbutils-0.10 +} else:gst-1.0 { + PKGCONFIG_PRIVATE += \ + gstreamer-1.0 \ + gstreamer-base-1.0 \ + gstreamer-audio-1.0 \ + gstreamer-video-1.0 \ + gstreamer-pbutils-1.0 +} + +CONFIG -= qt + diff --git a/configure b/configure index 9c07e3713b..ecf223f074 100755 --- a/configure +++ b/configure @@ -644,6 +644,8 @@ CFG_QNX_IMF=auto CFG_LGMON=auto CFG_SYSTEM_PROXIES=no CFG_ANDROID_STYLE_ASSETS=yes +CFG_GSTREAMER=auto +CFG_GSTREAMER_VERSION="" # Target architecture CFG_ARCH= @@ -968,7 +970,17 @@ while [ "$#" -gt 0 ]; do shift; VAL=$1 fi - ;; + ;; + -gstreamer) + VAR=gstreamer + # this option may or may not be followed by an argument + if [ -z "$2" ] || echo "$2" | grep '^-' >/dev/null 2>&1; then + VAL=yes + else + shift; + VAL=$1 + fi + ;; -hostprefix) VAR=`echo $1 | sed 's,^-\(.*\),\1,'` # this option may or may not be followed by an argument @@ -1896,6 +1908,15 @@ while [ "$#" -gt 0 ]; do UNKNOWN_OPT=yes fi ;; + gstreamer) + if [ "$VAL" = "auto" ] || [ "$VAL" = "yes" ] || + [ "$VAL" = "0.10" ] || [ "$VAL" = "1.0" ] || + [ "$VAL" = "no" ]; then + CFG_GSTREAMER="$VAL" + else + UNKNOWN_OPT=yes + fi + ;; gtkstyle) if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then CFG_QGTKSTYLE="$VAL" @@ -2612,6 +2633,12 @@ Additional options: -no-libinput ........ Do not support libinput. * -libinput ........... Enable libinput support. + -no-gstreamer ....... Do not support GStreamer. + + -gstreamer Enable GStreamer support + With no parameter, this will attempt to auto-detect GStreamer 0.10 and + 1.0. GStreamer 0.10 is used by default when available. + Use 0.10 or 1.0 for to override auto-detection. + * -no-system-proxies .. Do not use system network proxies by default. -system-proxies ..... Use system network proxies by default. @@ -5852,6 +5879,42 @@ if [ "$CFG_AUDIO_BACKEND" = "auto" ]; then CFG_AUDIO_BACKEND=yes fi +# detect GStreamer support +if [ "$CFG_GSTREAMER" = "auto" ] || [ "$CFG_GSTREAMER" = "yes" ]; then + if compileTest unix/gstreamer "GStreamer 0.10" -config gst-0.10; then + CFG_GSTREAMER=yes + CFG_GSTREAMER_VERSION=0.10 + elif compileTest unix/gstreamer "GStreamer 1.0" -config gst-1.0; then + CFG_GSTREAMER=yes + CFG_GSTREAMER_VERSION=1.0 + else + if [ "$CFG_GSTREAMER" = "yes" ]; then + echo "GStreamer support cannot be enabled due to functionality tests!" + echo " Turn on verbose messaging (-v) to $0 to see the final report." + exit 1 + fi + CFG_GSTREAMER=no + fi +elif [ "$CFG_GSTREAMER" = "0.10" ]; then + if compileTest unix/gstreamer "GStreamer 0.10" -config gst-0.10; then + CFG_GSTREAMER=yes + CFG_GSTREAMER_VERSION=0.10 + else + echo "The GStreamer 0.10 functionality test failed!" + echo " Turn on verbose messaging (-v) to $0 to see the final report." + exit 1 + fi +elif [ "$CFG_GSTREAMER" = "1.0" ]; then + if compileTest unix/gstreamer "GStreamer 1.0" -config gst-1.0; then + CFG_GSTREAMER=yes + CFG_GSTREAMER_VERSION=1.0 + else + echo "The GStreamer 1.0 functionality test failed!" + echo " Turn on verbose messaging (-v) to $0 to see the final report." + exit 1 + fi +fi + if [ "$CFG_LARGEFILE" != "yes" ] && [ "$XPLATFORM_MINGW" = "yes" ]; then echo "Warning: largefile support cannot be disabled for win32." CFG_LARGEFILE="yes" @@ -6124,6 +6187,9 @@ if [ "$CFG_PULSEAUDIO" = "yes" ]; then QT_CONFIG="$QT_CONFIG pulseaudio" fi +[ "$CFG_GSTREAMER_VERSION" = "0.10" ] && QT_CONFIG="$QT_CONFIG gstreamer-0.10" +[ "$CFG_GSTREAMER_VERSION" = "1.0" ] && QT_CONFIG="$QT_CONFIG gstreamer-1.0" + if [ "$CFG_COREWLAN" = "yes" ]; then QT_CONFIG="$QT_CONFIG corewlan" fi @@ -6892,6 +6958,7 @@ report_support " Evdev .................." "$CFG_EVDEV" report_support " FontConfig ............." "$CFG_FONTCONFIG" report_support " FreeType ..............." "$CFG_FREETYPE" system "system library" yes "bundled copy" report_support " Glib ..................." "$CFG_GLIB" +report_support " GStreamer .............." "$CFG_GSTREAMER" yes "$CFG_GSTREAMER_VERSION" report_support " GTK theme .............." "$CFG_QGTKSTYLE" report_support " HarfBuzz ..............." "$CFG_HARFBUZZ" system "system library" qt "bundled copy" report_support " Iconv .................." "$CFG_ICONV" From 3d835eb62e70435fe32318441dc7c10aba3a6fba Mon Sep 17 00:00:00 2001 From: BogDan Vatra Date: Fri, 13 Feb 2015 18:26:48 +0200 Subject: [PATCH 06/10] Android: Fix compile on arm64-v8a Android arm64-v8a redefines _POSIX_C_SOURCE to 199506 if _XOPEN_SOURCE is defined. Change-Id: I04ff616eaac6e08094fc1f58f49bc5a2c31733f0 Reviewed-by: Daniel Teske Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/corelib/io/forkfd_qt.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/io/forkfd_qt.cpp b/src/corelib/io/forkfd_qt.cpp index ed96f9db20..56a39f8df0 100644 --- a/src/corelib/io/forkfd_qt.cpp +++ b/src/corelib/io/forkfd_qt.cpp @@ -35,7 +35,7 @@ #ifndef _POSIX_C_SOURCE # define _POSIX_C_SOURCE 200809L #endif -#if !defined(_XOPEN_SOURCE) && !defined(__QNXNTO__) +#if !defined(_XOPEN_SOURCE) && !defined(__QNXNTO__) && !defined(ANDROID) # define _XOPEN_SOURCE 500 #endif From 515e802ae20c045e5c47b400ee6ef6e92349c978 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Wed, 14 Jan 2015 11:17:47 +0100 Subject: [PATCH 07/10] Use C++ instead of Including math.h can pollute the default namespace, and break some compilers if cmath versions of the method are declared as using. Switching to C++ math functions also greatly simplifies handling of float qreal as C++ automatically chooses the right method. [ChangeLog][QtCore][QtMath] qmath.h no longer includes math.h, so any sources depending on that indirect inclusion may fail to build. Change-Id: I4d0e331dafba354ec05dc5052e61ef4ff8d387fe Reviewed-by: Rafael Roquetto --- config.tests/unix/floatmath/floatmath.cpp | 50 -------- config.tests/unix/floatmath/floatmath.pro | 3 - configure | 11 -- .../threads/mandelbrot/renderthread.cpp | 9 +- .../imagescaling/imagescaling.cpp | 4 +- .../widgets/animation/animatedtiles/main.cpp | 9 +- .../widgets/effects/blurpicker/blurpicker.cpp | 5 +- .../widgets/effects/lighting/lighting.cpp | 7 +- examples/widgets/graphicsview/boxes/qtbox.cpp | 10 +- examples/widgets/graphicsview/boxes/scene.cpp | 5 +- .../widgets/graphicsview/boxes/trackball.cpp | 7 +- examples/widgets/itemviews/chart/pieview.cpp | 6 +- .../itemviews/stardelegate/starrating.cpp | 6 +- .../itemviews/storageview/storagemodel.cpp | 5 +- .../widgets/painting/painterpaths/window.cpp | 6 +- .../basictools/basictoolsplugin.cpp | 6 +- .../widgets/widgets/calculator/calculator.cpp | 6 +- .../doc/snippets/code/doc_src_qiterator.cpp | 6 +- .../code/src_corelib_tools_qpoint.cpp | 2 +- src/corelib/kernel/qmath.h | 113 +++++------------- src/corelib/tools/qeasingcurve.cpp | 14 +-- src/gui/math3d/qmatrix4x4.cpp | 16 +-- src/gui/math3d/qquaternion.cpp | 54 ++++----- src/gui/math3d/qvector2d.cpp | 6 +- src/gui/math3d/qvector3d.cpp | 6 +- src/gui/math3d/qvector4d.cpp | 6 +- src/gui/opengl/qopenglpaintengine.cpp | 4 +- src/gui/opengl/qtriangulatingstroker_p.h | 6 +- src/gui/opengl/qtriangulator.cpp | 8 +- src/gui/painting/qdrawhelper.cpp | 8 +- src/gui/painting/qmath_p.h | 7 +- src/gui/painting/qrasterizer.cpp | 16 +-- src/gui/text/qdistancefield.cpp | 6 +- src/gui/text/qfontdatabase.cpp | 2 +- src/gui/util/qgridlayoutengine.cpp | 4 +- src/gui/util/qvalidator.cpp | 4 +- .../qpaintengineex_opengl2.cpp | 4 +- .../fontdatabases/mac/qfontengine_coretext.mm | 4 +- .../platforms/cocoa/qpaintengine_mac.mm | 4 +- .../windows/qwindowstabletsupport.cpp | 6 +- src/widgets/widgets/qdial.cpp | 6 +- 41 files changed, 171 insertions(+), 296 deletions(-) delete mode 100644 config.tests/unix/floatmath/floatmath.cpp delete mode 100644 config.tests/unix/floatmath/floatmath.pro diff --git a/config.tests/unix/floatmath/floatmath.cpp b/config.tests/unix/floatmath/floatmath.cpp deleted file mode 100644 index 4becf2a266..0000000000 --- a/config.tests/unix/floatmath/floatmath.cpp +++ /dev/null @@ -1,50 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the config.tests 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 The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/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. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include - -int main(int argc, char **argv) -{ - float c = ceilf(1.3f); - float f = floorf(1.7f); - float s = sinf(3.8); - float t = cosf(7.3); - float u = sqrtf(8.4); - float l = logf(9.2); - - if (c == 1.0f && f == 2.0f && s == 3.0f && t == 4.0f && u == 5.0f && l == 6.0f) - return 0; - else - return 1; -} - diff --git a/config.tests/unix/floatmath/floatmath.pro b/config.tests/unix/floatmath/floatmath.pro deleted file mode 100644 index 4c785638b2..0000000000 --- a/config.tests/unix/floatmath/floatmath.pro +++ /dev/null @@ -1,3 +0,0 @@ -SOURCES = floatmath.cpp -CONFIG -= x11 qt - diff --git a/configure b/configure index ecf223f074..f74af093b9 100755 --- a/configure +++ b/configure @@ -4261,13 +4261,6 @@ if [ "$CFG_CXX11" != "no" ]; then fi fi -# detect availability of float math.h functions -if compileTest unix/floatmath "floatmath"; then - CFG_USE_FLOATMATH=yes -else - CFG_USE_FLOATMATH=no -fi - # detect sse2 support if [ "${CFG_SSE2}" = "auto" ]; then if compileTest common/sse2 "sse2"; then @@ -6498,10 +6491,6 @@ fi # Add QPA to config.h QCONFIG_FLAGS="$QCONFIG_FLAGS" -if [ "${CFG_USE_FLOATMATH}" = "yes" ]; then - QCONFIG_FLAGS="${QCONFIG_FLAGS} QT_USE_MATH_H_FLOATS" -fi - # Add turned on SQL drivers for DRIVER in $CFG_SQL_AVAILABLE; do eval "VAL=\$CFG_SQL_$DRIVER" diff --git a/examples/corelib/threads/mandelbrot/renderthread.cpp b/examples/corelib/threads/mandelbrot/renderthread.cpp index e114fa0e7e..d52a5f2320 100644 --- a/examples/corelib/threads/mandelbrot/renderthread.cpp +++ b/examples/corelib/threads/mandelbrot/renderthread.cpp @@ -41,8 +41,7 @@ #include "renderthread.h" #include - -#include +#include //! [0] RenderThread::RenderThread(QObject *parent) @@ -207,9 +206,9 @@ uint RenderThread::rgbFromWaveLength(double wave) else if (wave < 420.0) s = 0.3 + 0.7 * (wave - 380.0) / (420.0 - 380.0); - r = pow(r * s, 0.8); - g = pow(g * s, 0.8); - b = pow(b * s, 0.8); + r = std::pow(r * s, 0.8); + g = std::pow(g * s, 0.8); + b = std::pow(b * s, 0.8); return qRgb(int(r * 255), int(g * 255), int(b * 255)); } //! [10] diff --git a/examples/qtconcurrent/imagescaling/imagescaling.cpp b/examples/qtconcurrent/imagescaling/imagescaling.cpp index 15b0e7ca5b..169531119a 100644 --- a/examples/qtconcurrent/imagescaling/imagescaling.cpp +++ b/examples/qtconcurrent/imagescaling/imagescaling.cpp @@ -38,7 +38,7 @@ ** ****************************************************************************/ #include "imagescaling.h" -#include "math.h" +#include const int imageSize = 100; @@ -110,7 +110,7 @@ void Images::open() qDeleteAll(labels); labels.clear(); - int dim = sqrt(qreal(files.count())) + 1; + int dim = qSqrt(qreal(files.count())) + 1; for (int i = 0; i < dim; ++i) { for (int j = 0; j < dim; ++j) { QLabel *imageLabel = new QLabel; diff --git a/examples/widgets/animation/animatedtiles/main.cpp b/examples/widgets/animation/animatedtiles/main.cpp index f51f69f1ac..5802d0f4cd 100644 --- a/examples/widgets/animation/animatedtiles/main.cpp +++ b/examples/widgets/animation/animatedtiles/main.cpp @@ -39,6 +39,7 @@ ****************************************************************************/ #include +#include #include class Pixmap : public QObject, public QGraphicsPixmapItem @@ -181,13 +182,13 @@ int main(int argc, char **argv) Pixmap *item = items.at(i); // Ellipse ellipseState->assignProperty(item, "pos", - QPointF(cos((i / 63.0) * 6.28) * 250, - sin((i / 63.0) * 6.28) * 250)); + QPointF(qCos((i / 63.0) * 6.28) * 250, + qSin((i / 63.0) * 6.28) * 250)); // Figure 8 figure8State->assignProperty(item, "pos", - QPointF(sin((i / 63.0) * 6.28) * 250, - sin(((i * 2)/63.0) * 6.28) * 250)); + QPointF(qSin((i / 63.0) * 6.28) * 250, + qSin(((i * 2)/63.0) * 6.28) * 250)); // Random randomState->assignProperty(item, "pos", diff --git a/examples/widgets/effects/blurpicker/blurpicker.cpp b/examples/widgets/effects/blurpicker/blurpicker.cpp index f354a15c53..b5ac7950bd 100644 --- a/examples/widgets/effects/blurpicker/blurpicker.cpp +++ b/examples/widgets/effects/blurpicker/blurpicker.cpp @@ -41,6 +41,7 @@ #include "blurpicker.h" #include +#include #include "blureffect.h" @@ -76,8 +77,8 @@ void BlurPicker::setIndex(qreal index) for (int i = 0; i < m_icons.count(); ++i) { QGraphicsItem *icon = m_icons[i]; qreal a = ((i + m_index) * 2 * M_PI) / m_icons.count(); - qreal xs = 170 * sin(a); - qreal ys = 100 * cos(a); + qreal xs = 170 * qSin(a); + qreal ys = 100 * qCos(a); QPointF pos(xs, ys); pos = QTransform().rotate(-20).map(pos); pos -= QPointF(40, 40); diff --git a/examples/widgets/effects/lighting/lighting.cpp b/examples/widgets/effects/lighting/lighting.cpp index 1bf18160b4..67bcb8147b 100644 --- a/examples/widgets/effects/lighting/lighting.cpp +++ b/examples/widgets/effects/lighting/lighting.cpp @@ -41,6 +41,7 @@ #include "lighting.h" #include +#include #ifndef M_PI #define M_PI 3.14159265358979323846 @@ -110,8 +111,8 @@ void Lighting::setupScene() void Lighting::animate() { angle += (M_PI / 30); - qreal xs = 200 * sin(angle) - 40 + 25; - qreal ys = 200 * cos(angle) - 40 + 25; + qreal xs = 200 * qSin(angle) - 40 + 25; + qreal ys = 200 * qCos(angle) - 40 + 25; m_lightSource->setPos(xs, ys); for (int i = 0; i < m_items.size(); ++i) { @@ -125,7 +126,7 @@ void Lighting::animate() qreal dx = delta.x(); qreal dy = delta.y(); - qreal dd = sqrt(dx * dx + dy * dy); + qreal dd = qSqrt(dx * dx + dy * dy); QColor color = effect->color(); color.setAlphaF(qBound(0.4, 1 - dd / 200.0, 0.7)); effect->setColor(color); diff --git a/examples/widgets/graphicsview/boxes/qtbox.cpp b/examples/widgets/graphicsview/boxes/qtbox.cpp index e368ddb307..5e142832e0 100644 --- a/examples/widgets/graphicsview/boxes/qtbox.cpp +++ b/examples/widgets/graphicsview/boxes/qtbox.cpp @@ -242,7 +242,7 @@ void ItemBase::keyPressEvent(QKeyEvent *event) void ItemBase::wheelEvent(QGraphicsSceneWheelEvent *event) { prepareGeometryChange(); - m_size = int(m_size * exp(-event->delta() / 600.0)); + m_size = int(m_size * qExp(-event->delta() / 600.0)); if (m_size > MAX_ITEM_SIZE) m_size = MAX_ITEM_SIZE; else if (m_size < MIN_ITEM_SIZE) @@ -404,10 +404,10 @@ void CircleItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option { int dt = m_startTime.msecsTo(QTime::currentTime()); - qreal r0 = 0.5 * m_size * (1.0 - exp(-0.001 * ((dt + 3800) % 4000))); - qreal r1 = 0.5 * m_size * (1.0 - exp(-0.001 * ((dt + 0) % 4000))); - qreal r2 = 0.5 * m_size * (1.0 - exp(-0.001 * ((dt + 1800) % 4000))); - qreal r3 = 0.5 * m_size * (1.0 - exp(-0.001 * ((dt + 2000) % 4000))); + qreal r0 = 0.5 * m_size * (1.0 - qExp(-0.001 * ((dt + 3800) % 4000))); + qreal r1 = 0.5 * m_size * (1.0 - qExp(-0.001 * ((dt + 0) % 4000))); + qreal r2 = 0.5 * m_size * (1.0 - qExp(-0.001 * ((dt + 1800) % 4000))); + qreal r3 = 0.5 * m_size * (1.0 - qExp(-0.001 * ((dt + 2000) % 4000))); if (r0 > r1) r0 = 0.0; diff --git a/examples/widgets/graphicsview/boxes/scene.cpp b/examples/widgets/graphicsview/boxes/scene.cpp index 2ca061a43a..48bdcb9d93 100644 --- a/examples/widgets/graphicsview/boxes/scene.cpp +++ b/examples/widgets/graphicsview/boxes/scene.cpp @@ -35,6 +35,7 @@ #include "scene.h" #include #include +#include #include "3rdparty/fbm.h" @@ -856,7 +857,7 @@ void Scene::renderCubemaps() float angle = 2.0f * PI * i / m_cubemaps.size(); - center = m_trackBalls[1].rotation().rotatedVector(QVector3D(cos(angle), sin(angle), 0.0f)); + center = m_trackBalls[1].rotation().rotatedVector(QVector3D(std::cos(angle), std::sin(angle), 0.0f)); for (int face = 0; face < 6; ++face) { m_cubemaps[i]->begin(face); @@ -910,7 +911,7 @@ void Scene::drawBackground(QPainter *painter, const QRectF &) QMatrix4x4 view; view.rotate(m_trackBalls[2].rotation()); - view(2, 3) -= 2.0f * exp(m_distExp / 1200.0f); + view(2, 3) -= 2.0f * std::exp(m_distExp / 1200.0f); renderBoxes(view); defaultStates(); diff --git a/examples/widgets/graphicsview/boxes/trackball.cpp b/examples/widgets/graphicsview/boxes/trackball.cpp index 2267636fa4..b1159b4989 100644 --- a/examples/widgets/graphicsview/boxes/trackball.cpp +++ b/examples/widgets/graphicsview/boxes/trackball.cpp @@ -33,6 +33,7 @@ #include "trackball.h" #include "scene.h" +#include //============================================================================// // TrackBall // @@ -94,19 +95,19 @@ void TrackBall::move(const QPointF& p, const QQuaternion &transformation) QVector3D lastPos3D = QVector3D(m_lastPos.x(), m_lastPos.y(), 0.0f); float sqrZ = 1 - QVector3D::dotProduct(lastPos3D, lastPos3D); if (sqrZ > 0) - lastPos3D.setZ(sqrt(sqrZ)); + lastPos3D.setZ(std::sqrt(sqrZ)); else lastPos3D.normalize(); QVector3D currentPos3D = QVector3D(p.x(), p.y(), 0.0f); sqrZ = 1 - QVector3D::dotProduct(currentPos3D, currentPos3D); if (sqrZ > 0) - currentPos3D.setZ(sqrt(sqrZ)); + currentPos3D.setZ(std::sqrt(sqrZ)); else currentPos3D.normalize(); m_axis = QVector3D::crossProduct(lastPos3D, currentPos3D); - float angle = 180 / PI * asin(sqrt(QVector3D::dotProduct(m_axis, m_axis))); + float angle = 180 / PI * std::asin(std::sqrt(QVector3D::dotProduct(m_axis, m_axis))); m_angularVelocity = angle / msecs; m_axis.normalize(); diff --git a/examples/widgets/itemviews/chart/pieview.cpp b/examples/widgets/itemviews/chart/pieview.cpp index 6e55afa5f0..9793e7d89b 100644 --- a/examples/widgets/itemviews/chart/pieview.cpp +++ b/examples/widgets/itemviews/chart/pieview.cpp @@ -38,8 +38,8 @@ ** ****************************************************************************/ -#include #include +#include #ifndef M_PI #define M_PI 3.1415927 @@ -109,13 +109,13 @@ QModelIndex PieView::indexAt(const QPoint &point) const double cy = totalSize / 2 - wy; // positive cy for items above the center // Determine the distance from the center point of the pie chart. - double d = pow(pow(cx, 2) + pow(cy, 2), 0.5); + double d = std::sqrt(std::pow(cx, 2) + std::pow(cy, 2)); if (d == 0 || d > pieSize / 2) return QModelIndex(); // Determine the angle of the point. - double angle = (180 / M_PI) * acos(cx / d); + double angle = (180 / M_PI) * std::acos(cx / d); if (cy < 0) angle = 360 - angle; diff --git a/examples/widgets/itemviews/stardelegate/starrating.cpp b/examples/widgets/itemviews/stardelegate/starrating.cpp index af67ae11da..568666f93a 100644 --- a/examples/widgets/itemviews/stardelegate/starrating.cpp +++ b/examples/widgets/itemviews/stardelegate/starrating.cpp @@ -39,7 +39,7 @@ ****************************************************************************/ #include -#include +#include #include "starrating.h" @@ -53,8 +53,8 @@ StarRating::StarRating(int starCount, int maxStarCount) starPolygon << QPointF(1.0, 0.5); for (int i = 1; i < 5; ++i) - starPolygon << QPointF(0.5 + 0.5 * cos(0.8 * i * 3.14), - 0.5 + 0.5 * sin(0.8 * i * 3.14)); + starPolygon << QPointF(0.5 + 0.5 * std::cos(0.8 * i * 3.14), + 0.5 + 0.5 * std::sin(0.8 * i * 3.14)); diamondPolygon << QPointF(0.4, 0.5) << QPointF(0.5, 0.4) << QPointF(0.6, 0.5) << QPointF(0.5, 0.6) diff --git a/examples/widgets/itemviews/storageview/storagemodel.cpp b/examples/widgets/itemviews/storageview/storagemodel.cpp index d70f53ce89..9f8d229c77 100644 --- a/examples/widgets/itemviews/storageview/storagemodel.cpp +++ b/examples/widgets/itemviews/storageview/storagemodel.cpp @@ -43,6 +43,7 @@ #include #include +#include static QString sizeToString(qint64 size) { @@ -51,11 +52,11 @@ static QString sizeToString(qint64 size) if (size <= 0) return StorageModel::tr("0 b"); - double power = log((double)size)/log(1024.0); + double power = std::log((double)size)/std::log(1024.0); int intPower = (int)power; intPower = intPower >= 8 ? 8 - 1 : intPower; - double normSize = size / pow(1024.0, intPower); + double normSize = size / std::pow(1024.0, intPower); //: this should expand to "1.23 GB" return StorageModel::tr("%1 %2").arg(normSize, 0, 'f', intPower > 0 ? 2 : 0).arg(strings[intPower]); } diff --git a/examples/widgets/painting/painterpaths/window.cpp b/examples/widgets/painting/painterpaths/window.cpp index 5b1acf9c01..d3311075f5 100644 --- a/examples/widgets/painting/painterpaths/window.cpp +++ b/examples/widgets/painting/painterpaths/window.cpp @@ -43,7 +43,7 @@ #include -#include +#include //! [0] const float Pi = 3.14159f; @@ -123,8 +123,8 @@ Window::Window() QPainterPath starPath; starPath.moveTo(90, 50); for (int i = 1; i < 5; ++i) { - starPath.lineTo(50 + 40 * cos(0.8 * i * Pi), - 50 + 40 * sin(0.8 * i * Pi)); + starPath.lineTo(50 + 40 * std::cos(0.8 * i * Pi), + 50 + 40 * std::sin(0.8 * i * Pi)); } starPath.closeSubpath(); //! [9] diff --git a/examples/widgets/tools/plugandpaintplugins/basictools/basictoolsplugin.cpp b/examples/widgets/tools/plugandpaintplugins/basictools/basictoolsplugin.cpp index b3e45b585b..a5ca14a39c 100644 --- a/examples/widgets/tools/plugandpaintplugins/basictools/basictoolsplugin.cpp +++ b/examples/widgets/tools/plugandpaintplugins/basictools/basictoolsplugin.cpp @@ -40,7 +40,7 @@ #include -#include +#include #include #include "basictoolsplugin.h" @@ -139,8 +139,8 @@ QPainterPath BasicToolsPlugin::generateShape(const QString &shape, } else if (shape == tr("Star")) { path.moveTo(90, 50); for (int i = 1; i < 5; ++i) { - path.lineTo(50 + 40 * cos(0.8 * i * Pi), - 50 + 40 * sin(0.8 * i * Pi)); + path.lineTo(50 + 40 * std::cos(0.8 * i * Pi), + 50 + 40 * std::sin(0.8 * i * Pi)); } path.closeSubpath(); } else if (shape == tr("Text...")) { diff --git a/examples/widgets/widgets/calculator/calculator.cpp b/examples/widgets/widgets/calculator/calculator.cpp index 620c61a804..e76011ee0d 100644 --- a/examples/widgets/widgets/calculator/calculator.cpp +++ b/examples/widgets/widgets/calculator/calculator.cpp @@ -40,7 +40,7 @@ #include -#include +#include #include "button.h" #include "calculator.h" @@ -164,9 +164,9 @@ void Calculator::unaryOperatorClicked() abortOperation(); return; } - result = sqrt(operand); + result = std::sqrt(operand); } else if (clickedOperator == tr("x\302\262")) { - result = pow(operand, 2.0); + result = std::pow(operand, 2.0); } else if (clickedOperator == tr("1/x")) { if (operand == 0.0) { abortOperation(); diff --git a/src/corelib/doc/snippets/code/doc_src_qiterator.cpp b/src/corelib/doc/snippets/code/doc_src_qiterator.cpp index e37212b475..c311db957c 100644 --- a/src/corelib/doc/snippets/code/doc_src_qiterator.cpp +++ b/src/corelib/doc/snippets/code/doc_src_qiterator.cpp @@ -257,7 +257,7 @@ while (i.hasNext()) { QMutableListIterator i(list); while (i.hasNext()) { double val = i.next(); - i.setValue(sqrt(val)); + i.setValue(std::sqrt(val)); } //! [23] @@ -266,7 +266,7 @@ while (i.hasNext()) { QMutableLinkedListIterator i(list); while (i.hasNext()) { double val = i.next(); - i.setValue(sqrt(val)); + i.setValue(std::sqrt(val)); } //! [24] @@ -275,7 +275,7 @@ while (i.hasNext()) { QMutableVectorIterator i(list); while (i.hasNext()) { double val = i.next(); - i.setValue(sqrt(val)); + i.setValue(std::sqrt(val)); } //! [25] diff --git a/src/corelib/doc/snippets/code/src_corelib_tools_qpoint.cpp b/src/corelib/doc/snippets/code/src_corelib_tools_qpoint.cpp index 17a252cc1b..b545c2dad8 100644 --- a/src/corelib/doc/snippets/code/src_corelib_tools_qpoint.cpp +++ b/src/corelib/doc/snippets/code/src_corelib_tools_qpoint.cpp @@ -105,7 +105,7 @@ MyWidget::mouseMoveEvent(QMouseEvent *event) //! [8] -double trueLength = sqrt(pow(x(), 2) + pow(y(), 2)); +double trueLength = std::sqrt(std::pow(x(), 2) + std::pow(y(), 2)); //! [8] diff --git a/src/corelib/kernel/qmath.h b/src/corelib/kernel/qmath.h index 2395e9ee1c..5cc3ec586e 100644 --- a/src/corelib/kernel/qmath.h +++ b/src/corelib/kernel/qmath.h @@ -38,153 +38,98 @@ #pragma qt_class(QtMath) #endif -#include - #include -#include + +#include QT_BEGIN_NAMESPACE - #define QT_SINE_TABLE_SIZE 256 extern Q_CORE_EXPORT const qreal qt_sine_table[QT_SINE_TABLE_SIZE]; inline int qCeil(qreal v) { -#ifdef QT_USE_MATH_H_FLOATS - if (sizeof(qreal) == sizeof(float)) - return int(ceilf(float(v))); - else -#endif - return int(ceil(v)); + using std::ceil; + return int(ceil(v)); } inline int qFloor(qreal v) { -#ifdef QT_USE_MATH_H_FLOATS - if (sizeof(qreal) == sizeof(float)) - return int(floorf(float(v))); - else -#endif - return int(floor(v)); + using std::floor; + return int(floor(v)); } inline qreal qFabs(qreal v) { -#ifdef QT_USE_MATH_H_FLOATS - if(sizeof(qreal) == sizeof(float)) - return fabsf(float(v)); - else -#endif - return fabs(v); + using std::fabs; + return fabs(v); } inline qreal qSin(qreal v) { -#ifdef QT_USE_MATH_H_FLOATS - if (sizeof(qreal) == sizeof(float)) - return sinf(float(v)); - else -#endif - return sin(v); + using std::sin; + return sin(v); } inline qreal qCos(qreal v) { -#ifdef QT_USE_MATH_H_FLOATS - if (sizeof(qreal) == sizeof(float)) - return cosf(float(v)); - else -#endif - return cos(v); + using std::cos; + return cos(v); } inline qreal qTan(qreal v) { -#ifdef QT_USE_MATH_H_FLOATS - if (sizeof(qreal) == sizeof(float)) - return tanf(float(v)); - else -#endif - return tan(v); + using std::tan; + return tan(v); } inline qreal qAcos(qreal v) { -#ifdef QT_USE_MATH_H_FLOATS - if (sizeof(qreal) == sizeof(float)) - return acosf(float(v)); - else -#endif - return acos(v); + using std::acos; + return acos(v); } inline qreal qAsin(qreal v) { -#ifdef QT_USE_MATH_H_FLOATS - if (sizeof(qreal) == sizeof(float)) - return asinf(float(v)); - else -#endif - return asin(v); + using std::asin; + return asin(v); } inline qreal qAtan(qreal v) { -#ifdef QT_USE_MATH_H_FLOATS - if (sizeof(qreal) == sizeof(float)) - return atanf(float(v)); - else -#endif - return atan(v); + using std::atan; + return atan(v); } inline qreal qAtan2(qreal y, qreal x) { -#ifdef QT_USE_MATH_H_FLOATS - if (sizeof(qreal) == sizeof(float)) - return atan2f(float(y), float(x)); - else -#endif - return atan2(y, x); + using std::atan2; + return atan2(y, x); } inline qreal qSqrt(qreal v) { -#ifdef QT_USE_MATH_H_FLOATS - if (sizeof(qreal) == sizeof(float)) - return sqrtf(float(v)); - else -#endif - return sqrt(v); + using std::sqrt; + return sqrt(v); } inline qreal qLn(qreal v) { -#ifdef QT_USE_MATH_H_FLOATS - if (sizeof(qreal) == sizeof(float)) - return logf(float(v)); - else -#endif - return log(v); + using std::log; + return log(v); } inline qreal qExp(qreal v) { - // only one signature - // exists, exp(double) + using std::exp; return exp(v); } inline qreal qPow(qreal x, qreal y) { -#ifdef QT_USE_MATH_H_FLOATS - if (sizeof(qreal) == sizeof(float)) - return powf(float(x), float(y)); - else -#endif - return pow(x, y); + using std::pow; + return pow(x, y); } #ifndef M_E diff --git a/src/corelib/tools/qeasingcurve.cpp b/src/corelib/tools/qeasingcurve.cpp index c1d74b3b43..1bd9c5ebb9 100644 --- a/src/corelib/tools/qeasingcurve.cpp +++ b/src/corelib/tools/qeasingcurve.cpp @@ -657,7 +657,7 @@ struct BezierEase : public QEasingCurveFunction qreal static inline _acos(qreal x) { - return sqrt(1-x)*(1.5707963267948966192313216916398f + x*(-0.213300989f + x*(0.077980478f + x*-0.02164095f))); + return std::sqrt(1-x)*(1.5707963267948966192313216916398f + x*(-0.213300989f + x*(0.077980478f + x*-0.02164095f))); } qreal static inline _cos(qreal x) //super fast _cos @@ -704,8 +704,8 @@ struct BezierEase : public QEasingCurveFunction //We use approximations instead const qreal x_squared = x * x; - const qreal x_plus_one_sqrt = sqrt(1.0 + x); - const qreal one_minus_x_sqrt = sqrt(1.0 - x); + const qreal x_plus_one_sqrt = qSqrt(1.0 + x); + const qreal one_minus_x_sqrt = qSqrt(1.0 - x); //cos(acos(x) / 3) //s1 = _cos(_acos(x) / 3); @@ -743,7 +743,7 @@ struct BezierEase : public QEasingCurveFunction const qreal D = 0.25 * q_squared + p_cubic / 27.0; if (D >= 0) { - const qreal D_sqrt = sqrt(D); + const qreal D_sqrt = qSqrt(D); qreal u = _cbrt( -q * 0.5 + D_sqrt); qreal v = _cbrt( -q * 0.5 - D_sqrt); qreal z1 = u + v; @@ -758,13 +758,13 @@ struct BezierEase : public QEasingCurveFunction } //casus irreducibilis - const qreal p_minus_sqrt = sqrt(-p); + const qreal p_minus_sqrt = qSqrt(-p); //const qreal f = sqrt(4.0 / 3.0 * -p); - const qreal f = sqrt(4.0 / 3.0) * p_minus_sqrt; + const qreal f = qSqrt(4.0 / 3.0) * p_minus_sqrt; //const qreal sqrtP = sqrt(27.0 / -p_cubic); - const qreal sqrtP = -3.0*sqrt(3.0) / (p_minus_sqrt * p); + const qreal sqrtP = -3.0*qSqrt(3.0) / (p_minus_sqrt * p); const qreal g = -q * 0.5 * sqrtP; diff --git a/src/gui/math3d/qmatrix4x4.cpp b/src/gui/math3d/qmatrix4x4.cpp index 42aae6c20c..c196f7cff8 100644 --- a/src/gui/math3d/qmatrix4x4.cpp +++ b/src/gui/math3d/qmatrix4x4.cpp @@ -1125,8 +1125,8 @@ void QMatrix4x4::rotate(float angle, float x, float y, float z) c = -1.0f; } else { float a = angle * M_PI / 180.0f; - c = cosf(a); - s = sinf(a); + c = std::cos(a); + s = std::sin(a); } if (x == 0.0f) { if (y == 0.0f) { @@ -1186,7 +1186,7 @@ void QMatrix4x4::rotate(float angle, float x, float y, float z) double(y) * double(y) + double(z) * double(z); if (!qFuzzyCompare(len, 1.0) && !qFuzzyIsNull(len)) { - len = sqrt(len); + len = std::sqrt(len); x = float(double(x) / len); y = float(double(y) / len); z = float(double(z) / len); @@ -1234,8 +1234,8 @@ void QMatrix4x4::projectedRotate(float angle, float x, float y, float z) c = -1.0f; } else { float a = angle * M_PI / 180.0f; - c = cosf(a); - s = sinf(a); + c = std::cos(a); + s = std::sin(a); } if (x == 0.0f) { if (y == 0.0f) { @@ -1282,7 +1282,7 @@ void QMatrix4x4::projectedRotate(float angle, float x, float y, float z) double(y) * double(y) + double(z) * double(z); if (!qFuzzyCompare(len, 1.0) && !qFuzzyIsNull(len)) { - len = sqrt(len); + len = std::sqrt(len); x = float(double(x) / len); y = float(double(y) / len); z = float(double(z) / len); @@ -1487,10 +1487,10 @@ void QMatrix4x4::perspective(float verticalAngle, float aspectRatio, float nearP // Construct the projection. QMatrix4x4 m(1); float radians = (verticalAngle / 2.0f) * M_PI / 180.0f; - float sine = sinf(radians); + float sine = std::sin(radians); if (sine == 0.0f) return; - float cotan = cosf(radians) / sine; + float cotan = std::cos(radians) / sine; float clip = farPlane - nearPlane; m.m[0][0] = cotan / aspectRatio; m.m[1][0] = 0.0f; diff --git a/src/gui/math3d/qquaternion.cpp b/src/gui/math3d/qquaternion.cpp index 0653ace5a4..f2e79cb834 100644 --- a/src/gui/math3d/qquaternion.cpp +++ b/src/gui/math3d/qquaternion.cpp @@ -219,7 +219,7 @@ QT_BEGIN_NAMESPACE */ float QQuaternion::length() const { - return qSqrt(xp * xp + yp * yp + zp * zp + wp * wp); + return std::sqrt(xp * xp + yp * yp + zp * zp + wp * wp); } /*! @@ -252,7 +252,7 @@ QQuaternion QQuaternion::normalized() const if (qFuzzyIsNull(len - 1.0f)) return *this; else if (!qFuzzyIsNull(len)) - return *this / qSqrt(len); + return *this / std::sqrt(len); else return QQuaternion(0.0f, 0.0f, 0.0f, 0.0f); } @@ -273,7 +273,7 @@ void QQuaternion::normalize() if (qFuzzyIsNull(len - 1.0f) || qFuzzyIsNull(len)) return; - len = qSqrt(len); + len = std::sqrt(len); xp /= len; yp /= len; @@ -386,8 +386,8 @@ QQuaternion QQuaternion::fromAxisAndAngle(const QVector3D& axis, float angle) // We normalize the result just in case the values are close // to zero, as suggested in the above FAQ. float a = (angle / 2.0f) * M_PI / 180.0f; - float s = sinf(a); - float c = cosf(a); + float s = std::sin(a); + float c = std::cos(a); QVector3D ax = axis.normalized(); return QQuaternion(c, ax.x() * s, ax.y() * s, ax.z() * s).normalized(); } @@ -415,12 +415,12 @@ void QQuaternion::toAxisAndAngle(float *x, float *y, float *z, float *angle) con *y = yp; *z = zp; if (!qFuzzyIsNull(length - 1.0f)) { - length = sqrtf(length); + length = std::sqrt(length); *x /= length; *y /= length; *z /= length; } - *angle = 2.0f * acosf(wp); + *angle = 2.0f * std::acos(wp); } else { // angle is 0 (mod 2*pi), so any axis will fit *x = *y = *z = *angle = 0.0f; @@ -438,15 +438,15 @@ void QQuaternion::toAxisAndAngle(float *x, float *y, float *z, float *angle) con QQuaternion QQuaternion::fromAxisAndAngle (float x, float y, float z, float angle) { - float length = qSqrt(x * x + y * y + z * z); + float length = std::sqrt(x * x + y * y + z * z); if (!qFuzzyIsNull(length - 1.0f) && !qFuzzyIsNull(length)) { x /= length; y /= length; z /= length; } float a = (angle / 2.0f) * M_PI / 180.0f; - float s = sinf(a); - float c = cosf(a); + float s = std::sin(a); + float c = std::cos(a); return QQuaternion(c, x * s, y * s, z * s).normalized(); } @@ -515,20 +515,20 @@ void QQuaternion::toEulerAngles(float *pitch, float *yaw, float *roll) const zw /= lengthSquared; } - *pitch = asinf(-2.0f * (yz - xw)); + *pitch = std::asin(-2.0f * (yz - xw)); if (*pitch < M_PI_2) { if (*pitch > -M_PI_2) { - *yaw = atan2f(2.0f * (xz + yw), 1.0f - 2.0f * (xx + yy)); - *roll = atan2f(2.0f * (xy + zw), 1.0f - 2.0f * (xx + zz)); + *yaw = std::atan2(2.0f * (xz + yw), 1.0f - 2.0f * (xx + yy)); + *roll = std::atan2(2.0f * (xy + zw), 1.0f - 2.0f * (xx + zz)); } else { // not a unique solution *roll = 0.0f; - *yaw = -atan2f(-2.0f * (xy - zw), 1.0f - 2.0f * (yy + zz)); + *yaw = -std::atan2(-2.0f * (xy - zw), 1.0f - 2.0f * (yy + zz)); } } else { // not a unique solution *roll = 0.0f; - *yaw = atan2f(-2.0f * (xy - zw), 1.0f - 2.0f * (yy + zz)); + *yaw = std::atan2(-2.0f * (xy - zw), 1.0f - 2.0f * (yy + zz)); } *pitch = qRadiansToDegrees(*pitch); @@ -558,12 +558,12 @@ QQuaternion QQuaternion::fromEulerAngles(float pitch, float yaw, float roll) yaw *= 0.5f; roll *= 0.5f; - const float c1 = cosf(yaw); - const float s1 = sinf(yaw); - const float c2 = cosf(roll); - const float s2 = sinf(roll); - const float c3 = cosf(pitch); - const float s3 = sinf(pitch); + const float c1 = std::cos(yaw); + const float s1 = std::sin(yaw); + const float c2 = std::cos(roll); + const float s2 = std::sin(roll); + const float c3 = std::cos(pitch); + const float s3 = std::sin(pitch); const float c1c2 = c1 * c2; const float s1s2 = s1 * s2; @@ -635,7 +635,7 @@ QQuaternion QQuaternion::fromRotationMatrix(const QMatrix3x3 &rot3x3) const float trace = rot3x3(0, 0) + rot3x3(1, 1) + rot3x3(2, 2); if (trace > 0.00000001f) { - const float s = 2.0f * sqrtf(trace + 1.0f); + const float s = 2.0f * std::sqrt(trace + 1.0f); scalar = 0.25f * s; axis[0] = (rot3x3(2, 1) - rot3x3(1, 2)) / s; axis[1] = (rot3x3(0, 2) - rot3x3(2, 0)) / s; @@ -650,7 +650,7 @@ QQuaternion QQuaternion::fromRotationMatrix(const QMatrix3x3 &rot3x3) int j = s_next[i]; int k = s_next[j]; - const float s = 2.0f * sqrtf(rot3x3(i, i) - rot3x3(j, j) - rot3x3(k, k) + 1.0f); + const float s = 2.0f * std::sqrt(rot3x3(i, i) - rot3x3(j, j) - rot3x3(k, k) + 1.0f); axis[i] = 0.25f * s; scalar = (rot3x3(k, j) - rot3x3(j, k)) / s; axis[j] = (rot3x3(j, i) + rot3x3(i, j)) / s; @@ -792,11 +792,11 @@ QQuaternion QQuaternion::slerp float factor1 = 1.0f - t; float factor2 = t; if ((1.0f - dot) > 0.0000001) { - float angle = acosf(dot); - float sinOfAngle = sinf(angle); + float angle = std::acos(dot); + float sinOfAngle = std::sin(angle); if (sinOfAngle > 0.0000001) { - factor1 = sinf((1.0f - t) * angle) / sinOfAngle; - factor2 = sinf(t * angle) / sinOfAngle; + factor1 = std::sin((1.0f - t) * angle) / sinOfAngle; + factor2 = std::sin(t * angle) / sinOfAngle; } } diff --git a/src/gui/math3d/qvector2d.cpp b/src/gui/math3d/qvector2d.cpp index bad46c6e0b..fe4c9f8cc2 100644 --- a/src/gui/math3d/qvector2d.cpp +++ b/src/gui/math3d/qvector2d.cpp @@ -189,7 +189,7 @@ float QVector2D::length() const // Need some extra precision if the length is very small. double len = double(xp) * double(xp) + double(yp) * double(yp); - return float(sqrt(len)); + return float(std::sqrt(len)); } /*! @@ -220,7 +220,7 @@ QVector2D QVector2D::normalized() const if (qFuzzyIsNull(len - 1.0f)) { return *this; } else if (!qFuzzyIsNull(len)) { - double sqrtLen = sqrt(len); + double sqrtLen = std::sqrt(len); return QVector2D(float(double(xp) / sqrtLen), float(double(yp) / sqrtLen)); } else { return QVector2D(); @@ -241,7 +241,7 @@ void QVector2D::normalize() if (qFuzzyIsNull(len - 1.0f) || qFuzzyIsNull(len)) return; - len = sqrt(len); + len = std::sqrt(len); xp = float(double(xp) / len); yp = float(double(yp) / len); diff --git a/src/gui/math3d/qvector3d.cpp b/src/gui/math3d/qvector3d.cpp index fa09a43480..a93d994a70 100644 --- a/src/gui/math3d/qvector3d.cpp +++ b/src/gui/math3d/qvector3d.cpp @@ -235,7 +235,7 @@ QVector3D QVector3D::normalized() const if (qFuzzyIsNull(len - 1.0f)) { return *this; } else if (!qFuzzyIsNull(len)) { - double sqrtLen = sqrt(len); + double sqrtLen = std::sqrt(len); return QVector3D(float(double(xp) / sqrtLen), float(double(yp) / sqrtLen), float(double(zp) / sqrtLen)); @@ -259,7 +259,7 @@ void QVector3D::normalize() if (qFuzzyIsNull(len - 1.0f) || qFuzzyIsNull(len)) return; - len = sqrt(len); + len = std::sqrt(len); xp = float(double(xp) / len); yp = float(double(yp) / len); @@ -679,7 +679,7 @@ float QVector3D::length() const double len = double(xp) * double(xp) + double(yp) * double(yp) + double(zp) * double(zp); - return float(sqrt(len)); + return float(std::sqrt(len)); } /*! diff --git a/src/gui/math3d/qvector4d.cpp b/src/gui/math3d/qvector4d.cpp index 1eed1c1301..6afe9b8cad 100644 --- a/src/gui/math3d/qvector4d.cpp +++ b/src/gui/math3d/qvector4d.cpp @@ -256,7 +256,7 @@ float QVector4D::length() const double(yp) * double(yp) + double(zp) * double(zp) + double(wp) * double(wp); - return float(sqrt(len)); + return float(std::sqrt(len)); } /*! @@ -289,7 +289,7 @@ QVector4D QVector4D::normalized() const if (qFuzzyIsNull(len - 1.0f)) { return *this; } else if (!qFuzzyIsNull(len)) { - double sqrtLen = sqrt(len); + double sqrtLen = std::sqrt(len); return QVector4D(float(double(xp) / sqrtLen), float(double(yp) / sqrtLen), float(double(zp) / sqrtLen), @@ -315,7 +315,7 @@ void QVector4D::normalize() if (qFuzzyIsNull(len - 1.0f) || qFuzzyIsNull(len)) return; - len = sqrt(len); + len = std::sqrt(len); xp = float(double(xp) / len); yp = float(double(yp) / len); diff --git a/src/gui/opengl/qopenglpaintengine.cpp b/src/gui/opengl/qopenglpaintengine.cpp index c23e0c28ea..576558022e 100644 --- a/src/gui/opengl/qopenglpaintengine.cpp +++ b/src/gui/opengl/qopenglpaintengine.cpp @@ -462,8 +462,8 @@ void QOpenGL2PaintEngineExPrivate::updateMatrix() // anti-aliased text rendering. In such cases, we snap the translate to the pixel grid. if (snapToPixelGrid && transform.type() == QTransform::TxTranslate) { // 0.50 needs to rounded down to 0.0 for consistency with raster engine: - dx = ceilf(dx - 0.5f); - dy = ceilf(dy - 0.5f); + dx = std::ceil(dx - 0.5f); + dy = std::ceil(dy - 0.5f); } pmvMatrix[0][0] = (wfactor * transform.m11()) - transform.m13(); pmvMatrix[1][0] = (wfactor * transform.m21()) - transform.m23(); diff --git a/src/gui/opengl/qtriangulatingstroker_p.h b/src/gui/opengl/qtriangulatingstroker_p.h index 2561810d7a..dd46cbe1e5 100644 --- a/src/gui/opengl/qtriangulatingstroker_p.h +++ b/src/gui/opengl/qtriangulatingstroker_p.h @@ -134,11 +134,11 @@ inline void QTriangulatingStroker::normalVector(float x1, float y1, float x2, fl float pw; if (dx == 0) - pw = m_width / qAbs(dy); + pw = m_width / std::abs(dy); else if (dy == 0) - pw = m_width / qAbs(dx); + pw = m_width / std::abs(dx); else - pw = m_width / sqrt(dx*dx + dy*dy); + pw = m_width / std::sqrt(dx*dx + dy*dy); *nx = -dy * pw; *ny = dx * pw; diff --git a/src/gui/opengl/qtriangulator.cpp b/src/gui/opengl/qtriangulator.cpp index b0d754b87e..6574fe9975 100644 --- a/src/gui/opengl/qtriangulator.cpp +++ b/src/gui/opengl/qtriangulator.cpp @@ -49,8 +49,6 @@ #include #include -#include - QT_BEGIN_NAMESPACE //#define Q_TRIANGULATOR_DEBUG @@ -1700,8 +1698,8 @@ void QTriangulator::ComplexToSimple::DebugDialog::paintEvent(QPaintEvent *) QPodPoint q = vertices.at(splits.at(i).vertex); QPodPoint u = vertices.at(edges.at(splits.at(i).edge).from) - q; QPodPoint v = vertices.at(edges.at(splits.at(i).edge).to) - q; - qreal uLen = sqrt(qreal(qDot(u, u))); - qreal vLen = sqrt(qreal(qDot(v, v))); + qreal uLen = qSqrt(qDot(u, u)); + qreal vLen = qSqrt(qDot(v, v)); if (uLen) { u.x *= 2 * halfPointSize / uLen; u.y *= 2 * halfPointSize / uLen; @@ -1719,7 +1717,7 @@ void QTriangulator::ComplexToSimple::DebugDialog::paintEvent(QPaintEvent *) template void QTriangulator::ComplexToSimple::DebugDialog::wheelEvent(QWheelEvent *event) { - qreal scale = exp(-0.001 * event->delta()); + qreal scale = qExp(-0.001 * event->delta()); QPointF center = m_window.center(); QPointF delta = scale * (m_window.bottomRight() - center); m_window = QRectF(center - delta, center + delta); diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp index f461dfef06..84063eb692 100644 --- a/src/gui/painting/qdrawhelper.cpp +++ b/src/gui/painting/qdrawhelper.cpp @@ -1684,7 +1684,7 @@ static const uint * QT_FASTCALL fetchTransformedBilinearARGB32PM(uint *buffer, c b++; fx += fdx; } - } else if ((fdx < 0 && fdx > -(fixed_scale / 8)) || fabs(data->m22) < (1./8.)) { // scale up more than 8x + } else if ((fdx < 0 && fdx > -(fixed_scale / 8)) || std::abs(data->m22) < (1./8.)) { // scale up more than 8x int y1 = (fy >> 16); int y2; fetchTransformedBilinear_pixelBounds(image_height, image_y1, image_y2, y1, y2); @@ -1843,7 +1843,7 @@ static const uint * QT_FASTCALL fetchTransformedBilinearARGB32PM(uint *buffer, c } } } else { //rotation - if (fabs(data->m11) > 8 || fabs(data->m22) > 8) { + if (std::abs(data->m11) > 8 || std::abs(data->m22) > 8) { //if we are zooming more than 8 times, we use 8bit precision for the position. while (b < end) { int x1 = (fx >> 16); @@ -2196,7 +2196,7 @@ static const uint *QT_FASTCALL fetchTransformedBilinear(uint *buffer, const Oper layout->convertToARGB32PM(buf1, buf1, len * 2, layout, clut); layout->convertToARGB32PM(buf2, buf2, len * 2, layout, clut); - if ((fdx < 0 && fdx > -(fixed_scale / 8)) || fabs(data->m22) < (1./8.)) { // scale up more than 8x + if ((fdx < 0 && fdx > -(fixed_scale / 8)) || std::abs(data->m22) < (1./8.)) { // scale up more than 8x int disty = (fy & 0x0000ffff) >> 8; for (int i = 0; i < len; ++i) { uint tl = buf1[i * 2 + 0]; @@ -2255,7 +2255,7 @@ static const uint *QT_FASTCALL fetchTransformedBilinear(uint *buffer, const Oper layout->convertToARGB32PM(buf1, buf1, len * 2, layout, clut); layout->convertToARGB32PM(buf2, buf2, len * 2, layout, clut); - if (fabs(data->m11) > 8 || fabs(data->m22) > 8) { + if (std::abs(data->m11) > 8 || std::abs(data->m22) > 8) { //if we are zooming more than 8 times, we use 8bit precision for the position. for (int i = 0; i < len; ++i) { uint tl = buf1[i * 2 + 0]; diff --git a/src/gui/painting/qmath_p.h b/src/gui/painting/qmath_p.h index 50a49c2cb5..9cb64a46cb 100644 --- a/src/gui/painting/qmath_p.h +++ b/src/gui/painting/qmath_p.h @@ -45,14 +45,13 @@ // We mean it. // -#include #include QT_BEGIN_NAMESPACE -static const qreal Q_PI = qreal(3.14159265358979323846); // pi -static const qreal Q_2PI = qreal(6.28318530717958647693); // 2*pi -static const qreal Q_PI2 = qreal(1.57079632679489661923); // pi/2 +static const qreal Q_PI = qreal(M_PI); // pi +static const qreal Q_2PI = qreal(2 * M_PI); // 2*pi +static const qreal Q_PI2 = qreal(M_PI_2); // pi/2 static const qreal Q_MM_PER_INCH = 25.4; inline int qIntSqrtInt(int v) diff --git a/src/gui/painting/qrasterizer.cpp b/src/gui/painting/qrasterizer.cpp index 426dd846ed..75bf31cde1 100644 --- a/src/gui/painting/qrasterizer.cpp +++ b/src/gui/painting/qrasterizer.cpp @@ -712,20 +712,10 @@ static inline bool q26Dot6Compare(qreal p1, qreal p2) return int((p2 - p1) * 64.) == 0; } -static inline qreal qFloorF(qreal v) -{ -#ifdef QT_USE_MATH_H_FLOATS - if (sizeof(qreal) == sizeof(float)) - return floorf(v); - else -#endif - return floor(v); -} - static inline QPointF snapTo26Dot6Grid(const QPointF &p) { - return QPointF(qFloorF(p.x() * 64) * (1 / qreal(64)), - qFloorF(p.y() * 64) * (1 / qreal(64))); + return QPointF(std::floor(p.x() * 64) * (1 / qreal(64)), + std::floor(p.y() * 64) * (1 / qreal(64))); } /* @@ -832,7 +822,7 @@ void QRasterizer::rasterizeLine(const QPointF &a, const QPointF &b, qreal width, return; // adjust width which is given relative to |b - a| - width *= sqrt(w0 / w); + width *= qSqrt(w0 / w); } QSpanBuffer buffer(d->blend, d->data, d->clipRect); diff --git a/src/gui/text/qdistancefield.cpp b/src/gui/text/qdistancefield.cpp index 49ec31fc19..471a39a6e1 100644 --- a/src/gui/text/qdistancefield.cpp +++ b/src/gui/text/qdistancefield.cpp @@ -509,8 +509,8 @@ static void makeDistanceField(QDistanceFieldData *data, const QPainterPath &path bits[i] = exteriorColor; const qreal angleStep = qreal(15 * 3.141592653589793238 / 180); - const QPoint rotation(qRound(cos(angleStep) * 0x4000), - qRound(sin(angleStep) * 0x4000)); // 2:14 signed + const QPoint rotation(qRound(qCos(angleStep) * 0x4000), + qRound(qSin(angleStep) * 0x4000)); // 2:14 signed const quint32 *indices = pathIndices.data(); QVarLengthArray normals; @@ -544,7 +544,7 @@ static void makeDistanceField(QDistanceFieldData *data, const QPainterPath &path QPoint n(to.y() - from.y(), from.x() - to.x()); if (n.x() == 0 && n.y() == 0) continue; - int scale = qRound((offs << 16) / sqrt(qreal(n.x() * n.x() + n.y() * n.y()))); // 8:16 + int scale = qRound((offs << 16) / qSqrt(qreal(n.x() * n.x() + n.y() * n.y()))); // 8:16 n.rx() = n.x() * scale >> 8; n.ry() = n.y() * scale >> 8; normals.append(n); diff --git a/src/gui/text/qfontdatabase.cpp b/src/gui/text/qfontdatabase.cpp index 211b8b6659..1cdbf6aa8e 100644 --- a/src/gui/text/qfontdatabase.cpp +++ b/src/gui/text/qfontdatabase.cpp @@ -2640,7 +2640,7 @@ void QFontDatabase::load(const QFontPrivate *d, int script) QFontDef req = d->request; if (req.pixelSize == -1) { - req.pixelSize = floor(((req.pointSize * d->dpi) / 72) * 100 + 0.5) / 100; + req.pixelSize = std::floor(((req.pointSize * d->dpi) / 72) * 100 + 0.5) / 100; req.pixelSize = qRound(req.pixelSize); } if (req.pointSize < 0) diff --git a/src/gui/util/qgridlayoutengine.cpp b/src/gui/util/qgridlayoutengine.cpp index 5b98001b38..df8dab2903 100644 --- a/src/gui/util/qgridlayoutengine.cpp +++ b/src/gui/util/qgridlayoutengine.cpp @@ -193,7 +193,7 @@ namespace { // does not return int static inline qreal qround(qreal f) { - return floor(f + 0.5); + return std::floor(f + qreal(0.5)); } } @@ -355,7 +355,7 @@ void QGridLayoutRowData::calculateGeometries(int start, int end, qreal targetSiz qreal maxBoxSize = box.q_maximumSize; if (snapToPixelGrid) - maxBoxSize = qMax(box.q_minimumSize, floor(maxBoxSize)); + maxBoxSize = qMax(box.q_minimumSize, std::floor(maxBoxSize)); qreal avail = sumCurrentAvailable * factors[i] / sumFactors; if (sizes[i] + avail >= maxBoxSize) { diff --git a/src/gui/util/qvalidator.cpp b/src/gui/util/qvalidator.cpp index dcb1f9817f..6b1e20c844 100644 --- a/src/gui/util/qvalidator.cpp +++ b/src/gui/util/qvalidator.cpp @@ -40,7 +40,7 @@ #include "private/qlocale_p.h" #include -#include +#include QT_BEGIN_NAMESPACE @@ -384,7 +384,7 @@ static int numDigits(qlonglong n) { if (n == 0) return 1; - return (int)log10(double(n)) + 1; + return (int)std::log10(double(n)) + 1; } static qlonglong pow10(int exp) diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp index 69bd080477..e461dd0fd4 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp @@ -400,8 +400,8 @@ void QGL2PaintEngineExPrivate::updateMatrix() // anti-aliased text rendering. In such cases, we snap the translate to the pixel grid. if (snapToPixelGrid && transform.type() == QTransform::TxTranslate) { // 0.50 needs to rounded down to 0.0 for consistency with raster engine: - dx = ceilf(dx - 0.5f); - dy = ceilf(dy - 0.5f); + dx = std::ceil(dx - 0.5f); + dy = std::ceil(dy - 0.5f); } pmvMatrix[0][0] = (wfactor * transform.m11()) - transform.m13(); pmvMatrix[1][0] = (wfactor * transform.m21()) - transform.m23(); diff --git a/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm b/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm index 3485c9a558..123a2c4c79 100644 --- a/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm +++ b/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm @@ -39,9 +39,11 @@ #include +#include + QT_BEGIN_NAMESPACE -static float SYNTHETIC_ITALIC_SKEW = tanf(14 * acosf(0) / 90); +static float SYNTHETIC_ITALIC_SKEW = std::tan(14.f * std::acos(0.f) / 90.f); bool QCoreTextFontEngine::ct_getSfntTable(void *user_data, uint tag, uchar *buffer, uint *length) { diff --git a/src/plugins/platforms/cocoa/qpaintengine_mac.mm b/src/plugins/platforms/cocoa/qpaintengine_mac.mm index 2df4c588cc..16eb281a2f 100644 --- a/src/plugins/platforms/cocoa/qpaintengine_mac.mm +++ b/src/plugins/platforms/cocoa/qpaintengine_mac.mm @@ -654,11 +654,11 @@ QCoreGraphicsPaintEngine::updateState(const QPaintEngineState &state) d->cosmeticPenSize = 1.0; } else { d->cosmeticPen = QCoreGraphicsPaintEnginePrivate::CosmeticSetPenWidth; - static const float sqrt2 = sqrt(2); + static const float sqrt2 = std::sqrt(2.0f); qreal width = d->current.pen.widthF(); if (!width) width = 1; - d->cosmeticPenSize = sqrt(pow(d->pixelSize.y(), 2) + pow(d->pixelSize.x(), 2)) / sqrt2 * width; + d->cosmeticPenSize = std::sqrt(std::pow(d->pixelSize.y(), 2) + std::pow(d->pixelSize.x(), 2)) / sqrt2 * width; } } } diff --git a/src/plugins/platforms/windows/qwindowstabletsupport.cpp b/src/plugins/platforms/windows/qwindowstabletsupport.cpp index 1818d614fd..7b871be015 100644 --- a/src/plugins/platforms/windows/qwindowstabletsupport.cpp +++ b/src/plugins/platforms/windows/qwindowstabletsupport.cpp @@ -455,10 +455,10 @@ bool QWindowsTabletSupport::translateTabletPacketEvent() // X Tilt = arctan(X / Z) // Y Tilt = arctan(Y / Z) const double radAzim = (packet.pkOrientation.orAzimuth / 10.0) * (M_PI / 180); - const double tanAlt = tan((abs(packet.pkOrientation.orAltitude / 10.0)) * (M_PI / 180)); + const double tanAlt = std::tan((std::abs(packet.pkOrientation.orAltitude / 10.0)) * (M_PI / 180)); - const double degX = atan(sin(radAzim) / tanAlt); - const double degY = atan(cos(radAzim) / tanAlt); + const double degX = std::atan(std::sin(radAzim) / tanAlt); + const double degY = std::atan(std::cos(radAzim) / tanAlt); tiltX = int(degX * (180 / M_PI)); tiltY = int(-degY * (180 / M_PI)); rotation = 360.0 - (packet.pkOrientation.orTwist / 10.0); diff --git a/src/widgets/widgets/qdial.cpp b/src/widgets/widgets/qdial.cpp index c9e16205f0..b6ec54997b 100644 --- a/src/widgets/widgets/qdial.cpp +++ b/src/widgets/widgets/qdial.cpp @@ -136,9 +136,9 @@ void QDial::initStyleOption(QStyleOptionSlider *option) const int QDialPrivate::valueFromPoint(const QPoint &p) const { Q_Q(const QDial); - double yy = (double)q->height()/2.0 - p.y(); - double xx = (double)p.x() - q->width()/2.0; - double a = (xx || yy) ? qAtan2(yy, xx) : 0; + double yy = q->height()/2.0 - p.y(); + double xx = p.x() - q->width()/2.0; + double a = (xx || yy) ? std::atan2(yy, xx) : 0; if (a < Q_PI / -2) a = a + Q_PI * 2; From 3c1d9911c4c327ebc8180efb31fa8e83b1f932fd Mon Sep 17 00:00:00 2001 From: Sergio Ahumada Date: Mon, 16 Feb 2015 13:02:28 +0100 Subject: [PATCH 08/10] Fix license headers Change-Id: I964ca9d3aff1a1cbe39dc53d04a408c754e96a77 Reviewed-by: Jani Heikkinen --- src/plugins/platforms/ios/qiosfiledialog.h | 36 ++++++++----------- src/plugins/platforms/ios/qiosfiledialog.mm | 36 ++++++++----------- .../ios/qiosfileengineassetslibrary.h | 36 ++++++++----------- .../ios/qiosfileengineassetslibrary.mm | 36 ++++++++----------- .../platforms/ios/qiosfileenginefactory.h | 36 ++++++++----------- 5 files changed, 70 insertions(+), 110 deletions(-) diff --git a/src/plugins/platforms/ios/qiosfiledialog.h b/src/plugins/platforms/ios/qiosfiledialog.h index 7442e21422..b4bf85edd9 100644 --- a/src/plugins/platforms/ios/qiosfiledialog.h +++ b/src/plugins/platforms/ios/qiosfiledialog.h @@ -1,40 +1,32 @@ /**************************************************************************** ** -** Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ ** ** This file is part of the plugins of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL$ +** $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. +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/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 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** 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 +** As a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/plugins/platforms/ios/qiosfiledialog.mm b/src/plugins/platforms/ios/qiosfiledialog.mm index b844f7d0c0..1d4298a158 100644 --- a/src/plugins/platforms/ios/qiosfiledialog.mm +++ b/src/plugins/platforms/ios/qiosfiledialog.mm @@ -1,40 +1,32 @@ /**************************************************************************** ** -** Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ ** ** This file is part of the plugins of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL$ +** $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. +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/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 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** 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 +** As a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/plugins/platforms/ios/qiosfileengineassetslibrary.h b/src/plugins/platforms/ios/qiosfileengineassetslibrary.h index ef5b6e7415..043e101a21 100644 --- a/src/plugins/platforms/ios/qiosfileengineassetslibrary.h +++ b/src/plugins/platforms/ios/qiosfileengineassetslibrary.h @@ -1,40 +1,32 @@ /**************************************************************************** ** -** Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ ** ** This file is part of the plugins of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL$ +** $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. +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/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 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** 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 +** As a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/plugins/platforms/ios/qiosfileengineassetslibrary.mm b/src/plugins/platforms/ios/qiosfileengineassetslibrary.mm index 427a205f3f..c4be7cf4dc 100644 --- a/src/plugins/platforms/ios/qiosfileengineassetslibrary.mm +++ b/src/plugins/platforms/ios/qiosfileengineassetslibrary.mm @@ -1,40 +1,32 @@ /**************************************************************************** ** -** Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ ** ** This file is part of the plugins of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL$ +** $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. +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/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 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** 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 +** As a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/plugins/platforms/ios/qiosfileenginefactory.h b/src/plugins/platforms/ios/qiosfileenginefactory.h index cba5818e51..a8604c77d1 100644 --- a/src/plugins/platforms/ios/qiosfileenginefactory.h +++ b/src/plugins/platforms/ios/qiosfileenginefactory.h @@ -1,40 +1,32 @@ /**************************************************************************** ** -** Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ ** ** This file is part of the plugins of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL$ +** $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. +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/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 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** 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 +** As a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** ** $QT_END_LICENSE$ ** ****************************************************************************/ From fbeeaf23fe1755bc28185781d8182ddcb4e7985a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9rgio=20Martins?= Date: Sun, 15 Feb 2015 16:39:13 +0000 Subject: [PATCH 09/10] Introduce QT_NO_MIMETYPE The mime type stuff generates one of the biggest translation units in QtCore due to the compressed 1.7MB freedesktop.org.xml resource. With QT_NO_MIMETYPE, libQt5Core.so is almost 400Kb smaller (4.8MB->4.4MB gcc 4.9 stripped release build) Change-Id: I5339090994034355724ff4deddb64720e81baeaf Reviewed-by: Oswald Buddenhagen Reviewed-by: David Faure Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/corelib/global/qconfig-minimal.h | 3 +++ src/corelib/global/qconfig-small.h | 3 +++ src/corelib/global/qfeatures.txt | 6 ++++++ src/corelib/mimetypes/mimetypes.pri | 6 +++--- src/corelib/mimetypes/qmimedatabase.cpp | 5 ++++- src/corelib/mimetypes/qmimedatabase.h | 7 ++++++- src/corelib/mimetypes/qmimedatabase_p.h | 12 ++++++++---- src/corelib/mimetypes/qmimeglobpattern.cpp | 4 ++++ src/corelib/mimetypes/qmimeglobpattern_p.h | 5 +++++ src/corelib/mimetypes/qmimemagicrule.cpp | 4 ++++ src/corelib/mimetypes/qmimemagicrule_p.h | 5 +++++ src/corelib/mimetypes/qmimemagicrulematcher.cpp | 3 +++ src/corelib/mimetypes/qmimemagicrulematcher_p.h | 7 +++++-- src/corelib/mimetypes/qmimeprovider.cpp | 4 ++++ src/corelib/mimetypes/qmimeprovider_p.h | 6 +++++- src/corelib/mimetypes/qmimetype.cpp | 4 ++++ src/corelib/mimetypes/qmimetype.h | 8 +++++++- src/corelib/mimetypes/qmimetype_p.h | 3 +++ src/corelib/mimetypes/qmimetypeparser.cpp | 4 ++++ src/corelib/mimetypes/qmimetypeparser_p.h | 4 ++++ src/plugins/printsupport/cups/qppdprintdevice.cpp | 2 ++ src/plugins/printsupport/cups/qppdprintdevice.h | 2 ++ src/printsupport/kernel/qplatformprintdevice.cpp | 2 ++ src/printsupport/kernel/qplatformprintdevice.h | 6 ++++++ src/printsupport/kernel/qprintdevice.cpp | 2 ++ src/printsupport/kernel/qprintdevice_p.h | 2 ++ src/widgets/dialogs/qfiledialog.cpp | 9 ++++++++- src/widgets/dialogs/qfiledialog.h | 2 ++ 28 files changed, 116 insertions(+), 14 deletions(-) diff --git a/src/corelib/global/qconfig-minimal.h b/src/corelib/global/qconfig-minimal.h index de6f2401b8..f307e98dd7 100644 --- a/src/corelib/global/qconfig-minimal.h +++ b/src/corelib/global/qconfig-minimal.h @@ -297,6 +297,9 @@ #ifndef QT_NO_DESKTOPSERVICES # define QT_NO_DESKTOPSERVICES #endif +#ifndef QT_NO_MIMETYPE +# define QT_NO_MIMETYPE +#endif #ifndef QT_NO_SYSTEMTRAYICON # define QT_NO_SYSTEMTRAYICON #endif diff --git a/src/corelib/global/qconfig-small.h b/src/corelib/global/qconfig-small.h index 48c08e4f36..43ae101515 100644 --- a/src/corelib/global/qconfig-small.h +++ b/src/corelib/global/qconfig-small.h @@ -187,6 +187,9 @@ #ifndef QT_NO_DESKTOPSERVICES # define QT_NO_DESKTOPSERVICES #endif +#ifndef QT_NO_MIMETYPE +# define QT_NO_MIMETYPE +#endif #ifndef QT_NO_SYSTEMTRAYICON # define QT_NO_SYSTEMTRAYICON #endif diff --git a/src/corelib/global/qfeatures.txt b/src/corelib/global/qfeatures.txt index fb6e56ec7d..dec16eaef1 100644 --- a/src/corelib/global/qfeatures.txt +++ b/src/corelib/global/qfeatures.txt @@ -879,6 +879,12 @@ Section: Utilities Requires: Name: QDesktopServices +Feature: MIMETYPE +Description: Describes types of file or data, represented by a MIME type string. +Section: Utilities +Requires: +Name: QMimeType + Feature: SYSTEMTRAYICON Description: Provides an icon for an application in the system tray. Section: Utilities diff --git a/src/corelib/mimetypes/mimetypes.pri b/src/corelib/mimetypes/mimetypes.pri index 238aa837e2..1ab773fc10 100644 --- a/src/corelib/mimetypes/mimetypes.pri +++ b/src/corelib/mimetypes/mimetypes.pri @@ -20,6 +20,6 @@ SOURCES += \ mimetypes/qmimeglobpattern.cpp \ mimetypes/qmimeprovider.cpp -RESOURCES += \ - mimetypes/mimetypes.qrc - +!contains(DEFINES, QT_NO_MIMETYPE) { + RESOURCES += mimetypes/mimetypes.qrc +} diff --git a/src/corelib/mimetypes/qmimedatabase.cpp b/src/corelib/mimetypes/qmimedatabase.cpp index 89560e4adf..b919e1c48a 100644 --- a/src/corelib/mimetypes/qmimedatabase.cpp +++ b/src/corelib/mimetypes/qmimedatabase.cpp @@ -33,8 +33,9 @@ #include // always first -#include "qmimedatabase.h" +#ifndef QT_NO_MIMETYPE +#include "qmimedatabase.h" #include "qmimedatabase_p.h" #include "qmimeprovider_p.h" @@ -597,3 +598,5 @@ QList QMimeDatabase::allMimeTypes() const */ QT_END_NAMESPACE + +#endif // QT_NO_MIMETYPE diff --git a/src/corelib/mimetypes/qmimedatabase.h b/src/corelib/mimetypes/qmimedatabase.h index 4fb9308a15..912d9b8443 100644 --- a/src/corelib/mimetypes/qmimedatabase.h +++ b/src/corelib/mimetypes/qmimedatabase.h @@ -35,6 +35,9 @@ #define QMIMEDATABASE_H #include + +#ifndef QT_NO_MIMETYPE + #include QT_BEGIN_NAMESPACE @@ -81,4 +84,6 @@ private: }; QT_END_NAMESPACE -#endif // QMIMEDATABASE_H + +#endif // QT_NO_MIMETYPE +#endif // QMIMEDATABASE_H diff --git a/src/corelib/mimetypes/qmimedatabase_p.h b/src/corelib/mimetypes/qmimedatabase_p.h index dd54c3a185..e3cfe3443f 100644 --- a/src/corelib/mimetypes/qmimedatabase_p.h +++ b/src/corelib/mimetypes/qmimedatabase_p.h @@ -45,13 +45,16 @@ // We mean it. // -#include -#include - #include "qmimetype.h" + +#ifndef QT_NO_MIMETYPE + #include "qmimetype_p.h" #include "qmimeglobpattern_p.h" +#include +#include + QT_BEGIN_NAMESPACE class QIODevice; @@ -90,4 +93,5 @@ public: QT_END_NAMESPACE -#endif // QMIMEDATABASE_P_H +#endif // QT_NO_MIMETYPE +#endif // QMIMEDATABASE_P_H diff --git a/src/corelib/mimetypes/qmimeglobpattern.cpp b/src/corelib/mimetypes/qmimeglobpattern.cpp index d852a9f249..57d834ac78 100644 --- a/src/corelib/mimetypes/qmimeglobpattern.cpp +++ b/src/corelib/mimetypes/qmimeglobpattern.cpp @@ -33,6 +33,8 @@ #include "qmimeglobpattern_p.h" +#ifndef QT_NO_MIMETYPE + #include #include #include @@ -234,3 +236,5 @@ void QMimeAllGlobPatterns::clear() } QT_END_NAMESPACE + +#endif // QT_NO_MIMETYPE diff --git a/src/corelib/mimetypes/qmimeglobpattern_p.h b/src/corelib/mimetypes/qmimeglobpattern_p.h index f2524a0d36..9ee3eb61cf 100644 --- a/src/corelib/mimetypes/qmimeglobpattern_p.h +++ b/src/corelib/mimetypes/qmimeglobpattern_p.h @@ -45,6 +45,10 @@ // We mean it. // +#include + +#ifndef QT_NO_MIMETYPE + #include #include @@ -146,4 +150,5 @@ public: QT_END_NAMESPACE +#endif // QT_NO_MIMETYPE #endif // QMIMEGLOBPATTERN_P_H diff --git a/src/corelib/mimetypes/qmimemagicrule.cpp b/src/corelib/mimetypes/qmimemagicrule.cpp index d9240a9fce..9693558a4c 100644 --- a/src/corelib/mimetypes/qmimemagicrule.cpp +++ b/src/corelib/mimetypes/qmimemagicrule.cpp @@ -36,6 +36,8 @@ #include "qmimemagicrule_p.h" +#ifndef QT_NO_MIMETYPE + #include #include #include @@ -377,3 +379,5 @@ bool QMimeMagicRule::matches(const QByteArray &data) const } QT_END_NAMESPACE + +#endif // QT_NO_MIMETYPE diff --git a/src/corelib/mimetypes/qmimemagicrule_p.h b/src/corelib/mimetypes/qmimemagicrule_p.h index 3b2c9c1a12..03ac1d1de9 100644 --- a/src/corelib/mimetypes/qmimemagicrule_p.h +++ b/src/corelib/mimetypes/qmimemagicrule_p.h @@ -45,6 +45,10 @@ // We mean it. // +#include + +#ifndef QT_NO_MIMETYPE + #include #include #include @@ -89,4 +93,5 @@ Q_DECLARE_TYPEINFO(QMimeMagicRule, Q_MOVABLE_TYPE); QT_END_NAMESPACE +#endif // QT_NO_MIMETYPE #endif // QMIMEMAGICRULE_H diff --git a/src/corelib/mimetypes/qmimemagicrulematcher.cpp b/src/corelib/mimetypes/qmimemagicrulematcher.cpp index fc92a4cdcd..629e8d9d2f 100644 --- a/src/corelib/mimetypes/qmimemagicrulematcher.cpp +++ b/src/corelib/mimetypes/qmimemagicrulematcher.cpp @@ -35,6 +35,8 @@ #include "qmimemagicrulematcher_p.h" +#ifndef QT_NO_MIMETYPE + #include "qmimetype_p.h" QT_BEGIN_NAMESPACE @@ -98,3 +100,4 @@ unsigned QMimeMagicRuleMatcher::priority() const } QT_END_NAMESPACE +#endif // QT_NO_MIMETYPE diff --git a/src/corelib/mimetypes/qmimemagicrulematcher_p.h b/src/corelib/mimetypes/qmimemagicrulematcher_p.h index f600e9801a..1ea6227378 100644 --- a/src/corelib/mimetypes/qmimemagicrulematcher_p.h +++ b/src/corelib/mimetypes/qmimemagicrulematcher_p.h @@ -45,12 +45,14 @@ // We mean it. // +#include "qmimemagicrule_p.h" + +#ifndef QT_NO_MIMETYPE + #include #include #include -#include "qmimemagicrule_p.h" - QT_BEGIN_NAMESPACE class QMimeMagicRuleMatcher @@ -78,4 +80,5 @@ private: QT_END_NAMESPACE +#endif // QT_NO_MIMETYPE #endif // QMIMEMAGICRULEMATCHER_P_H diff --git a/src/corelib/mimetypes/qmimeprovider.cpp b/src/corelib/mimetypes/qmimeprovider.cpp index a65782de6b..7342a5cd77 100644 --- a/src/corelib/mimetypes/qmimeprovider.cpp +++ b/src/corelib/mimetypes/qmimeprovider.cpp @@ -33,6 +33,8 @@ #include "qmimeprovider_p.h" +#ifndef QT_NO_MIMETYPE + #include "qmimetypeparser_p.h" #include #include "qmimemagicrulematcher_p.h" @@ -866,3 +868,5 @@ void QMimeXMLProvider::addMagicMatcher(const QMimeMagicRuleMatcher &matcher) } QT_END_NAMESPACE + +#endif // QT_NO_MIMETYPE diff --git a/src/corelib/mimetypes/qmimeprovider_p.h b/src/corelib/mimetypes/qmimeprovider_p.h index b438c4f076..5a89ac23c3 100644 --- a/src/corelib/mimetypes/qmimeprovider_p.h +++ b/src/corelib/mimetypes/qmimeprovider_p.h @@ -45,8 +45,11 @@ // We mean it. // -#include #include "qmimedatabase_p.h" + +#ifndef QT_NO_MIMETYPE + +#include #include QT_BEGIN_NAMESPACE @@ -168,4 +171,5 @@ private: QT_END_NAMESPACE +#endif // QT_NO_MIMETYPE #endif // QMIMEPROVIDER_P_H diff --git a/src/corelib/mimetypes/qmimetype.cpp b/src/corelib/mimetypes/qmimetype.cpp index e000359980..70df9868b6 100644 --- a/src/corelib/mimetypes/qmimetype.cpp +++ b/src/corelib/mimetypes/qmimetype.cpp @@ -33,6 +33,8 @@ #include "qmimetype.h" +#ifndef QT_NO_MIMETYPE + #include "qmimetype_p.h" #include "qmimedatabase_p.h" #include "qmimeprovider_p.h" @@ -449,3 +451,5 @@ QDebug operator<<(QDebug debug, const QMimeType &mime) #endif QT_END_NAMESPACE + +#endif // QT_NO_MIMETYPE diff --git a/src/corelib/mimetypes/qmimetype.h b/src/corelib/mimetypes/qmimetype.h index d6d12a7ec4..4ba3c53470 100644 --- a/src/corelib/mimetypes/qmimetype.h +++ b/src/corelib/mimetypes/qmimetype.h @@ -34,6 +34,10 @@ #ifndef QMIMETYPE_H #define QMIMETYPE_H +#include + +#ifndef QT_NO_MIMETYPE + #include #include @@ -108,4 +112,6 @@ Q_CORE_EXPORT QDebug operator<<(QDebug debug, const QMimeType &mime); #endif QT_END_NAMESPACE -#endif // QMIMETYPE_H + +#endif // QT_NO_MIMETYPE +#endif // QMIMETYPE_H diff --git a/src/corelib/mimetypes/qmimetype_p.h b/src/corelib/mimetypes/qmimetype_p.h index bfaf32422e..bf533bbcb0 100644 --- a/src/corelib/mimetypes/qmimetype_p.h +++ b/src/corelib/mimetypes/qmimetype_p.h @@ -47,6 +47,8 @@ #include "qmimetype.h" +#ifndef QT_NO_MIMETYPE + #include #include @@ -112,4 +114,5 @@ QT_END_NAMESPACE QT_END_NAMESPACE #endif +#endif // QT_NO_MIMETYPE #endif // QMIMETYPE_P_H diff --git a/src/corelib/mimetypes/qmimetypeparser.cpp b/src/corelib/mimetypes/qmimetypeparser.cpp index 1af426d7e7..9610162c4f 100644 --- a/src/corelib/mimetypes/qmimetypeparser.cpp +++ b/src/corelib/mimetypes/qmimetypeparser.cpp @@ -35,6 +35,8 @@ #include "qmimetypeparser_p.h" +#ifndef QT_NO_MIMETYPE + #include "qmimetype_p.h" #include "qmimemagicrulematcher_p.h" @@ -341,3 +343,5 @@ bool QMimeTypeParserBase::parse(QIODevice *dev, const QString &fileName, QString } QT_END_NAMESPACE + +#endif // QT_NO_MIMETYPE diff --git a/src/corelib/mimetypes/qmimetypeparser_p.h b/src/corelib/mimetypes/qmimetypeparser_p.h index 292a5ab38e..2be4380cee 100644 --- a/src/corelib/mimetypes/qmimetypeparser_p.h +++ b/src/corelib/mimetypes/qmimetypeparser_p.h @@ -47,6 +47,9 @@ // #include "qmimedatabase_p.h" + +#ifndef QT_NO_MIMETYPE + #include "qmimeprovider_p.h" QT_BEGIN_NAMESPACE @@ -118,4 +121,5 @@ private: QT_END_NAMESPACE +#endif // QT_NO_MIMETYPE #endif // MIMETYPEPARSER_P_H diff --git a/src/plugins/printsupport/cups/qppdprintdevice.cpp b/src/plugins/printsupport/cups/qppdprintdevice.cpp index bb2edb33b5..c2bd2872a9 100644 --- a/src/plugins/printsupport/cups/qppdprintdevice.cpp +++ b/src/plugins/printsupport/cups/qppdprintdevice.cpp @@ -438,6 +438,7 @@ QPrint::ColorMode QPpdPrintDevice::defaultColorMode() const return QPrint::GrayScale; } +#ifndef QT_NO_MIMETYPE void QPpdPrintDevice::loadMimeTypes() const { // TODO No CUPS api? Need to manually load CUPS mime.types file? @@ -453,6 +454,7 @@ void QPpdPrintDevice::loadMimeTypes() const m_mimeTypes.append(db.mimeTypeForName(QStringLiteral("text/plain"))); m_haveMimeTypes = true; } +#endif void QPpdPrintDevice::loadPrinter() { diff --git a/src/plugins/printsupport/cups/qppdprintdevice.h b/src/plugins/printsupport/cups/qppdprintdevice.h index d72ab469da..0d618192fe 100644 --- a/src/plugins/printsupport/cups/qppdprintdevice.h +++ b/src/plugins/printsupport/cups/qppdprintdevice.h @@ -95,7 +95,9 @@ protected: void loadOutputBins() const Q_DECL_OVERRIDE; void loadDuplexModes() const Q_DECL_OVERRIDE; void loadColorModes() const Q_DECL_OVERRIDE; +#ifndef QT_NO_MIMETYPE void loadMimeTypes() const Q_DECL_OVERRIDE; +#endif private: void loadPrinter(); diff --git a/src/printsupport/kernel/qplatformprintdevice.cpp b/src/printsupport/kernel/qplatformprintdevice.cpp index b18d4a1cc6..bd6d81774c 100644 --- a/src/printsupport/kernel/qplatformprintdevice.cpp +++ b/src/printsupport/kernel/qplatformprintdevice.cpp @@ -359,6 +359,7 @@ QList QPlatformPrintDevice::supportedColorModes() const return m_colorModes.toList(); } +#ifndef QT_NO_MIMETYPE void QPlatformPrintDevice::loadMimeTypes() const { } @@ -369,6 +370,7 @@ QList QPlatformPrintDevice::supportedMimeTypes() const loadMimeTypes(); return m_mimeTypes.toList(); } +#endif // QT_NO_MIMETYPE QPageSize QPlatformPrintDevice::createPageSize(const QString &key, const QSize &size, const QString &localizedName) { diff --git a/src/printsupport/kernel/qplatformprintdevice.h b/src/printsupport/kernel/qplatformprintdevice.h index 684c37c35d..cb8c47f99e 100644 --- a/src/printsupport/kernel/qplatformprintdevice.h +++ b/src/printsupport/kernel/qplatformprintdevice.h @@ -114,7 +114,9 @@ public: virtual QPrint::ColorMode defaultColorMode() const; virtual QList supportedColorModes() const; +#ifndef QT_NO_MIMETYPE virtual QList supportedMimeTypes() const; +#endif static QPageSize createPageSize(const QString &key, const QSize &size, const QString &localizedName); static QPageSize createPageSize(int windowsId, const QSize &size, const QString &localizedName); @@ -126,7 +128,9 @@ protected: virtual void loadOutputBins() const; virtual void loadDuplexModes() const; virtual void loadColorModes() const; +#ifndef QT_NO_MIMETYPE virtual void loadMimeTypes() const; +#endif QPageSize supportedPageSizeMatch(const QPageSize &pageSize) const; @@ -163,8 +167,10 @@ protected: mutable bool m_haveColorModes; mutable QVector m_colorModes; +#ifndef QT_NO_MIMETYPE mutable bool m_haveMimeTypes; mutable QVector m_mimeTypes; +#endif }; QT_END_NAMESPACE diff --git a/src/printsupport/kernel/qprintdevice.cpp b/src/printsupport/kernel/qprintdevice.cpp index 373cc08bcb..e645442be2 100644 --- a/src/printsupport/kernel/qprintdevice.cpp +++ b/src/printsupport/kernel/qprintdevice.cpp @@ -237,10 +237,12 @@ QList QPrintDevice::supportedColorModes() const return isValid() ? d->supportedColorModes() : QList(); } +#ifndef QT_NO_MIMETYPE QList QPrintDevice::supportedMimeTypes() const { return isValid() ? d->supportedMimeTypes() : QList(); } +#endif // QT_NO_MIMETYPE #endif // QT_NO_PRINTER diff --git a/src/printsupport/kernel/qprintdevice_p.h b/src/printsupport/kernel/qprintdevice_p.h index e2a3e7872b..0250b937bd 100644 --- a/src/printsupport/kernel/qprintdevice_p.h +++ b/src/printsupport/kernel/qprintdevice_p.h @@ -123,7 +123,9 @@ public: QPrint::ColorMode defaultColorMode() const; QList supportedColorModes() const; +#ifndef QT_NO_MIMETYPE QList supportedMimeTypes() const; +#endif private: friend class QPlatformPrinterSupport; diff --git a/src/widgets/dialogs/qfiledialog.cpp b/src/widgets/dialogs/qfiledialog.cpp index 625e40e4f5..70da6ff99b 100644 --- a/src/widgets/dialogs/qfiledialog.cpp +++ b/src/widgets/dialogs/qfiledialog.cpp @@ -1516,6 +1516,8 @@ void QFileDialog::setFilter(QDir::Filters filters) d->showHiddenAction->setChecked((filters & QDir::Hidden)); } +#ifndef QT_NO_MIMETYPE + static QString nameFilterForMime(const QString &mimeType) { QMimeDatabase db; @@ -1585,6 +1587,8 @@ void QFileDialog::selectMimeTypeFilter(const QString &filter) selectNameFilter(text); } +#endif // QT_NO_MIMETYPE + /*! \property QFileDialog::viewMode \brief the way files and directories are displayed in the dialog @@ -2843,9 +2847,12 @@ void QFileDialogPrivate::createWidgets() if (!options->sidebarUrls().isEmpty()) q->setSidebarUrls(options->sidebarUrls()); q->setDirectoryUrl(options->initialDirectory()); +#ifndef QT_NO_MIMETYPE if (!options->mimeTypeFilters().isEmpty()) q->setMimeTypeFilters(options->mimeTypeFilters()); - else if (!options->nameFilters().isEmpty()) + else +#endif + if (!options->nameFilters().isEmpty()) q->setNameFilters(options->nameFilters()); q->selectNameFilter(options->initiallySelectedNameFilter()); q->setDefaultSuffix(options->defaultSuffix()); diff --git a/src/widgets/dialogs/qfiledialog.h b/src/widgets/dialogs/qfiledialog.h index e921ae0d05..95209bceb5 100644 --- a/src/widgets/dialogs/qfiledialog.h +++ b/src/widgets/dialogs/qfiledialog.h @@ -119,9 +119,11 @@ public: void selectNameFilter(const QString &filter); QString selectedNameFilter() const; +#ifndef QT_NO_MIMETYPE void setMimeTypeFilters(const QStringList &filters); QStringList mimeTypeFilters() const; void selectMimeTypeFilter(const QString &filter); +#endif QDir::Filters filter() const; void setFilter(QDir::Filters filters); From b63c721a0e8d637dd2a34cc5d335195349443366 Mon Sep 17 00:00:00 2001 From: Andrew Knight Date: Mon, 9 Feb 2015 16:19:40 +0200 Subject: [PATCH 10/10] xcb: Fix build with -no-xcb-xlib -qt-xcb MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The EGL integration should not call Xlib functions in this case. Change-Id: I46656b12d603ca1b4b0b41f34c3c0e8410c91db8 Reviewed-by: Laszlo Agocs Reviewed-by: Jørgen Lind --- .../xcb_egl/qxcbeglintegration.cpp | 17 ++++++++++------- .../xcb_egl/qxcbeglintegration.h | 2 +- .../gl_integrations/xcb_egl/qxcbeglwindow.cpp | 4 ++++ .../xcb/gl_integrations/xcb_egl/xcb_egl.pro | 5 +---- 4 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglintegration.cpp b/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglintegration.cpp index e82a24539e..16d32b3235 100644 --- a/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglintegration.cpp +++ b/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglintegration.cpp @@ -57,13 +57,7 @@ QXcbEglIntegration::~QXcbEglIntegration() bool QXcbEglIntegration::initialize(QXcbConnection *connection) { m_connection = connection; - -#ifdef USE_XCB_XLIB - Display *dpy = (Display *)m_connection->xlib_display(); -#else - EGLNativeDisplayType dpy = EGL_DEFAULT_DISPLAY; -#endif - m_egl_display = eglGetDisplay(dpy); + m_egl_display = eglGetDisplay(reinterpret_cast(xlib_display())); EGLint major, minor; bool success = eglInitialize(m_egl_display, &major, &minor); @@ -101,4 +95,13 @@ QPlatformOffscreenSurface *QXcbEglIntegration::createPlatformOffscreenSurface(QO return new QEGLPbuffer(eglDisplay(), surface->requestedFormat(), surface); } +void *QXcbEglIntegration::xlib_display() const +{ +#ifdef XCB_USE_XLIB + return m_connection->xlib_display(); +#else + return EGL_DEFAULT_DISPLAY; +#endif +} + QT_END_NAMESPACE diff --git a/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglintegration.h b/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglintegration.h index d16b8eed6a..1f7fd4fc94 100644 --- a/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglintegration.h +++ b/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglintegration.h @@ -65,7 +65,7 @@ public: bool supportsThreadedOpenGL() const Q_DECL_OVERRIDE { return true; } EGLDisplay eglDisplay() const { return m_egl_display; } - void *xlib_display() const { return m_connection->xlib_display(); } + void *xlib_display() const; private: QXcbConnection *m_connection; EGLDisplay m_egl_display; diff --git a/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglwindow.cpp b/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglwindow.cpp index 6df57bcfe6..9e5b67438c 100644 --- a/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglwindow.cpp +++ b/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglwindow.cpp @@ -61,6 +61,7 @@ void QXcbEglWindow::resolveFormat() void *QXcbEglWindow::createVisual() { +#ifdef XCB_USE_XLIB Display *xdpy = static_cast(m_glIntegration->xlib_display()); VisualID id = QXlibEglIntegration::getCompatibleVisualId(xdpy, m_glIntegration->eglDisplay(), m_config); @@ -72,6 +73,9 @@ void *QXcbEglWindow::createVisual() int matchingCount = 0; visualInfo = XGetVisualInfo(xdpy, VisualIDMask, &visualInfoTemplate, &matchingCount); return visualInfo; +#else + return QXcbWindow::createVisual(); +#endif } void QXcbEglWindow::create() diff --git a/src/plugins/platforms/xcb/gl_integrations/xcb_egl/xcb_egl.pro b/src/plugins/platforms/xcb/gl_integrations/xcb_egl/xcb_egl.pro index 082c22821a..28a572a2c9 100644 --- a/src/plugins/platforms/xcb/gl_integrations/xcb_egl/xcb_egl.pro +++ b/src/plugins/platforms/xcb/gl_integrations/xcb_egl/xcb_egl.pro @@ -9,10 +9,7 @@ include(../gl_integrations_plugin_base.pri) CONFIG += egl -DEFINES += SUPPORT_X11 -#should be removed from sources -DEFINES += XCB_USE_EGL XCB_USE_XLIB - +contains(QT_CONFIG, xcb-xlib): DEFINES += XCB_USE_XLIB HEADERS += \ qxcbeglcontext.h \