From c71fc3860b0947c3c793578117e9eb0a3eb3fb31 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Thu, 24 Nov 2016 11:58:19 +0100 Subject: add docs for QPlatformTheme::WheelScrollLines, MouseDoubleClickDistance MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit These theme hints were added in fac71528 and 4a2e297b respectively. Change-Id: Ic39f32dae4d0843b1b2398beb27081ad07d75772 Reviewed-by: Jan Arve Sæther (cherry picked from commit 847a152474550e0952d31f15069fb346565938df) Reviewed-by: Simo Fält --- src/gui/kernel/qplatformtheme.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src') diff --git a/src/gui/kernel/qplatformtheme.cpp b/src/gui/kernel/qplatformtheme.cpp index 7f74959a60..2379b238f9 100644 --- a/src/gui/kernel/qplatformtheme.cpp +++ b/src/gui/kernel/qplatformtheme.cpp @@ -79,6 +79,10 @@ QT_BEGIN_NAMESPACE \value MouseDoubleClickInterval (int) Mouse double click interval in ms, overriding QPlatformIntegration::styleHint. + \value MouseDoubleClickDistance (int) The maximum distance in logical pixels which the mouse can travel + between clicks in order for the click sequence to be handled as a double click. + The default value is 5 logical pixels. + \value MousePressAndHoldInterval (int) Mouse press and hold interval in ms, overriding QPlatformIntegration::styleHint. @@ -88,6 +92,9 @@ QT_BEGIN_NAMESPACE \value StartDragTime (int) Start drag time in ms, overriding QPlatformIntegration::styleHint. + \value WheelScrollLines (int) The number of lines to scroll a widget, when the mouse wheel is rotated. + The default value is 3. \sa QApplication::wheelScrollLines() + \value KeyboardAutoRepeatRate (int) Keyboard auto repeat rate, overriding QPlatformIntegration::styleHint. -- cgit v1.2.3 From 8325808dcf0cc9061f05ec89b6c3e3afb8c1ab8f Mon Sep 17 00:00:00 2001 From: Peter Varga Date: Wed, 28 Sep 2016 11:20:54 +0200 Subject: QTestLib: Add timestamp to mouse click events Timestamp is necessary for testing custom mouse event handlers e.g. what Qt WebEngine uses for handling triple and quadruple mouse clicks. Based on commit 181ee8f9ffacc51265ccc3a0005bf146f230cf85 Task-number: QTBUG-56223 Change-Id: I2bf840f326255333eec83ca8c42f087cb7deb1fb Reviewed-by: Kai Koehne --- src/testlib/qtestmouse.h | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/testlib/qtestmouse.h b/src/testlib/qtestmouse.h index 1143361323..166622e950 100644 --- a/src/testlib/qtestmouse.h +++ b/src/testlib/qtestmouse.h @@ -73,6 +73,11 @@ namespace QTest extern Q_TESTLIB_EXPORT Qt::MouseButton lastMouseButton; extern Q_TESTLIB_EXPORT int lastMouseTimestamp; + // This value is used to emulate timestamps to avoid creating double clicks by mistake. + // Use this constant instead of QStyleHints::mouseDoubleClickInterval property to avoid tests + // to depend on platform themes. + static const int mouseDoubleClickInterval = 500; + static void waitForEvents() { #ifdef Q_OS_MAC @@ -125,7 +130,7 @@ namespace QTest Q_FALLTHROUGH(); case MouseRelease: qt_handleMouseEvent(w, pos, global, Qt::NoButton, stateKey, ++lastMouseTimestamp); - lastMouseTimestamp += 500; // avoid double clicks being generated + lastMouseTimestamp += mouseDoubleClickInterval; // avoid double clicks being generated lastMouseButton = Qt::NoButton; break; case MouseMove: @@ -176,8 +181,10 @@ namespace QTest if (delay == -1 || delay < defaultMouseDelay()) delay = defaultMouseDelay(); - if (delay > 0) + if (delay > 0) { QTest::qWait(delay); + lastMouseTimestamp += delay; + } if (action == MouseClick) { mouseEvent(MousePress, widget, button, stateKey, pos); @@ -194,12 +201,16 @@ namespace QTest { case MousePress: me = QMouseEvent(QEvent::MouseButtonPress, pos, widget->mapToGlobal(pos), button, button, stateKey); + me.setTimestamp(++lastMouseTimestamp); break; case MouseRelease: me = QMouseEvent(QEvent::MouseButtonRelease, pos, widget->mapToGlobal(pos), button, Qt::MouseButton(), stateKey); + me.setTimestamp(++lastMouseTimestamp); + lastMouseTimestamp += mouseDoubleClickInterval; // avoid double clicks being generated break; case MouseDClick: me = QMouseEvent(QEvent::MouseButtonDblClick, pos, widget->mapToGlobal(pos), button, button, stateKey); + me.setTimestamp(++lastMouseTimestamp); break; case MouseMove: QCursor::setPos(widget->mapToGlobal(pos)); -- cgit v1.2.3 From 7ca66b1e66e73a0cb35705df04507ef9f3440cab Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 9 Dec 2016 16:53:30 -0800 Subject: Fix race condition in QFactoryLoader: lock the mutex we already have The process of loading a plugin is examplified by the qLoadPlugin function (though not all users of QFactoryLoader use this function, they all do something similar): const int index = loader->indexOf(key); if (index != -1) { QObject *factoryObject = loader->instance(index); if (FactoryInterface *factory = qobject_cast(factoryObject)) if (PluginInterface *result = factory->create(key, std::forward(args)...)) return result; } QFactoryLoader::indexOf already locked the mutex, but not QFactoryLoader::instance. This commit fixes that. Note that calling the virtual create() in the plugin's factory is not protected by the mutex. Each plugin's factory must be thread-safe and also create an object that works on any thread too. It's also the responsibility of the caller of qLoadPlugin to ensure that it's called thread-safely. Task-number: QTBUG-42855 Change-Id: I63e21df51c7448bc8b5ffffd148ebee33d4c47de Reviewed-by: Olivier Goffart (Woboq GmbH) Reviewed-by: Marc Mutz --- src/corelib/plugin/qfactoryloader.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/corelib/plugin/qfactoryloader.cpp b/src/corelib/plugin/qfactoryloader.cpp index c09dc6c22b..b8e18cc9a8 100644 --- a/src/corelib/plugin/qfactoryloader.cpp +++ b/src/corelib/plugin/qfactoryloader.cpp @@ -282,6 +282,7 @@ QObject *QFactoryLoader::instance(int index) const return 0; #ifndef QT_NO_LIBRARY + QMutexLocker lock(&d->mutex); if (index < d->libraryList.size()) { QLibraryPrivate *library = d->libraryList.at(index); if (library->instance || library->loadPlugin()) { @@ -297,6 +298,7 @@ QObject *QFactoryLoader::instance(int index) const return 0; } index -= d->libraryList.size(); + lock.unlock(); #endif QVector staticPlugins = QPluginLoader::staticPlugins(); -- cgit v1.2.3 From c7b0f56fb1d33ebd8e0b96cee64a1bfb99abdbbd Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 2 Dec 2016 13:02:56 -0800 Subject: Fix build on Windows: winsock2.h requires WIN32_LEAN_AND_MEAN This is required for the next commit. Change-Id: I73fa1e59a4844c43a109fffd148c8c3e3a100c79 Reviewed-by: Oliver Wolff Reviewed-by: Friedemann Kleint --- src/plugins/bearer/generic/qgenericengine.cpp | 3 +++ src/plugins/bearer/platformdefs_win.h | 2 ++ src/plugins/bearer/qnetworksession_impl.cpp | 3 +++ 3 files changed, 8 insertions(+) (limited to 'src') diff --git a/src/plugins/bearer/generic/qgenericengine.cpp b/src/plugins/bearer/generic/qgenericengine.cpp index 02ea7abf88..059617b367 100644 --- a/src/plugins/bearer/generic/qgenericengine.cpp +++ b/src/plugins/bearer/generic/qgenericengine.cpp @@ -37,6 +37,9 @@ ** ****************************************************************************/ +// see comment in ../platformdefs_win.h. +#define WIN32_LEAN_AND_MEAN 1 + #include "qgenericengine.h" #include "../qnetworksession_impl.h" diff --git a/src/plugins/bearer/platformdefs_win.h b/src/plugins/bearer/platformdefs_win.h index 8fb2f1bcc5..5a8487d868 100644 --- a/src/plugins/bearer/platformdefs_win.h +++ b/src/plugins/bearer/platformdefs_win.h @@ -40,6 +40,8 @@ #ifndef QPLATFORMDEFS_WIN_H #define QPLATFORMDEFS_WIN_H +// Since we need to include winsock2.h, we need to define WIN32_LEAN_AND_MEAN +// somewhere above so windows.h won't include winsock.h. #include #include #undef interface diff --git a/src/plugins/bearer/qnetworksession_impl.cpp b/src/plugins/bearer/qnetworksession_impl.cpp index 5ce51670f7..7756709e55 100644 --- a/src/plugins/bearer/qnetworksession_impl.cpp +++ b/src/plugins/bearer/qnetworksession_impl.cpp @@ -37,6 +37,9 @@ ** ****************************************************************************/ +// see comment in ../platformdefs_win.h. +#define WIN32_LEAN_AND_MEAN 1 + #include "qnetworksession_impl.h" #include "qbearerengine_impl.h" -- cgit v1.2.3 From 7c402ad3d15ff5e7c2b7319b1bea821f6f67e26c Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 27 Sep 2016 16:52:55 -0700 Subject: Make the bearer QFactoryLoader a member variable, not a static Because it was a function-level static, the QFactoryLoader was getting destroyed out-of-sync with the bearer thread stopping. Under normal conditions, the thread stopped first (~QApplication / ~QCoreApplication via qAddPostRoutine), and the static got destroyed when the process exited. However, if QApplication leaked or if the destruction order is wonky (as seen in PyQt5), the thread could still be running when the plugins were already unloaded. With the loader a member variable, it gets destroyed when the thread stops. Note: in Qt 5.7, QFactoryLoader no longer unloads the plugins (since commit 494376f980e96339b6f1eff7c41336ca4d853065), so this crash cannot happen in that version. [ChangeLog][QtNetwork][Bearer management] Fixed a bug that could cause a crash on application exit, depending on the order of destruction of the QCoreApplication object and the QtDBus manager thread. Task-number: QTBUG-56228 Task-number: QTBUG-52988 Change-Id: I33dc971f005a4848bb8ffffd147853376f82de2a Reviewed-by: Lorn Potter Reviewed-by: Edward Welbourne --- src/network/bearer/qnetworkconfigmanager_p.cpp | 7 +++---- src/network/bearer/qnetworkconfigmanager_p.h | 2 ++ 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/network/bearer/qnetworkconfigmanager_p.cpp b/src/network/bearer/qnetworkconfigmanager_p.cpp index 2da073fa5a..a903ecda5f 100644 --- a/src/network/bearer/qnetworkconfigmanager_p.cpp +++ b/src/network/bearer/qnetworkconfigmanager_p.cpp @@ -40,8 +40,6 @@ #include "qnetworkconfigmanager_p.h" #include "qbearerplugin_p.h" -#include - #include #include #include @@ -60,7 +58,9 @@ QT_BEGIN_NAMESPACE QNetworkConfigurationManagerPrivate::QNetworkConfigurationManagerPrivate() - : QObject(), pollTimer(0), mutex(QMutex::Recursive), forcedPolling(0), firstUpdate(true) + : QObject(), pollTimer(0), mutex(QMutex::Recursive), + loader(QBearerEngineFactoryInterface_iid, QLatin1String("/bearer")), + forcedPolling(0), firstUpdate(true) { qRegisterMetaType(); qRegisterMetaType(); @@ -365,7 +365,6 @@ void QNetworkConfigurationManagerPrivate::updateConfigurations() bool envOK = false; const int skipGeneric = qEnvironmentVariableIntValue("QT_EXCLUDE_GENERIC_BEARER", &envOK); QBearerEngine *generic = 0; - static QFactoryLoader loader(QBearerEngineFactoryInterface_iid, QLatin1String("/bearer")); QFactoryLoader *l = &loader; const PluginKeyMap keyMap = l->keyMap(); const PluginKeyMapConstIterator cend = keyMap.constEnd(); diff --git a/src/network/bearer/qnetworkconfigmanager_p.h b/src/network/bearer/qnetworkconfigmanager_p.h index a804e037a3..380e25c22f 100644 --- a/src/network/bearer/qnetworkconfigmanager_p.h +++ b/src/network/bearer/qnetworkconfigmanager_p.h @@ -55,6 +55,7 @@ #include "qnetworkconfigmanager.h" #include "qnetworkconfiguration_p.h" +#include #include #include @@ -118,6 +119,7 @@ private: private: mutable QMutex mutex; + QFactoryLoader loader; QList sessionEngines; QSet onlineConfigurations; -- cgit v1.2.3 From 7adfe7494bb4a2c1d3a036fe9dfd946bc00c5d49 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 18 Dec 2016 11:32:27 +0000 Subject: Update model-view documentation about layoutChanged This has always been true, but hasn't been documented well enough, so triagers are giving incorrect information in bug reports (eg QTBUG-47711 and QTBUG-53221). That incorrect information is being treated as truth by Qt users which take action based on incorrect information. That is a problem, so try to make the documentation clear. Change-Id: I4e44a9a0675cdd7d9289ec209ae32d5a92899fc9 Reviewed-by: David Faure --- src/widgets/doc/src/model-view-programming.qdoc | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/widgets/doc/src/model-view-programming.qdoc b/src/widgets/doc/src/model-view-programming.qdoc index e727d7fe56..84819e8c1a 100644 --- a/src/widgets/doc/src/model-view-programming.qdoc +++ b/src/widgets/doc/src/model-view-programming.qdoc @@ -2070,9 +2070,22 @@ Normally, the begin and end functions are capable of informing other components about changes to the model's underlying structure. For more complex changes to the - model's structure, perhaps involving internal reorganization or sorting of data, - it is necessary to emit the \l{QAbstractItemModel::layoutChanged()}{layoutChanged()} - signal to cause any attached views to be updated. + model's structure, perhaps involving internal reorganization, sorting of data or + any other structural change, it is necessary to perform the following sequence: + + \li Emit the \l{QAbstractItemModel::layoutAboutToBeChanged()}{layoutAboutToBeChanged()} signal + \li Update internal data which represents the structure of the model. + \li Update persistent indexes using \l{QAbstractItemModel::changePersistentIndexList()}{changePersistentIndexList()} + \li Emit the \l{QAbstractItemModel::layoutChanged()}{layoutChanged()} signal. + + This sequence can be used for any structural update in lieu of the more + high-level and convenient protected methods. For example, if a model of + two million rows needs to have all odd numbered rows removed, that + is 1 million discountiguous ranges of 1 element each. It would be + possible to use beginRemoveRows and endRemoveRows 1 million times, but + that would obviously be inefficient. Instead, this can be signalled as a + single layout change which updates all necessary persistent indexes at + once. \section3 Lazy population of model data -- cgit v1.2.3 From 6614f7754c2616aa66ddd9bbad23d0f415db5b6c Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Thu, 15 Dec 2016 15:21:23 +0100 Subject: Silence implicit-fallthough warnings Fixes Werror build with GCC 7. Change-Id: Ie0e9fb907af545b6c200558faaaf83b8ec058b7a Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/tools/moc/moc.cpp | 1 + src/tools/moc/parser.h | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/tools/moc/moc.cpp b/src/tools/moc/moc.cpp index 89bf2bd6a1..03f022da69 100644 --- a/src/tools/moc/moc.cpp +++ b/src/tools/moc/moc.cpp @@ -197,6 +197,7 @@ Type Moc::parseType() prev(); break; } + Q_FALLTHROUGH(); case CHAR: case SHORT: case INT: diff --git a/src/tools/moc/parser.h b/src/tools/moc/parser.h index ee8761108b..bedcbbf7e2 100644 --- a/src/tools/moc/parser.h +++ b/src/tools/moc/parser.h @@ -68,8 +68,8 @@ public: inline QByteArray unquotedLexem() { return symbols.at(index-1).unquotedLexem();} inline const Symbol &symbol() { return symbols.at(index-1);} - void error(int rollback); - void error(const char *msg = 0); + Q_NORETURN void error(int rollback); + Q_NORETURN void error(const char *msg = 0); void warning(const char * = 0); void note(const char * = 0); -- cgit v1.2.3 From 20fd99d86379b0df3c9c4159d397d3451622c325 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Wed, 14 Dec 2016 19:00:37 +0100 Subject: fix typos in "ras[p]berry pi" Change-Id: I2d8910df9266d9cbf2426e5f2ba2a88eb2e821ef Reviewed-by: Joerg Bornemann --- src/gui/configure.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/gui/configure.json b/src/gui/configure.json index f4171a8e9f..2fce7eebb8 100644 --- a/src/gui/configure.json +++ b/src/gui/configure.json @@ -322,7 +322,7 @@ "use": "egl xcb_xlib" }, "egl-brcm": { - "label": "Broadcom EGL (Rasberry Pi)", + "label": "Broadcom EGL (Raspberry Pi)", "type": "compile", "test": "qpa/eglfs-brcm", "use": "egl bcm_host" @@ -599,7 +599,7 @@ "output": [ "privateFeature" ] }, "eglfs_brcm": { - "label": "EGLFS Rasberry Pi", + "label": "EGLFS Raspberry Pi", "condition": "features.eglfs && tests.egl-brcm", "output": [ "privateFeature" ] }, -- cgit v1.2.3 From bee9a78e13a903fd26a467464aa178fc67dbd0a2 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Mon, 12 Dec 2016 14:38:34 +0100 Subject: Avoid using QRgba64 for buffers Benchmarking showed most time rendering in rgb64 mode was spend on memsetting the buffers because they were not declared with a primitive type. This patch changes the buffers to quint64, but leaves refactoring function arguments to a later patch in the dev branch. Change-Id: Iacc81b0d8e9570b1975dffb85c955b0aabb096a7 Reviewed-by: Eirik Aavitsland --- src/gui/painting/qdrawhelper.cpp | 66 ++++++++++++++++++++-------------------- 1 file changed, 33 insertions(+), 33 deletions(-) (limited to 'src') diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp index a2e49dbfdb..adc28f07d3 100644 --- a/src/gui/painting/qdrawhelper.cpp +++ b/src/gui/painting/qdrawhelper.cpp @@ -2870,8 +2870,8 @@ static const QRgba64 *QT_FASTCALL fetchTransformedBilinear64(QRgba64 *buffer, co FetchPixelFunc fetch = qFetchPixel[layout->bpp]; uint sbuf1[buffer_size]; uint sbuf2[buffer_size]; - QRgba64 buf1[buffer_size]; - QRgba64 buf2[buffer_size]; + quint64 buf1[buffer_size]; + quint64 buf2[buffer_size]; QRgba64 *b = buffer; while (length) { int len = qMin(length, buffer_size / 2); @@ -2947,9 +2947,9 @@ static const QRgba64 *QT_FASTCALL fetchTransformedBilinear64(QRgba64 *buffer, co fx += fdx; } - layout->convertToARGB64PM(buf1, sbuf1, len * 2, clut, 0); + layout->convertToARGB64PM((QRgba64 *)buf1, sbuf1, len * 2, clut, 0); if (disty) - layout->convertToARGB64PM(buf2, sbuf2, len * 2, clut, 0); + layout->convertToARGB64PM((QRgba64 *)buf2, sbuf2, len * 2, clut, 0); for (int i = 0; i < len; ++i) { int distx = (fracX & 0x0000ffff); @@ -2967,7 +2967,7 @@ static const QRgba64 *QT_FASTCALL fetchTransformedBilinear64(QRgba64 *buffer, co vt = _mm_add_epi16(vt, _mm_srli_si128(vt, 8)); _mm_storel_epi64((__m128i*)(b+i), vt); #else - b[i] = interpolate_4_pixels_rgb64(buf1 + i*2, buf2 + i*2, distx, disty); + b[i] = interpolate_4_pixels_rgb64((QRgba64 *)buf1 + i*2, (QRgba64 *)buf2 + i*2, distx, disty); #endif fracX += fdx; } @@ -2978,8 +2978,8 @@ static const QRgba64 *QT_FASTCALL fetchTransformedBilinear64(QRgba64 *buffer, co FetchPixelFunc fetch = qFetchPixel[layout->bpp]; uint sbuf1[buffer_size]; uint sbuf2[buffer_size]; - QRgba64 buf1[buffer_size]; - QRgba64 buf2[buffer_size]; + quint64 buf1[buffer_size]; + quint64 buf2[buffer_size]; QRgba64 *end = buffer + length; QRgba64 *b = buffer; @@ -3087,13 +3087,13 @@ static const QRgba64 *QT_FASTCALL fetchTransformedBilinear64(QRgba64 *buffer, co fx += fdx; fy += fdy; } - layout->convertToARGB64PM(buf1, sbuf1, len * 2, clut, 0); - layout->convertToARGB64PM(buf2, sbuf2, len * 2, clut, 0); + layout->convertToARGB64PM((QRgba64 *)buf1, sbuf1, len * 2, clut, 0); + layout->convertToARGB64PM((QRgba64 *)buf2, sbuf2, len * 2, clut, 0); for (int i = 0; i < len; ++i) { int distx = (fracX & 0x0000ffff); int disty = (fracY & 0x0000ffff); - b[i] = interpolate_4_pixels_rgb64(buf1 + i*2, buf2 + i*2, distx, disty); + b[i] = interpolate_4_pixels_rgb64((QRgba64 *)buf1 + i*2, (QRgba64 *)buf2 + i*2, distx, disty); fracX += fdx; fracY += fdy; } @@ -3110,8 +3110,8 @@ static const QRgba64 *QT_FASTCALL fetchTransformedBilinear64(QRgba64 *buffer, co FetchPixelFunc fetch = qFetchPixel[layout->bpp]; uint sbuf1[buffer_size]; uint sbuf2[buffer_size]; - QRgba64 buf1[buffer_size]; - QRgba64 buf2[buffer_size]; + quint64 buf1[buffer_size]; + quint64 buf2[buffer_size]; QRgba64 *b = buffer; int distxs[buffer_size / 2]; @@ -3159,13 +3159,13 @@ static const QRgba64 *QT_FASTCALL fetchTransformedBilinear64(QRgba64 *buffer, co fw += fdw; } - layout->convertToARGB64PM(buf1, sbuf1, len * 2, clut, 0); - layout->convertToARGB64PM(buf2, sbuf2, len * 2, clut, 0); + layout->convertToARGB64PM((QRgba64 *)buf1, sbuf1, len * 2, clut, 0); + layout->convertToARGB64PM((QRgba64 *)buf2, sbuf2, len * 2, clut, 0); for (int i = 0; i < len; ++i) { int distx = distxs[i]; int disty = distys[i]; - b[i] = interpolate_4_pixels_rgb64(buf1 + i*2, buf2 + i*2, distx, disty); + b[i] = interpolate_4_pixels_rgb64((QRgba64 *)buf1 + i*2, (QRgba64 *)buf2 + i*2, distx, disty); } length -= len; @@ -3712,7 +3712,7 @@ void blend_color_generic_rgb64(int count, const QSpan *spans, void *userData) return blend_color_generic(count, spans, userData); } - QRgba64 buffer[buffer_size]; + quint64 buffer[buffer_size]; const QRgba64 color = data->solid.color; while (count--) { @@ -3720,7 +3720,7 @@ void blend_color_generic_rgb64(int count, const QSpan *spans, void *userData) int length = spans->len; while (length) { int l = qMin(buffer_size, length); - QRgba64 *dest = op.destFetch64(buffer, data->rasterBuffer, x, spans->y, l); + QRgba64 *dest = op.destFetch64((QRgba64 *)buffer, data->rasterBuffer, x, spans->y, l); op.funcSolid64(dest, l, color, spans->coverage); op.destStore64(data->rasterBuffer, x, spans->y, dest, l); length -= l; @@ -3901,11 +3901,11 @@ public: } }; -class BlendSrcGenericRGB64 : public QBlendBase +class BlendSrcGenericRGB64 : public QBlendBase { public: BlendSrcGenericRGB64(QSpanData *d, const Operator &o) - : QBlendBase(d, o) + : QBlendBase(d, o) { } @@ -3914,20 +3914,20 @@ public: return op.func64 && op.destFetch64 && op.destStore64; } - const QRgba64 *fetch(int x, int y, int len) + const quint64 *fetch(int x, int y, int len) { - dest = op.destFetch64(buffer, data->rasterBuffer, x, y, len); - return op.srcFetch64(src_buffer, &op, data, y, x, len); + dest = (quint64 *)op.destFetch64((QRgba64 *)buffer, data->rasterBuffer, x, y, len); + return (const quint64 *)op.srcFetch64((QRgba64 *)src_buffer, &op, data, y, x, len); } - void process(int, int, int len, int coverage, const QRgba64 *src, int offset) + void process(int, int, int len, int coverage, const quint64 *src, int offset) { - op.func64(dest + offset, src + offset, len, coverage); + op.func64((QRgba64 *)dest + offset, (const QRgba64 *)src + offset, len, coverage); } void store(int x, int y, int len) { - op.destStore64(data->rasterBuffer, x, y, dest, len); + op.destStore64(data->rasterBuffer, x, y, (QRgba64 *)dest, len); } }; @@ -4006,8 +4006,8 @@ static void blend_untransformed_generic_rgb64(int count, const QSpan *spans, voi qWarning("Unsupported blend"); return blend_untransformed_generic(count, spans, userData); } - QRgba64 buffer[buffer_size]; - QRgba64 src_buffer[buffer_size]; + quint64 buffer[buffer_size]; + quint64 src_buffer[buffer_size]; const int image_width = data->texture.width; const int image_height = data->texture.height; @@ -4031,8 +4031,8 @@ static void blend_untransformed_generic_rgb64(int count, const QSpan *spans, voi const int coverage = (spans->coverage * data->texture.const_alpha) >> 8; while (length) { int l = qMin(buffer_size, length); - const QRgba64 *src = op.srcFetch64(src_buffer, &op, data, sy, sx, l); - QRgba64 *dest = op.destFetch64(buffer, data->rasterBuffer, x, spans->y, l); + const QRgba64 *src = op.srcFetch64((QRgba64 *)src_buffer, &op, data, sy, sx, l); + QRgba64 *dest = op.destFetch64((QRgba64 *)buffer, data->rasterBuffer, x, spans->y, l); op.func64(dest, src, l, coverage); op.destStore64(data->rasterBuffer, x, spans->y, dest, l); x += l; @@ -4247,8 +4247,8 @@ static void blend_tiled_generic_rgb64(int count, const QSpan *spans, void *userD qDebug("unsupported rgb64 blend"); return blend_tiled_generic(count, spans, userData); } - QRgba64 buffer[buffer_size]; - QRgba64 src_buffer[buffer_size]; + quint64 buffer[buffer_size]; + quint64 src_buffer[buffer_size]; const int image_width = data->texture.width; const int image_height = data->texture.height; @@ -4275,8 +4275,8 @@ static void blend_tiled_generic_rgb64(int count, const QSpan *spans, void *userD int l = qMin(image_width - sx, length); if (buffer_size < l) l = buffer_size; - const QRgba64 *src = op.srcFetch64(src_buffer, &op, data, sy, sx, l); - QRgba64 *dest = op.destFetch64(buffer, data->rasterBuffer, x, spans->y, l); + const QRgba64 *src = op.srcFetch64((QRgba64 *)src_buffer, &op, data, sy, sx, l); + QRgba64 *dest = op.destFetch64((QRgba64 *)buffer, data->rasterBuffer, x, spans->y, l); op.func64(dest, src, l, coverage); op.destStore64(data->rasterBuffer, x, spans->y, dest, l); x += l; -- cgit v1.2.3 From 1274a7e419c9f25d6dcd01b8dc86d764776ef1b4 Mon Sep 17 00:00:00 2001 From: Samuel Gaist Date: Wed, 14 Dec 2016 22:04:37 +0100 Subject: Doc: Updated code sample to match documentation of QCompleter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The QCompleter documentation mentions QFileSystemModel while the code sample still uses QDirModel. This patch fixes this by updating the code sample. Change-Id: I99a0d2419efcf781af3e9530508df088d77fbbfa Reviewed-by: Sze Howe Koh Reviewed-by: Topi Reiniö --- src/widgets/doc/snippets/code/src_gui_util_qcompleter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/widgets/doc/snippets/code/src_gui_util_qcompleter.cpp b/src/widgets/doc/snippets/code/src_gui_util_qcompleter.cpp index 284a4ce404..7d003e4886 100644 --- a/src/widgets/doc/snippets/code/src_gui_util_qcompleter.cpp +++ b/src/widgets/doc/snippets/code/src_gui_util_qcompleter.cpp @@ -62,7 +62,7 @@ lineEdit->setCompleter(completer); //! [1] QCompleter *completer = new QCompleter(this); -completer->setModel(new QDirModel(completer)); +completer->setModel(new QFileSystemModel(completer)); lineEdit->setCompleter(completer); //! [1] -- cgit v1.2.3 From 3bd0fd8f97e7a33a874929a383a42e6c710bfff3 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 17 Dec 2016 06:20:06 +0000 Subject: QSFPM: Fix handling of source model layout change In sourceLayoutAboutToBeChanged the source model update is ignored if the affected parents are filtered out anyway. The same logic is attempted in the sourceLayoutChanged slot, but there the early-return logic is applied too late - the mapping is cleared before performing the early-return. Because pointers into the mapping are used in the internalPointer of QModelIndexes in this class, persistent indexes used later will segfault when attempting to dereference it. Additionally, if a parent becomes invalid as a result of the layoutChange, it would be filtered out by the condition in the loop, resulting in a different result in the comparison of emptiness of the parents container. Fix that by persisting the parent's container, and performing the test for early-return before clearing the mapping. Task-number: QTBUG-47711 Task-number: QTBUG-32981 Change-Id: If45e8a1c97d39454160f52041bc9ae7e337dce97 Reviewed-by: David Faure --- src/corelib/itemmodels/qsortfilterproxymodel.cpp | 31 +++++++++--------------- 1 file changed, 11 insertions(+), 20 deletions(-) (limited to 'src') diff --git a/src/corelib/itemmodels/qsortfilterproxymodel.cpp b/src/corelib/itemmodels/qsortfilterproxymodel.cpp index b0ddfa879d..333152138e 100644 --- a/src/corelib/itemmodels/qsortfilterproxymodel.cpp +++ b/src/corelib/itemmodels/qsortfilterproxymodel.cpp @@ -171,6 +171,7 @@ public: QRowsRemoval itemsBeingRemoved; QModelIndexPairList saved_persistent_indexes; + QList saved_layoutChange_parents; QHash::const_iterator create_mapping( const QModelIndex &source_parent) const; @@ -1331,23 +1332,23 @@ void QSortFilterProxyModelPrivate::_q_sourceLayoutAboutToBeChanged(const QList parents; + saved_layoutChange_parents.clear(); for (const QPersistentModelIndex &parent : sourceParents) { if (!parent.isValid()) { - parents << QPersistentModelIndex(); + saved_layoutChange_parents << QPersistentModelIndex(); continue; } const QModelIndex mappedParent = q->mapFromSource(parent); // Might be filtered out. if (mappedParent.isValid()) - parents << mappedParent; + saved_layoutChange_parents << mappedParent; } // All parents filtered out. - if (!sourceParents.isEmpty() && parents.isEmpty()) + if (!sourceParents.isEmpty() && saved_layoutChange_parents.isEmpty()) return; - emit q->layoutAboutToBeChanged(parents); + emit q->layoutAboutToBeChanged(saved_layoutChange_parents); if (persistent.indexes.isEmpty()) return; @@ -1359,6 +1360,9 @@ void QSortFilterProxyModelPrivate::_q_sourceLayoutChanged(const QList parents; - for (const QPersistentModelIndex &parent : sourceParents) { - if (!parent.isValid()) { - parents << QPersistentModelIndex(); - continue; - } - const QModelIndex mappedParent = q->mapFromSource(parent); - if (mappedParent.isValid()) - parents << mappedParent; - } - - if (!sourceParents.isEmpty() && parents.isEmpty()) - return; - - emit q->layoutChanged(parents); + emit q->layoutChanged(saved_layoutChange_parents); + saved_layoutChange_parents.clear(); } void QSortFilterProxyModelPrivate::_q_sourceRowsAboutToBeInserted( -- cgit v1.2.3 From 0874861bcc70313c343aba5e5566ed30b69eed1c Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Mon, 19 Dec 2016 21:13:57 +0000 Subject: QSFPM: Remove data manipulation from move handlers Similar to the fix in the parent commit, incorrect updating of the internal data structures during layout changes can lead to dangling pointers being dereferenced later. Moves are treated as layoutChanges by this proxy by forwarding to the appropriate method. However, data is incorrectly cleared prior to that forwarding. Remove that, and let the layoutChange handling take appropriate action. Change-Id: Iee951e37152328a4e6a5fb8e5385c32a2fe4c0bd Reviewed-by: David Faure --- src/corelib/itemmodels/qsortfilterproxymodel.cpp | 67 +++++------------------- 1 file changed, 12 insertions(+), 55 deletions(-) (limited to 'src') diff --git a/src/corelib/itemmodels/qsortfilterproxymodel.cpp b/src/corelib/itemmodels/qsortfilterproxymodel.cpp index 333152138e..226a2401e1 100644 --- a/src/corelib/itemmodels/qsortfilterproxymodel.cpp +++ b/src/corelib/itemmodels/qsortfilterproxymodel.cpp @@ -1418,49 +1418,27 @@ void QSortFilterProxyModelPrivate::_q_sourceRowsRemoved( void QSortFilterProxyModelPrivate::_q_sourceRowsAboutToBeMoved( const QModelIndex &sourceParent, int /* sourceStart */, int /* sourceEnd */, const QModelIndex &destParent, int /* dest */) { - Q_Q(QSortFilterProxyModel); // Because rows which are contiguous in the source model might not be contiguous // in the proxy due to sorting, the best thing we can do here is be specific about what // parents are having their children changed. // Optimize: Emit move signals if the proxy is not sorted. Will need to account for rows // being filtered out though. - saved_persistent_indexes.clear(); - QList parents; - parents << q->mapFromSource(sourceParent); + parents << sourceParent; if (sourceParent != destParent) - parents << q->mapFromSource(destParent); - emit q->layoutAboutToBeChanged(parents); - if (persistent.indexes.isEmpty()) - return; - saved_persistent_indexes = store_persistent_indexes(); + parents << destParent; + _q_sourceLayoutAboutToBeChanged(parents, QAbstractItemModel::NoLayoutChangeHint); } void QSortFilterProxyModelPrivate::_q_sourceRowsMoved( const QModelIndex &sourceParent, int /* sourceStart */, int /* sourceEnd */, const QModelIndex &destParent, int /* dest */) { - Q_Q(QSortFilterProxyModel); - - // Optimize: We only need to clear and update the persistent indexes which are children of - // sourceParent or destParent - qDeleteAll(source_index_mapping); - source_index_mapping.clear(); - - update_persistent_indexes(saved_persistent_indexes); - saved_persistent_indexes.clear(); - - if (dynamic_sortfilter && update_source_sort_column()) { - //update_source_sort_column might have created wrong mapping so we have to clear it again - qDeleteAll(source_index_mapping); - source_index_mapping.clear(); - } - QList parents; - parents << q->mapFromSource(sourceParent); + parents << sourceParent; if (sourceParent != destParent) - parents << q->mapFromSource(destParent); - emit q->layoutChanged(parents); + parents << destParent; + _q_sourceLayoutChanged(parents, QAbstractItemModel::NoLayoutChangeHint); } void QSortFilterProxyModelPrivate::_q_sourceColumnsAboutToBeInserted( @@ -1522,42 +1500,21 @@ void QSortFilterProxyModelPrivate::_q_sourceColumnsRemoved( void QSortFilterProxyModelPrivate::_q_sourceColumnsAboutToBeMoved( const QModelIndex &sourceParent, int /* sourceStart */, int /* sourceEnd */, const QModelIndex &destParent, int /* dest */) { - Q_Q(QSortFilterProxyModel); - - saved_persistent_indexes.clear(); - QList parents; - parents << q->mapFromSource(sourceParent); + parents << sourceParent; if (sourceParent != destParent) - parents << q->mapFromSource(destParent); - emit q->layoutAboutToBeChanged(parents); - - if (persistent.indexes.isEmpty()) - return; - saved_persistent_indexes = store_persistent_indexes(); + parents << destParent; + _q_sourceLayoutAboutToBeChanged(parents, QAbstractItemModel::NoLayoutChangeHint); } void QSortFilterProxyModelPrivate::_q_sourceColumnsMoved( const QModelIndex &sourceParent, int /* sourceStart */, int /* sourceEnd */, const QModelIndex &destParent, int /* dest */) { - Q_Q(QSortFilterProxyModel); - - qDeleteAll(source_index_mapping); - source_index_mapping.clear(); - - update_persistent_indexes(saved_persistent_indexes); - saved_persistent_indexes.clear(); - - if (dynamic_sortfilter && update_source_sort_column()) { - qDeleteAll(source_index_mapping); - source_index_mapping.clear(); - } - QList parents; - parents << q->mapFromSource(sourceParent); + parents << sourceParent; if (sourceParent != destParent) - parents << q->mapFromSource(destParent); - emit q->layoutChanged(parents); + parents << destParent; + _q_sourceLayoutChanged(parents, QAbstractItemModel::NoLayoutChangeHint); } /*! -- cgit v1.2.3 From baad82d242a4d8c1af6c87faaa7f25584183fd53 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 20 Dec 2016 00:44:12 +0000 Subject: QIPM: Persist model indexes after emitting layoutChange, not before Callers can persist a QModelIndex which was not persisted before in a slot connected to the signal, and such a persisted index must be updated in the course of the layoutChange. Store the indexes to persist after emitting the signal. Task-number: QTBUG-32981 Change-Id: Ibee4c0d84817d72603a03fe5b22fdeefeac0695e Reviewed-by: David Faure --- src/corelib/itemmodels/qidentityproxymodel.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/corelib/itemmodels/qidentityproxymodel.cpp b/src/corelib/itemmodels/qidentityproxymodel.cpp index e537793146..7c306799d0 100644 --- a/src/corelib/itemmodels/qidentityproxymodel.cpp +++ b/src/corelib/itemmodels/qidentityproxymodel.cpp @@ -496,15 +496,6 @@ void QIdentityProxyModelPrivate::_q_sourceLayoutAboutToBeChanged(const QListpersistentIndexList(); - for (const QPersistentModelIndex &proxyPersistentIndex : proxyPersistentIndexes) { - proxyIndexes << proxyPersistentIndex; - Q_ASSERT(proxyPersistentIndex.isValid()); - const QPersistentModelIndex srcPersistentIndex = q->mapToSource(proxyPersistentIndex); - Q_ASSERT(srcPersistentIndex.isValid()); - layoutChangePersistentIndexes << srcPersistentIndex; - } - QList parents; parents.reserve(sourceParents.size()); for (const QPersistentModelIndex &parent : sourceParents) { @@ -518,6 +509,15 @@ void QIdentityProxyModelPrivate::_q_sourceLayoutAboutToBeChanged(const QListlayoutAboutToBeChanged(parents, hint); + + const auto proxyPersistentIndexes = q->persistentIndexList(); + for (const QPersistentModelIndex &proxyPersistentIndex : proxyPersistentIndexes) { + proxyIndexes << proxyPersistentIndex; + Q_ASSERT(proxyPersistentIndex.isValid()); + const QPersistentModelIndex srcPersistentIndex = q->mapToSource(proxyPersistentIndex); + Q_ASSERT(srcPersistentIndex.isValid()); + layoutChangePersistentIndexes << srcPersistentIndex; + } } void QIdentityProxyModelPrivate::_q_sourceLayoutChanged(const QList &sourceParents, QAbstractItemModel::LayoutChangeHint hint) -- cgit v1.2.3 From b9edbb5d54290331f89a7ced4e4d7807098b61d7 Mon Sep 17 00:00:00 2001 From: David Faure Date: Wed, 21 Dec 2016 12:49:53 +0100 Subject: QLockFile: make sure we encode the hostname as UTF-8 in the lock file We chose to use UTF-8 as it allows us to ensure there's no mistaking the hostname in case the locale is changed, if the host name contains characters outside of US-ASCII. But this didn't work because the code that wrote the hostname always used the local 8-bit codec instead of UTF-8. On Unix, we used the result of gethostname(3) directly, which is supposedly on the locale codec. This commit doesn't fix Windows, which requires _wgetenv, the plan being to encapsulate that with a qEnvironmentVariable() method. [ChangeLog][QtCore][QLockFile] Fixed a bug that caused QLockFile not to recognize a stale lock file if the machine's hostname contained non-US- ASCII characters, on Unix. A Windows fix is still pending. Task-number: QTBUG-49640 Change-Id: Ib9d045544ff370ec901626658a84ec4e6575fe21 Reviewed-by: Thiago Macieira --- src/corelib/io/qlockfile_unix.cpp | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/corelib/io/qlockfile_unix.cpp b/src/corelib/io/qlockfile_unix.cpp index 82beb15912..3a80014c00 100644 --- a/src/corelib/io/qlockfile_unix.cpp +++ b/src/corelib/io/qlockfile_unix.cpp @@ -81,15 +81,6 @@ QT_BEGIN_NAMESPACE -static QByteArray localHostName() // from QHostInfo::localHostName(), modified to return a QByteArray -{ - QByteArray hostName(512, Qt::Uninitialized); - if (gethostname(hostName.data(), hostName.size()) == -1) - return QByteArray(); - hostName.truncate(strlen(hostName.data())); - return hostName; -} - // ### merge into qt_safe_write? static qint64 qt_write_loop(int fd, const char *data, qint64 len) { @@ -185,7 +176,7 @@ QLockFile::LockError QLockFilePrivate::tryLock_sys() // Use operator% from the fast builder to avoid multiple memory allocations. QByteArray fileData = QByteArray::number(QCoreApplication::applicationPid()) % '\n' % QCoreApplication::applicationName().toUtf8() % '\n' - % localHostName() % '\n'; + % QSysInfo::machineHostName().toUtf8() % '\n'; const QByteArray lockFileName = QFile::encodeName(fileName); const int fd = qt_safe_open(lockFileName.constData(), O_WRONLY | O_CREAT | O_EXCL, 0666); @@ -242,7 +233,7 @@ bool QLockFilePrivate::isApparentlyStale() const qint64 pid; QString hostname, appname; if (getLockInfo(&pid, &hostname, &appname)) { - if (hostname.isEmpty() || hostname == QString::fromLocal8Bit(localHostName())) { + if (hostname.isEmpty() || hostname == QSysInfo::machineHostName()) { if (::kill(pid, 0) == -1 && errno == ESRCH) return true; // PID doesn't exist anymore const QString processName = processNameByPid(pid); -- cgit v1.2.3 From 8533c94a244b7ed14dcfaac69b512901fe10737e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Tue, 20 Dec 2016 14:28:23 +0100 Subject: macOS: Take DPR into account when creating CGContexts for a QPixmap Missing logic when refactoring image manipulation methods into QtGui in c52bb030907. Task-number: QTBUG-57723 Change-Id: I7b55d4451d35faf5fd794daa0b80acbd712f30cd Reviewed-by: Gabriel de Dietrich --- src/gui/painting/qcoregraphics.mm | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/gui/painting/qcoregraphics.mm b/src/gui/painting/qcoregraphics.mm index 466b18d59b..804c40ecbb 100644 --- a/src/gui/painting/qcoregraphics.mm +++ b/src/gui/painting/qcoregraphics.mm @@ -495,6 +495,8 @@ QMacCGContext::QMacCGContext(QPaintDevice *paintDevice) : context(0) context = CGBitmapContextCreate(image->bits(), image->width(), image->height(), 8, image->bytesPerLine(), colorspace, flags); CGContextTranslateCTM(context, 0, image->height()); + qreal devicePixelRatio = paintDevice->devicePixelRatioF(); + CGContextScaleCTM(context, devicePixelRatio, devicePixelRatio); CGContextScaleCTM(context, 1, -1); } -- cgit v1.2.3 From 674430cea0edafc374552b4743e2da7d29143453 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Thu, 17 Nov 2016 14:59:34 +0100 Subject: Silence maybe_uninitialized warning with gcc -Og GCC produces false positives for maybe_uninitialized when compiling with -Og in these three places. Simply initialize the variables to silence it. This should be entirely cost-free for normal compilation. Change-Id: Iab778a6ba25993f78f190e928c1fcc2dbd8b2fcd Reviewed-by: Oswald Buddenhagen Reviewed-by: Thiago Macieira --- src/gui/painting/qtriangulatingstroker.cpp | 2 +- src/plugins/platforms/xcb/qxcbconnection.cpp | 2 +- src/widgets/kernel/qapplication.cpp | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/gui/painting/qtriangulatingstroker.cpp b/src/gui/painting/qtriangulatingstroker.cpp index d9a3231165..6243f1e2a4 100644 --- a/src/gui/painting/qtriangulatingstroker.cpp +++ b/src/gui/painting/qtriangulatingstroker.cpp @@ -321,7 +321,7 @@ void QTriangulatingStroker::cubicTo(const qreal *pts) if (threshold < 4) threshold = 4; qreal threshold_minus_1 = threshold - 1; - float vx, vy; + float vx = 0, vy = 0; float cx = m_cx, cy = m_cy; float x, y; diff --git a/src/plugins/platforms/xcb/qxcbconnection.cpp b/src/plugins/platforms/xcb/qxcbconnection.cpp index 9e275efa25..1af2cf9b89 100644 --- a/src/plugins/platforms/xcb/qxcbconnection.cpp +++ b/src/plugins/platforms/xcb/qxcbconnection.cpp @@ -417,7 +417,7 @@ void QXcbConnection::initializeScreens() qWarning("failed to get the current screen resources"); free(error); } else { - xcb_timestamp_t timestamp; + xcb_timestamp_t timestamp = 0; xcb_randr_output_t *outputs = Q_NULLPTR; int outputCount = xcb_randr_get_screen_resources_current_outputs_length(resources_current.data()); if (outputCount) { diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index 358838b4e9..128b5dc2b8 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -3305,7 +3305,7 @@ bool QApplication::notify(QObject *receiver, QEvent *e) QWheelEvent we(relpos, wheel->globalPos(), wheel->pixelDelta(), wheel->angleDelta(), wheel->delta(), wheel->orientation(), wheel->buttons(), wheel->modifiers(), phase, wheel->source(), wheel->inverted()); bool eventAccepted; - while (w) { + do { we.spont = spontaneous && w == receiver; we.ignore(); res = d->notify_helper(w, &we); @@ -3323,7 +3323,7 @@ bool QApplication::notify(QObject *receiver, QEvent *e) we.p += w->pos(); w = w->parentWidget(); - } + } while (w); wheel->setAccepted(eventAccepted); } else if (!spontaneous) { // wheel_widget may forward the wheel event to a delegate widget, -- cgit v1.2.3 From a71b53d6004edb59ad1801f3281ef631fb38c7c4 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Tue, 20 Dec 2016 12:34:20 +0100 Subject: fix sysrootification of install paths initially, the idea was that QLibraryInfo would receive a pre-sysrootified ExtPrefix from the builtin qt.conf. matching this against the sysroot would then tell us whether to sysrootify the Prefix from a "regular" qt.conf as well. however, this would have lead to some major ugliness and inconsistency between the code paths, so i changed my mind. unfortunately, i failed to adjust the remaining code, leading to 169a40d51 entirely breaking sysrootification ... the proper (and nicely consistent) solution is to introduce a SysrootifyPrefix key to qt.conf. this is user-accessible as well, so as a bonus it is now possible to adjust the setting at qmake installation time. incidentally, this omission was the last thing that prevented using the same qmake host build for any imaginable configuration of the same qt version ... i think. Change-Id: Ic0eebf21f93651f6374628c0ad8b206d696a4a7e Reviewed-by: Andy Nichols --- src/corelib/global/qlibraryinfo.cpp | 30 ++++++++++++++---------------- src/corelib/global/qlibraryinfo.h | 1 + 2 files changed, 15 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/corelib/global/qlibraryinfo.cpp b/src/corelib/global/qlibraryinfo.cpp index 87ee75fa45..3ff37a5818 100644 --- a/src/corelib/global/qlibraryinfo.cpp +++ b/src/corelib/global/qlibraryinfo.cpp @@ -113,13 +113,6 @@ public: ? ls->haveDevicePaths : ls->havePaths) : false; } - static bool sysrootify() - { - // This is actually bogus, as it does not consider post-configure settings. - QLibrarySettings *ls = qt_library_settings(); - return ls ? (!ls->builtinValues[QLibraryInfo::SysrootPath].isEmpty() - && ls->builtinValues[QLibraryInfo::ExtPrefixPath].isEmpty()) : false; - } static QString builtinValue(int loc) { QLibrarySettings *ls = qt_library_settings(); @@ -483,6 +476,7 @@ static const struct { { "Tests", "tests" }, #ifdef QT_BUILD_QMAKE { "Sysroot", "" }, + { "SysrootifyPrefix", "" }, { "HostBinaries", "bin" }, { "HostLibraries", "lib" }, { "HostData", "." }, @@ -522,13 +516,17 @@ QLibraryInfo::location(LibraryLocation loc) QString ret = rawLocation(loc, FinalPaths); // Automatically prepend the sysroot to target paths - if ((loc < SysrootPath || loc > LastHostPath) && QLibraryInfoPrivate::sysrootify()) { + if (loc < SysrootPath || loc > LastHostPath) { QString sysroot = rawLocation(SysrootPath, FinalPaths); - if (!sysroot.isEmpty() && ret.length() > 2 && ret.at(1) == QLatin1Char(':') - && (ret.at(2) == QLatin1Char('/') || ret.at(2) == QLatin1Char('\\'))) - ret.replace(0, 2, sysroot); // Strip out the drive on Windows targets - else - ret.prepend(sysroot); + if (!sysroot.isEmpty() + && QVariant::fromValue(rawLocation(SysrootifyPrefixPath, FinalPaths)).toBool()) { + if (ret.length() > 2 && ret.at(1) == QLatin1Char(':') + && (ret.at(2) == QLatin1Char('/') || ret.at(2) == QLatin1Char('\\'))) { + ret.replace(0, 2, sysroot); // Strip out the drive on Windows targets + } else { + ret.prepend(sysroot); + } + } } return ret; @@ -591,7 +589,7 @@ QLibraryInfo::rawLocation(LibraryLocation loc, PathGroup group) if (loc == HostPrefixPath) ret = config->value(QLatin1String(qtConfEntries[PrefixPath].key), QLatin1String(qtConfEntries[PrefixPath].value)).toString(); - else if (loc == TargetSpecPath || loc == HostSpecPath) + else if (loc == TargetSpecPath || loc == HostSpecPath || loc == SysrootifyPrefixPath) fromConf = false; // The last case here is SysrootPath, which can be legitimately empty. // All other keys have non-empty fallbacks to start with. @@ -645,8 +643,8 @@ QLibraryInfo::rawLocation(LibraryLocation loc, PathGroup group) } #ifdef QT_BUILD_QMAKE - // The specs need to be returned verbatim. - if (loc == TargetSpecPath || loc == HostSpecPath) + // These values aren't actually paths and thus need to be returned verbatim. + if (loc == TargetSpecPath || loc == HostSpecPath || loc == SysrootifyPrefixPath) return ret; #endif diff --git a/src/corelib/global/qlibraryinfo.h b/src/corelib/global/qlibraryinfo.h index 9d794ce1da..812ab9a263 100644 --- a/src/corelib/global/qlibraryinfo.h +++ b/src/corelib/global/qlibraryinfo.h @@ -91,6 +91,7 @@ public: #ifdef QT_BUILD_QMAKE // These are not subject to binary compatibility constraints SysrootPath, + SysrootifyPrefixPath, HostBinariesPath, HostLibrariesPath, HostDataPath, -- cgit v1.2.3 From 49f1b667fa810428f9d3b5451d616c6cd9f390ca Mon Sep 17 00:00:00 2001 From: Alexander Volkov Date: Mon, 28 Nov 2016 15:14:46 +0300 Subject: platform plugins: Remove unused former overriders They were implied to override QPlatformIntegrationPlugin::keys() but it was removed before releasing Qt 5.0. Change-Id: Ia1f1ad27b7511b1141887f5dcde0dadeb2e5cabf Reviewed-by: Paul Olav Tvete --- src/plugins/platforms/mirclient/qmirclientplugin.cpp | 7 ------- src/plugins/platforms/mirclient/qmirclientplugin.h | 1 - src/plugins/platforms/winrt/main.cpp | 6 ------ 3 files changed, 14 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/mirclient/qmirclientplugin.cpp b/src/plugins/platforms/mirclient/qmirclientplugin.cpp index 201b68c304..6899d70f2e 100644 --- a/src/plugins/platforms/mirclient/qmirclientplugin.cpp +++ b/src/plugins/platforms/mirclient/qmirclientplugin.cpp @@ -41,13 +41,6 @@ #include "qmirclientplugin.h" #include "qmirclientintegration.h" -QStringList QMirClientIntegrationPlugin::keys() const -{ - QStringList list; - list << QStringLiteral("mirclient"); - return list; -} - QPlatformIntegration* QMirClientIntegrationPlugin::create(const QString &system, const QStringList &) { diff --git a/src/plugins/platforms/mirclient/qmirclientplugin.h b/src/plugins/platforms/mirclient/qmirclientplugin.h index 8b5da6e4f6..c91f2d1924 100644 --- a/src/plugins/platforms/mirclient/qmirclientplugin.h +++ b/src/plugins/platforms/mirclient/qmirclientplugin.h @@ -49,7 +49,6 @@ class QMirClientIntegrationPlugin : public QPlatformIntegrationPlugin Q_PLUGIN_METADATA(IID QPlatformIntegrationFactoryInterface_iid FILE "mirclient.json") public: - QStringList keys() const; QPlatformIntegration* create(const QString&, const QStringList&); }; diff --git a/src/plugins/platforms/winrt/main.cpp b/src/plugins/platforms/winrt/main.cpp index 5d0d9e94eb..222287b3ef 100644 --- a/src/plugins/platforms/winrt/main.cpp +++ b/src/plugins/platforms/winrt/main.cpp @@ -49,15 +49,9 @@ class QWinRTIntegrationPlugin : public QPlatformIntegrationPlugin Q_PLUGIN_METADATA(IID QPlatformIntegrationFactoryInterface_iid FILE "winrt.json") public: - QStringList keys() const; QPlatformIntegration *create(const QString&, const QStringList&) override; }; -QStringList QWinRTIntegrationPlugin::keys() const -{ - return QStringList(QStringLiteral("WinRT")); -} - QPlatformIntegration *QWinRTIntegrationPlugin::create(const QString& system, const QStringList& paramList) { Q_UNUSED(paramList); -- cgit v1.2.3 From 8f49da6c18a2a86576f06deb9a6ff1deef748837 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Fri, 18 Nov 2016 16:24:31 +0100 Subject: ... and so configureapp.exe disappeareth Change-Id: I3fd9f2b0d4cf05a625484fce21532da8563cd62c Reviewed-by: Thiago Macieira --- src/corelib/global/qconfig-bootstrapped.h | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/corelib/global/qconfig-bootstrapped.h b/src/corelib/global/qconfig-bootstrapped.h index d0e45478cc..2bca82535f 100644 --- a/src/corelib/global/qconfig-bootstrapped.h +++ b/src/corelib/global/qconfig-bootstrapped.h @@ -84,10 +84,11 @@ #define QT_FEATURE_translation -1 #define QT_NO_GEOM_VARIANT -#if defined(QT_BUILD_QMAKE) || defined(QT_BUILD_CONFIGURE) +#ifdef QT_BUILD_QMAKE #define QT_FEATURE_commandlineparser -1 #define QT_NO_COMPRESS #define QT_JSON_READONLY +#define QT_NO_STANDARDPATHS #define QT_NO_TEXTCODEC #define QT_FEATURE_textcodec -1 #else @@ -97,8 +98,4 @@ #define QT_FEATURE_textcodec 1 #endif -#if defined(QT_BUILD_QMAKE) -#define QT_NO_STANDARDPATHS -#endif - #endif // QT_BOOTSTRAPPED -- cgit v1.2.3 From ab732e3b2f775df3c30bd67238b0c1b8cd2fa31a Mon Sep 17 00:00:00 2001 From: Konstantin Ritt Date: Thu, 22 Dec 2016 15:07:40 +0300 Subject: Optimize QtActivity's onCreate a little bit Change-Id: Iabb0f561d99f363dfe1dc206b3ad3e8f1a1d04c0 Reviewed-by: Alex Blasche --- .../java/src/org/qtproject/qt5/android/bindings/QtActivityLoader.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/android/java/src/org/qtproject/qt5/android/bindings/QtActivityLoader.java b/src/android/java/src/org/qtproject/qt5/android/bindings/QtActivityLoader.java index ce0ce3abc7..759daf4393 100644 --- a/src/android/java/src/org/qtproject/qt5/android/bindings/QtActivityLoader.java +++ b/src/android/java/src/org/qtproject/qt5/android/bindings/QtActivityLoader.java @@ -118,10 +118,12 @@ public class QtActivityLoader extends QtLoader { public void onCreate(Bundle savedInstanceState) { try { m_contextInfo = m_activity.getPackageManager().getActivityInfo(m_activity.getComponentName(), PackageManager.GET_META_DATA); + int theme = ((ActivityInfo)m_contextInfo).getThemeResource(); for (Field f : Class.forName("android.R$style").getDeclaredFields()) { - if (f.getInt(null) == ((ActivityInfo)m_contextInfo).getThemeResource()) { + if (f.getInt(null) == theme) { QT_ANDROID_THEMES = new String[] {f.getName()}; QT_ANDROID_DEFAULT_THEME = f.getName(); + break; } } } catch (Exception e) { -- cgit v1.2.3 From 7322c65ba70bc93d034dc570dd314dc9d738f0fa Mon Sep 17 00:00:00 2001 From: David Faure Date: Mon, 26 Dec 2016 13:38:21 +0100 Subject: QMimeMagicRule: fix off by one in the number of bytes checked Since the loop says p <= e, no +1 should be added to e. Testcase: The magic for application/x-gameboy-rom says and this code was checking both byte 323 and byte 324, finding a match at pos 324, returning application/x-gameboy-rom erroneously. Given the magic for application/x-gameboy-color-rom: the expected result for game-boy-color-test.gbc is application/x-gameboy-color-rom Not yet detected by tst_qmimedatabase which is based on shared-mime-info 1.0, will be covered by the upgrade to 1.8. Change-Id: I2396cb1ccfb26db5a24d5551fef493cc0b98a247 Reviewed-by: Thiago Macieira --- src/corelib/mimetypes/qmimemagicrule.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/corelib/mimetypes/qmimemagicrule.cpp b/src/corelib/mimetypes/qmimemagicrule.cpp index 7e07f8acb9..7a807dccdb 100644 --- a/src/corelib/mimetypes/qmimemagicrule.cpp +++ b/src/corelib/mimetypes/qmimemagicrule.cpp @@ -161,7 +161,7 @@ bool QMimeMagicRule::matchNumber(const QByteArray &data) const //qDebug() << "mask" << QString::number(m_numberMask, 16); const char *p = data.constData() + m_startPos; - const char *e = data.constData() + qMin(data.size() - int(sizeof(T)), m_endPos + 1); + const char *e = data.constData() + qMin(data.size() - int(sizeof(T)), m_endPos); for ( ; p <= e; ++p) { if ((qFromUnaligned(p) & mask) == (value & mask)) return true; -- cgit v1.2.3 From f163912b5d577705c3d42428b0af75222f84b761 Mon Sep 17 00:00:00 2001 From: David Faure Date: Mon, 26 Dec 2016 13:42:30 +0100 Subject: QMimeMagicRule: endianness fixes * apply endianness to the mask as well * do not apply endianness to "host" entries, they were wrongly behaving exactly like "big endian" entries. The issue with the mask was detected by the audio/aac magic which failed to identify the test file ct_faac-adts.aac since it was applying the mask 0xFFF6 instead of 0xF6FF (on a little-endian machine). Not yet detected by tst_qmimedatabase which is based on shared-mime-info 1.0, will be covered by the upgrade to 1.8 in dev. Change-Id: I4fb7af2d367099817e712b14f2a031066d0ac432 Reviewed-by: Thiago Macieira --- src/corelib/mimetypes/qmimemagicrule.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/corelib/mimetypes/qmimemagicrule.cpp b/src/corelib/mimetypes/qmimemagicrule.cpp index 7a807dccdb..5bbf1bba9d 100644 --- a/src/corelib/mimetypes/qmimemagicrule.cpp +++ b/src/corelib/mimetypes/qmimemagicrule.cpp @@ -299,20 +299,30 @@ QMimeMagicRule::QMimeMagicRule(const QString &type, } break; case Big16: - case Host16: case Little16: if (m_number <= quint16(-1)) { m_number = m_type == Little16 ? qFromLittleEndian(m_number) : qFromBigEndian(m_number); + if (m_numberMask != 0) + m_numberMask = m_type == Little16 ? qFromLittleEndian(m_numberMask) : qFromBigEndian(m_numberMask); + } + Q_FALLTHROUGH(); + case Host16: + if (m_number <= quint16(-1)) { if (m_numberMask == 0) m_numberMask = quint16(-1); m_matchFunction = &QMimeMagicRule::matchNumber; } break; case Big32: - case Host32: case Little32: if (m_number <= quint32(-1)) { m_number = m_type == Little32 ? qFromLittleEndian(m_number) : qFromBigEndian(m_number); + if (m_numberMask != 0) + m_numberMask = m_type == Little32 ? qFromLittleEndian(m_numberMask) : qFromBigEndian(m_numberMask); + } + Q_FALLTHROUGH(); + case Host32: + if (m_number <= quint32(-1)) { if (m_numberMask == 0) m_numberMask = quint32(-1); m_matchFunction = &QMimeMagicRule::matchNumber; -- cgit v1.2.3 From 6722147696c7ba603d24163498a3f7de76ad6cea Mon Sep 17 00:00:00 2001 From: David Faure Date: Mon, 26 Dec 2016 13:46:40 +0100 Subject: QMimeDatabase: fix handling of conflicting globs This code always intended to follow the recommended checking order from the spec, which says "if multiple globs match, use file contents". But if the globs had different weights, it would discard globs with lower weights, and then wrongly conclude, if there is only one glob left, that there was no ambiguity. The correct way is rather: remember that multiple globs matched, do determination from contents, and if that didn't work, *then* use (one of) the highest-weight glob(s). This fixes PGP-encrypted *.asc files being detected as text/plain rather than application/pgp-encrypted. (https://bugs.kde.org/show_bug.cgi?id=346754) Change-Id: I734459daf9f502baa95ebb89432819964e0ce304 Reviewed-by: Thiago Macieira --- src/corelib/mimetypes/qmimedatabase.cpp | 27 +++++++++------- src/corelib/mimetypes/qmimedatabase_p.h | 2 +- src/corelib/mimetypes/qmimeglobpattern.cpp | 50 ++++++++++++++++-------------- src/corelib/mimetypes/qmimeglobpattern_p.h | 5 +-- src/corelib/mimetypes/qmimeprovider.cpp | 15 ++++----- src/corelib/mimetypes/qmimeprovider_p.h | 7 +++-- 6 files changed, 55 insertions(+), 51 deletions(-) (limited to 'src') diff --git a/src/corelib/mimetypes/qmimedatabase.cpp b/src/corelib/mimetypes/qmimedatabase.cpp index 448e6117b1..fda9f01643 100644 --- a/src/corelib/mimetypes/qmimedatabase.cpp +++ b/src/corelib/mimetypes/qmimedatabase.cpp @@ -108,12 +108,12 @@ QMimeType QMimeDatabasePrivate::mimeTypeForName(const QString &nameOrAlias) return provider()->mimeTypeForName(provider()->resolveAlias(nameOrAlias)); } -QStringList QMimeDatabasePrivate::mimeTypeForFileName(const QString &fileName, QString *foundSuffix) +QStringList QMimeDatabasePrivate::mimeTypeForFileName(const QString &fileName) { if (fileName.endsWith(QLatin1Char('/'))) return QStringList() << QLatin1String("inode/directory"); - QStringList matchingMimeTypes = provider()->findByFileName(QFileInfo(fileName).fileName(), foundSuffix); + QStringList matchingMimeTypes = provider()->findByFileName(QFileInfo(fileName).fileName()).m_matchingMimeTypes; matchingMimeTypes.sort(); // make it deterministic return matchingMimeTypes; } @@ -168,13 +168,17 @@ QMimeType QMimeDatabasePrivate::mimeTypeForFileNameAndData(const QString &fileNa *accuracyPtr = 0; // Pass 1) Try to match on the file name - QStringList candidatesByName = mimeTypeForFileName(fileName); - if (candidatesByName.count() == 1) { + QMimeGlobMatchResult candidatesByName; + if (fileName.endsWith(QLatin1Char('/'))) + candidatesByName.addMatch(QLatin1String("inode/directory"), 100, QString()); + else + candidatesByName = provider()->findByFileName(QFileInfo(fileName).fileName()); + if (candidatesByName.m_allMatchingMimeTypes.count() == 1) { *accuracyPtr = 100; - const QMimeType mime = mimeTypeForName(candidatesByName.at(0)); + const QMimeType mime = mimeTypeForName(candidatesByName.m_matchingMimeTypes.at(0)); if (mime.isValid()) return mime; - candidatesByName.clear(); + candidatesByName = {}; } // Extension is unknown, or matches multiple mimetypes. @@ -193,7 +197,7 @@ QMimeType QMimeDatabasePrivate::mimeTypeForFileNameAndData(const QString &fileNa // "for glob_match in glob_matches:" // "if glob_match is subclass or equal to sniffed_type, use glob_match" const QString sniffedMime = candidateByData.name(); - for (const QString &m : qAsConst(candidatesByName)) { + for (const QString &m : qAsConst(candidatesByName.m_matchingMimeTypes)) { if (inherits(m, sniffedMime)) { // We have magic + pattern pointing to this, so it's a pretty good match *accuracyPtr = 100; @@ -205,9 +209,10 @@ QMimeType QMimeDatabasePrivate::mimeTypeForFileNameAndData(const QString &fileNa } } - if (candidatesByName.count() > 1) { + if (candidatesByName.m_allMatchingMimeTypes.count() > 1) { + candidatesByName.m_matchingMimeTypes.sort(); // make it deterministic *accuracyPtr = 20; - const QMimeType mime = mimeTypeForName(candidatesByName.at(0)); + const QMimeType mime = mimeTypeForName(candidatesByName.m_matchingMimeTypes.at(0)); if (mime.isValid()) return mime; } @@ -455,9 +460,7 @@ QList QMimeDatabase::mimeTypesForFileName(const QString &fileName) co QString QMimeDatabase::suffixForFileName(const QString &fileName) const { QMutexLocker locker(&d->mutex); - QString foundSuffix; - d->mimeTypeForFileName(fileName, &foundSuffix); - return foundSuffix; + return d->provider()->findByFileName(QFileInfo(fileName).fileName()).m_foundSuffix; } /*! diff --git a/src/corelib/mimetypes/qmimedatabase_p.h b/src/corelib/mimetypes/qmimedatabase_p.h index 4ff5110a5b..3f63f5f103 100644 --- a/src/corelib/mimetypes/qmimedatabase_p.h +++ b/src/corelib/mimetypes/qmimedatabase_p.h @@ -90,7 +90,7 @@ public: QMimeType mimeTypeForName(const QString &nameOrAlias); QMimeType mimeTypeForFileNameAndData(const QString &fileName, QIODevice *device, int *priorityPtr); QMimeType findByData(const QByteArray &data, int *priorityPtr); - QStringList mimeTypeForFileName(const QString &fileName, QString *foundSuffix = 0); + QStringList mimeTypeForFileName(const QString &fileName); mutable QMimeProviderBase *m_provider; const QString m_defaultMimeType; diff --git a/src/corelib/mimetypes/qmimeglobpattern.cpp b/src/corelib/mimetypes/qmimeglobpattern.cpp index 568f9bf4de..a4d2b046fa 100644 --- a/src/corelib/mimetypes/qmimeglobpattern.cpp +++ b/src/corelib/mimetypes/qmimeglobpattern.cpp @@ -58,9 +58,13 @@ QT_BEGIN_NAMESPACE void QMimeGlobMatchResult::addMatch(const QString &mimeType, int weight, const QString &pattern) { + if (m_allMatchingMimeTypes.contains(mimeType)) + return; // Is this a lower-weight pattern than the last match? Skip this match then. - if (weight < m_weight) + if (weight < m_weight) { + m_allMatchingMimeTypes.append(mimeType); return; + } bool replace = weight > m_weight; if (!replace) { // Compare the length of the match @@ -79,6 +83,7 @@ void QMimeGlobMatchResult::addMatch(const QString &mimeType, int weight, const Q } if (!m_matchingMimeTypes.contains(mimeType)) { m_matchingMimeTypes.append(mimeType); + m_allMatchingMimeTypes.append(mimeType); if (pattern.startsWith(QLatin1String("*."))) m_foundSuffix = pattern.mid(2); } @@ -201,35 +206,32 @@ void QMimeGlobPatternList::match(QMimeGlobMatchResult &result, } } -QStringList QMimeAllGlobPatterns::matchingGlobs(const QString &fileName, QString *foundSuffix) const +QMimeGlobMatchResult QMimeAllGlobPatterns::matchingGlobs(const QString &fileName) const { // First try the high weight matches (>50), if any. QMimeGlobMatchResult result; m_highWeightGlobs.match(result, fileName); - if (result.m_matchingMimeTypes.isEmpty()) { - - // Now use the "fast patterns" dict, for simple *.foo patterns with weight 50 - // (which is most of them, so this optimization is definitely worth it) - const int lastDot = fileName.lastIndexOf(QLatin1Char('.')); - if (lastDot != -1) { // if no '.', skip the extension lookup - const int ext_len = fileName.length() - lastDot - 1; - const QString simpleExtension = fileName.right(ext_len).toLower(); - // (toLower because fast patterns are always case-insensitive and saved as lowercase) - - const QStringList matchingMimeTypes = m_fastPatterns.value(simpleExtension); - const QString simplePattern = QLatin1String("*.") + simpleExtension; - for (const QString &mime : matchingMimeTypes) - result.addMatch(mime, 50, simplePattern); - // Can't return yet; *.tar.bz2 has to win over *.bz2, so we need the low-weight mimetypes anyway, - // at least those with weight 50. - } - // Finally, try the low weight matches (<=50) - m_lowWeightGlobs.match(result, fileName); + // Now use the "fast patterns" dict, for simple *.foo patterns with weight 50 + // (which is most of them, so this optimization is definitely worth it) + const int lastDot = fileName.lastIndexOf(QLatin1Char('.')); + if (lastDot != -1) { // if no '.', skip the extension lookup + const int ext_len = fileName.length() - lastDot - 1; + const QString simpleExtension = fileName.right(ext_len).toLower(); + // (toLower because fast patterns are always case-insensitive and saved as lowercase) + + const QStringList matchingMimeTypes = m_fastPatterns.value(simpleExtension); + const QString simplePattern = QLatin1String("*.") + simpleExtension; + for (const QString &mime : matchingMimeTypes) + result.addMatch(mime, 50, simplePattern); + // Can't return yet; *.tar.bz2 has to win over *.bz2, so we need the low-weight mimetypes anyway, + // at least those with weight 50. } - if (foundSuffix) - *foundSuffix = result.m_foundSuffix; - return result.m_matchingMimeTypes; + + // Finally, try the low weight matches (<=50) + m_lowWeightGlobs.match(result, fileName); + + return result; } void QMimeAllGlobPatterns::clear() diff --git a/src/corelib/mimetypes/qmimeglobpattern_p.h b/src/corelib/mimetypes/qmimeglobpattern_p.h index 3e4fdb50f6..c8b70464fd 100644 --- a/src/corelib/mimetypes/qmimeglobpattern_p.h +++ b/src/corelib/mimetypes/qmimeglobpattern_p.h @@ -68,7 +68,8 @@ struct QMimeGlobMatchResult void addMatch(const QString &mimeType, int weight, const QString &pattern); - QStringList m_matchingMimeTypes; + QStringList m_matchingMimeTypes; // only those with highest weight + QStringList m_allMatchingMimeTypes; int m_weight; int m_matchingPatternLength; QString m_foundSuffix; @@ -153,7 +154,7 @@ public: void addGlob(const QMimeGlobPattern &glob); void removeMimeType(const QString &mimeType); - QStringList matchingGlobs(const QString &fileName, QString *foundSuffix) const; + QMimeGlobMatchResult matchingGlobs(const QString &fileName) const; void clear(); PatternsMap m_fastPatterns; // example: "doc" -> "application/msword", "text/plain" diff --git a/src/corelib/mimetypes/qmimeprovider.cpp b/src/corelib/mimetypes/qmimeprovider.cpp index 65b011b439..959421bf52 100644 --- a/src/corelib/mimetypes/qmimeprovider.cpp +++ b/src/corelib/mimetypes/qmimeprovider.cpp @@ -287,13 +287,13 @@ QMimeType QMimeBinaryProvider::mimeTypeForName(const QString &name) return mimeTypeForNameUnchecked(name); } -QStringList QMimeBinaryProvider::findByFileName(const QString &fileName, QString *foundSuffix) +QMimeGlobMatchResult QMimeBinaryProvider::findByFileName(const QString &fileName) { checkCache(); + QMimeGlobMatchResult result; if (fileName.isEmpty()) - return QStringList(); + return result; const QString lowerFileName = fileName.toLower(); - QMimeGlobMatchResult result; // TODO this parses in the order (local, global). Check that it handles "NOGLOBS" correctly. for (CacheFile *cacheFile : qAsConst(m_cacheFiles)) { matchGlobList(result, cacheFile, cacheFile->getUint32(PosLiteralListOffset), fileName); @@ -305,9 +305,7 @@ QStringList QMimeBinaryProvider::findByFileName(const QString &fileName, QString if (result.m_matchingMimeTypes.isEmpty()) matchSuffixTree(result, cacheFile, numRoots, firstRootOffset, fileName, fileName.length() - 1, true); } - if (foundSuffix) - *foundSuffix = result.m_foundSuffix; - return result.m_matchingMimeTypes; + return result; } void QMimeBinaryProvider::matchGlobList(QMimeGlobMatchResult &result, CacheFile *cacheFile, int off, const QString &fileName) @@ -728,12 +726,11 @@ QMimeType QMimeXMLProvider::mimeTypeForName(const QString &name) return m_nameMimeTypeMap.value(name); } -QStringList QMimeXMLProvider::findByFileName(const QString &fileName, QString *foundSuffix) +QMimeGlobMatchResult QMimeXMLProvider::findByFileName(const QString &fileName) { ensureLoaded(); - const QStringList matchingMimeTypes = m_mimeTypeGlobs.matchingGlobs(fileName, foundSuffix); - return matchingMimeTypes; + return m_mimeTypeGlobs.matchingGlobs(fileName); } QMimeType QMimeXMLProvider::findByMagic(const QByteArray &data, int *accuracyPtr) diff --git a/src/corelib/mimetypes/qmimeprovider_p.h b/src/corelib/mimetypes/qmimeprovider_p.h index e6fc47bf80..f410e62267 100644 --- a/src/corelib/mimetypes/qmimeprovider_p.h +++ b/src/corelib/mimetypes/qmimeprovider_p.h @@ -56,6 +56,7 @@ #ifndef QT_NO_MIMETYPE +#include "qmimeglobpattern_p.h" #include #include #include @@ -72,7 +73,7 @@ public: virtual bool isValid() = 0; virtual QMimeType mimeTypeForName(const QString &name) = 0; - virtual QStringList findByFileName(const QString &fileName, QString *foundSuffix) = 0; + virtual QMimeGlobMatchResult findByFileName(const QString &fileName) = 0; virtual QStringList parents(const QString &mime) = 0; virtual QString resolveAlias(const QString &name) = 0; virtual QStringList listAliases(const QString &name) = 0; @@ -99,7 +100,7 @@ public: virtual bool isValid() Q_DECL_OVERRIDE; virtual QMimeType mimeTypeForName(const QString &name) Q_DECL_OVERRIDE; - virtual QStringList findByFileName(const QString &fileName, QString *foundSuffix) Q_DECL_OVERRIDE; + virtual QMimeGlobMatchResult findByFileName(const QString &fileName) Q_DECL_OVERRIDE; virtual QStringList parents(const QString &mime) Q_DECL_OVERRIDE; virtual QString resolveAlias(const QString &name) Q_DECL_OVERRIDE; virtual QStringList listAliases(const QString &name) Q_DECL_OVERRIDE; @@ -142,7 +143,7 @@ public: virtual bool isValid() Q_DECL_OVERRIDE; virtual QMimeType mimeTypeForName(const QString &name) Q_DECL_OVERRIDE; - virtual QStringList findByFileName(const QString &fileName, QString *foundSuffix) Q_DECL_OVERRIDE; + virtual QMimeGlobMatchResult findByFileName(const QString &fileName) Q_DECL_OVERRIDE; virtual QStringList parents(const QString &mime) Q_DECL_OVERRIDE; virtual QString resolveAlias(const QString &name) Q_DECL_OVERRIDE; virtual QStringList listAliases(const QString &name) Q_DECL_OVERRIDE; -- cgit v1.2.3 From 0f5687280ecb19bc0a16e86c3040b0229539a160 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Klitzing?= Date: Tue, 27 Dec 2016 10:50:45 +0100 Subject: Fix typo in documentation Change-Id: I86584392f2646e87f26bf6de725802e5c6a6c6e0 Reviewed-by: Thiago Macieira --- src/network/kernel/qnetworkdatagram.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/network/kernel/qnetworkdatagram.cpp b/src/network/kernel/qnetworkdatagram.cpp index ba8a063edf..88ca763187 100644 --- a/src/network/kernel/qnetworkdatagram.cpp +++ b/src/network/kernel/qnetworkdatagram.cpp @@ -46,7 +46,7 @@ QT_BEGIN_NAMESPACE /*! \class QNetworkDatagram - \brief The QNetworkDatagram class provides the data and matadata of a UDP datagram. + \brief The QNetworkDatagram class provides the data and metadata of a UDP datagram. \since 5.8 \ingroup network \inmodule QtNetwork -- cgit v1.2.3 From b16e73804429af32ed4f536cbcd782ceb9cd3e8e Mon Sep 17 00:00:00 2001 From: Andrew Knight Date: Tue, 27 Dec 2016 00:46:05 +0200 Subject: Fix warning from MinGW/GCC 6.2 src/widgets/styles/qwindowsvistastyle.cpp: In member function 'virtual QSize QWindowsVistaStyle::sizeFromContents(QStyle::ContentsType, const QStyleOption*, const QSize&, const QWidget*) const': src/widgets/styles/qwindowsvistastyle.cpp:1872:9: error: this 'if' clause does not guard... [-Werror=misleading-indentation] if (!sz.isEmpty()) ^~ src/widgets/styles/qwindowsvistastyle.cpp:1874:13: note: ...this statement, but the latter is misleadingly indented as if it is guarded by the 'if' return sz; Change-Id: Ifd3faef8c93f12d5fadaf4edf875fbe0fc6fb785 Reviewed-by: Friedemann Kleint --- src/widgets/styles/qwindowsvistastyle.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src') diff --git a/src/widgets/styles/qwindowsvistastyle.cpp b/src/widgets/styles/qwindowsvistastyle.cpp index 7759df9959..7f52d3d2f3 100644 --- a/src/widgets/styles/qwindowsvistastyle.cpp +++ b/src/widgets/styles/qwindowsvistastyle.cpp @@ -1871,8 +1871,7 @@ QSize QWindowsVistaStyle::sizeFromContents(ContentsType type, const QStyleOption case CT_MenuBarItem: if (!sz.isEmpty()) sz += QSize(windowsItemHMargin * 5 + 1, 5); - return sz; - break; + return sz; #endif case CT_ItemViewItem: sz = QWindowsXPStyle::sizeFromContents(type, option, size, widget); -- cgit v1.2.3 From dfaa32a9455f0449cf2a2d7b5d916f99d5119fdc Mon Sep 17 00:00:00 2001 From: Andrew Knight Date: Tue, 27 Dec 2016 07:47:30 +0200 Subject: windows: use lowercase #include MinGW's headers are lowercase, and MSVC is generally run on a case- insensitive file system. Including in the lowercase is the more compatible option. Change-Id: I288cecb77ddd8029bb3925e613a830dd9ce96a6c Reviewed-by: Friedemann Kleint --- src/plugins/platforms/windows/qwin10helpers.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/plugins/platforms/windows/qwin10helpers.cpp b/src/plugins/platforms/windows/qwin10helpers.cpp index 977bbfd11b..12cccd124b 100644 --- a/src/plugins/platforms/windows/qwin10helpers.cpp +++ b/src/plugins/platforms/windows/qwin10helpers.cpp @@ -57,7 +57,7 @@ #endif #ifdef HAS_UI_VIEW_SETTINGS_INTEROP -# include +# include #endif #ifndef HAS_UI_VIEW_SETTINGS_INTEROP -- cgit v1.2.3 From 2be9880ebb3864e6ed703d96c7db5a12a76fe7c3 Mon Sep 17 00:00:00 2001 From: Kavindra Palaraja Date: Wed, 28 Dec 2016 11:09:34 +0100 Subject: Removed random notes in the documentation that should not be there Two sentences that read like author notes likely added by accident. Task-number: QTBUG-56630 Change-Id: I7a0b114e128f95e54e9e8f26b43493f67747d650 Reviewed-by: Simon Hausmann --- src/corelib/kernel/qmetatype.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'src') diff --git a/src/corelib/kernel/qmetatype.cpp b/src/corelib/kernel/qmetatype.cpp index f27fde6b8d..ef68878f68 100644 --- a/src/corelib/kernel/qmetatype.cpp +++ b/src/corelib/kernel/qmetatype.cpp @@ -207,8 +207,6 @@ struct DefinedTypesFilter { \enum QMetaType::Type These are the built-in types supported by QMetaType: - Read doc on QChar - Read doc on \l QChar \value Void \c void \value Bool \c bool -- cgit v1.2.3 From a89c39209721cb194131b2597733a4c235ab44d8 Mon Sep 17 00:00:00 2001 From: Kavindra Palaraja Date: Wed, 28 Dec 2016 11:29:16 +0100 Subject: Link QVariant class documentation to the Creating Custom Qt Types article The article does answer the questions asked in the bug. Task-number: QTBUG-56629 Change-Id: Ib8bac0acf45bc10598fc47feb6dd73005b5ad040 Reviewed-by: Thiago Macieira --- src/corelib/kernel/qvariant.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp index 0ffc22d810..9476ab3f5b 100644 --- a/src/corelib/kernel/qvariant.cpp +++ b/src/corelib/kernel/qvariant.cpp @@ -1186,7 +1186,7 @@ Q_CORE_EXPORT void QVariantPrivate::registerHandler(const int /* Modules::Names \snippet code/src_corelib_kernel_qvariant.cpp 1 QVariant can be extended to support other types than those - mentioned in the \l Type enum. See the \l QMetaType documentation + mentioned in the \l Type enum. See \l{Creating Custom Qt Types}{Creating Custom Qt Types} for details. \section1 A Note on GUI Types -- cgit v1.2.3 From 69ce68cb899da31d96ce7b9337600ebdc910e024 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 22 Dec 2016 10:02:26 -0200 Subject: Doc: add a quick note about unfixed Windows encoding bug Task-number: QTBUG-49640 Change-Id: Icb0289e3118a41dd9438fffd1492925b03de62d6 Reviewed-by: David Faure --- src/corelib/io/qlockfile.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src') diff --git a/src/corelib/io/qlockfile.cpp b/src/corelib/io/qlockfile.cpp index ae3a7c6abc..cb1ff93ad3 100644 --- a/src/corelib/io/qlockfile.cpp +++ b/src/corelib/io/qlockfile.cpp @@ -84,6 +84,9 @@ QT_BEGIN_NAMESPACE For the use case of protecting a resource over a long time, you should therefore call setStaleLockTime(0), and when tryLock() returns LockFailedError, inform the user that the document is locked, possibly using getLockInfo() for more details. + + \note On Windows, this class has problems detecting a stale lock if the + machine's hostname contains characters outside the US-ASCII character set. */ /*! -- cgit v1.2.3 From 73dafaf265a6c6a51611a093c2cc81a6d61767a9 Mon Sep 17 00:00:00 2001 From: Alexander Volkov Date: Thu, 22 Dec 2016 15:12:28 +0300 Subject: xcb: Ignore XI2 LMB mouse events from touch screens 157ee01a8d0be9a4dbac03883c9eaf3609fc1172 was trying to minimize some side effects of the bug in the evdev driver (https://bugs.freedesktop.org/show_bug.cgi?id=98188) by not changing mouse button state on motion. Unfortunately it resurrected bugs that were fixed by 76de1ac0a4cd384f608a14b5d77a8cf3ef1ec868. Filter out mouse events from touch screens instead. This change reverts 157ee01a8d0be9a4dbac03883c9eaf3609fc1172. Task-number: QTBUG-32609 Task-number: QTBUG-35065 Task-number: QTBUG-43776 Task-number: QTBUG-44166 Task-number: QTBUG-44231 Task-number: QTBUG-56156 Change-Id: Ie17710d94beabeb08681d669a9d8309be9b44e73 Reviewed-by: Shawn Rutledge --- src/plugins/platforms/xcb/qxcbconnection.h | 1 + src/plugins/platforms/xcb/qxcbconnection_xi2.cpp | 7 +++++++ src/plugins/platforms/xcb/qxcbwindow.cpp | 26 ++++++++++++------------ src/plugins/platforms/xcb/qxcbwindow.h | 1 - 4 files changed, 21 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/xcb/qxcbconnection.h b/src/plugins/platforms/xcb/qxcbconnection.h index 60f0f487c5..a9208ffe09 100644 --- a/src/plugins/platforms/xcb/qxcbconnection.h +++ b/src/plugins/platforms/xcb/qxcbconnection.h @@ -517,6 +517,7 @@ public: #ifdef XCB_USE_XINPUT22 bool xi2MouseEvents() const; + bool isTouchScreen(int id) const; #endif protected: diff --git a/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp b/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp index 0ace79a4f5..f4f56f25f1 100644 --- a/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp +++ b/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp @@ -1025,6 +1025,13 @@ Qt::MouseButton QXcbConnection::xiToQtMouseButton(uint32_t b) return Qt::NoButton; } +bool QXcbConnection::isTouchScreen(int id) const +{ + auto device = m_touchDevices.value(id); + return device && device->qtTouchDevice + && device->qtTouchDevice->type() == QTouchDevice::TouchScreen; +} + static QTabletEvent::TabletDevice toolIdToTabletDevice(quint32 toolId) { // keep in sync with wacom_intuos_inout() in Linux kernel driver wacom_wac.c switch (toolId) { diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp index ff01fa019e..3204fab197 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbwindow.cpp @@ -2423,22 +2423,27 @@ static inline int fixed1616ToInt(FP1616 val) return int((qreal(val >> 16)) + (val & 0xFFFF) / (qreal)0xFFFF); } -void QXcbWindow::handleXIMouseButtonState(const xcb_ge_event_t *event) +// With XI 2.2+ press/release/motion comes here instead of the above handlers. +void QXcbWindow::handleXIMouseEvent(xcb_ge_event_t *event, Qt::MouseEventSource source) { QXcbConnection *conn = connection(); - const xXIDeviceEvent *ev = reinterpret_cast(event); + xXIDeviceEvent *ev = reinterpret_cast(event); + if (ev->buttons_len > 0) { unsigned char *buttonMask = (unsigned char *) &ev[1]; + // There is a bug in the evdev driver which leads to receiving mouse events without + // XIPointerEmulated being set: https://bugs.freedesktop.org/show_bug.cgi?id=98188 + // Filter them out by other attributes: when their source device is a touch screen + // and the LMB is pressed. + if (XIMaskIsSet(buttonMask, 1) && conn->isTouchScreen(ev->sourceid)) { + if (Q_UNLIKELY(lcQpaXInputEvents().isDebugEnabled())) + qCDebug(lcQpaXInput, "XI2 mouse event from touch device %d was ignored", ev->sourceid); + return; + } for (int i = 1; i <= 15; ++i) conn->setButton(conn->translateMouseButton(i), XIMaskIsSet(buttonMask, i)); } -} -// With XI 2.2+ press/release/motion comes here instead of the above handlers. -void QXcbWindow::handleXIMouseEvent(xcb_ge_event_t *event, Qt::MouseEventSource source) -{ - QXcbConnection *conn = connection(); - xXIDeviceEvent *ev = reinterpret_cast(event); const Qt::KeyboardModifiers modifiers = conn->keyboard()->translateModifiers(ev->mods.effective_mods); const int event_x = fixed1616ToInt(ev->event_x); const int event_y = fixed1616ToInt(ev->event_y); @@ -2458,23 +2463,18 @@ void QXcbWindow::handleXIMouseEvent(xcb_ge_event_t *event, Qt::MouseEventSource switch (ev->evtype) { case XI_ButtonPress: - handleXIMouseButtonState(event); if (Q_UNLIKELY(lcQpaXInputEvents().isDebugEnabled())) qCDebug(lcQpaXInputEvents, "XI2 mouse press, button %d, time %d, source %s", button, ev->time, sourceName); conn->setButton(button, true); handleButtonPressEvent(event_x, event_y, root_x, root_y, ev->detail, modifiers, ev->time, source); break; case XI_ButtonRelease: - handleXIMouseButtonState(event); if (Q_UNLIKELY(lcQpaXInputEvents().isDebugEnabled())) qCDebug(lcQpaXInputEvents, "XI2 mouse release, button %d, time %d, source %s", button, ev->time, sourceName); conn->setButton(button, false); handleButtonReleaseEvent(event_x, event_y, root_x, root_y, ev->detail, modifiers, ev->time, source); break; case XI_Motion: - // Here we do NOT call handleXIMouseButtonState because we don't expect button state change to be bundled with motion. - // When a touchscreen is pressed, an XI_Motion event occurs in which XIMaskIsSet says the left button is pressed, - // but we don't want QGuiApplicationPrivate::processMouseEvent() to react by generating a mouse press event. if (Q_UNLIKELY(lcQpaXInputEvents().isDebugEnabled())) qCDebug(lcQpaXInputEvents, "XI2 mouse motion %d,%d, time %d, source %s", event_x, event_y, ev->time, sourceName); handleMotionNotifyEvent(event_x, event_y, root_x, root_y, modifiers, ev->time, source); diff --git a/src/plugins/platforms/xcb/qxcbwindow.h b/src/plugins/platforms/xcb/qxcbwindow.h index 089df8f3f6..cfa4964151 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.h +++ b/src/plugins/platforms/xcb/qxcbwindow.h @@ -139,7 +139,6 @@ public: void handleFocusOutEvent(const xcb_focus_out_event_t *event) override; void handlePropertyNotifyEvent(const xcb_property_notify_event_t *event) override; #ifdef XCB_USE_XINPUT22 - void handleXIMouseButtonState(const xcb_ge_event_t *); void handleXIMouseEvent(xcb_ge_event_t *, Qt::MouseEventSource source = Qt::MouseEventNotSynthesized) override; void handleXIEnterLeave(xcb_ge_event_t *) override; #endif -- cgit v1.2.3 From 77a8e90cddcfa1c34518ef846a4838874a7bc0c7 Mon Sep 17 00:00:00 2001 From: David Faure Date: Thu, 29 Dec 2016 18:15:53 +0100 Subject: QHeaderView: fix restoreState() on a model with more columns MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When saving state for a 3-columns headerview and then restoring that state onto a 5-column headerview, the headerview shouldn't suddenly think it has 3 columns. Rather than making restoreState() fail, we adjust for the additional columns, so that we can still apply the customizations from the user to all other columns (hiding, moving, etc.). Change-Id: I3f220aa322ea8b629d2fe345f8cde13e0ea615d6 Reviewed-by: Thorbjørn Lund Martsum --- src/widgets/itemviews/qheaderview.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src') diff --git a/src/widgets/itemviews/qheaderview.cpp b/src/widgets/itemviews/qheaderview.cpp index 837383f016..1310a060ea 100644 --- a/src/widgets/itemviews/qheaderview.cpp +++ b/src/widgets/itemviews/qheaderview.cpp @@ -3857,6 +3857,20 @@ bool QHeaderViewPrivate::read(QDataStream &in) if (sectionItemsLengthTotal != lengthIn) return false; + const int currentCount = (orient == Qt::Horizontal ? model->columnCount(root) : model->rowCount(root)); + if (newSectionItems.count() < currentCount) { + // we have sections not in the saved state, give them default settings + for (int i = newSectionItems.count(); i < currentCount; ++i) { + visualIndicesIn.append(i); + logicalIndicesIn.append(i); + } + const int insertCount = currentCount - newSectionItems.count(); + const int insertLength = defaultSectionSizeIn * insertCount; + lengthIn += insertLength; + SectionItem section(defaultSectionSizeIn, globalResizeMode); + newSectionItems.insert(newSectionItems.count(), insertCount, section); // append + } + orientation = static_cast(orient); sortIndicatorOrder = static_cast(order); sortIndicatorSection = sortIndicatorSectionIn; -- cgit v1.2.3 From 8292326f1bc986f8d87b9f3c244a5e0eb06563f9 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Fri, 23 Dec 2016 15:48:54 +0100 Subject: configure: make library sources fail more verbosely log a message in all unsuccessful exit paths. Task-number: QTBUG-57217 Change-Id: I8b0f2685d327da583c3e42c8149327e05b2a66cc Reviewed-by: Lars Knoll --- src/network/configure.pri | 1 + src/sql/configure.pri | 2 ++ 2 files changed, 3 insertions(+) (limited to 'src') diff --git a/src/network/configure.pri b/src/network/configure.pri index 57568902e4..f87b7f635f 100644 --- a/src/network/configure.pri +++ b/src/network/configure.pri @@ -7,6 +7,7 @@ defineTest(qtConfLibrary_openssl) { export($${1}.libs) return(true) } + qtLog("$OPENSSL_LIBS is not set.") return(false) } diff --git a/src/sql/configure.pri b/src/sql/configure.pri index 62d56e2186..a8bc09e524 100644 --- a/src/sql/configure.pri +++ b/src/sql/configure.pri @@ -26,6 +26,7 @@ defineTest(qtConfLibrary_psqlConfig) { export($${1}.includedir) return(true) } + qtLog("pg_config not found.") return(false) } @@ -74,6 +75,7 @@ defineTest(qtConfLibrary_mysqlConfig) { export($${1}.includedir) return(true) } + qtLog("mysql_config not found.") return(false) } -- cgit v1.2.3 From f55db6738bb5a14ba6ebcfe840225fe9d2ae98c2 Mon Sep 17 00:00:00 2001 From: Robert Griebl Date: Thu, 22 Dec 2016 03:59:08 +0100 Subject: Silence bogus whitespace "errors" from the DBus XML parser Any amount of whitespace between elements is now reported as an error starting with 5.8. This is (a) wrong and (b) very confusing for users. Change-Id: I2530b2138f95912e5be07e94b7d7fdab49dedbb1 Reviewed-by: Thiago Macieira Reviewed-by: Lars Knoll --- src/dbus/qdbusxmlparser.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src') diff --git a/src/dbus/qdbusxmlparser.cpp b/src/dbus/qdbusxmlparser.cpp index 3618c76a1d..94223e1574 100644 --- a/src/dbus/qdbusxmlparser.cpp +++ b/src/dbus/qdbusxmlparser.cpp @@ -385,6 +385,11 @@ QDBusXmlParser::QDBusXmlParser(const QString& service, const QString& path, case QXmlStreamReader::Comment: // ignore comments and processing instructions break; + case QXmlStreamReader::Characters: + // ignore whitespace + if (xml.isWhitespace()) + break; + Q_FALLTHROUGH(); default: qDBusParserError() << "unknown token" << xml.name() << xml.tokenString(); break; -- cgit v1.2.3 From 9449325f2b234981a2ecc1b0a0bd6ec74f30ff6c Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 26 Dec 2016 14:23:39 -0200 Subject: Partially revert "Windows: stop using _beginthreadex on regular builds" This pertially reverts commit 3ec57107cedb154f256e3ad001ea5475cc64fa94 and brings back the hack to prevent the DLL from being unloaded. It should have been enough, but we've got reports that it's still causing trouble. Since it causes not much harm to keep the DLL loaded (worst case scenario is that QtDBus and QtCore remain loaded after a plugin gets unloaded), we'll keep it. Note: Microsoft is aware that their way of killing threads on process exit is a flaw. See https://blogs.msdn.microsoft.com/oldnewthing/20070502-00/?p=27023/ Task-number: QTBUG-53031 Change-Id: I2962773739e34633b033fffd1493dce695b008c0 Reviewed-by: Friedemann Kleint Reviewed-by: Maurice Kalinowski --- src/dbus/qdbusconnection.cpp | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'src') diff --git a/src/dbus/qdbusconnection.cpp b/src/dbus/qdbusconnection.cpp index f95cc3a15d..da7557d7e8 100644 --- a/src/dbus/qdbusconnection.cpp +++ b/src/dbus/qdbusconnection.cpp @@ -69,6 +69,10 @@ QT_BEGIN_NAMESPACE +#ifdef Q_OS_WIN +static void preventDllUnload(); +#endif + Q_GLOBAL_STATIC(QDBusConnectionManager, _q_manager) struct QDBusConnectionManager::ConnectionRequestData @@ -139,6 +143,10 @@ QDBusConnectionManager::QDBusConnectionManager() this, &QDBusConnectionManager::createServer, Qt::BlockingQueuedConnection); moveToThread(this); // ugly, don't do this in other projects +#ifdef Q_OS_WIN + // prevent the library from being unloaded on Windows. See comments in the function. + preventDllUnload(); +#endif defaultBuses[0] = defaultBuses[1] = Q_NULLPTR; start(); } @@ -1262,4 +1270,31 @@ QByteArray QDBusConnection::localMachineId() QT_END_NAMESPACE +#ifdef Q_OS_WIN +# include + +QT_BEGIN_NAMESPACE +static void preventDllUnload() +{ + // Thread termination is really wacky on Windows. For some reason we don't + // understand, exiting from the thread may try to unload the DLL. Since the + // QDBusConnectionManager thread runs until the DLL is unloaded, we've got + // a deadlock: the main thread is waiting for the manager thread to exit, + // but the manager thread is attempting to acquire a lock to unload the DLL. + // + // We work around the issue by preventing the unload from happening in the + // first place. + // + // For this trick, see + // https://blogs.msdn.microsoft.com/oldnewthing/20131105-00/?p=2733 + + static HMODULE self; + GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | + GET_MODULE_HANDLE_EX_FLAG_PIN, + reinterpret_cast(&self), // any address in this DLL + &self); +} +QT_END_NAMESPACE +#endif + #endif // QT_NO_DBUS -- cgit v1.2.3 From a8ae8e3130fe4953ebfd54bce15648f58cd3f5be Mon Sep 17 00:00:00 2001 From: David Faure Date: Fri, 3 Mar 2017 14:06:49 +0100 Subject: QDateTime::fromString(): improve performance by 33% getMaximum() and getMinimum(), called during parsing, create new QDateTime instances, which on Linux end up calling mktime(). Making these static (for the common case of LocalTime spec) improves performance dramatically, when parsing several date/times. tests/benchmarks/corelib/tools/qdatetime/ (after fixing it to actually parse a valid date/time) says: RESULT : tst_QDateTime::fromString(): - 36,742,060 instruction reads per iteration (total: 36,742,060, iterations: 1) + 24,230,060 instruction reads per iteration (total: 24,230,060, iterations: 1) Change-Id: I0c3931285475bf19a5be8cba1486ed07cbf5e134 Reviewed-by: Thiago Macieira --- src/corelib/tools/qdatetimeparser.cpp | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/corelib/tools/qdatetimeparser.cpp b/src/corelib/tools/qdatetimeparser.cpp index 621c877174..ae429950c8 100644 --- a/src/corelib/tools/qdatetimeparser.cpp +++ b/src/corelib/tools/qdatetimeparser.cpp @@ -1216,15 +1216,15 @@ end: } else { if (context == FromString) { // optimization - Q_ASSERT(getMaximum().date().toJulianDay() == 4642999); + Q_ASSERT(maximum.date().toJulianDay() == 4642999); if (newCurrentValue.date().toJulianDay() > 4642999) state = Invalid; } else { - if (newCurrentValue > getMaximum()) + if (newCurrentValue > maximum) state = Invalid; } - QDTPDEBUG << "not checking intermediate because newCurrentValue is" << newCurrentValue << getMinimum() << getMaximum(); + QDTPDEBUG << "not checking intermediate because newCurrentValue is" << newCurrentValue << minimum << maximum; } } StateNode node; @@ -1607,13 +1607,13 @@ bool QDateTimeParser::potentialValue(const QStringRef &str, int min, int max, in bool QDateTimeParser::skipToNextSection(int index, const QDateTime ¤t, const QStringRef &text) const { - Q_ASSERT(current >= getMinimum() && current <= getMaximum()); - const SectionNode &node = sectionNode(index); Q_ASSERT(text.size() < sectionMaxSize(index)); const QDateTime maximum = getMaximum(); const QDateTime minimum = getMinimum(); + Q_ASSERT(current >= minimum && current <= maximum); + QDateTime tmp = current; int min = absoluteMin(index); setDigit(tmp, index, min); @@ -1713,11 +1713,21 @@ bool QDateTimeParser::fromString(const QString &t, QDate *date, QTime *time) con QDateTime QDateTimeParser::getMinimum() const { + // Cache the most common case + if (spec == Qt::LocalTime) { + static const QDateTime localTimeMin(QDATETIMEEDIT_DATE_MIN, QDATETIMEEDIT_TIME_MIN, Qt::LocalTime); + return localTimeMin; + } return QDateTime(QDATETIMEEDIT_DATE_MIN, QDATETIMEEDIT_TIME_MIN, spec); } QDateTime QDateTimeParser::getMaximum() const { + // Cache the most common case + if (spec == Qt::LocalTime) { + static const QDateTime localTimeMax(QDATETIMEEDIT_DATE_MAX, QDATETIMEEDIT_TIME_MAX, Qt::LocalTime); + return localTimeMax; + } return QDateTime(QDATETIMEEDIT_DATE_MAX, QDATETIMEEDIT_TIME_MAX, spec); } -- cgit v1.2.3 From 39e80062d0cf0c25b456bd89be827e50a6077efa Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 16 Dec 2016 12:48:18 -0800 Subject: Work around MSVC ABI stupidity in exporting inline members of base class In this case, the issue was ICC, when compiling QtQml: qv4sequenceobject.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __cdecl QList::replace(int,class QItemSelectionRange const &)" (__imp_?replace@?$QList@VQItemSelectionRange@@@@QEAAXHAEBVQItemSelectionRange@@@Z) referenced in function "public: static bool __cdecl QV4::QQmlSequence::deleteIndexedProperty(struct QV4::Managed *,unsigned int)" (?deleteIndexedProperty@?$QQmlSequence@VQItemSelection@@@QV4@@SA_NPEAUManaged@2@I@Z) This applies the same fix as qvector.h has had for ages due to QPolygon. Change-Id: I15b62e0f9cec482fbb40fffd1490d791db5056bc Reviewed-by: Marc Mutz Reviewed-by: Lars Knoll --- src/corelib/itemmodels/qitemselectionmodel.h | 18 ++++++++++++++++++ src/corelib/tools/qvector.h | 2 ++ 2 files changed, 20 insertions(+) (limited to 'src') diff --git a/src/corelib/itemmodels/qitemselectionmodel.h b/src/corelib/itemmodels/qitemselectionmodel.h index 3d3cb00750..c22ac6dbe5 100644 --- a/src/corelib/itemmodels/qitemselectionmodel.h +++ b/src/corelib/itemmodels/qitemselectionmodel.h @@ -251,6 +251,24 @@ Q_DECLARE_OPERATORS_FOR_FLAGS(QItemSelectionModel::SelectionFlags) // dummy implentation of qHash() necessary for instantiating QList::toSet() with MSVC inline uint qHash(const QItemSelectionRange &) { return 0; } +#ifdef Q_CC_MSVC + +/* + ### Qt 6: + ### This needs to be removed for next releases of Qt. It is a workaround for vc++ because + ### Qt exports QItemSelection that inherits QList. +*/ + +# ifndef Q_TEMPLATE_EXTERN +# if defined(QT_BUILD_CORE_LIB) +# define Q_TEMPLATE_EXTERN +# else +# define Q_TEMPLATE_EXTERN extern +# endif +# endif +Q_TEMPLATE_EXTERN template class Q_CORE_EXPORT QList; +#endif // Q_CC_MSVC + class Q_CORE_EXPORT QItemSelection : public QList { public: diff --git a/src/corelib/tools/qvector.h b/src/corelib/tools/qvector.h index 4dbf95c315..5225b68d40 100644 --- a/src/corelib/tools/qvector.h +++ b/src/corelib/tools/qvector.h @@ -982,11 +982,13 @@ QT_BEGIN_INCLUDE_NAMESPACE #include QT_END_INCLUDE_NAMESPACE +#ifndef Q_TEMPLATE_EXTERN #if defined(QT_BUILD_CORE_LIB) #define Q_TEMPLATE_EXTERN #else #define Q_TEMPLATE_EXTERN extern #endif +#endif Q_TEMPLATE_EXTERN template class Q_CORE_EXPORT QVector; Q_TEMPLATE_EXTERN template class Q_CORE_EXPORT QVector; #endif -- cgit v1.2.3 From 1c3c2486c63de620abc70cb57be2908ed56a4d89 Mon Sep 17 00:00:00 2001 From: Frederik Schwarzer Date: Mon, 19 Dec 2016 17:39:18 +0100 Subject: Fix broken link in documentation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Task-number: QTBUG-57530 Change-Id: Iecb1a26f6b8a7e8a506d768668cde1c277d15dde Reviewed-by: Topi Reiniö Reviewed-by: Martin Smith --- src/corelib/doc/src/filestorage.qdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/corelib/doc/src/filestorage.qdoc b/src/corelib/doc/src/filestorage.qdoc index c6a4a85646..e291ba1375 100644 --- a/src/corelib/doc/src/filestorage.qdoc +++ b/src/corelib/doc/src/filestorage.qdoc @@ -75,7 +75,7 @@ by a Sun SPARC running Solaris. You can also use a data stream to read/write raw unencoded binary data. For more details on the datatypes that QDataStream can serialize, see -{Serializing Qt Data Types}. +\l{Serializing Qt Data Types}. The QTextStream class provides a convenient interface for reading and writing text. QTextStream can operate on a QIODevice, a QByteArray or -- cgit v1.2.3 From c96a4058f1d8979279c249e4ecd96e2bb4945ddb Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Thu, 29 Dec 2016 17:13:59 +0100 Subject: Avoid compile warnings in qabstractanimation.cpp Change-Id: I57f90fc335b50231fb2093f096ad38168d476145 Reviewed-by: Thiago Macieira Reviewed-by: Marc Mutz --- src/corelib/animation/qabstractanimation.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/corelib/animation/qabstractanimation.cpp b/src/corelib/animation/qabstractanimation.cpp index 662774b484..8c189e9288 100644 --- a/src/corelib/animation/qabstractanimation.cpp +++ b/src/corelib/animation/qabstractanimation.cpp @@ -242,6 +242,7 @@ QUnifiedTimer *QUnifiedTimer::instance(bool create) inst = unifiedTimer() ? unifiedTimer()->localData() : 0; } #else + Q_UNUSED(create); static QUnifiedTimer unifiedTimer; inst = &unifiedTimer; #endif @@ -576,6 +577,7 @@ QAnimationTimer *QAnimationTimer::instance(bool create) inst = animationTimer() ? animationTimer()->localData() : 0; } #else + Q_UNUSED(create); static QAnimationTimer animationTimer; inst = &animationTimer; #endif -- cgit v1.2.3 From 1b82a9aea5e2385c08543f3a9ebbed71a0bae3cc Mon Sep 17 00:00:00 2001 From: Aleksey Lysenko Date: Tue, 3 Jan 2017 22:41:20 +0200 Subject: Doc: add note about unsupported platforms for QProcess Task-number: QTBUG-57840 Change-Id: I46a26a9c4c6ad0aa6994945091a2904c3b51080f Reviewed-by: Martin Smith Reviewed-by: Jake Petroules --- src/corelib/io/qprocess.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src') diff --git a/src/corelib/io/qprocess.cpp b/src/corelib/io/qprocess.cpp index 23a3cc1a16..c7d6cb426d 100644 --- a/src/corelib/io/qprocess.cpp +++ b/src/corelib/io/qprocess.cpp @@ -509,6 +509,9 @@ void QProcessPrivate::Channel::clear() You can also call error() to find the type of error that occurred last, and state() to find the current process state. + \note QProcess is not supported on VxWorks, iOS, tvOS, watchOS, + or the Universal Windows Platform. + \section1 Communicating via Channels Processes have two predefined output channels: The standard -- cgit v1.2.3 From 86abf43122c0b41371d1f6eee7311079ed7cf2bb Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Tue, 3 Jan 2017 16:53:35 -0800 Subject: QMacCGContext: Take paint device pixel ratio into account This seems to have been omitted in c52bb0309071bed9e040c79d87f764bac6a396b8. Change-Id: If8cde889af75934c85d9b21bd22095b7e5a4bf32 Task-number: QTBUG-57894 Reviewed-by: Jake Petroules --- src/gui/painting/qcoregraphics.mm | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/gui/painting/qcoregraphics.mm b/src/gui/painting/qcoregraphics.mm index 466b18d59b..803328c10f 100644 --- a/src/gui/painting/qcoregraphics.mm +++ b/src/gui/painting/qcoregraphics.mm @@ -495,6 +495,8 @@ QMacCGContext::QMacCGContext(QPaintDevice *paintDevice) : context(0) context = CGBitmapContextCreate(image->bits(), image->width(), image->height(), 8, image->bytesPerLine(), colorspace, flags); CGContextTranslateCTM(context, 0, image->height()); + const qreal devicePixelRatio = paintDevice->devicePixelRatioF(); + CGContextScaleCTM(context, devicePixelRatio, devicePixelRatio); CGContextScaleCTM(context, 1, -1); } -- cgit v1.2.3 From 99245e9576c28777fa1b1fc639c1c24e4aed3789 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Thu, 29 Dec 2016 17:39:13 +0100 Subject: Avoid zero-as-nullpointer warnings in QThread Change-Id: I3fd557a54d63c2dcabe58fab65326538896d02a2 Reviewed-by: Thiago Macieira Reviewed-by: Marc Mutz --- src/corelib/thread/qthread.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/corelib/thread/qthread.h b/src/corelib/thread/qthread.h index 410f642ca7..45786537e2 100644 --- a/src/corelib/thread/qthread.h +++ b/src/corelib/thread/qthread.h @@ -140,10 +140,10 @@ public: static QThread* currentThread(); protected: - QThread(QThreadPrivate &dd, QObject *parent = 0); + QThread(QThreadPrivate &dd, QObject *parent = nullptr); private: - explicit QThread(QObject *parent = 0); + explicit QThread(QObject *parent = nullptr); static QThread *instance; friend class QCoreApplication; -- cgit v1.2.3 From 9ba39c4b05ccfbfbafe3d9e6546d4e5514a892ea Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Thu, 29 Dec 2016 18:42:07 +0100 Subject: Remove pointless QT_NO_THREAD ifdefs from qpropertyanimation.cpp Change-Id: I7b7e80abbddf4d43c6135775136d993196d708b3 Reviewed-by: Thiago Macieira --- src/corelib/animation/qpropertyanimation.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'src') diff --git a/src/corelib/animation/qpropertyanimation.cpp b/src/corelib/animation/qpropertyanimation.cpp index 6e5b08c295..9fd845bb93 100644 --- a/src/corelib/animation/qpropertyanimation.cpp +++ b/src/corelib/animation/qpropertyanimation.cpp @@ -269,10 +269,8 @@ void QPropertyAnimation::updateState(QAbstractAnimation::State newState, QPropertyAnimation *animToStop = 0; { -#ifndef QT_NO_THREAD static QBasicMutex mutex; QMutexLocker locker(&mutex); -#endif typedef QPair QPropertyAnimationPair; typedef QHash QPropertyAnimationHash; static QPropertyAnimationHash hash; -- cgit v1.2.3 From b49660bba4df13b88defbd5c3c789da0f93110c9 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Thu, 29 Dec 2016 17:19:14 +0100 Subject: Make filesystemmodel feature depend on itemmodel QFileSystemModel inherits from QAbstractItemModel, so it has to be disabled if the latter is not available. Change-Id: Ifc56f7e311d84bd15e8b4ed95d67bf9ad9aba888 Reviewed-by: Lars Knoll --- src/widgets/configure.json | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/widgets/configure.json b/src/widgets/configure.json index 1e72b61886..8acbffef6a 100644 --- a/src/widgets/configure.json +++ b/src/widgets/configure.json @@ -86,6 +86,7 @@ "label": "QFileSystemModel", "purpose": "Provides a data model for the local filesystem.", "section": "File I/O", + "condition": "features.itemmodel", "output": [ "publicFeature", "feature" ] }, "itemviews": { -- cgit v1.2.3 From 2ed9a52ebf1dfb1a16ad65413bea01314010720d Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Wed, 30 Nov 2016 16:37:15 +0100 Subject: Fix compilation without sharedmemory We have to enable qt_safe_ftok with either sharedmemory or systemsemaphore. In order to make the resulting QT_CONFIG work with the bootstrap library we switch the features off for bootstrapping. Some tests and examples have to be excluded when sharedmemory is not available. Change-Id: I3fc3926d160202b378be2293fba40201a4bf50c5 Reviewed-by: Thiago Macieira --- src/corelib/global/qconfig-bootstrapped.h | 2 ++ src/corelib/kernel/qcore_unix_p.h | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/corelib/global/qconfig-bootstrapped.h b/src/corelib/global/qconfig-bootstrapped.h index 2bca82535f..d7849d4699 100644 --- a/src/corelib/global/qconfig-bootstrapped.h +++ b/src/corelib/global/qconfig-bootstrapped.h @@ -83,6 +83,8 @@ #define QT_NO_TRANSLATION #define QT_FEATURE_translation -1 #define QT_NO_GEOM_VARIANT +#define QT_FEATURE_sharedmemory -1 +#define QT_FEATURE_systemsemaphore -1 #ifdef QT_BUILD_QMAKE #define QT_FEATURE_commandlineparser -1 diff --git a/src/corelib/kernel/qcore_unix_p.h b/src/corelib/kernel/qcore_unix_p.h index b5756af994..80058d9115 100644 --- a/src/corelib/kernel/qcore_unix_p.h +++ b/src/corelib/kernel/qcore_unix_p.h @@ -370,7 +370,7 @@ union qt_semun { }; #ifndef QT_POSIX_IPC -#ifndef QT_NO_SHAREDMEMORY +#if QT_CONFIG(sharedmemory) || QT_CONFIG(systemsemaphore) #ifndef Q_OS_ANDROID static inline key_t qt_safe_ftok(const QByteArray &filename, int proj_id) { @@ -379,7 +379,7 @@ static inline key_t qt_safe_ftok(const QByteArray &filename, int proj_id) return ::ftok(filename.constData(), qHash(filename, proj_id)); } #endif // !Q_OS_ANDROID -#endif // !QT_NO_SHAREDMEMORY +#endif // QT_CONFIG(sharedmemory) || QT_CONFIG(systemsemaphore) #endif // !QT_POSIX_IPC QT_END_NAMESPACE -- cgit v1.2.3 From af5c8d04fb0c9ddda58925e4862e857c78a5e563 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Mon, 2 Jan 2017 08:10:57 +0100 Subject: Win: Account for windows which are WindowTransparentForInput Task-number: QTBUG-57864 Change-Id: I8793aaa3719fbcf97f95ae462135cbf6b5823097 Reviewed-by: Friedemann Kleint --- src/plugins/platforms/windows/qwindowscontext.cpp | 11 +++++++++-- .../platforms/windows/qwindowsmousehandler.cpp | 21 +++++---------------- 2 files changed, 14 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/windows/qwindowscontext.cpp b/src/plugins/platforms/windows/qwindowscontext.cpp index 1a03df6ac2..bb9ed730a3 100644 --- a/src/plugins/platforms/windows/qwindowscontext.cpp +++ b/src/plugins/platforms/windows/qwindowscontext.cpp @@ -990,11 +990,18 @@ bool QWindowsContext::windowsProc(HWND hwnd, UINT message, case QtWindows::MouseWheelEvent: case QtWindows::MouseEvent: case QtWindows::LeaveEvent: + { + QWindow *window = platformWindow->window(); + while (window->flags() & Qt::WindowTransparentForInput) + window = window->parent(); + if (!window) + return false; #if !defined(QT_NO_SESSIONMANAGER) - return platformSessionManager()->isInteractionBlocked() ? true : d->m_mouseHandler.translateMouseEvent(platformWindow->window(), hwnd, et, msg, result); + return platformSessionManager()->isInteractionBlocked() ? true : d->m_mouseHandler.translateMouseEvent(window, hwnd, et, msg, result); #else - return d->m_mouseHandler.translateMouseEvent(platformWindow->window(), hwnd, et, msg, result); + return d->m_mouseHandler.translateMouseEvent(window, hwnd, et, msg, result); #endif + } case QtWindows::TouchEvent: #if !defined(QT_NO_SESSIONMANAGER) return platformSessionManager()->isInteractionBlocked() ? true : d->m_mouseHandler.translateTouchEvent(platformWindow->window(), hwnd, et, msg, result); diff --git a/src/plugins/platforms/windows/qwindowsmousehandler.cpp b/src/plugins/platforms/windows/qwindowsmousehandler.cpp index 3f6230172e..e4025fe60d 100644 --- a/src/plugins/platforms/windows/qwindowsmousehandler.cpp +++ b/src/plugins/platforms/windows/qwindowsmousehandler.cpp @@ -313,7 +313,8 @@ bool QWindowsMouseHandler::translateMouseEvent(QWindow *window, HWND hwnd, // events, "click-through") can be considered as the window under mouse. QWindow *currentWindowUnderMouse = platformWindow->hasMouseCapture() ? QWindowsScreen::windowAt(globalPosition, CWP_SKIPINVISIBLE | CWP_SKIPTRANSPARENT) : window; - + while (currentWindowUnderMouse && currentWindowUnderMouse->flags() & Qt::WindowTransparentForInput) + currentWindowUnderMouse = currentWindowUnderMouse->parent(); // QTBUG-44332: When Qt is running at low integrity level and // a Qt Window is parented on a Window of a higher integrity process // using QWindow::fromWinId() (for example, Qt running in a browser plugin) @@ -432,22 +433,10 @@ static bool isValidWheelReceiver(QWindow *candidate) static void redirectWheelEvent(QWindow *window, const QPoint &globalPos, int delta, Qt::Orientation orientation, Qt::KeyboardModifiers mods) { - // Redirect wheel event to one of the following, in order of preference: - // 1) The window under mouse - // 2) The window receiving the event // If a window is blocked by modality, it can't get the event. - - QWindow *receiver = QWindowsScreen::windowAt(globalPos, CWP_SKIPINVISIBLE); - bool handleEvent = true; - if (!isValidWheelReceiver(receiver)) { - receiver = window; - if (!isValidWheelReceiver(receiver)) - handleEvent = false; - } - - if (handleEvent) { - QWindowSystemInterface::handleWheelEvent(receiver, - QWindowsGeometryHint::mapFromGlobal(receiver, globalPos), + if (isValidWheelReceiver(window)) { + QWindowSystemInterface::handleWheelEvent(window, + QWindowsGeometryHint::mapFromGlobal(window, globalPos), globalPos, delta, orientation, mods); } } -- cgit v1.2.3 From 47de2ef27f9d68d5c1f2f935380e1517f99c9721 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Wed, 21 Dec 2016 14:02:14 +0100 Subject: QOCIDriver: Ensure the where clause is correctly setup Commit 88e043a8 introduced two bugs: 1. When constructing the WHERE clause, the closing ' around the owner name was dropped. 2. When constructing QLatin1Strings for comparison with system owners, a size of -1 was passed, with the comment "force strlen call". But, unlike QString, QLatin1String does not invoke strlen(), but stores the negative length unchanged, making the comparisons always fail. Change-Id: Ie2835b76877c31ee32c900f67eb0853df7110dbb Reviewed-by: Marc Mutz --- src/plugins/sqldrivers/oci/qsql_oci.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/plugins/sqldrivers/oci/qsql_oci.cpp b/src/plugins/sqldrivers/oci/qsql_oci.cpp index 47d6db7ea4..32d3681a17 100644 --- a/src/plugins/sqldrivers/oci/qsql_oci.cpp +++ b/src/plugins/sqldrivers/oci/qsql_oci.cpp @@ -2405,16 +2405,16 @@ static QString make_where_clause(const QString &user, Expression e) static const char joinC[][4] = { "or" , "and" }; static Q_CONSTEXPR QLatin1Char bang[] = { QLatin1Char(' '), QLatin1Char('!') }; - const QLatin1String join(joinC[e], -1); // -1: force strlen call + const QLatin1String join(joinC[e]); QString result; result.reserve(sizeof sysUsers / sizeof *sysUsers * // max-sizeof(owner != and ) (9 + sizeof *sysUsers + 5)); for (const auto &sysUser : sysUsers) { - const QLatin1String l1(sysUser, -1); // -1: force strlen call + const QLatin1String l1(sysUser); if (l1 != user) - result += QLatin1String("owner ") + bang[e] + QLatin1String("= '") + l1 + QLatin1Char(' ') + join + QLatin1Char(' '); + result += QLatin1String("owner ") + bang[e] + QLatin1String("= '") + l1 + QLatin1String("' ") + join + QLatin1Char(' '); } result.chop(join.size() + 2); // remove final " " -- cgit v1.2.3 From 04b095b24bb335c5e1d28f3470c2c8033df26634 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Fri, 2 Dec 2016 16:25:54 +0100 Subject: Doc: Properly mention valgrind & callgrind MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Julian Seward is the author mentioned in valgrind_p.h. Also call the whole thing valgrind, since callgrind is part of valgrind. Change-Id: Iaf5958c520b919c1acf93ce368b0839bd06ccd46 Reviewed-by: Friedemann Kleint Reviewed-by: hjk Reviewed-by: Topi Reiniö --- src/testlib/3rdparty/CALLGRIND_LICENSE.txt | 35 ------------------------------ src/testlib/3rdparty/VALGRIND_LICENSE.txt | 33 ++++++++++++++++++++++++++++ src/testlib/3rdparty/qt_attribution.json | 11 +++++----- 3 files changed, 39 insertions(+), 40 deletions(-) delete mode 100644 src/testlib/3rdparty/CALLGRIND_LICENSE.txt create mode 100644 src/testlib/3rdparty/VALGRIND_LICENSE.txt (limited to 'src') diff --git a/src/testlib/3rdparty/CALLGRIND_LICENSE.txt b/src/testlib/3rdparty/CALLGRIND_LICENSE.txt deleted file mode 100644 index 0a6a793422..0000000000 --- a/src/testlib/3rdparty/CALLGRIND_LICENSE.txt +++ /dev/null @@ -1,35 +0,0 @@ - This file is part of callgrind, a valgrind tool for cache simulation - and call tree tracing. - - Copyright (C) 2003-2007 Josef Weidendorfer. All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - 1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - 2. The origin of this software must not be misrepresented; you must - not claim that you wrote the original software. If you use this - software in a product, an acknowledgment in the product - documentation would be appreciated but is not required. - - 3. Altered source versions must be plainly marked as such, and must - not be misrepresented as being the original software. - - 4. The name of the author may not be used to endorse or promote - products derived from this software without specific prior written - permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS - OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/src/testlib/3rdparty/VALGRIND_LICENSE.txt b/src/testlib/3rdparty/VALGRIND_LICENSE.txt new file mode 100644 index 0000000000..714b75e6d1 --- /dev/null +++ b/src/testlib/3rdparty/VALGRIND_LICENSE.txt @@ -0,0 +1,33 @@ + Copyright (C) 2000-2007 Julian Seward + Copyright (C) 2003-2007 Josef Weidendorfer. All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + 2. The origin of this software must not be misrepresented; you must + not claim that you wrote the original software. If you use this + software in a product, an acknowledgment in the product + documentation would be appreciated but is not required. + + 3. Altered source versions must be plainly marked as such, and must + not be misrepresented as being the original software. + + 4. The name of the author may not be used to endorse or promote + products derived from this software without specific prior written + permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/src/testlib/3rdparty/qt_attribution.json b/src/testlib/3rdparty/qt_attribution.json index d8b0ad1fc7..49d12580bd 100644 --- a/src/testlib/3rdparty/qt_attribution.json +++ b/src/testlib/3rdparty/qt_attribution.json @@ -1,17 +1,18 @@ [ { - "Id": "callgrind", - "Name": "Callgrind", + "Id": "valgrind", + "Name": "Valgrind", "QDocModule": "qttestlib", "QtUsage": "Used on Linux ond MacOS in the Qt Test module.", "Files": "valgrind_p.h callgrind_p.h", - "Description": "Part of Valgrind: an instrumentation framework for building dynamic analysis tools.", + "Description": "An instrumentation framework for building dynamic analysis tools.", "Homepage": "http://valgrind.org/", "License": "BSD 4-clause \"Original\" or \"Old\" License", "LicenseId": "BSD-4-Clause", - "LicenseFile": "CALLGRIND_LICENSE.txt", - "Copyright": "Copyright (C) 2003-2007 Josef Weidendorfer. All rights reserved." + "LicenseFile": "VALGRIND_LICENSE.txt", + "Copyright": "Copyright (C) 2000-2007 Julian Seward +Copyright (C) 2003-2007 Josef Weidendorfer." }, { "Id": "cycle", -- cgit v1.2.3 From fafdb171e0c317ee8f871dc7b504d3713d5860eb Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Tue, 3 Jan 2017 18:00:05 +0100 Subject: Accessibility macOS: fix parentElement MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Try to return the immediate parent first, nothing else makes sense. The original code relied on the window pointer usually being nullptr, which is not reliable. Make sure to check the validity of the handle returned, since it's possible to have the platform window being nullptr. It's not quite clear to me how to end up with a null window though. Task-number: QTBUG-52304 Change-Id: Id3e70cdab980fb0a86cebbb7c10d824d8a7dd80b Reviewed-by: Jan Arve Sæther --- .../platforms/cocoa/qcocoaaccessibilityelement.mm | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm b/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm index 97bd402b73..982c98976b 100644 --- a/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm +++ b/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm @@ -235,19 +235,19 @@ static void convertLineOffset(QAccessibleTextInterface *text, int *line, int *of if (!iface || !iface->isValid()) return nil; - if (QWindow *window = iface->window()) { - QCocoaWindow *win = static_cast(window->handle()); - return qnsview_cast(win->view()); + if (QAccessibleInterface *parent = iface->parent()) { + QAccessible::Id parentId = QAccessible::uniqueId(parent); + return [QMacAccessibilityElement elementWithId: parentId]; } - QAccessibleInterface *parent = iface->parent(); - if (!parent) { - qWarning() << "INVALID PARENT FOR INTERFACE: " << iface; - return nil; + if (QWindow *window = iface->window()) { + QPlatformWindow *platformWindow = window->handle(); + if (platformWindow) { + QCocoaWindow *win = static_cast(platformWindow); + return qnsview_cast(win->view()); + } } - - QAccessible::Id parentId = QAccessible::uniqueId(parent); - return [QMacAccessibilityElement elementWithId: parentId]; + return nil; } -- cgit v1.2.3 From d330ae0da27f54ede10dabdc937bfb570ac244cb Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Wed, 4 Jan 2017 23:23:42 +0100 Subject: Accessibility macOS: check for valid interfaces MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There are a few places that did not check if the returned interface is valid. Task-number: QTBUG-52536 Change-Id: I56ca0952fec0b44dfd4b3991aa94554e9c829642 Reviewed-by: Jan Arve Sæther --- src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm b/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm index 982c98976b..e743dd56bf 100644 --- a/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm +++ b/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm @@ -537,7 +537,7 @@ static void convertLineOffset(QAccessibleTextInterface *text, int *line, int *of - (void)accessibilityPerformAction:(NSString *)action { QAccessibleInterface *iface = QAccessible::accessibleInterface(axid); - if (iface) { + if (iface && iface->isValid()) { const QString qtAction = QCocoaAccessible::translateAction(action, iface); QAccessibleBridgeUtils::performEffectiveAction(iface, qtAction); } @@ -562,16 +562,16 @@ static void convertLineOffset(QAccessibleTextInterface *text, int *line, int *of int y = qt_mac_flipYCoordinate(point.y); QAccessibleInterface *childInterface = iface->childAt(point.x, y); // No child found, meaning we hit this element. - if (!childInterface) + if (!childInterface || !childInterface->isValid()) return NSAccessibilityUnignoredAncestor(self); // find the deepest child at the point QAccessibleInterface *childOfChildInterface = 0; do { childOfChildInterface = childInterface->childAt(point.x, y); - if (childOfChildInterface) + if (childOfChildInterface && childOfChildInterface->isValid()) childInterface = childOfChildInterface; - } while (childOfChildInterface); + } while (childOfChildInterface && childOfChildInterface->isValid()); QAccessible::Id childId = QAccessible::uniqueId(childInterface); // hit a child, forward to child accessible interface. @@ -590,7 +590,7 @@ static void convertLineOffset(QAccessibleTextInterface *text, int *line, int *of } QAccessibleInterface *childInterface = iface->focusChild(); - if (childInterface) { + if (childInterface && childInterface->isValid()) { QAccessible::Id childAxid = QAccessible::uniqueId(childInterface); QMacAccessibilityElement *accessibleElement = [QMacAccessibilityElement elementWithId:childAxid]; return NSAccessibilityUnignoredAncestor(accessibleElement); -- cgit v1.2.3 From 7e3e5b2dcf2e2576065ca9f9850cd1f2126f397f Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Thu, 5 Jan 2017 11:28:45 +0100 Subject: Fix regression in handling Chinese system default font Register font's english name as alias when populating font families. This was incorrectly undone when support for subfamilies was added. Task-number: QTBUG-57856 Change-Id: Ib71f905bb00db86d44fa0921ec56c8c76c332e06 Reviewed-by: Friedemann Kleint Reviewed-by: Liang Qi Reviewed-by: Eskil Abrahamsen Blomfeldt --- .../fontdatabases/windows/qwindowsfontdatabase.cpp | 13 +++++++++++-- .../fontdatabases/windows/qwindowsfontdatabase_ft.cpp | 13 +++++++++++-- 2 files changed, 22 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase.cpp b/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase.cpp index 1c615e06ed..887123083a 100644 --- a/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase.cpp +++ b/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase.cpp @@ -1159,7 +1159,7 @@ void QWindowsFontDatabase::populateFamily(const QString &familyName) ReleaseDC(0, dummy); } -static int QT_WIN_CALLBACK populateFontFamilies(const LOGFONT *logFont, const TEXTMETRIC *, +static int QT_WIN_CALLBACK populateFontFamilies(const LOGFONT *logFont, const TEXTMETRIC *textmetric, DWORD, LPARAM) { // the "@family" fonts are just the same as "family". Ignore them. @@ -1168,6 +1168,13 @@ static int QT_WIN_CALLBACK populateFontFamilies(const LOGFONT *logFont, const TE if (faceNameW[0] && faceNameW[0] != L'@' && wcsncmp(faceNameW, L"WST_", 4)) { const QString faceName = QString::fromWCharArray(faceNameW); QPlatformFontDatabase::registerFontFamily(faceName); + // Register current font's english name as alias + const bool ttf = (textmetric->tmPitchAndFamily & TMPF_TRUETYPE); + if (ttf && qt_localizedName(faceName)) { + const QString englishName = qt_getEnglishName(faceName); + if (!englishName.isEmpty()) + QPlatformFontDatabase::registerAliasToFontFamily(faceName, englishName); + } } return 1; // continue } @@ -1183,7 +1190,9 @@ void QWindowsFontDatabase::populateFontDatabase() EnumFontFamiliesEx(dummy, &lf, populateFontFamilies, 0, 0); ReleaseDC(0, dummy); // Work around EnumFontFamiliesEx() not listing the system font. - QPlatformFontDatabase::registerFontFamily(QWindowsFontDatabase::systemDefaultFont().family()); + QString systemDefaultFamily = QWindowsFontDatabase::systemDefaultFont().family(); + if (QPlatformFontDatabase::resolveFontFamilyAlias(systemDefaultFamily).isEmpty()) + QPlatformFontDatabase::registerFontFamily(systemDefaultFamily); } typedef QSharedPointer QWindowsFontEngineDataPtr; diff --git a/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase_ft.cpp b/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase_ft.cpp index df84198862..ebb82baf6f 100644 --- a/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase_ft.cpp +++ b/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase_ft.cpp @@ -362,8 +362,15 @@ static int QT_WIN_CALLBACK populateFontFamilies(const LOGFONT *logFont, const TE if (!key && ttf && qt_localizedName(faceName)) key = findFontKey(qt_getEnglishName(faceName)); } - if (key) + if (key) { QPlatformFontDatabase::registerFontFamily(faceName); + // Register current font's english name as alias + if (ttf && qt_localizedName(faceName)) { + const QString englishName = qt_getEnglishName(faceName); + if (!englishName.isEmpty()) + QPlatformFontDatabase::registerAliasToFontFamily(faceName, englishName); + } + } } return 1; // continue } @@ -378,7 +385,9 @@ void QWindowsFontDatabaseFT::populateFontDatabase() EnumFontFamiliesEx(dummy, &lf, populateFontFamilies, 0, 0); ReleaseDC(0, dummy); // Work around EnumFontFamiliesEx() not listing the system font - QPlatformFontDatabase::registerFontFamily(QWindowsFontDatabase::systemDefaultFont().family()); + QString systemDefaultFamily = QWindowsFontDatabase::systemDefaultFont().family(); + if (QPlatformFontDatabase::resolveFontFamilyAlias(systemDefaultFamily).isEmpty()) + QPlatformFontDatabase::registerFontFamily(systemDefaultFamily); } QFontEngine * QWindowsFontDatabaseFT::fontEngine(const QFontDef &fontDef, void *handle) -- cgit v1.2.3 From fb85a72325d7954592ac88bbe82c913ae6124424 Mon Sep 17 00:00:00 2001 From: David Faure Date: Mon, 26 Dec 2016 18:37:47 +0100 Subject: Fix deleting of QOpenGLVersionFunctionsBackend Since the destructor is not virtual we need to cast to the proper class when deleting otherwise the wrong destructor is called and the object memory is not entirely freed. Change-Id: Ie4e0e91bfa6e802c7d72fd1f137f5c7f3f31c8a0 Reviewed-by: Simon Hausmann Reviewed-by: Marc Mutz --- src/gui/opengl/qopenglversionfunctions.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/gui/opengl/qopenglversionfunctions.cpp b/src/gui/opengl/qopenglversionfunctions.cpp index 54df2e5734..a3d3bb6bd1 100644 --- a/src/gui/opengl/qopenglversionfunctions.cpp +++ b/src/gui/opengl/qopenglversionfunctions.cpp @@ -74,15 +74,21 @@ QOpenGLVersionFunctionsStorage::QOpenGLVersionFunctionsStorage() QOpenGLVersionFunctionsStorage::~QOpenGLVersionFunctionsStorage() { +#ifndef QT_OPENGL_ES if (backends) { - for (int i = 0; i < QOpenGLVersionFunctionsBackend::OpenGLVersionBackendCount; ++i) { - if (backends[i] && !--backends[i]->refs) { - // deleting the base class is ok, as the derived classes don't have a destructor - delete backends[i]; - } - } + + int i = 0; + +#define DELETE_BACKEND(X) \ + if (backends[i] && !--backends[i]->refs) \ + delete static_cast(backends[i]); \ + ++i; + + QT_OPENGL_VERSIONS(DELETE_BACKEND) +#undef DELETE_BACKEND delete[] backends; } +#endif } QOpenGLVersionFunctionsBackend *QOpenGLVersionFunctionsStorage::backend(QOpenGLContext *context, QOpenGLVersionFunctionsBackend::Version v) -- cgit v1.2.3 From f4d3c87f0caab71f15e12f0f376f94a3e90a8adf Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Wed, 4 Jan 2017 13:43:44 +0100 Subject: Fix UB (signed integer overflows) in QProgressBar The expression 'minimum - 1' invokes UB when 'minimum == INT_MIN'. Likewise, the expression 'maximum - minimum' invokes UB when 'qint64(maximum) - minimum > INT_MAX'. Fix by restructuring the code or else by using 64-bit arithmetic. Change-Id: I352eafa72f28ae907f41c8f88abcf0a81705c718 Task-number: QTBUG-57857 Reviewed-by: David Faure --- src/widgets/widgets/qprogressbar.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/widgets/widgets/qprogressbar.cpp b/src/widgets/widgets/qprogressbar.cpp index 10f005e6d3..2893849c42 100644 --- a/src/widgets/widgets/qprogressbar.cpp +++ b/src/widgets/widgets/qprogressbar.cpp @@ -144,16 +144,17 @@ bool QProgressBarPrivate::repaintRequired() const if (value == lastPaintedValue) return false; - int valueDifference = qAbs(value - lastPaintedValue); - + const auto valueDifference = qAbs(qint64(value) - lastPaintedValue); // Check if the text needs to be repainted if (value == minimum || value == maximum) return true; + + const auto totalSteps = qint64(maximum) - minimum; if (textVisible) { if ((format.contains(QLatin1String("%v")))) return true; if ((format.contains(QLatin1String("%p")) - && valueDifference >= qAbs((maximum - minimum) / 100))) + && valueDifference >= qAbs(totalSteps / 100))) return true; } @@ -166,7 +167,7 @@ bool QProgressBarPrivate::repaintRequired() const // (valueDifference / (maximum - minimum) > cw / groove.width()) // transformed to avoid integer division. int grooveBlock = (q->orientation() == Qt::Horizontal) ? groove.width() : groove.height(); - return (valueDifference * grooveBlock > cw * (maximum - minimum)); + return valueDifference * grooveBlock > cw * totalSteps; } /*! @@ -260,9 +261,10 @@ QProgressBar::~QProgressBar() void QProgressBar::reset() { Q_D(QProgressBar); - d->value = d->minimum - 1; if (d->minimum == INT_MIN) d->value = INT_MIN; + else + d->value = d->minimum - 1; repaint(); } @@ -358,7 +360,7 @@ void QProgressBar::setRange(int minimum, int maximum) d->minimum = minimum; d->maximum = qMax(minimum, maximum); - if (d->value < (d->minimum - 1) || d->value > d->maximum) + if (d->value < qint64(d->minimum) - 1 || d->value > d->maximum) reset(); else update(); -- cgit v1.2.3 From afefed06952d5edd5c6be4376469b022975930cf Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Fri, 6 Jan 2017 07:38:50 +0100 Subject: QAndroidStyle: fix UB (signed integer overflow) in AndroidProgressBarControl::drawControl() The expression 'maximum - minimum' has undefined behavior when 'qint64(maximum) - minimum > INT_MAX'. Use 64-bit arithmetic instead. Also fix calculation of the progress when minimum != 0. Rename QStyleOptionProgressBar* variable to avoid line wraps. Change-Id: I1d48a7930e7f6d69798c2e878bb0045d55c2f057 Reviewed-by: David Faure --- src/widgets/styles/qandroidstyle.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/widgets/styles/qandroidstyle.cpp b/src/widgets/styles/qandroidstyle.cpp index b37dffbe80..110153d0f6 100644 --- a/src/widgets/styles/qandroidstyle.cpp +++ b/src/widgets/styles/qandroidstyle.cpp @@ -1606,15 +1606,14 @@ void QAndroidStyle::AndroidProgressBarControl::drawControl(const QStyleOption *o if (!m_progressDrawable) return; - if (const QStyleOptionProgressBar *progressBarOption = - qstyleoption_cast(option)) { + if (const QStyleOptionProgressBar *pb = qstyleoption_cast(option)) { if (m_progressDrawable->type() == QAndroidStyle::Layer) { - const double fraction = progressBarOption->progress / double(progressBarOption->maximum - progressBarOption->minimum); + const double fraction = double(qint64(pb->progress) - pb->minimum) / (qint64(pb->maximum) - pb->minimum); QAndroidStyle::AndroidDrawable *clipDrawable = static_cast(m_progressDrawable)->layer(m_progressId); if (clipDrawable->type() == QAndroidStyle::Clip) - static_cast(clipDrawable)->setFactor(fraction, progressBarOption->orientation); + static_cast(clipDrawable)->setFactor(fraction, pb->orientation); else - static_cast(m_progressDrawable)->setFactor(m_progressId, fraction, progressBarOption->orientation); + static_cast(m_progressDrawable)->setFactor(m_progressId, fraction, pb->orientation); } m_progressDrawable->draw(p, option); } -- cgit v1.2.3 From 5c207c6c792b016635d0ca79ea1b832037c32c08 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Mon, 21 Nov 2016 18:21:47 +0100 Subject: Add a feature for Qt Network This way you can disable support for QtNetwork by specifying -no-feature-network on the configure line. Change-Id: I46217ccc525a9e2c85394ed4eb6db0e2b60b6d86 Reviewed-by: Thiago Macieira Reviewed-by: Lars Knoll Reviewed-by: Oswald Buddenhagen --- src/src.pro | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/src.pro b/src/src.pro index 90d7e2b76c..7c7eb7c34a 100644 --- a/src/src.pro +++ b/src/src.pro @@ -124,7 +124,7 @@ src_printsupport.depends = src_corelib src_gui src_widgets src_tools_uic src_plugins.subdir = $$PWD/plugins src_plugins.target = sub-plugins -src_plugins.depends = src_sql src_xml src_network +src_plugins.depends = src_sql src_xml src_android.subdir = $$PWD/android @@ -144,7 +144,11 @@ qtConfig(regularexpression):pcre { SUBDIRS += src_corelib src_tools_qlalr TOOLS = src_tools_moc src_tools_rcc src_tools_qlalr win32:SUBDIRS += src_winmain -SUBDIRS += src_network src_sql src_xml src_testlib +SUBDIRS += src_sql src_xml src_testlib +qtConfig(network) { + SUBDIRS += src_network + src_plugins.depends += src_network +} qtConfig(dbus) { force_dbus_bootstrap|qtConfig(private_tests): \ SUBDIRS += src_tools_bootstrap_dbus -- cgit v1.2.3 From 3b609fc76fd6bf72faa52884c039bb0a074b4e72 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Wed, 23 Nov 2016 10:12:16 +0100 Subject: Add a feature for Qt Sql This way we can disable it by passing -no-feature-sql to configure. Change-Id: Ia47d72101de0788478997fa1854cedcd1742f6fd Reviewed-by: Lars Knoll Reviewed-by: Oswald Buddenhagen --- src/src.pro | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/src.pro b/src/src.pro index 7c7eb7c34a..fa408d4787 100644 --- a/src/src.pro +++ b/src/src.pro @@ -124,7 +124,7 @@ src_printsupport.depends = src_corelib src_gui src_widgets src_tools_uic src_plugins.subdir = $$PWD/plugins src_plugins.target = sub-plugins -src_plugins.depends = src_sql src_xml +src_plugins.depends = src_xml src_android.subdir = $$PWD/android @@ -144,11 +144,15 @@ qtConfig(regularexpression):pcre { SUBDIRS += src_corelib src_tools_qlalr TOOLS = src_tools_moc src_tools_rcc src_tools_qlalr win32:SUBDIRS += src_winmain -SUBDIRS += src_sql src_xml src_testlib +SUBDIRS += src_xml src_testlib qtConfig(network) { SUBDIRS += src_network src_plugins.depends += src_network } +qtConfig(sql) { + SUBDIRS += src_sql + src_plugins.depends += src_sql +} qtConfig(dbus) { force_dbus_bootstrap|qtConfig(private_tests): \ SUBDIRS += src_tools_bootstrap_dbus -- cgit v1.2.3 From f704aba7fc73b75f7bc3a1be962b28859d83e3aa Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Wed, 23 Nov 2016 10:14:48 +0100 Subject: Add a feature for Qt Testlib ... so that we can turn it off if we don't want to build it. Change-Id: Ib27386da4754d843d4e4cbb05f9542852efefb88 Reviewed-by: Lars Knoll Reviewed-by: Oswald Buddenhagen --- src/src.pro | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/src.pro b/src/src.pro index fa408d4787..5b353fde09 100644 --- a/src/src.pro +++ b/src/src.pro @@ -144,7 +144,7 @@ qtConfig(regularexpression):pcre { SUBDIRS += src_corelib src_tools_qlalr TOOLS = src_tools_moc src_tools_rcc src_tools_qlalr win32:SUBDIRS += src_winmain -SUBDIRS += src_xml src_testlib +SUBDIRS += src_xml qtConfig(network) { SUBDIRS += src_network src_plugins.depends += src_network @@ -153,6 +153,7 @@ qtConfig(sql) { SUBDIRS += src_sql src_plugins.depends += src_sql } +qtConfig(testlib): SUBDIRS += src_testlib qtConfig(dbus) { force_dbus_bootstrap|qtConfig(private_tests): \ SUBDIRS += src_tools_bootstrap_dbus -- cgit v1.2.3 From 20e0bca834a1cae1816f17ef0dbfe8b74192d8dd Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Wed, 23 Nov 2016 10:43:47 +0100 Subject: Add a feature for Qt Xml ... so that we can turn it off if we don't want to build it. Change-Id: Ia330dfa1477bcd2dc8e24eb55400e100fca156b5 Reviewed-by: Lars Knoll Reviewed-by: Oswald Buddenhagen --- src/src.pro | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src') diff --git a/src/src.pro b/src/src.pro index 5b353fde09..c0366f32b6 100644 --- a/src/src.pro +++ b/src/src.pro @@ -124,7 +124,6 @@ src_printsupport.depends = src_corelib src_gui src_widgets src_tools_uic src_plugins.subdir = $$PWD/plugins src_plugins.target = sub-plugins -src_plugins.depends = src_xml src_android.subdir = $$PWD/android @@ -144,7 +143,6 @@ qtConfig(regularexpression):pcre { SUBDIRS += src_corelib src_tools_qlalr TOOLS = src_tools_moc src_tools_rcc src_tools_qlalr win32:SUBDIRS += src_winmain -SUBDIRS += src_xml qtConfig(network) { SUBDIRS += src_network src_plugins.depends += src_network @@ -153,6 +151,7 @@ qtConfig(sql) { SUBDIRS += src_sql src_plugins.depends += src_sql } +qtConfig(xml): SUBDIRS += src_xml qtConfig(testlib): SUBDIRS += src_testlib qtConfig(dbus) { force_dbus_bootstrap|qtConfig(private_tests): \ -- cgit v1.2.3 From 4a738424aaef7958917b92bd64a08eb6208d9c06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Thu, 5 Jan 2017 15:01:02 +0100 Subject: Fall back to platform theme in QPlatformSystemTrayIcon::createMenu() Commit 824f08046 introduced QPlatformSystemTrayIcon::createMenu() as a way for platforms to provide a system tray menu independently of the menu created by QPlatformTheme::createPlatformMenu(), which would on some platforms be null. Commit 063997f44ffc then made menu creation lazy, which meant that the logic in QSystemTrayIconPrivate::addPlatformMenu() to create the menu turned from "create menu via QPSTI::createMenu() if QPT::createPlatformMenu() returned null", to "create menu via QPSTI::createMenu() if menu was not created yet". The latter logic relied on each platform having implementations of QPlatformSystemTrayIcon::createMenu() which they didn't, resulting in missing menus for system trays on e.g. macOS. With the new lazy logic, the reasonable approach is for the default implementation of createMenu() to use createPlatformMenu(), which will ensure system tray menus on platforms that implement createPlatformMenu(), while still allowing platforms that don't to override createMenu() for special-casing system tray menus. Task-number: QTBUG-57365 Change-Id: Id393e802ac0435200fc885a7f4436b744962f27f Reviewed-by: J-P Nurmi --- src/gui/kernel/qplatformsystemtrayicon.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/gui/kernel/qplatformsystemtrayicon.cpp b/src/gui/kernel/qplatformsystemtrayicon.cpp index 30db966df7..973b998059 100644 --- a/src/gui/kernel/qplatformsystemtrayicon.cpp +++ b/src/gui/kernel/qplatformsystemtrayicon.cpp @@ -40,6 +40,9 @@ #include "qplatformsystemtrayicon.h" +#include +#include + #ifndef QT_NO_SYSTEMTRAYICON QT_BEGIN_NAMESPACE @@ -158,11 +161,10 @@ QPlatformSystemTrayIcon::~QPlatformSystemTrayIcon() */ /*! - This method is called in case there is no QPlatformMenu available when - updating the menu. This allows the abstraction to provide a menu for the - system tray icon even if normally a non-native menu is used. - - The default implementation returns a null pointer. + This method allows platforms to use a different QPlatformMenu for system + tray menus than what would normally be used for e.g. menu bars. The default + implementation falls back to a platform menu created by the platform theme, + which may be null on platforms without native menus. \sa updateMenu() \since 5.3 @@ -170,7 +172,7 @@ QPlatformSystemTrayIcon::~QPlatformSystemTrayIcon() QPlatformMenu *QPlatformSystemTrayIcon::createMenu() const { - return Q_NULLPTR; + return QGuiApplicationPrivate::platformTheme()->createPlatformMenu(); } QT_END_NAMESPACE -- cgit v1.2.3 From 52d64fca662d0e488801fc40dffdc0a732cfdbd5 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Tue, 3 Jan 2017 16:40:30 +0100 Subject: revert to building qmake with qconfig.cpp turns out that just appending builtin-qt.conf isn't a good idea: executable-editing tools (objcopy, prelink, etc.) will happily drop the "attachment". a safe method would be adding a proper section to the executable, but there doesn't appear to be an objcopy equivalent in msvc, and using entirely different methods of embedding the file with different toolchains seems like a rather bad idea. so instead go back to the old method of building qmake with a generated qconfig.cpp. of course, as said file is now created by qmake itself, we have to compile qlibraryinfo.cpp a second time, and link a second qmake executable. Task-number: QTBUG-57803 Change-Id: I9e232693550aa870cec154e49cc06add13017cc2 Reviewed-by: Lars Knoll --- src/corelib/global/qlibraryinfo.cpp | 100 ++++++------------------------------ src/corelib/global/qlibraryinfo.h | 1 - 2 files changed, 16 insertions(+), 85 deletions(-) (limited to 'src') diff --git a/src/corelib/global/qlibraryinfo.cpp b/src/corelib/global/qlibraryinfo.cpp index 3ff37a5818..0de8b50900 100644 --- a/src/corelib/global/qlibraryinfo.cpp +++ b/src/corelib/global/qlibraryinfo.cpp @@ -41,18 +41,15 @@ #include "qdir.h" #include "qstringlist.h" #include "qfile.h" -#include "qtemporaryfile.h" #include "qsettings.h" #include "qlibraryinfo.h" #include "qscopedpointer.h" #ifdef QT_BUILD_QMAKE QT_BEGIN_NAMESPACE -extern QString qmake_absoluteLocation(); extern QString qmake_libraryInfoFile(); QT_END_NAMESPACE #else -# include "qconfig.cpp" # include "qcoreapplication.h" #endif @@ -60,6 +57,10 @@ QT_END_NAMESPACE # include "private/qcore_mac_p.h" #endif +#ifndef QT_BUILD_QMAKE_BOOTSTRAP +# include "qconfig.cpp" +#endif + #include "archdetect.cpp" QT_BEGIN_NAMESPACE @@ -72,16 +73,9 @@ struct QLibrarySettings { QLibrarySettings(); void load(); -#ifdef QT_BUILD_QMAKE - void loadBuiltinValues(QSettings *config); -#endif QScopedPointer settings; #ifdef QT_BUILD_QMAKE - QString builtinValues[QLibraryInfo::LastHostPath + 1]; -# ifndef Q_OS_WIN - QString builtinSettingsPath; -# endif bool haveDevicePaths; bool haveEffectiveSourcePaths; bool haveEffectivePaths; @@ -113,18 +107,6 @@ public: ? ls->haveDevicePaths : ls->havePaths) : false; } - static QString builtinValue(int loc) - { - QLibrarySettings *ls = qt_library_settings(); - return ls ? ls->builtinValues[loc] : QString(); - } -# ifndef Q_OS_WIN - static QString builtinSettingsPath() - { - QLibrarySettings *ls = qt_library_settings(); - return ls ? ls->builtinSettingsPath : QString(); - } -# endif #endif static QSettings *configuration() { @@ -148,20 +130,6 @@ QLibrarySettings::QLibrarySettings() load(); } -#ifdef QT_BUILD_QMAKE -static QByteArray qtconfSeparator() -{ -# ifdef Q_OS_WIN - QByteArray header = QByteArrayLiteral("\r\n===========================================================\r\n"); -# else - QByteArray header = QByteArrayLiteral("\n===========================================================\n"); -# endif - QByteArray content = QByteArrayLiteral("==================== qt.conf beginning ===================="); - // Assemble from pieces to avoid that the string appears in a raw executable - return header + content + header; -} -#endif - void QLibrarySettings::load() { // If we get any settings here, those won't change when the application shows up. @@ -199,27 +167,6 @@ void QLibrarySettings::load() havePaths = false; #endif } - -#ifdef QT_BUILD_QMAKE - // Try to use an embedded qt.conf appended to the QMake executable. - QFile qmakeFile(qmake_absoluteLocation()); - if (!qmakeFile.open(QIODevice::ReadOnly)) - return; - qmakeFile.seek(qmakeFile.size() - 10000); - QByteArray tail = qmakeFile.read(10000); - QByteArray separator = qtconfSeparator(); - int qtconfOffset = tail.lastIndexOf(separator); - if (qtconfOffset < 0) - return; - tail.remove(0, qtconfOffset + separator.size()); - // If QSettings had a c'tor taking a QIODevice, we'd pass a QBuffer ... - QTemporaryFile tmpFile; - tmpFile.open(); - tmpFile.write(tail); - tmpFile.close(); - QSettings builtinSettings(tmpFile.fileName(), QSettings::IniFormat); - loadBuiltinValues(&builtinSettings); -#endif } QSettings *QLibraryInfoPrivate::findConfiguration() @@ -482,24 +429,11 @@ static const struct { { "HostData", "." }, { "TargetSpec", "" }, { "HostSpec", "" }, - { "ExtPrefix", "" }, { "HostPrefix", "" }, #endif }; #ifdef QT_BUILD_QMAKE -void QLibrarySettings::loadBuiltinValues(QSettings *config) -{ - config->beginGroup(QLatin1String("Paths")); - for (int i = 0; i <= QLibraryInfo::LastHostPath; i++) - builtinValues[i] = config->value(QLatin1String(qtConfEntries[i].key), - QLatin1String(qtConfEntries[i].value)).toString(); -# ifndef Q_OS_WIN - builtinSettingsPath = config->value(QLatin1String("Settings")).toString(); -# endif - config->endGroup(); -} - void QLibraryInfo::reload() { QLibraryInfoPrivate::reload(); @@ -613,34 +547,32 @@ QLibraryInfo::rawLocation(LibraryLocation loc, PathGroup group) } #endif // QT_NO_SETTINGS +#ifndef QT_BUILD_QMAKE_BOOTSTRAP if (!fromConf) { -#ifdef QT_BUILD_QMAKE - if ((unsigned)loc <= (unsigned)LastHostPath) { - if (loc == PrefixPath && group != DevicePaths) - ret = QLibraryInfoPrivate::builtinValue(ExtPrefixPath); - else - ret = QLibraryInfoPrivate::builtinValue(loc); -# ifndef Q_OS_WIN // On Windows we use the registry - } else if (loc == SettingsPath) { - ret = QLibraryInfoPrivate::builtinSettingsPath(); -# endif - } -#else // QT_BUILD_QMAKE const char * volatile path = 0; if (loc == PrefixPath) { - path = QT_CONFIGURE_PREFIX_PATH; + path = +# ifdef QT_BUILD_QMAKE + (group != DevicePaths) ? + QT_CONFIGURE_EXT_PREFIX_PATH : +# endif + QT_CONFIGURE_PREFIX_PATH; } else if (unsigned(loc) <= sizeof(qt_configure_str_offsets)/sizeof(qt_configure_str_offsets[0])) { path = qt_configure_strs + qt_configure_str_offsets[loc - 1]; #ifndef Q_OS_WIN // On Windows we use the registry } else if (loc == SettingsPath) { path = QT_CONFIGURE_SETTINGS_PATH; #endif +# ifdef QT_BUILD_QMAKE + } else if (loc == HostPrefixPath) { + path = QT_CONFIGURE_HOST_PREFIX_PATH; +# endif } if (path) ret = QString::fromLocal8Bit(path); -#endif } +#endif #ifdef QT_BUILD_QMAKE // These values aren't actually paths and thus need to be returned verbatim. diff --git a/src/corelib/global/qlibraryinfo.h b/src/corelib/global/qlibraryinfo.h index 812ab9a263..809813d99d 100644 --- a/src/corelib/global/qlibraryinfo.h +++ b/src/corelib/global/qlibraryinfo.h @@ -97,7 +97,6 @@ public: HostDataPath, TargetSpecPath, HostSpecPath, - ExtPrefixPath, HostPrefixPath, LastHostPath = HostPrefixPath, #endif -- cgit v1.2.3 From e35c993020228fc2f173d116bc8ba34d419ae7c9 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 5 Jan 2017 10:00:18 +0100 Subject: QProgressBar: remove unneeded ctor-style no-op cast The expression '100' already has type int, so the cast is not necessary, and confusing. Remove it. Change-Id: Id63f56645b1b13532f73e481547c2a606dfc9c9a Reviewed-by: David Faure --- src/widgets/widgets/qprogressbar.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/widgets/widgets/qprogressbar.cpp b/src/widgets/widgets/qprogressbar.cpp index 2893849c42..be6091f499 100644 --- a/src/widgets/widgets/qprogressbar.cpp +++ b/src/widgets/widgets/qprogressbar.cpp @@ -481,7 +481,7 @@ QString QProgressBar::text() const // progress bar has one step and that we are on that step. Return // 100% here in order to avoid division by zero further down. if (totalSteps == 0) { - result.replace(QLatin1String("%p"), locale.toString(int(100))); + result.replace(QLatin1String("%p"), locale.toString(100)); return result; } -- cgit v1.2.3 From a3d0983f5909c37205cf0bdd4c4eba15d26d58c9 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 5 Jan 2017 08:10:53 +0100 Subject: QProgressBar: don't lose precision in text() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When qreal is float, it cannot represent all values an int can take, so we may lose precision in the expression qreal(d->value) - d->minimum as opposed to the exact result qint64(d->value) - d->minimum' For lack of trying, I do not know of a value where this would change the resulting 'progress' value, but better be safe than sorry, and use the 64-bit integer expression instead. Found while reviewing integer arithmetic in QProgressBar as part of the fix for QTBUG-57857. While touching the line, make the (intended) double → int truncation explicit, by using a static_cast. Change-Id: I03dbfce24c709310c3bbad9487a2bf0d1d78137a Reviewed-by: David Faure --- src/widgets/widgets/qprogressbar.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/widgets/widgets/qprogressbar.cpp b/src/widgets/widgets/qprogressbar.cpp index be6091f499..64f19047b6 100644 --- a/src/widgets/widgets/qprogressbar.cpp +++ b/src/widgets/widgets/qprogressbar.cpp @@ -485,7 +485,7 @@ QString QProgressBar::text() const return result; } - int progress = (qreal(d->value) - d->minimum) * 100.0 / totalSteps; + const auto progress = static_cast((qint64(d->value) - d->minimum) * 100.0 / totalSteps); result.replace(QLatin1String("%p"), locale.toString(progress)); return result; } -- cgit v1.2.3 From 3f996edbb69a575267a4ff816f09510f14729149 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 5 Jan 2017 09:12:10 +0100 Subject: QPixmapStyle: do not assume minimum == 0 when painting progress bars The arithmetic used to calculate the size of the progress bar fill in QPixmapStyle assumed minimum == 0, but that does not necessarily hold, since the minimum value is user-defined. So, fix the arithmetic to take the minimum into account, taking care, as done elsewhere, to avoid signed integer and qreal=float overflows, by using qint64 and double, respectively. [ChangeLog][QtWidgets][QPixmapStyle] Now handles progress bars with minimum != 0 correctly. Change-Id: I738ded56e8234716c36a5e9fde15bae691c43a35 Reviewed-by: David Faure --- src/widgets/styles/qpixmapstyle.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/widgets/styles/qpixmapstyle.cpp b/src/widgets/styles/qpixmapstyle.cpp index e973a96a91..ce37065fb6 100644 --- a/src/widgets/styles/qpixmapstyle.cpp +++ b/src/widgets/styles/qpixmapstyle.cpp @@ -819,11 +819,14 @@ void QPixmapStyle::drawProgressBarFill(const QStyleOption *option, drawCachedPixmap(vertical ? PB_VComplete : PB_HComplete, option->rect, painter); } else { - if (pbar->progress == 0) + if (pbar->progress == pbar->minimum) return; - const int maximum = pbar->maximum; - const qreal ratio = qreal(vertical?option->rect.height():option->rect.width())/maximum; - const int progress = pbar->progress*ratio; + const auto totalSteps = qint64(pbar->maximum) - pbar->minimum; + const auto progressSteps = qint64(pbar->progress) - pbar->minimum; + const auto availablePixels = vertical ? option->rect.height() : option->rect.width(); + const auto pixelsPerStep = double(availablePixels) / totalSteps; + + const auto progress = static_cast(progressSteps * pixelsPerStep); // width in pixels QRect optRect = option->rect; if (vertical) { -- cgit v1.2.3 From 894cd9bcfc041ee3064b7f7b4215415fe99cd6b8 Mon Sep 17 00:00:00 2001 From: Kavindra Palaraja Date: Fri, 6 Jan 2017 23:56:22 +0100 Subject: Remove strange, incoherent sentences in QColor docs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There were some strange sentences that did not add to the documentation of HSL vs. HSV. Task-number: QTBUG-52483 Change-Id: I5f2b8c3bd420fe9cabc74a94af4b78945723b6cf Reviewed-by: Tor Arne Vestbø Reviewed-by: Mitch Curtis --- src/gui/painting/qcolor.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/gui/painting/qcolor.cpp b/src/gui/painting/qcolor.cpp index 6a8091bf8b..9e1785c11d 100644 --- a/src/gui/painting/qcolor.cpp +++ b/src/gui/painting/qcolor.cpp @@ -545,12 +545,8 @@ static QStringList get_colornames() \section1 The HSL Color Model - HSL is similar to HSV. Instead of value parameter from HSV, - HSL has the lightness parameter. - The lightness parameter goes from black to color and from color to white. - If you go outside at the night its black or dark gray. At day its colorful but - if you look in a really strong light a things they are going to white and - wash out. + HSL is similar to HSV, however instead of the Value parameter, HSL + specifies a Lightness parameter. \section1 The CMYK Color Model -- cgit v1.2.3 From 555a0f3c511368eff51cd0f8e52f0abc7a0ff28c Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 5 Jan 2017 08:10:53 +0100 Subject: QFusionStyle: don't lose precision when drawing a progress bar When qreal is float, it cannot represent all values an int can take, so we may lose precision in the expression qreal(value) - minimum as opposed to the exact result qint64(value) - minimum' For lack of trying, I do not know of a value where this would change the resulting 'progressBarWidth' value, but better be safe than sorry, and use the 64-bit integer expression instead of floating-point. Found while reviewing integer arithmetic in QProgressBar as part of the fix for QTBUG-57857. Change-Id: I0240c143bb75af6986910489b34042ce9b3a8caa Reviewed-by: David Faure --- src/widgets/styles/qfusionstyle.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/widgets/styles/qfusionstyle.cpp b/src/widgets/styles/qfusionstyle.cpp index 74e4d53dca..c2b4ef382b 100644 --- a/src/widgets/styles/qfusionstyle.cpp +++ b/src/widgets/styles/qfusionstyle.cpp @@ -1352,10 +1352,11 @@ void QFusionStyle::drawControl(ControlElement element, const QStyleOption *optio } int maxWidth = rect.width(); - int minWidth = 0; - qreal progress = qMax(bar->progress, bar->minimum); // workaround for bug in QProgressBar - int progressBarWidth = (progress - bar->minimum) * qreal(maxWidth) / qMax(qreal(1.0), qreal(bar->maximum) - bar->minimum); - int width = indeterminate ? maxWidth : qMax(minWidth, progressBarWidth); + const auto progress = qMax(bar->progress, bar->minimum); // workaround for bug in QProgressBar + const auto totalSteps = qMax(Q_INT64_C(1), qint64(bar->maximum) - bar->minimum); + const auto progressSteps = qint64(progress) - bar->minimum; + const auto progressBarWidth = progressSteps * maxWidth / totalSteps; + int width = indeterminate ? maxWidth : progressBarWidth; bool reverse = (!vertical && (bar->direction == Qt::RightToLeft)) || vertical; if (inverted) @@ -1450,8 +1451,9 @@ void QFusionStyle::drawControl(ControlElement element, const QStyleOption *optio inverted = bar->invertedAppearance; if (vertical) rect = QRect(rect.left(), rect.top(), rect.height(), rect.width()); // flip width and height - const int progressIndicatorPos = (bar->progress - qreal(bar->minimum)) * rect.width() / - qMax(qreal(1.0), qreal(bar->maximum) - bar->minimum); + const auto totalSteps = qMax(Q_INT64_C(1), qint64(bar->maximum) - bar->minimum); + const auto progressSteps = qint64(bar->progress) - bar->minimum; + const auto progressIndicatorPos = progressSteps * rect.width() / totalSteps; if (progressIndicatorPos >= 0 && progressIndicatorPos <= rect.width()) leftRect = QRect(rect.left(), rect.top(), progressIndicatorPos, rect.height()); if (vertical) -- cgit v1.2.3 From 1d1b60dee40de3b8d67be46399b58d4b1ecddab1 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 5 Jan 2017 08:10:53 +0100 Subject: QStylesheetStyle: don't lose precision when drawing a progress bar When qreal is float, it cannot represent all values an int can take, so we may lose precision in the expression qreal(a) / b as opposed to the double result double(a) / b For lack of trying, I do not know of a value where this would change the resulting 'fillWidth' value, but better be safe than sorry, and use double instead of qreal arithmetic. Also, when calculating fillRatio, we were converting values back and forth between qreal and double. Using double everywhere avoids that. Found while reviewing integer arithmetic in QProgressBar as part of the fix for QTBUG-57857. Change-Id: I054cb11d35e3ecf5bf79b5c8ee39029bd23bcf49 Reviewed-by: David Faure --- src/widgets/styles/qstylesheetstyle.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp index d63c96bf0e..68ee8c22d3 100644 --- a/src/widgets/styles/qstylesheetstyle.cpp +++ b/src/widgets/styles/qstylesheetstyle.cpp @@ -3903,8 +3903,8 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q if (inverted) reverse = !reverse; const bool indeterminate = pb->minimum == pb->maximum; - qreal fillRatio = indeterminate ? 0.50 : qreal(progress - minimum)/(maximum - minimum); - int fillWidth = int(rect.width() * fillRatio); + const auto fillRatio = indeterminate ? 0.50 : double(progress - minimum) / (maximum - minimum); + const auto fillWidth = static_cast(rect.width() * fillRatio); int chunkWidth = fillWidth; if (subRule.hasContentsSize()) { QSize sz = subRule.size(); -- cgit v1.2.3 From 389165dd25a30a0ff9ea368555ecb84d40ceacfa Mon Sep 17 00:00:00 2001 From: Kavindra Palaraja Date: Sun, 8 Jan 2017 10:32:52 +0100 Subject: Clarify StripTrailingSlash behavior StripTrailingSlash removes trailing slashes from the path, but not the entire URL. Task-number: QTBUG-47607 Change-Id: Id62b971e563e290b7ca000576bcc328616a3f1a2 Reviewed-by: David Faure --- src/corelib/io/qurl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp index 066052ade9..38f2a708b5 100644 --- a/src/corelib/io/qurl.cpp +++ b/src/corelib/io/qurl.cpp @@ -240,7 +240,7 @@ Only valid if RemovePath is not set. \value PreferLocalFile If the URL is a local file according to isLocalFile() and contains no query or fragment, a local file path is returned. - \value StripTrailingSlash The trailing slash is removed if one is present. + \value StripTrailingSlash The trailing slash is removed from the path, if one is present. \value NormalizePathSegments Modifies the path to remove redundant directory separators, and to resolve "."s and ".."s (as far as possible). -- cgit v1.2.3 From 9e0837bd6ef7f9d5d4c219e2a17fdbde43243aaa Mon Sep 17 00:00:00 2001 From: Nico Vertriest Date: Mon, 9 Jan 2017 15:28:04 +0100 Subject: Doc: removed reference to non-existing snippet Command \snippet (//! [3])' failed at end of file ../widgets/widgets/charactermap/mainwindow.cpp Change-Id: Ib095053bd4ff3901d7a9cd91aae3d83ec5f60807 Reviewed-by: Friedemann Kleint --- src/gui/doc/src/dnd.qdoc | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'src') diff --git a/src/gui/doc/src/dnd.qdoc b/src/gui/doc/src/dnd.qdoc index 03b3cbfa24..945c485705 100644 --- a/src/gui/doc/src/dnd.qdoc +++ b/src/gui/doc/src/dnd.qdoc @@ -343,9 +343,7 @@ Applications can also communicate with each other by putting data on the clipboard. To access this, you need to obtain a QClipboard object - from the QApplication object: - - \snippet ../widgets/widgets/charactermap/mainwindow.cpp 3 + from the QApplication object. The QMimeData class is used to represent data that is transferred to and from the clipboard. To put data on the clipboard, you can use the -- cgit v1.2.3 From 6650d65b0baac23ffc2db352437ba501b2b4511a Mon Sep 17 00:00:00 2001 From: Nico Vertriest Date: Mon, 9 Jan 2017 15:45:38 +0100 Subject: Doc: corrected qdoc syntax parameter description qxcbwindowfunctions.qdoc: 109: warning - Unknown command '\role' [Maybe you meant '\row'?] Change-Id: I1f6f8e449921bd415432ebd06e6169b3d8757e22 Reviewed-by: Venugopal Shivashankar --- src/platformheaders/xcbfunctions/qxcbwindowfunctions.qdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/platformheaders/xcbfunctions/qxcbwindowfunctions.qdoc b/src/platformheaders/xcbfunctions/qxcbwindowfunctions.qdoc index f0ef5ee2a7..fab473b91b 100644 --- a/src/platformheaders/xcbfunctions/qxcbwindowfunctions.qdoc +++ b/src/platformheaders/xcbfunctions/qxcbwindowfunctions.qdoc @@ -106,7 +106,7 @@ \fn void QXcbWindowFunctions::setWmWindowRole(QWindow *window, const QByteArray &role) \since 5.6.2 - Sets the WM_WINDOW_ROLE property from \role on the corresponding + Sets the WM_WINDOW_ROLE property from \a role on the corresponding X11 window. This is a convenience function that can be used directly instead -- cgit v1.2.3 From 280f067fe0c5a11a38e60d42d6cc74152515793a Mon Sep 17 00:00:00 2001 From: Nico Vertriest Date: Mon, 9 Jan 2017 16:27:44 +0100 Subject: Doc: corrected qdoc list syntax qundostack.cpp: Command '\li' outside of '\list' and '\table' Change-Id: Ic162e246c754e125f6ae82a2a66312e925b231c2 Reviewed-by: Martin Smith --- src/widgets/util/qundostack.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/widgets/util/qundostack.cpp b/src/widgets/util/qundostack.cpp index 59d517e77b..033d4e9e05 100644 --- a/src/widgets/util/qundostack.cpp +++ b/src/widgets/util/qundostack.cpp @@ -654,10 +654,12 @@ void QUndoStack::setClean() This method resets the clean index to -1. This is typically called in the following cases, when a document has been: + \list \li created basing on some template and has not been saved, so no filename has been associated with the document yet. \li restored from a backup file. \li changed outside of the editor and the user did not reload it. + \endlist \sa isClean(), setClean(), cleanIndex() */ -- cgit v1.2.3 From b0a9b9ab87aedab65888f8d71f3a33da06ba9c7d Mon Sep 17 00:00:00 2001 From: James McDonnell Date: Wed, 7 Dec 2016 11:10:51 -0500 Subject: Adjust QNX choices Don't use Dinkum choices when the C++ library is libC++ (QNX 7.0). Change-Id: I18c3f716ccfb0c02dbfdc01eac4b707d3ae9aab6 Reviewed-by: Thiago Macieira --- src/corelib/global/qcompilerdetection.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/corelib/global/qcompilerdetection.h b/src/corelib/global/qcompilerdetection.h index 4142c17b42..77ce488ca0 100644 --- a/src/corelib/global/qcompilerdetection.h +++ b/src/corelib/global/qcompilerdetection.h @@ -999,7 +999,7 @@ // Older versions (QNX 650) do not support C++11 features // _HAS_* macros are set to 1 by toolchains that actually include // Dinkum C++11 libcpp. -# if !defined(__GLIBCXX__) +# if !defined(__GLIBCXX__) && !defined(_LIBCPP_VERSION) # if !defined(_HAS_CPP0X) || !_HAS_CPP0X // Disable C++11 features that depend on library support # undef Q_COMPILER_INITIALIZER_LISTS -- cgit v1.2.3 From dfa08d65a55dbc54d2573fd179e1197f4fdd5a90 Mon Sep 17 00:00:00 2001 From: Kavindra Palaraja Date: Sun, 8 Jan 2017 10:22:55 +0100 Subject: Replace non-existent signals with the correct ones activated() is actually triggered(), highlighted() is actually hovered() Task-number: QTBUG-50315 Change-Id: Ieefdc8376102d80d0885a6c7ca47a9380945afef Reviewed-by: Gabriel de Dietrich --- src/widgets/widgets/qmenu.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/widgets/widgets/qmenu.cpp b/src/widgets/widgets/qmenu.cpp index 36a8a96b79..2917083415 100644 --- a/src/widgets/widgets/qmenu.cpp +++ b/src/widgets/widgets/qmenu.cpp @@ -1507,7 +1507,7 @@ void QMenu::initStyleOption(QStyleOptionMenuItem *option, const QAction *action) When inserting action items you usually specify a receiver and a slot. The receiver will be notifed whenever the item is \l{QAction::triggered()}{triggered()}. In addition, QMenu provides - two signals, activated() and highlighted(), which signal the + two signals, triggered() and hovered(), which signal the QAction that was triggered from the menu. You clear a menu with clear() and remove individual action items -- cgit v1.2.3 From 41d1785e130e5ab43b24635c890ee501971de18b Mon Sep 17 00:00:00 2001 From: Kavindra Palaraja Date: Sun, 8 Jan 2017 12:37:03 +0100 Subject: Clarify that QString::toDouble does not have a fallback QString::toDouble always uses the 'C' locale. Task-number: QTBUG-44045 Change-Id: Ifb0c2f11c83c209907dd35bb39d1450022c8e85c Reviewed-by: Thiago Macieira --- src/corelib/tools/qlocale.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/corelib/tools/qlocale.cpp b/src/corelib/tools/qlocale.cpp index f499681ca9..20a984fafe 100644 --- a/src/corelib/tools/qlocale.cpp +++ b/src/corelib/tools/qlocale.cpp @@ -1305,8 +1305,8 @@ float QLocale::toFloat(const QString &s, bool *ok) const If \a ok is not 0, reports failure by setting *ok to false and success by setting *ok to true. - Unlike QString::toDouble(), this function does not fall back to - the "C" locale if the string cannot be interpreted in this + Unlike QString::toDouble(), this function does not use + the 'C' locale if the string cannot be interpreted in this locale. \snippet code/src_corelib_tools_qlocale.cpp 3 -- cgit v1.2.3 From 7f12f94e481d4908ee7b68e2cab8263b7476b054 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Kundr=C3=A1t?= Date: Thu, 21 Jul 2016 11:26:21 +0200 Subject: Restore binary compatibility with pre-5.6 qt_handleMouseEvent An internal, private symbol was changed in beef975f92e42143c464d68afa6b8cd4f7ef7389. However, this symbol was being used by some inline functions in QtTest, and this therefore introduced a BIC. This change simple adds back a symbol with the original signature. I recall seeing this in my own work, and the KDE CI system hits this as well: libKF5KDELibs4Support.so.5.25.0: undefined reference to `qt_handleMouseEvent(QWindow*, QPointF const&, QPointF const&, QFlags, QFlags)' Task-number: QTBUG-52205 Change-Id: I4e85996850cc436b6a31addca3a8f9829c0c5edd Reviewed-by: Lars Knoll --- src/gui/kernel/qwindowsysteminterface.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src') diff --git a/src/gui/kernel/qwindowsysteminterface.cpp b/src/gui/kernel/qwindowsysteminterface.cpp index 667304859e..8e86ce0b5c 100644 --- a/src/gui/kernel/qwindowsysteminterface.cpp +++ b/src/gui/kernel/qwindowsysteminterface.cpp @@ -924,6 +924,13 @@ Q_GUI_EXPORT void qt_handleMouseEvent(QWindow *w, const QPointF &local, const QP QWindowSystemInterface::handleMouseEvent(w, timestamp, local * factor, global * factor, b, mods); } +// Wrapper for compatibility with Qt < 5.6 +// ### Qt6: Remove +Q_GUI_EXPORT void qt_handleMouseEvent(QWindow *w, const QPointF &local, const QPointF &global, Qt::MouseButtons b, Qt::KeyboardModifiers mods = Qt::NoModifier) +{ + qt_handleMouseEvent(w, local, global, b, mods, QWindowSystemInterfacePrivate::eventTime.elapsed()); +} + Q_GUI_EXPORT void qt_handleKeyEvent(QWindow *w, QEvent::Type t, int k, Qt::KeyboardModifiers mods, const QString & text = QString(), bool autorep = false, ushort count = 1) { QWindowSystemInterface::handleKeyEvent(w, t, k, mods, text, autorep, count); -- cgit v1.2.3 From 2005b9fae12b19a4d087035789fa3bc9730d303a Mon Sep 17 00:00:00 2001 From: Jesus Fernandez Date: Mon, 2 Jan 2017 11:34:44 +0100 Subject: Remove unreachable code The unknown types are treated as strings by default. Coverity-Id: 59489 Change-Id: Ib0eaf5c27d3afaf694c8a2acca42bef6808c8a9f Reviewed-by: Timur Pocheptsov --- src/plugins/sqldrivers/mysql/qsql_mysql.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/plugins/sqldrivers/mysql/qsql_mysql.cpp b/src/plugins/sqldrivers/mysql/qsql_mysql.cpp index 0bea9ebfa1..7cfa554418 100644 --- a/src/plugins/sqldrivers/mysql/qsql_mysql.cpp +++ b/src/plugins/sqldrivers/mysql/qsql_mysql.cpp @@ -699,10 +699,8 @@ QVariant QMYSQLResult::data(int field) } if(ok) return v; - else - return QVariant(); + return QVariant(); } - return QVariant(val.toDouble()); case QVariant::Date: return qDateFromString(val); case QVariant::Time: @@ -719,12 +717,11 @@ QVariant QMYSQLResult::data(int field) } return QVariant(ba); } - default: case QVariant::String: + default: return QVariant(val); } - qWarning("QMYSQLResult::data: unknown data type"); - return QVariant(); + Q_UNREACHABLE(); } bool QMYSQLResult::isNull(int field) -- cgit v1.2.3 From 25b00c88b6fda2eecd9ff566ab44974136dabf51 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Tue, 10 Jan 2017 10:56:34 +0100 Subject: cocoa: Account for getting a keyboard using input methods correctly MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When a keyboard is using an input method then the layout for it needs to be retrieved with TISCopyInputMethodKeyboardLayoutOverride(). For cases where it is not using an input method this will return null and in that case we can use the original approach as before. Task-number: QTBUG-53804 Task-number: QTBUG-57934 Change-Id: I6283785bf002602113e208bb38d5eb2a9a7ceb36 Reviewed-by: Tor Arne Vestbø --- src/plugins/platforms/cocoa/qcocoakeymapper.mm | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/plugins/platforms/cocoa/qcocoakeymapper.mm b/src/plugins/platforms/cocoa/qcocoakeymapper.mm index e7952ae1f6..1ef7f11011 100644 --- a/src/plugins/platforms/cocoa/qcocoakeymapper.mm +++ b/src/plugins/platforms/cocoa/qcocoakeymapper.mm @@ -366,7 +366,9 @@ Qt::KeyboardModifiers QCocoaKeyMapper::queryKeyboardModifiers() bool QCocoaKeyMapper::updateKeyboard() { const UCKeyboardLayout *uchrData = 0; - QCFType source = TISCopyCurrentKeyboardInputSource(); + QCFType source = TISCopyInputMethodKeyboardLayoutOverride(); + if (!source) + source = TISCopyCurrentKeyboardInputSource(); if (keyboard_mode != NullMode && source == currentInputSource) { return false; } -- cgit v1.2.3 From 0dc85f78083f4e2777697d998a5bc3ffdf13a6a1 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Mon, 9 Jan 2017 11:20:20 +0100 Subject: Don't build SQL driver plugins if we are not building Qt SQL Change-Id: I60fb0d7c05652fbad9884b19e612cfef6156d9ae Reviewed-by: Oswald Buddenhagen --- src/plugins/plugins.pro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/plugins/plugins.pro b/src/plugins/plugins.pro index 941c25361f..620d9cb8c9 100644 --- a/src/plugins/plugins.pro +++ b/src/plugins/plugins.pro @@ -1,7 +1,7 @@ TEMPLATE = subdirs QT_FOR_CONFIG += network -SUBDIRS *= sqldrivers +qtHaveModule(sql): SUBDIRS += sqldrivers qtHaveModule(network):qtConfig(bearermanagement): SUBDIRS += bearer qtHaveModule(gui) { SUBDIRS *= platforms platforminputcontexts platformthemes -- cgit v1.2.3 From eaa0063b707c214925c3a98ff7a5d1f890581c08 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Wed, 23 Nov 2016 12:25:59 +0100 Subject: Fix compilation with QT_NO_SHAREDMEMORY If we use QLatin1String we should include qstring.h. Change-Id: Iebd761b98e515e9cd9cd34b96a0f8a602d00f086 Reviewed-by: Thiago Macieira --- src/corelib/kernel/qsharedmemory_p.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/corelib/kernel/qsharedmemory_p.h b/src/corelib/kernel/qsharedmemory_p.h index 51f729cf23..95fe0d1083 100644 --- a/src/corelib/kernel/qsharedmemory_p.h +++ b/src/corelib/kernel/qsharedmemory_p.h @@ -53,6 +53,8 @@ #include "qsharedmemory.h" +#include + #ifdef QT_NO_SHAREDMEMORY # ifndef QT_NO_SYSTEMSEMAPHORE namespace QSharedMemoryPrivate -- cgit v1.2.3 From cb1a4d8e06d34c9c55eb678715e2ac8596d8882b Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Mon, 9 Jan 2017 11:19:38 +0100 Subject: Testlib: Exclude qtest_network.h when building without Qt Network Change-Id: If085684ed5252a01a682222510f6849be974feea Reviewed-by: Marc Mutz --- src/testlib/testlib.pro | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/testlib/testlib.pro b/src/testlib/testlib.pro index 5b2205e875..e84651ccd5 100644 --- a/src/testlib/testlib.pro +++ b/src/testlib/testlib.pro @@ -111,4 +111,6 @@ mac { !qtHaveModule(widgets): HEADERSCLEAN_EXCLUDE += qtest_widgets.h +!qtHaveModule(network): HEADERSCLEAN_EXCLUDE += qtest_network.h + load(qt_module) -- cgit v1.2.3 From 858c1afb7af7d374520cbfb99aef8acadfaa9d88 Mon Sep 17 00:00:00 2001 From: Rafael Roquetto Date: Tue, 10 Jan 2017 08:42:35 -0200 Subject: QNX: Fix comments on qcompilerdetection.h Change-Id: I75495b4ba3d8742419f824aa0e0b52694dbd42ed Reviewed-by: James McDonnell Reviewed-by: Thiago Macieira --- src/corelib/global/qcompilerdetection.h | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/corelib/global/qcompilerdetection.h b/src/corelib/global/qcompilerdetection.h index 77ce488ca0..c0f14e0f03 100644 --- a/src/corelib/global/qcompilerdetection.h +++ b/src/corelib/global/qcompilerdetection.h @@ -995,11 +995,20 @@ #ifdef __cplusplus # include # if defined(Q_OS_QNX) -// QNX: test if we are using libcpp (Dinkumware-based). -// Older versions (QNX 650) do not support C++11 features +// By default, QNX 7.0 uses libc++ (from LLVM) and +// QNX 6.X uses Dinkumware's libcpp. In all versions, +// it is also possible to use GNU libstdc++. + +// For Dinkumware, some features must be disabled +// (mostly because of library problems). +// Dinkumware is assumed when __GLIBCXX__ (GNU libstdc++) +// and _LIBCPP_VERSION (LLVM libc++) are both absent. +# if !defined(__GLIBCXX__) && !defined(_LIBCPP_VERSION) + +// Older versions of libcpp (QNX 650) do not support C++11 features // _HAS_* macros are set to 1 by toolchains that actually include // Dinkum C++11 libcpp. -# if !defined(__GLIBCXX__) && !defined(_LIBCPP_VERSION) + # if !defined(_HAS_CPP0X) || !_HAS_CPP0X // Disable C++11 features that depend on library support # undef Q_COMPILER_INITIALIZER_LISTS @@ -1016,7 +1025,7 @@ // Disable constexpr support on QNX even if the compiler supports it # undef Q_COMPILER_CONSTEXPR # endif // !_HAS_CONSTEXPR -# endif // !__GLIBCXX__ +# endif // !__GLIBCXX__ && !_LIBCPP_VERSION # endif // Q_OS_QNX # if (defined(Q_CC_CLANG) || defined(Q_CC_INTEL)) && defined(Q_OS_MAC) && defined(__GNUC_LIBSTD__) \ && ((__GNUC_LIBSTD__-0) * 100 + __GNUC_LIBSTD_MINOR__-0 <= 402) -- cgit v1.2.3 From ae42bf0f9b2b8c65ef509d5d0ecdd9a0535bb3d2 Mon Sep 17 00:00:00 2001 From: Jason Erb Date: Sun, 15 May 2016 12:16:50 -0400 Subject: Fixed Chinese language selection on iOS For language "Traditional Chinese" on iOS with region "US", the logic was formerly to attempt a match on country/language/script (fail), followed by country/language (which would result in script defaulting to "Simplified"). Now, the logic is to try language/script first if script is specified. Failing that, language/country will be attempted. Task-number: QTBUG-39639 Change-Id: I75a774b1e66686e95167ff221458a97a7ea2660d Reviewed-by: Konstantin Ritt Reviewed-by: Lars Knoll Reviewed-by: Jason Erb Reviewed-by: Thiago Macieira --- src/corelib/tools/qlocale.cpp | 83 ++++++++++++++++++++++++++++++++----------- 1 file changed, 62 insertions(+), 21 deletions(-) (limited to 'src') diff --git a/src/corelib/tools/qlocale.cpp b/src/corelib/tools/qlocale.cpp index 20a984fafe..5b53b8b338 100644 --- a/src/corelib/tools/qlocale.cpp +++ b/src/corelib/tools/qlocale.cpp @@ -334,33 +334,17 @@ QByteArray QLocalePrivate::bcp47Name(char separator) const return localeId.withLikelySubtagsRemoved().name(separator); } -const QLocaleData *QLocaleData::findLocaleData(QLocale::Language language, QLocale::Script script, QLocale::Country country) +static const QLocaleData *findLocaleDataById(const QLocaleId &localeId) { - QLocaleId localeId = QLocaleId::fromIds(language, script, country); - localeId = localeId.withLikelySubtagsAdded(); - - uint idx = locale_index[localeId.language_id]; + const uint idx = locale_index[localeId.language_id]; const QLocaleData *data = locale_data + idx; - if (idx == 0) // default language has no associated country + if (idx == 0) // default language has no associated script or country return data; Q_ASSERT(data->m_language_id == localeId.language_id); - if (localeId.script_id != QLocale::AnyScript && localeId.country_id != QLocale::AnyCountry) { - // both script and country are explicitly specified - do { - if (data->m_script_id == localeId.script_id && data->m_country_id == localeId.country_id) - return data; - ++data; - } while (data->m_language_id == localeId.language_id); - - // no match; try again with default script - localeId.script_id = QLocale::AnyScript; - data = locale_data + idx; - } - if (localeId.script_id == QLocale::AnyScript && localeId.country_id == QLocale::AnyCountry) return data; @@ -369,15 +353,72 @@ const QLocaleData *QLocaleData::findLocaleData(QLocale::Language language, QLoca if (data->m_country_id == localeId.country_id) return data; ++data; - } while (data->m_language_id == localeId.language_id); + } while (data->m_language_id && data->m_language_id == localeId.language_id); } else if (localeId.country_id == QLocale::AnyCountry) { do { if (data->m_script_id == localeId.script_id) return data; ++data; - } while (data->m_language_id == localeId.language_id); + } while (data->m_language_id && data->m_language_id == localeId.language_id); + } else { + do { + if (data->m_script_id == localeId.script_id && data->m_country_id == localeId.country_id) + return data; + ++data; + } while (data->m_language_id && data->m_language_id == localeId.language_id); + } + + return 0; +} + +const QLocaleData *QLocaleData::findLocaleData(QLocale::Language language, QLocale::Script script, QLocale::Country country) +{ + QLocaleId localeId = QLocaleId::fromIds(language, script, country); + localeId = localeId.withLikelySubtagsAdded(); + + const uint idx = locale_index[localeId.language_id]; + + // Try a straight match + if (const QLocaleData *const data = findLocaleDataById(localeId)) + return data; + QList tried; + tried.push_back(localeId); + + // No match; try again with likely country + localeId = QLocaleId::fromIds(language, script, QLocale::AnyCountry); + localeId = localeId.withLikelySubtagsAdded(); + if (!tried.contains(localeId)) { + if (const QLocaleData *const data = findLocaleDataById(localeId)) + return data; + tried.push_back(localeId); + } + + // No match; try again with any country + localeId = QLocaleId::fromIds(language, script, QLocale::AnyCountry); + if (!tried.contains(localeId)) { + if (const QLocaleData *const data = findLocaleDataById(localeId)) + return data; + tried.push_back(localeId); + } + + // No match; try again with likely script + localeId = QLocaleId::fromIds(language, QLocale::AnyScript, country); + localeId = localeId.withLikelySubtagsAdded(); + if (!tried.contains(localeId)) { + if (const QLocaleData *const data = findLocaleDataById(localeId)) + return data; + tried.push_back(localeId); + } + + // No match; try again with any script + localeId = QLocaleId::fromIds(language, QLocale::AnyScript, country); + if (!tried.contains(localeId)) { + if (const QLocaleData *const data = findLocaleDataById(localeId)) + return data; + tried.push_back(localeId); } + // No match; return data at original index return locale_data + idx; } -- cgit v1.2.3 From 22138f59075ccc5dce8ee0c96ffbb7b5454bb561 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Wed, 4 Jan 2017 10:03:20 +0100 Subject: Correct initial window size with highDPI MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use the scaling factor when calculating the initial size of the platform window. Change-Id: Ie21f0da14e32ac437efbc304a3fd9722a7f8615e Reviewed-by: Friedemann Kleint Reviewed-by: Tor Arne Vestbø --- src/gui/kernel/qplatformwindow.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/gui/kernel/qplatformwindow.cpp b/src/gui/kernel/qplatformwindow.cpp index bcd3e830dd..11432a4272 100644 --- a/src/gui/kernel/qplatformwindow.cpp +++ b/src/gui/kernel/qplatformwindow.cpp @@ -60,7 +60,7 @@ QPlatformWindow::QPlatformWindow(QWindow *window) , d_ptr(new QPlatformWindowPrivate) { Q_D(QPlatformWindow); - d->rect = window->geometry(); + d->rect = QHighDpi::toNativePixels(window->geometry(), window); } /*! -- cgit v1.2.3 From 64666b9ee0a0dc0a356e825a519fde566bddd2c9 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Tue, 10 Jan 2017 08:50:57 +0100 Subject: Windows: Check if the fallback key matches the shift modifier case too There are some keyboard layouts where pressing shift will give something different to what the expected key would be. For example, on a French keyboard layout, pressing SHIFT+! gives 1 as opposed to SHIFT+1 giving ! on a US keyboard layout. Therefore it should check against both cases to ensure it does not end up adding a new entry. Task-number: QTBUG-57938 Change-Id: I11c52619c048b98500f2d79876bb912720af6e65 Reviewed-by: Oliver Wolff --- src/plugins/platforms/windows/qwindowskeymapper.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/plugins/platforms/windows/qwindowskeymapper.cpp b/src/plugins/platforms/windows/qwindowskeymapper.cpp index 00c4a6191e..b84b586f7c 100644 --- a/src/plugins/platforms/windows/qwindowskeymapper.cpp +++ b/src/plugins/platforms/windows/qwindowskeymapper.cpp @@ -703,7 +703,8 @@ void QWindowsKeyMapper::updatePossibleKeyCodes(unsigned char *kbdBuffer, quint32 quint32 fallbackKey = winceKeyBend(vk_key); if (!fallbackKey || fallbackKey == Qt::Key_unknown) { fallbackKey = 0; - if (vk_key != keyLayout[vk_key].qtKey[0] && vk_key < 0x5B && vk_key > 0x2F) + if (vk_key != keyLayout[vk_key].qtKey[0] && vk_key != keyLayout[vk_key].qtKey[1] + && vk_key < 0x5B && vk_key > 0x2F) fallbackKey = vk_key; } keyLayout[vk_key].qtKey[8] = fallbackKey; -- cgit v1.2.3 From 461549c35ade73b3c048e2c5ecfbd412c438c026 Mon Sep 17 00:00:00 2001 From: Sergio Martins Date: Wed, 7 Dec 2016 12:28:05 +0000 Subject: Don't show bogus empty window when calling QMainWindow::restoreState() Qt doesn't create the actual QDockWidgets when restoring, the user must ensure they are created before restoring state. So lets not create an empty QDockWidgetGroupWindow which you can't close and with no tabs. Change-Id: If0a6aa7cf6f3932ff4274e03f787e27aef8fa53d Task-Id: QTBUG-57492 Reviewed-by: Friedemann Kleint Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/widgets/widgets/qdockarealayout.cpp | 10 ++++++++++ src/widgets/widgets/qdockarealayout_p.h | 1 + src/widgets/widgets/qmainwindowlayout.cpp | 11 +++++++++-- 3 files changed, 20 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/widgets/widgets/qdockarealayout.cpp b/src/widgets/widgets/qdockarealayout.cpp index 63f8172bf6..ad19e5d5f9 100644 --- a/src/widgets/widgets/qdockarealayout.cpp +++ b/src/widgets/widgets/qdockarealayout.cpp @@ -266,6 +266,16 @@ bool QDockAreaLayoutInfo::isEmpty() const return next(-1) == -1; } +bool QDockAreaLayoutInfo::onlyHasPlaceholders() const +{ + for (const QDockAreaLayoutItem &item : item_list) { + if (!item.placeHolderItem) + return false; + } + + return true; +} + QSize QDockAreaLayoutInfo::minimumSize() const { if (isEmpty()) diff --git a/src/widgets/widgets/qdockarealayout_p.h b/src/widgets/widgets/qdockarealayout_p.h index f22a3d2de2..21787283f4 100644 --- a/src/widgets/widgets/qdockarealayout_p.h +++ b/src/widgets/widgets/qdockarealayout_p.h @@ -167,6 +167,7 @@ public: void clear(); bool isEmpty() const; + bool onlyHasPlaceholders() const; bool hasFixedSize() const; QList findSeparator(const QPoint &pos) const; int next(int idx) const; diff --git a/src/widgets/widgets/qmainwindowlayout.cpp b/src/widgets/widgets/qmainwindowlayout.cpp index aef8b9cbd5..14d7f3d835 100644 --- a/src/widgets/widgets/qmainwindowlayout.cpp +++ b/src/widgets/widgets/qmainwindowlayout.cpp @@ -1030,12 +1030,19 @@ bool QMainWindowLayoutState::restoreState(QDataStream &_stream, Qt::Horizontal, QTabBar::RoundedSouth, mainWindow); QRect geometry; stream >> geometry; - if (!floatingTab->layoutInfo()->restoreState(stream, dockWidgets, false)) + QDockAreaLayoutInfo *info = floatingTab->layoutInfo(); + if (!info->restoreState(stream, dockWidgets, false)) return false; geometry = QDockAreaLayout::constrainedRect(geometry, floatingTab); floatingTab->move(geometry.topLeft()); floatingTab->resize(geometry.size()); - floatingTab->show(); + + // Don't show an empty QDockWidgetGroupWindow if no dock widget is available yet. + // reparentWidgets() would be triggered by show(), so do it explicitly here. + if (info->onlyHasPlaceholders()) + info->reparentWidgets(floatingTab); + else + floatingTab->show(); } break; #endif // QT_NO_TABBAR -- cgit v1.2.3 From c5332859c801c44f11269d7a4e65cdd43031784a Mon Sep 17 00:00:00 2001 From: Dmitry Chmerev Date: Tue, 10 Jan 2017 20:11:04 +0300 Subject: Fix QRect calculation in inputItemRectangle Because of QRect's width and height are caluculated values, they got spoiled after x and y values setting. This bug affects, in particular, Android software keyboard appearance: it could overlap focused input field. Change-Id: I27ccca27111219818722951fe6f463388d76c702 Reviewed-by: Lars Knoll Reviewed-by: Olivier Goffart (Woboq GmbH) Reviewed-by: BogDan Vatra --- src/plugins/platforms/android/qandroidinputcontext.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/android/qandroidinputcontext.cpp b/src/plugins/platforms/android/qandroidinputcontext.cpp index 12e85046f8..4ab8a9d060 100644 --- a/src/plugins/platforms/android/qandroidinputcontext.cpp +++ b/src/plugins/platforms/android/qandroidinputcontext.cpp @@ -354,10 +354,10 @@ static QRect inputItemRectangle() ? QHighDpiScaling::factor(window) : QHighDpiScaling::factor(QtAndroid::androidPlatformIntegration()->screen()); if (pixelDensity != 1.0) { - rect.setX(rect.x() * pixelDensity); - rect.setY(rect.y() * pixelDensity); - rect.setWidth(rect.width() * pixelDensity); - rect.setHeight(rect.height() * pixelDensity); + rect.setRect(rect.x() * pixelDensity, + rect.y() * pixelDensity, + rect.width() * pixelDensity, + rect.height() * pixelDensity); } return rect; } -- cgit v1.2.3 From 2bb01172a76f14b1f57010b79207f6b9a9bf3f53 Mon Sep 17 00:00:00 2001 From: David Faure Date: Mon, 9 Jan 2017 00:10:42 +0100 Subject: QFont: fix fromString(toString()) when application font has styleName The style name needs to be cleared if not present in the string, otherwise the style name from qApp->font() (which propagates to any default-constructed QFont) remains. Change-Id: I9b6522a39a38526cced8a11ed02ae32582026480 Reviewed-by: Simon Hausmann Reviewed-by: Konstantin Shegunov --- src/gui/text/qfont.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/gui/text/qfont.cpp b/src/gui/text/qfont.cpp index 3b24039ea6..7f3ed3adaa 100644 --- a/src/gui/text/qfont.cpp +++ b/src/gui/text/qfont.cpp @@ -2077,6 +2077,8 @@ bool QFont::fromString(const QString &descrip) setFixedPitch(l[8].toInt()); if (count == 11) d->request.styleName = l[10].toString(); + else + d->request.styleName.clear(); } if (count >= 9 && !d->request.fixedPitch) // assume 'false' fixedPitch equals default -- cgit v1.2.3 From 5fbee2c22381690282a8c9249d21e76edc4eeb05 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Fri, 6 Jan 2017 15:51:46 +0100 Subject: Remove superfluous assignment Change-Id: Ic37b5db8b031a3b10f8f98645a97265ca03a75e4 Reviewed-by: Oswald Buddenhagen --- src/angle/src/compiler/translator.pro | 1 - 1 file changed, 1 deletion(-) (limited to 'src') diff --git a/src/angle/src/compiler/translator.pro b/src/angle/src/compiler/translator.pro index 2e5adaee96..663a8892a7 100644 --- a/src/angle/src/compiler/translator.pro +++ b/src/angle/src/compiler/translator.pro @@ -204,6 +204,5 @@ bison_impl.output = $${BUILDSUBDIR}${QMAKE_FILE_BASE}_tab.cpp bison_impl.input = BISON_SOURCES bison_impl.commands = $$MAKEFILE_NOOP_COMMAND bison_impl.depends = $${BUILDSUBDIR}${QMAKE_FILE_BASE}_tab.h -bison_impl.output = $${BUILDSUBDIR}${QMAKE_FILE_BASE}_tab.cpp bison_impl.variable_out = GENERATED_SOURCES QMAKE_EXTRA_COMPILERS += bison_impl -- cgit v1.2.3 From 63baad4a3d39feb53dc52a9ff2270f6d06bf34fa Mon Sep 17 00:00:00 2001 From: Oleg Yadrov Date: Tue, 10 Jan 2017 13:03:42 -0800 Subject: macOS: convey correct mouse coordinates on drag release Task-number: QTBUG-57129 Change-Id: I6eb60c35bfaf63199d0f637bf2d579fadab0a644 Reviewed-by: Gabriel de Dietrich --- src/plugins/platforms/cocoa/qnsview.mm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm index a63bc4d570..ba91d3e40e 100644 --- a/src/plugins/platforms/cocoa/qnsview.mm +++ b/src/plugins/platforms/cocoa/qnsview.mm @@ -2193,7 +2193,8 @@ static QPoint mapWindowCoordinates(QWindow *source, QWindow *target, QPoint poin } NSPoint windowPoint = [self.window convertRectFromScreen:NSMakeRect(screenPoint.x, screenPoint.y, 1, 1)].origin; - QPoint qtWindowPoint(windowPoint.x, windowPoint.y); + NSPoint nsViewPoint = [self convertPoint: windowPoint fromView: nil]; // NSView/QWindow coordinates + QPoint qtWindowPoint(nsViewPoint.x, nsViewPoint.y); QPoint qtScreenPoint = QPoint(screenPoint.x, qt_mac_flipYCoordinate(screenPoint.y)); -- cgit v1.2.3 From 483ee17419a4f4bbdfa4369e703ef3a75b81531b Mon Sep 17 00:00:00 2001 From: Joni Poikelin Date: Fri, 2 Dec 2016 14:43:57 +0200 Subject: xcb: Fix colormap memory leak Change-Id: I54880c10dc089c2cd17184dcbab17fde3af6452c Reviewed-by: Louai Al-Khanji Reviewed-by: Shawn Rutledge --- src/plugins/platforms/xcb/qxcbwindow.cpp | 11 +++++++---- src/plugins/platforms/xcb/qxcbwindow.h | 1 + 2 files changed, 8 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp index 3204fab197..ffbe9a2325 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbwindow.cpp @@ -315,6 +315,7 @@ static const char *wm_window_role_property_id = "_q_xcb_wm_window_role"; QXcbWindow::QXcbWindow(QWindow *window) : QPlatformWindow(window) , m_window(0) + , m_cmap(0) , m_syncCounter(0) , m_gravity(XCB_GRAVITY_STATIC) , m_mapped(false) @@ -443,7 +444,6 @@ void QXcbWindow::create() m_visualId = visual->visual_id; m_depth = platformScreen->depthOfVisual(m_visualId); m_imageFormat = imageFormatForVisual(m_depth, visual->red_mask, visual->blue_mask, &m_imageRgbSwap); - xcb_colormap_t colormap = 0; quint32 mask = XCB_CW_BACK_PIXMAP | XCB_CW_BORDER_PIXEL @@ -455,10 +455,10 @@ void QXcbWindow::create() static const bool haveOpenGL = QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::OpenGL); if ((window()->supportsOpenGL() && haveOpenGL) || m_format.hasAlpha()) { - colormap = xcb_generate_id(xcb_connection()); + m_cmap = xcb_generate_id(xcb_connection()); Q_XCB_CALL(xcb_create_colormap(xcb_connection(), XCB_COLORMAP_ALLOC_NONE, - colormap, + m_cmap, xcb_parent_id, m_visualId)); @@ -472,7 +472,7 @@ void QXcbWindow::create() type == Qt::Popup || type == Qt::ToolTip || (window()->flags() & Qt::BypassWindowManagerHint), type == Qt::Popup || type == Qt::Tool || type == Qt::SplashScreen || type == Qt::ToolTip || type == Qt::Drawer, defaultEventMask, - colormap + m_cmap }; m_window = xcb_generate_id(xcb_connection()); @@ -638,6 +638,9 @@ void QXcbWindow::destroy() Q_XCB_CALL(xcb_destroy_window(xcb_connection(), m_window)); m_window = 0; } + if (m_cmap) { + xcb_free_colormap(xcb_connection(), m_cmap); + } m_mapped = false; if (m_pendingSyncRequest) diff --git a/src/plugins/platforms/xcb/qxcbwindow.h b/src/plugins/platforms/xcb/qxcbwindow.h index cfa4964151..d100120d46 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.h +++ b/src/plugins/platforms/xcb/qxcbwindow.h @@ -234,6 +234,7 @@ protected: quint8 mode, quint8 detail, xcb_timestamp_t timestamp); xcb_window_t m_window; + xcb_colormap_t m_cmap; uint m_depth; QImage::Format m_imageFormat; -- cgit v1.2.3 From 3ffc471385dfe6d489be10caa45c721633639060 Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Wed, 4 Jan 2017 23:28:28 +0100 Subject: Accessibility: make sure childAt calls isValid MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Generally isValid should be called by the bridge, but in this case, we must verify the validity internally since we derefernce the interface internally. Task-number: QTBUG-52536 Change-Id: I14950118e58d65135bc38d77c23b8a7fed8bf39a Reviewed-by: Jan Arve Sæther --- src/gui/accessible/qaccessibleobject.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/gui/accessible/qaccessibleobject.cpp b/src/gui/accessible/qaccessibleobject.cpp index b67b8062ba..2ef8502ad5 100644 --- a/src/gui/accessible/qaccessibleobject.cpp +++ b/src/gui/accessible/qaccessibleobject.cpp @@ -125,7 +125,7 @@ QAccessibleInterface *QAccessibleObject::childAt(int x, int y) const for (int i = 0; i < childCount(); ++i) { QAccessibleInterface *childIface = child(i); Q_ASSERT(childIface); - if (childIface->rect().contains(x,y)) + if (childIface->isValid() && childIface->rect().contains(x,y)) return childIface; } return 0; -- cgit v1.2.3 From d9cb0644258a2feb8b945ca73fded0a063cf7181 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Wed, 11 Jan 2017 13:19:14 +0000 Subject: Doc: fix the datatype returned by Qt::TextAlignmentRole It's supposed to be a full alignment (like Top | Right), not just one flag. Change-Id: I656adda83742d7e4f31955322e937e979b32747c Reviewed-by: David Faure --- src/corelib/global/qnamespace.qdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/corelib/global/qnamespace.qdoc b/src/corelib/global/qnamespace.qdoc index 250195a512..11044cef88 100644 --- a/src/corelib/global/qnamespace.qdoc +++ b/src/corelib/global/qnamespace.qdoc @@ -2651,7 +2651,7 @@ \value FontRole The font used for items rendered with the default delegate. (QFont) \value TextAlignmentRole The alignment of the text for items rendered with the - default delegate. (Qt::AlignmentFlag) + default delegate. (Qt::Alignment) \value BackgroundRole The background brush used for items rendered with the default delegate. (QBrush) \value BackgroundColorRole This role is obsolete. Use BackgroundRole instead. -- cgit v1.2.3 From db226cbadc93b83d59e76515ec9cdbb6a53d2b04 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Wed, 11 Jan 2017 16:38:04 +0100 Subject: Put the features for platform plugins into their own section Change-Id: Icde1555e6093c9d8dd38e0abee40004db85189de Reviewed-by: Oswald Buddenhagen --- src/gui/configure.json | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src') diff --git a/src/gui/configure.json b/src/gui/configure.json index 2fce7eebb8..01566ad35b 100644 --- a/src/gui/configure.json +++ b/src/gui/configure.json @@ -423,6 +423,7 @@ }, "directfb": { "label": "DirectFB", + "section": "Platform plugins", "autoDetect": false, "condition": "libs.directfb", "output": [ "privateFeature" ] @@ -441,6 +442,7 @@ }, "direct2d": { "label": "Direct 2D", + "section": "Platform plugins", "condition": "config.win32 && !config.winrt && libs.direct2d", "output": [ "privateFeature" ] }, @@ -493,6 +495,7 @@ }, "integrityfb": { "label": "INTEGRITY framebuffer", + "section": "Platform plugins", "condition": "config.integrity", "output": [ "privateFeature" ] }, @@ -519,11 +522,13 @@ }, "linuxfb": { "label": "LinuxFB", + "section": "Platform plugins", "condition": "tests.linuxfb", "output": [ "privateFeature" ] }, "mirclient": { "label": "Mir client", + "section": "Platform plugins", "condition": "libs.mirclient", "output": [ "privateFeature" ] }, @@ -594,6 +599,7 @@ }, "eglfs": { "label": "EGLFS", + "section": "Platform plugins", "autoDetect": "!config.android && !config.win32", "condition": "features.egl", "output": [ "privateFeature" ] @@ -691,6 +697,7 @@ }, "xcb": { "label": "XCB", + "section": "Platform plugins", "autoDetect": "!config.darwin", "condition": "libs.xcb", "output": [ "privateFeature" ] -- cgit v1.2.3 From f3992dac6aa8c925b27fc0da19f8547341f534ba Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Tue, 3 Jan 2017 12:11:02 +0100 Subject: Make QSimpleDrag work with highDPI scaling MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Task-number: QTBUG-57863 Change-Id: I940179a694ce992245dabb77ef6e92e027427524 Reviewed-by: Friedemann Kleint Reviewed-by: Tor Arne Vestbø Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/gui/kernel/qsimpledrag.cpp | 37 +++++++++++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/gui/kernel/qsimpledrag.cpp b/src/gui/kernel/qsimpledrag.cpp index a6ce04dc34..fc62273325 100644 --- a/src/gui/kernel/qsimpledrag.cpp +++ b/src/gui/kernel/qsimpledrag.cpp @@ -53,6 +53,8 @@ #include "qdir.h" #include "qimagereader.h" #include "qimagewriter.h" +#include "qplatformscreen.h" +#include "qplatformwindow.h" #include #include @@ -316,6 +318,25 @@ void QBasicDrag::updateCursor(Qt::DropAction action) updateAction(action); } + +static inline QPoint fromNativeGlobalPixels(const QPoint &point) +{ +#ifndef QT_NO_HIGHDPISCALING + QPoint res = point; + if (QHighDpiScaling::isActive()) { + for (const QScreen *s : qAsConst(QGuiApplicationPrivate::screen_list)) { + if (s->handle()->geometry().contains(point)) { + res = QHighDpi::fromNativePixels(point, s); + break; + } + } + } + return res; +#else + return point; +#endif +} + /*! \class QSimpleDrag \brief QSimpleDrag implements QBasicDrag for Drag and Drop operations within the Qt Application itself. @@ -344,7 +365,7 @@ void QSimpleDrag::startDrag() QBasicDrag::startDrag(); m_current_window = topLevelAt(QCursor::pos()); if (m_current_window) { - QPlatformDragQtResponse response = QWindowSystemInterface::handleDrag(m_current_window, drag()->mimeData(), QCursor::pos(), drag()->supportedActions()); + QPlatformDragQtResponse response = QWindowSystemInterface::handleDrag(m_current_window, drag()->mimeData(), QHighDpi::toNativePixels(QCursor::pos(), m_current_window), drag()->supportedActions()); setCanDrop(response.isAccepted()); updateCursor(response.acceptedAction()); } else { @@ -363,15 +384,15 @@ void QSimpleDrag::cancel() } } -void QSimpleDrag::move(const QPoint &globalPos) +void QSimpleDrag::move(const QPoint &nativeGlobalPos) { - //### not high-DPI aware + QPoint globalPos = fromNativeGlobalPixels(nativeGlobalPos); moveShapedPixmapWindow(globalPos); QWindow *window = topLevelAt(globalPos); if (!window) return; - const QPoint pos = globalPos - window->geometry().topLeft(); + const QPoint pos = nativeGlobalPos - window->handle()->geometry().topLeft(); const QPlatformDragQtResponse qt_response = QWindowSystemInterface::handleDrag(window, drag()->mimeData(), pos, drag()->supportedActions()); @@ -379,16 +400,16 @@ void QSimpleDrag::move(const QPoint &globalPos) setCanDrop(qt_response.isAccepted()); } -void QSimpleDrag::drop(const QPoint &globalPos) +void QSimpleDrag::drop(const QPoint &nativeGlobalPos) { - //### not high-DPI aware + QPoint globalPos = fromNativeGlobalPixels(nativeGlobalPos); - QBasicDrag::drop(globalPos); + QBasicDrag::drop(nativeGlobalPos); QWindow *window = topLevelAt(globalPos); if (!window) return; - const QPoint pos = globalPos - window->geometry().topLeft(); + const QPoint pos = nativeGlobalPos - window->handle()->geometry().topLeft(); const QPlatformDropQtResponse response = QWindowSystemInterface::handleDrop(window, drag()->mimeData(),pos, drag()->supportedActions()); if (response.isAccepted()) { -- cgit v1.2.3 From 635d0ae00717b9ba53a8e007e50fac0d2721ca35 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Thu, 12 Jan 2017 12:12:42 +0100 Subject: Fix typo in QT_REQUIRE_CONFIG error message Change-Id: Iecfd398935f9c10aa456bd3452d34b31bc7eb4c9 Reviewed-by: Lars Knoll Reviewed-by: Edward Welbourne --- src/corelib/global/qglobal.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index 32176913ea..b4245ac8f6 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -81,7 +81,7 @@ 1: The feature is available */ #define QT_CONFIG(feature) (1/QT_FEATURE_##feature == 1) -#define QT_REQUIRE_CONFIG(feature) Q_STATIC_ASSERT_X(QT_FEATURE_##feature == 1, "Required feature " #feature " for file " __FILE__ " not vailable.") +#define QT_REQUIRE_CONFIG(feature) Q_STATIC_ASSERT_X(QT_FEATURE_##feature == 1, "Required feature " #feature " for file " __FILE__ " not available.") #if QT_VERSION >= QT_VERSION_CHECK(6,0,0) # define QT_NO_UNSHARABLE_CONTAINERS -- cgit v1.2.3 From cfd069181c01bbade16c173a96100819aa719613 Mon Sep 17 00:00:00 2001 From: Maurice Kalinowski Date: Thu, 12 Jan 2017 11:31:17 +0100 Subject: winrt: Fix Qt5PrintSupport(d).lib generation With QT_NO_PRINTER set via the feature system there is no symbol exported at all in a packaging build. This implies that no .lib is generated. When an application has QT+=printsupport the build will fail due to a missing file. For android and ios it only worked as there is no separation and linker works against the .so file Task-number: QTBUG-56321 Change-Id: I389adaca61669b302b6c431effed2ef6d1c499a3 Reviewed-by: Simon Hausmann Reviewed-by: Friedemann Kleint --- src/printsupport/kernel/qprinter.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') diff --git a/src/printsupport/kernel/qprinter.cpp b/src/printsupport/kernel/qprinter.cpp index 6d6d61b343..7824d28ac5 100644 --- a/src/printsupport/kernel/qprinter.cpp +++ b/src/printsupport/kernel/qprinter.cpp @@ -2326,4 +2326,8 @@ QPrinter::PrintRange QPrinter::printRange() const QT_END_NAMESPACE +#elif defined(Q_OS_WINRT) +QT_BEGIN_NAMESPACE +bool Q_PRINTSUPPORT_EXPORT qt_winrt_export_lib_creation_variable; +QT_END_NAMESPACE #endif // QT_NO_PRINTER -- cgit v1.2.3 From 5a1b4832a2704e7fb386d6b4c73dab85facdc40b Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 10 Jan 2017 15:30:42 -0800 Subject: Adapt to the C++ SIC introduced by P0021: noexcept overloading C++17 adopts P0021R1[1], which makes noexcept be part of the function pointer's type and thus be overloadable. It contains some provisions for allowing a noexcept function pointer to cast implicitly to a non- noexcept function pointer, but that fails in the presence of templates and additional overloads that could match the type in question. Fortunately, the paper proposed a test macro, so we can change our sources now and be compatible with both C++14 and C++17 rules. This first failed with Clang 4.0 trunk. This source incompatibility is not our fault, it's the language's doing. [1] http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/p0012r1.html Task-number: QTBUG-58054 Change-Id: I2bc52f3c7a574209b213fffd14988cf0b875be63 Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/corelib/kernel/qobjectdefs_impl.h | 55 +++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) (limited to 'src') diff --git a/src/corelib/kernel/qobjectdefs_impl.h b/src/corelib/kernel/qobjectdefs_impl.h index 79c9c8303e..1768e8ccc6 100644 --- a/src/corelib/kernel/qobjectdefs_impl.h +++ b/src/corelib/kernel/qobjectdefs_impl.h @@ -149,6 +149,20 @@ namespace QtPrivate { (o->*f)((*reinterpret_cast::Type *>(arg[II+1]))...), ApplyReturnValue(arg[0]); } }; +#if defined(__cpp_noexcept_function_type) && __cpp_noexcept_function_type >= 201510 + template + struct FunctorCall, List, R, SlotRet (Obj::*)(SlotArgs...) noexcept> { + static void call(SlotRet (Obj::*f)(SlotArgs...) noexcept, Obj *o, void **arg) { + (o->*f)((*reinterpret_cast::Type *>(arg[II+1]))...), ApplyReturnValue(arg[0]); + } + }; + template + struct FunctorCall, List, R, SlotRet (Obj::*)(SlotArgs...) const noexcept> { + static void call(SlotRet (Obj::*f)(SlotArgs...) const noexcept, Obj *o, void **arg) { + (o->*f)((*reinterpret_cast::Type *>(arg[II+1]))...), ApplyReturnValue(arg[0]); + } + }; +#endif template struct FunctionPointer { @@ -187,6 +201,47 @@ namespace QtPrivate { } }; +#if defined(__cpp_noexcept_function_type) && __cpp_noexcept_function_type >= 201510 + template struct FunctionPointer + { + typedef Obj Object; + typedef List Arguments; + typedef Ret ReturnType; + typedef Ret (Obj::*Function) (Args...) noexcept; + template struct ChangeClass { typedef Ret (Base:: *Type)(Args...) noexcept; }; + enum {ArgumentCount = sizeof...(Args), IsPointerToMemberFunction = true}; + template + static void call(Function f, Obj *o, void **arg) { + FunctorCall::Value, SignalArgs, R, Function>::call(f, o, arg); + } + }; + template struct FunctionPointer + { + typedef Obj Object; + typedef List Arguments; + typedef Ret ReturnType; + typedef Ret (Obj::*Function) (Args...) const noexcept; + template struct ChangeClass { typedef Ret (Base:: *Type)(Args...) const noexcept; }; + enum {ArgumentCount = sizeof...(Args), IsPointerToMemberFunction = true}; + template + static void call(Function f, Obj *o, void **arg) { + FunctorCall::Value, SignalArgs, R, Function>::call(f, o, arg); + } + }; + + template struct FunctionPointer + { + typedef List Arguments; + typedef Ret ReturnType; + typedef Ret (*Function) (Args...) noexcept; + enum {ArgumentCount = sizeof...(Args), IsPointerToMemberFunction = false}; + template + static void call(Function f, void *, void **arg) { + FunctorCall::Value, SignalArgs, R, Function>::call(f, arg); + } + }; +#endif + template struct Functor { template -- cgit v1.2.3 From 67f11a31997dc2cf804b627a8d55cc7d78fec37a Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 6 Oct 2016 18:58:23 +0200 Subject: QtNetwork: fix GCC 7 warnings GCC 7 warns about implicit fall-throughs now. Fix by adding the missing Q_FALLTHROUGH(), and, in one case, by moving the existing suppressant into the correct position. Change-Id: I7383f47e690b6334ef69c9df745c2205247ca7d0 Reviewed-by: Timur Pocheptsov --- src/network/access/qhttpnetworkconnectionchannel.cpp | 2 +- src/network/kernel/qhostaddress.cpp | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/network/access/qhttpnetworkconnectionchannel.cpp b/src/network/access/qhttpnetworkconnectionchannel.cpp index 205490b830..7fa19dc65b 100644 --- a/src/network/access/qhttpnetworkconnectionchannel.cpp +++ b/src/network/access/qhttpnetworkconnectionchannel.cpp @@ -1080,8 +1080,8 @@ void QHttpNetworkConnectionChannel::_q_encrypted() "detected unknown Next Protocol Negotiation protocol"); break; } - Q_FALLTHROUGH(); } + Q_FALLTHROUGH(); case QSslConfiguration::NextProtocolNegotiationNone: protocolHandler.reset(new QHttpProtocolHandler(this)); connection->setConnectionType(QHttpNetworkConnection::ConnectionTypeHTTP); diff --git a/src/network/kernel/qhostaddress.cpp b/src/network/kernel/qhostaddress.cpp index 8fac76f86a..086e8cede1 100644 --- a/src/network/kernel/qhostaddress.cpp +++ b/src/network/kernel/qhostaddress.cpp @@ -291,21 +291,27 @@ bool QNetmaskAddress::setAddress(const QHostAddress &address) d->clear(); return false; // invalid IP-style netmask - // the rest always falls through case 254: ++netmask; + Q_FALLTHROUGH(); case 252: ++netmask; + Q_FALLTHROUGH(); case 248: ++netmask; + Q_FALLTHROUGH(); case 240: ++netmask; + Q_FALLTHROUGH(); case 224: ++netmask; + Q_FALLTHROUGH(); case 192: ++netmask; + Q_FALLTHROUGH(); case 128: ++netmask; + Q_FALLTHROUGH(); case 0: break; } -- cgit v1.2.3 From 7d898ae38e42f44dabcc972ad81cb7f05ecd8ad3 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Tue, 10 Jan 2017 12:49:11 +0100 Subject: QGradientCache: fix a new/delete mismatch Commit f839f536 fixed a data race in the gradient cache by reference-counting the CacheInfo objects stored in the cache. To this end, QSpanData gained a ref-counted pointer to the CacheInfo whose members it references to keep the object alive for as long as the QSpanData object needs it. However, since CacheInfo is only later defined in qpaintengine_raster.cpp, the counted pointer's payload was chosen as CacheInfo's base class, QSharedData. As it turns out, e.g. in the QPainter test, the data race was real and so QSpanData ends up being the entity that destroys (at least some) CacheInfos, either in its destructor, or in the setup() method. Since QSharedData's destructor is not virtual, and QExplicitlySharedDataPointer knows nothing of the CacheInfo-ness of its payload, we end up calling the destructor of the base class, and not the CacheInfo one. Fix by using QSharedPointer instead, which stores the correct deleter internally. Ideally, QSpanData would contain a QSharedPointer, but QSharedPointer's implementation is deficient in that respect and does not compile when instantiated with void, and we can't use std::shared_ptr, yet, so introduce an arbitrary base class, Pinnable, to be used instead. Change-Id: I5573c599d5464278d3a8e4248d887ef9ffcd7b70 Reviewed-by: Allan Sandfeld Jensen Reviewed-by: Lars Knoll Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/gui/painting/qdrawhelper_p.h | 8 +++++++- src/gui/painting/qpaintengine_raster.cpp | 18 +++++++++--------- 2 files changed, 16 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/gui/painting/qdrawhelper_p.h b/src/gui/painting/qdrawhelper_p.h index e537c343bb..0e46962784 100644 --- a/src/gui/painting/qdrawhelper_p.h +++ b/src/gui/painting/qdrawhelper_p.h @@ -64,6 +64,8 @@ #include "private/qrasterdefs_p.h" #include +#include + QT_BEGIN_NAMESPACE #if defined(Q_CC_GNU) @@ -335,7 +337,11 @@ struct QSpanData QGradientData gradient; QTextureData texture; }; - QExplicitlySharedDataPointer cachedGradient; + class Pinnable { + protected: + ~Pinnable() {} + }; // QSharedPointer is not supported + QSharedPointer cachedGradient; void init(QRasterBuffer *rb, const QRasterPaintEngine *pe); diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp index df96a993e3..6d5eaf5aed 100644 --- a/src/gui/painting/qpaintengine_raster.cpp +++ b/src/gui/painting/qpaintengine_raster.cpp @@ -4150,7 +4150,7 @@ void QRasterBuffer::flushToARGBImage(QImage *target) const class QGradientCache { public: - struct CacheInfo : public QSharedData + struct CacheInfo : QSpanData::Pinnable { inline CacheInfo(QGradientStops s, int op, QGradient::InterpolationMode mode) : stops(qMove(s)), opacity(op), interpolationMode(mode) {} @@ -4161,9 +4161,9 @@ public: QGradient::InterpolationMode interpolationMode; }; - typedef QMultiHash > QGradientColorTableHash; + typedef QMultiHash> QGradientColorTableHash; - inline QExplicitlySharedDataPointer getBuffer(const QGradient &gradient, int opacity) { + inline QSharedPointer getBuffer(const QGradient &gradient, int opacity) { quint64 hash_val = 0; const QGradientStops stops = gradient.stops(); @@ -4177,7 +4177,7 @@ public: return addCacheElement(hash_val, gradient, opacity); else { do { - const QExplicitlySharedDataPointer &cache_info = it.value(); + const auto &cache_info = it.value(); if (cache_info->stops == stops && cache_info->opacity == opacity && cache_info->interpolationMode == gradient.interpolationMode()) return cache_info; ++it; @@ -4193,12 +4193,12 @@ protected: inline void generateGradientColorTable(const QGradient& g, QRgba64 *colorTable, int size, int opacity) const; - QExplicitlySharedDataPointer addCacheElement(quint64 hash_val, const QGradient &gradient, int opacity) { + QSharedPointer addCacheElement(quint64 hash_val, const QGradient &gradient, int opacity) { if (cache.size() == maxCacheSize()) { // may remove more than 1, but OK cache.erase(cache.begin() + (qrand() % maxCacheSize())); } - QExplicitlySharedDataPointer cache_entry(new CacheInfo (gradient.stops(), opacity, gradient.interpolationMode())); + auto cache_entry = QSharedPointer::create(gradient.stops(), opacity, gradient.interpolationMode()); generateGradientColorTable(gradient, cache_entry->buffer64, paletteSize(), opacity); for (int i = 0; i < GRADIENT_STOPTABLE_SIZE; ++i) cache_entry->buffer32[i] = cache_entry->buffer64[i].toArgb32(); @@ -4438,7 +4438,7 @@ void QSpanData::setup(const QBrush &brush, int alpha, QPainter::CompositionMode const QLinearGradient *g = static_cast(brush.gradient()); gradient.alphaColor = !brush.isOpaque() || alpha != 256; - QExplicitlySharedDataPointer cacheInfo = qt_gradient_cache()->getBuffer(*g, alpha); + auto cacheInfo = qt_gradient_cache()->getBuffer(*g, alpha); cachedGradient = cacheInfo; gradient.colorTable32 = cacheInfo->buffer32; gradient.colorTable64 = cacheInfo->buffer64; @@ -4460,7 +4460,7 @@ void QSpanData::setup(const QBrush &brush, int alpha, QPainter::CompositionMode const QRadialGradient *g = static_cast(brush.gradient()); gradient.alphaColor = !brush.isOpaque() || alpha != 256; - QExplicitlySharedDataPointer cacheInfo = qt_gradient_cache()->getBuffer(*g, alpha); + auto cacheInfo = qt_gradient_cache()->getBuffer(*g, alpha); cachedGradient = cacheInfo; gradient.colorTable32 = cacheInfo->buffer32; gradient.colorTable64 = cacheInfo->buffer64; @@ -4486,7 +4486,7 @@ void QSpanData::setup(const QBrush &brush, int alpha, QPainter::CompositionMode const QConicalGradient *g = static_cast(brush.gradient()); gradient.alphaColor = !brush.isOpaque() || alpha != 256; - QExplicitlySharedDataPointer cacheInfo = qt_gradient_cache()->getBuffer(*g, alpha); + auto cacheInfo = qt_gradient_cache()->getBuffer(*g, alpha); cachedGradient = cacheInfo; gradient.colorTable32 = cacheInfo->buffer32; gradient.colorTable64 = cacheInfo->buffer64; -- cgit v1.2.3 From 6292ecdf6da6c13942dd3f39c9cd164c29c7ab37 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Wed, 5 Oct 2016 23:29:41 +0200 Subject: QSystemTrayIcon: initialize all members The 'showArrow' member was not init'ed. Initialize it to true, which is the default value of the QBalloonTip::showBalloon() function's argument of the same purpose. Reported as new by Coverity, but dating back all the way to cc3875c2e463be5cf126a18637295a0c56358eda, so affects all current branches. Coverity-Id: 171482 Change-Id: Ica519ecda3a4ae413f606faab8c22f7072f412a8 Reviewed-by: Friedemann Kleint --- src/widgets/util/qsystemtrayicon.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/widgets/util/qsystemtrayicon.cpp b/src/widgets/util/qsystemtrayicon.cpp index 224ffeb6e2..630524aadb 100644 --- a/src/widgets/util/qsystemtrayicon.cpp +++ b/src/widgets/util/qsystemtrayicon.cpp @@ -436,7 +436,10 @@ bool QBalloonTip::isBalloonVisible() QBalloonTip::QBalloonTip(QSystemTrayIcon::MessageIcon icon, const QString& title, const QString& message, QSystemTrayIcon *ti) - : QWidget(0, Qt::ToolTip), trayIcon(ti), timerId(-1) + : QWidget(0, Qt::ToolTip), + trayIcon(ti), + timerId(-1), + showArrow(true) { setAttribute(Qt::WA_DeleteOnClose); QObject::connect(ti, SIGNAL(destroyed()), this, SLOT(close())); -- cgit v1.2.3 From 21306bccc4fef8c78d550946ec4d7a5426eb5b0d Mon Sep 17 00:00:00 2001 From: Tasuku Suzuki Date: Fri, 13 Jan 2017 17:29:17 +0900 Subject: Fix build without feature.tabletevent Change-Id: I13950e184453318671e4cac6dac844e76771f430 Reviewed-by: Lars Knoll --- src/platformsupport/input/input.pro | 4 +++- src/plugins/platforms/xcb/qxcbconnection_xi2.cpp | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/platformsupport/input/input.pro b/src/platformsupport/input/input.pro index 2c2ace6780..f8ff4344cf 100644 --- a/src/platformsupport/input/input.pro +++ b/src/platformsupport/input/input.pro @@ -11,7 +11,9 @@ qtConfig(evdev) { include($$PWD/evdevmouse/evdevmouse.pri) include($$PWD/evdevkeyboard/evdevkeyboard.pri) include($$PWD/evdevtouch/evdevtouch.pri) - include($$PWD/evdevtablet/evdevtablet.pri) + qtConfig(tabletevent) { + include($$PWD/evdevtablet/evdevtablet.pri) + } } qtConfig(tslib) { diff --git a/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp b/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp index f4f56f25f1..d91cbfe82d 100644 --- a/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp +++ b/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp @@ -1032,6 +1032,7 @@ bool QXcbConnection::isTouchScreen(int id) const && device->qtTouchDevice->type() == QTouchDevice::TouchScreen; } +#if QT_CONFIG(tabletevent) static QTabletEvent::TabletDevice toolIdToTabletDevice(quint32 toolId) { // keep in sync with wacom_intuos_inout() in Linux kernel driver wacom_wac.c switch (toolId) { @@ -1065,7 +1066,6 @@ static QTabletEvent::TabletDevice toolIdToTabletDevice(quint32 toolId) { return QTabletEvent::Stylus; // Safe default assumption if nonzero } -#ifndef QT_NO_TABLETEVENT bool QXcbConnection::xi2HandleTabletEvent(const void *event, TabletData *tabletData) { bool handled = true; -- cgit v1.2.3 From 4baf08653c69fe5a131dae4ea27ac4cd67743f6e Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Sat, 14 Jan 2017 09:02:03 +0100 Subject: QHostAddress: add missing docs qHash(QHostAddress) was added in Qt 5.0 (at least the version with uint seed = 0). op==(QHostAddress::SpecialAddress, QHostAddress) was there since QHostAddress was added before public history. Since QHostAddress does not have a \since, the I did not supply one for op==, either. Since the equality operator did not have unit-tests, added one. Change-Id: I954a0df02464338f08a12ca58d4cc0ceb013e67a Reviewed-by: Thiago Macieira --- src/network/kernel/qhostaddress.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src') diff --git a/src/network/kernel/qhostaddress.cpp b/src/network/kernel/qhostaddress.cpp index 086e8cede1..fc753204a9 100644 --- a/src/network/kernel/qhostaddress.cpp +++ b/src/network/kernel/qhostaddress.cpp @@ -1251,6 +1251,11 @@ QDebug operator<<(QDebug d, const QHostAddress &address) } #endif +/*! + \since 5.0 + \relates QHostAddress + Returns a hash of the host address \a key, using \a seed to seed the calculation. +*/ uint qHash(const QHostAddress &key, uint seed) { // both lines might throw @@ -1258,6 +1263,15 @@ uint qHash(const QHostAddress &key, uint seed) return qHashBits(key.d->a6.c, 16, seed); } +/*! + \relates QHostAddress + \fn operator==(QHostAddress::SpecialAddress lhs, const QHostAddress &rhs) + + Returns \c true if special address \a lhs is the same as host address \a rhs; + otherwise returns \c false. + + \sa isEqual() +*/ #ifndef QT_NO_DATASTREAM /*! \relates QHostAddress -- cgit v1.2.3 From 0deca277d2d187a455b38d717578814be6f93231 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 6 Oct 2016 18:58:23 +0200 Subject: QtCore: fix GCC 7 warnings GCC 7 warns about implicit fall-throughs now. Fix by adding Q_FALLTHROUGH. Change-Id: I482ab4c6adc469b11e1fd163516ff486b3b55ef7 Reviewed-by: Thiago Macieira --- src/corelib/statemachine/qstatemachine.cpp | 4 +++- src/corelib/tools/qdatetimeparser.cpp | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/corelib/statemachine/qstatemachine.cpp b/src/corelib/statemachine/qstatemachine.cpp index 433f595611..d7cdec9aac 100644 --- a/src/corelib/statemachine/qstatemachine.cpp +++ b/src/corelib/statemachine/qstatemachine.cpp @@ -2024,7 +2024,9 @@ void QStateMachinePrivate::processEvents(EventProcessingMode processingMode) if (QThread::currentThread() == q->thread()) { _q_process(); break; - } // fallthrough -- processing must be done in the machine thread + } + // processing must be done in the machine thread, so: + Q_FALLTHROUGH(); case QueuedProcessing: processingScheduled = true; QMetaObject::invokeMethod(q, "_q_process", Qt::QueuedConnection); diff --git a/src/corelib/tools/qdatetimeparser.cpp b/src/corelib/tools/qdatetimeparser.cpp index ae429950c8..65016933a0 100644 --- a/src/corelib/tools/qdatetimeparser.cpp +++ b/src/corelib/tools/qdatetimeparser.cpp @@ -1139,6 +1139,7 @@ end: } break; } } + Q_FALLTHROUGH(); case MonthSection: if (sn.count >= 3) { const int currentMonth = newCurrentValue.date().month(); -- cgit v1.2.3 From dbb4504f1214cddff47eb3b8dd935f3adb7f0940 Mon Sep 17 00:00:00 2001 From: Kavindra Palaraja Date: Sun, 15 Jan 2017 00:26:42 +0100 Subject: Add Q_CC_CLANG to the documentation page Task-number: QTBUG-42247 Change-Id: I3f707df4d25cac12fabac863b4f6bb50bfac5e26 Reviewed-by: Jake Petroules --- src/corelib/global/qglobal.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src') diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp index 6efdc4c22c..f6053ce622 100644 --- a/src/corelib/global/qglobal.cpp +++ b/src/corelib/global/qglobal.cpp @@ -1518,6 +1518,13 @@ bool qSharedBuild() Q_DECL_NOTHROW C/C++, Intel C++ for Windows. */ +/*! + \macro Q_CC_CLANG + \relates + + Defined if the application is compiled using Clang. +*/ + /*! \macro Q_CC_BOR \relates -- cgit v1.2.3 From 9ad4e651d26334f77297cc7cbfb413e3c22c391d Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Thu, 12 Jan 2017 16:06:28 +0100 Subject: Fully qualify enum arguments in input device manager signals Otherwise queued connections may complain about DeviceType not being registered. Change-Id: I1f93f8b34e78919e72ea99000c42da7024b6bdf3 Reviewed-by: Shawn Rutledge --- src/gui/kernel/qinputdevicemanager_p.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/gui/kernel/qinputdevicemanager_p.h b/src/gui/kernel/qinputdevicemanager_p.h index 11bbaae592..db9d0596b6 100644 --- a/src/gui/kernel/qinputdevicemanager_p.h +++ b/src/gui/kernel/qinputdevicemanager_p.h @@ -79,7 +79,7 @@ public: void setCursorPos(const QPoint &pos); signals: - void deviceListChanged(DeviceType type); + void deviceListChanged(QInputDeviceManager::DeviceType type); void cursorPositionChangeRequested(const QPoint &pos); }; -- cgit v1.2.3 From ca7f67e82b380e1b45a29cb2d2982bfe5e773d4a Mon Sep 17 00:00:00 2001 From: Tasuku Suzuki Date: Sat, 14 Jan 2017 13:20:30 +0900 Subject: Fix build without feature.animation Change-Id: Ia1b9ae3a35cbc73d0bbf27db234d0cd120d0b601 Reviewed-by: Lars Knoll --- src/corelib/statemachine/qstatemachine_p.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/corelib/statemachine/qstatemachine_p.h b/src/corelib/statemachine/qstatemachine_p.h index 9418813afd..c28b162305 100644 --- a/src/corelib/statemachine/qstatemachine_p.h +++ b/src/corelib/statemachine/qstatemachine_p.h @@ -79,7 +79,7 @@ class QFinalState; class QHistoryState; class QState; -#ifndef QT_NO_ANIMATION +#if QT_CONFIG(animation) class QAbstractAnimation; #endif @@ -123,7 +123,7 @@ public: // private slots void _q_start(); void _q_process(); -#ifndef QT_NO_ANIMATION +#if QT_CONFIG(animation) void _q_animationFinished(); #endif void _q_startDelayedEventTimer(int id, int delay); @@ -152,7 +152,7 @@ public: const QList &statesToEnter_sorted, const QSet &statesForDefaultEntry, QHash > &propertyAssignmentsForState -#ifndef QT_NO_ANIMATION +#if QT_CONFIG(animation) , const QList &selectedAnimations #endif ); @@ -264,7 +264,7 @@ public: QSet pendingErrorStates; QSet pendingErrorStatesForDefaultEntry; -#ifndef QT_NO_ANIMATION +#if QT_CONFIG(animation) bool animated; struct InitializeAnimationResult { @@ -326,7 +326,9 @@ public: static const Handler *handler; }; +#if QT_CONFIG(animation) Q_DECLARE_SHARED(QStateMachinePrivate::InitializeAnimationResult) +#endif Q_CORE_EXPORT const QStateMachinePrivate::Handler *qcoreStateMachineHandler(); -- cgit v1.2.3 From f225a459a0555eed6f2a2eac6509173d9f5207a1 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Thu, 5 Jan 2017 12:39:56 +0100 Subject: Fix unneeded recompiles of glslang_tab.cpp To work around qmake deficiencies src/angle/src/compiler/translator.pro contains a no-op extra compiler that "creates" glslang_tab.cpp and adds a dependency to glslang_tab.h. However, both files are created in one bison call, and for some reason the .cpp file is created before the .h file. Then the dependency glslang_tab.cpp -> glslang_tab.h results in recompiling glslang_tab.cpp on every incremental build. Ensure that glslang_tab.cpp is newer than glslang_tab.h. Change-Id: I6f59e213c84af85c59c02d90ac220bd347faddd1 Reviewed-by: Oswald Buddenhagen --- src/angle/src/compiler/translator.pro | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/angle/src/compiler/translator.pro b/src/angle/src/compiler/translator.pro index 663a8892a7..398b9230cc 100644 --- a/src/angle/src/compiler/translator.pro +++ b/src/angle/src/compiler/translator.pro @@ -189,7 +189,8 @@ QMAKE_EXTRA_COMPILERS += flex defineReplace(myDirName) { return($$dirname(1)) } bison.commands = $$addGnuPath(bison) --no-lines --skeleton=yacc.c --defines=${QMAKE_FILE_OUT} \ --output=${QMAKE_FUNC_FILE_OUT_myDirName}$$QMAKE_DIR_SEP${QMAKE_FILE_OUT_BASE}.cpp \ - ${QMAKE_FILE_NAME} + ${QMAKE_FILE_NAME}$$escape_expand(\\n\\t) \ + @echo // EOF>>${QMAKE_FUNC_FILE_OUT_myDirName}$$QMAKE_DIR_SEP${QMAKE_FILE_OUT_BASE}.cpp bison.output = $${BUILDSUBDIR}${QMAKE_FILE_BASE}_tab.h bison.input = BISON_SOURCES bison.dependency_type = TYPE_C -- cgit v1.2.3 From 17515f1b621952846237dfcdd401bb76f132a20d Mon Sep 17 00:00:00 2001 From: Tasuku Suzuki Date: Sat, 14 Jan 2017 12:17:39 +0900 Subject: Fix build without feature.imageformatplugin Change-Id: I28c146bfa1795794ad27d27c458970c5127cca67 Reviewed-by: Lars Knoll --- src/gui/configure.json | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src') diff --git a/src/gui/configure.json b/src/gui/configure.json index 01566ad35b..154ba63f00 100644 --- a/src/gui/configure.json +++ b/src/gui/configure.json @@ -636,6 +636,7 @@ }, "gif": { "label": "GIF", + "condition": "features.imageformatplugin", "output": [ "privateFeature", { "type": "define", "negative": true, "name": "QT_NO_IMAGEFORMAT_GIF" } @@ -643,11 +644,13 @@ }, "ico": { "label": "ICO", + "condition": "features.imageformatplugin", "output": [ "privateFeature", "feature" ] }, "jpeg": { "label": "JPEG", "disable": "input.libjpeg == 'no'", + "condition": "features.imageformatplugin", "output": [ "privateFeature", { "type": "define", "negative": true, "name": "QT_NO_IMAGEFORMAT_JPEG" } -- cgit v1.2.3 From e12b9b0db32a7480f3beb0ee7be919f059b80c21 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Wed, 11 Jan 2017 10:01:44 +0100 Subject: QKeySequenceEdit: If the next key is Key_unknown then it should be ignored When triggering a combination of keys which is causing a dead key then it will send Key_unknown which is not a valid key to be used in a shortcut so it should just skip past it as if it were a modifier key. Task-number: QTBUG-57932 Change-Id: I16e004b84f3aa854f8f8f2bbdf86beb6d764de48 Reviewed-by: Friedemann Kleint Reviewed-by: Oliver Wolff --- src/widgets/widgets/qkeysequenceedit.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/widgets/widgets/qkeysequenceedit.cpp b/src/widgets/widgets/qkeysequenceedit.cpp index 2fbc42330d..3252ce5941 100644 --- a/src/widgets/widgets/qkeysequenceedit.cpp +++ b/src/widgets/widgets/qkeysequenceedit.cpp @@ -257,7 +257,8 @@ void QKeySequenceEdit::keyPressEvent(QKeyEvent *e) if (nextKey == Qt::Key_Control || nextKey == Qt::Key_Shift || nextKey == Qt::Key_Meta - || nextKey == Qt::Key_Alt) { + || nextKey == Qt::Key_Alt + || nextKey == Qt::Key_unknown) { return; } -- cgit v1.2.3 From 0243863382ab580a0d25c4df9e9bfa6e2f31c7cb Mon Sep 17 00:00:00 2001 From: Aleksei Ilin Date: Mon, 14 Nov 2016 20:27:38 +0300 Subject: Fix access incorrect index in QListView with batch layout The size of flowPositions is larger by one than the number of rows in the model so the last correct row number is flowPositions.count()-2, not flowPositions.count()-1. Change-Id: Idf8bbd155151d553947d5d299dd01ffaff0c95fa Task-number: QTBUG-47694 Reviewed-by: Alexander Volkov Reviewed-by: David Faure --- src/widgets/itemviews/qlistview.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/widgets/itemviews/qlistview.cpp b/src/widgets/itemviews/qlistview.cpp index 0788e0287a..65421bfb67 100644 --- a/src/widgets/itemviews/qlistview.cpp +++ b/src/widgets/itemviews/qlistview.cpp @@ -2348,7 +2348,7 @@ QListViewItem QListModeViewBase::indexToListViewItem(const QModelIndex &index) c { if (flowPositions.isEmpty() || segmentPositions.isEmpty() - || index.row() >= flowPositions.count()) + || index.row() >= flowPositions.count() - 1) return QListViewItem(); const int segment = qBinarySearch(segmentStartRows, index.row(), -- cgit v1.2.3 From 83583d7999181ba613a0e27a8006e4c092edffa7 Mon Sep 17 00:00:00 2001 From: Tasuku Suzuki Date: Fri, 13 Jan 2017 19:17:04 +0900 Subject: Fix build without feature.cssparser Change-Id: Ib751a3d1ad37aae68d6a05aab493833fbcc0b53d Reviewed-by: Lars Knoll --- src/gui/text/qtexthtmlparser_p.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/gui/text/qtexthtmlparser_p.h b/src/gui/text/qtexthtmlparser_p.h index e93d46a59f..77bfa685c0 100644 --- a/src/gui/text/qtexthtmlparser_p.h +++ b/src/gui/text/qtexthtmlparser_p.h @@ -243,7 +243,7 @@ struct QTextHtmlParserNode { void parseStyleAttribute(const QString &value, const QTextDocument *resourceProvider); -#ifndef QT_NO_CSSPARSER +#if QT_CONFIG(cssparser) void applyCssDeclarations(const QVector &declarations, const QTextDocument *resourceProvider); void setListStyle(const QVector &cssValues); @@ -317,7 +317,7 @@ protected: bool nodeIsChildOf(int i, QTextHTMLElements id) const; -#ifndef QT_NO_CSSPARSER +#if QT_CONFIG(cssparser) QVector declarationsForNode(int node) const; void resolveStyleSheetImports(const QCss::StyleSheet &sheet); void importStyleSheet(const QString &href); @@ -337,7 +337,9 @@ protected: const QTextDocument *resourceProvider; }; +#if QT_CONFIG(cssparser) Q_DECLARE_TYPEINFO(QTextHtmlParser::ExternalStyleSheet, Q_MOVABLE_TYPE); +#endif QT_END_NAMESPACE -- cgit v1.2.3 From 23ba2f073cf163b379312d5086a880c7ec040209 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 12 Jan 2017 16:04:33 +0100 Subject: Windows QPA: Fix QScreen::grabWindow(0) for non-primary screens Previously, the code grabbed the client rectangle of GetDesktopWindow(), which is always the primary screen. Fix by using the geometry of the QPlatformScreen. In addition, subtract x, y from the effective size when sizes < 0 were passed in as does XCB. Task-number: QTBUG-58110 Change-Id: I6ed439d2e1da8affd0a1475717d5570017fb1f2b Reviewed-by: Oliver Wolff Reviewed-by: Joerg Bornemann --- src/plugins/platforms/windows/qwindowsscreen.cpp | 28 +++++++++++++++++++----- 1 file changed, 22 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/windows/qwindowsscreen.cpp b/src/plugins/platforms/windows/qwindowsscreen.cpp index 23d43a95a5..7a885b462e 100644 --- a/src/plugins/platforms/windows/qwindowsscreen.cpp +++ b/src/plugins/platforms/windows/qwindowsscreen.cpp @@ -188,14 +188,30 @@ QWindowsScreen::QWindowsScreen(const QWindowsScreenData &data) : Q_GUI_EXPORT QPixmap qt_pixmapFromWinHBITMAP(HBITMAP bitmap, int hbitmapFormat = 0); -QPixmap QWindowsScreen::grabWindow(WId window, int x, int y, int width, int height) const +QPixmap QWindowsScreen::grabWindow(WId window, int xIn, int yIn, int width, int height) const { - RECT r; - HWND hwnd = window ? reinterpret_cast(window) : GetDesktopWindow(); - GetClientRect(hwnd, &r); + QSize windowSize; + int x = xIn; + int y = yIn; + HWND hwnd = reinterpret_cast(window); + if (hwnd) { + RECT r; + GetClientRect(hwnd, &r); + windowSize = QSize(r.right - r.left, r.bottom - r.top); + } else { + // Grab current screen. The client rectangle of GetDesktopWindow() is the + // primary screen, but it is possible to grab other screens from it. + hwnd = GetDesktopWindow(); + const QRect screenGeometry = geometry(); + windowSize = screenGeometry.size(); + x += screenGeometry.x(); + y += screenGeometry.y(); + } - if (width < 0) width = r.right - r.left; - if (height < 0) height = r.bottom - r.top; + if (width < 0) + width = windowSize.width() - xIn; + if (height < 0) + height = windowSize.height() - yIn; // Create and setup bitmap HDC display_dc = GetDC(0); -- cgit v1.2.3 From 19a1a0871d4a9081646925c422fe32e900846c2e Mon Sep 17 00:00:00 2001 From: Mikkel Krautz Date: Mon, 16 Jan 2017 21:43:12 +0100 Subject: QSslDiffieHellmanParameters: simplify defaultParameters() construction This commit simplifies defaultParameters() to simply construct an empty QSslDiffieHellmanParameters and assigning the DER-form of the DH parameters to QSslDiffieHellmanParametersPrivate's derData field. This creates a valid QSslDiffieHellmanParameters instance, but skips any potentially expensive verification steps. The previous implementation of defaultParameters() would use the public fromEncoded() method to construct an instance of the default parameters. This triggers a verification of the passed-in data, which can be expensive. To ensure our defaultParameters() QSslDiffieHellmanParameters instance does pass verification, this commit adds an autotest to verify that. Fixes QTBUG-57815. Change-Id: I6b1d9dbbfde526b232c319195ddbad42326be27c Task-number: QTBUG-57815 Reviewed-by: Timur Pocheptsov --- src/network/ssl/qssldiffiehellmanparameters.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/network/ssl/qssldiffiehellmanparameters.cpp b/src/network/ssl/qssldiffiehellmanparameters.cpp index d0fcb3189a..de7eab9a9e 100644 --- a/src/network/ssl/qssldiffiehellmanparameters.cpp +++ b/src/network/ssl/qssldiffiehellmanparameters.cpp @@ -68,6 +68,12 @@ QT_BEGIN_NAMESPACE +// The 1024-bit MODP group from RFC 2459 (Second Oakley Group) +Q_AUTOTEST_EXPORT const char *qssl_dhparams_default_base64 = + "MIGHAoGBAP//////////yQ/aoiFowjTExmKLgNwc0SkCTgiKZ8x0Agu+pjsTmyJR" + "Sgh5jjQE3e+VGbPNOkMbMCsKbfJfFDdP4TVtbVHCReSFtXZiXn7G9ExC6aY37WsL" + "/1y29Aa37e44a/taiZ+lrp8kEXxLH+ZJKGZR7OZTgf//////////AgEC"; + /*! Returns the default QSslDiffieHellmanParameters used by QSslSocket. @@ -76,15 +82,9 @@ QT_BEGIN_NAMESPACE */ QSslDiffieHellmanParameters QSslDiffieHellmanParameters::defaultParameters() { - // The 1024-bit MODP group from RFC 2459 (Second Oakley Group) - return fromEncoded( - QByteArray::fromBase64(QByteArrayLiteral( - "MIGHAoGBAP//////////yQ/aoiFowjTExmKLgNwc0SkCTgiKZ8x0Agu+pjsTmyJR" - "Sgh5jjQE3e+VGbPNOkMbMCsKbfJfFDdP4TVtbVHCReSFtXZiXn7G9ExC6aY37WsL" - "/1y29Aa37e44a/taiZ+lrp8kEXxLH+ZJKGZR7OZTgf//////////AgEC" - )), - QSsl::Der - ); + QSslDiffieHellmanParameters def; + def.d->derData = QByteArray::fromBase64(QByteArray(qssl_dhparams_default_base64)); + return def; } /*! -- cgit v1.2.3 From 3e31b71b9ca859cad8823a9d8d19063dd14be809 Mon Sep 17 00:00:00 2001 From: Dmitry Shachnev Date: Wed, 2 Nov 2016 20:40:12 +0300 Subject: dbusmenu: Map showPopup method to ItemActivationRequested signal MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This way the Qt accelerator shortcuts (i.e. Alt+F for the File menu) will cause the matching menu to be opened on the server side. Change-Id: I02a5b3c20c6eae130d0f133b33c9e247cff38d44 Reviewed-by: Tor Arne Vestbø --- .../themes/genericunix/dbusmenu/qdbusmenubar.cpp | 2 ++ .../themes/genericunix/dbusmenu/qdbusplatformmenu.cpp | 14 ++++++++++++++ .../themes/genericunix/dbusmenu/qdbusplatformmenu_p.h | 9 ++------- 3 files changed, 18 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenubar.cpp b/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenubar.cpp index 76d658f51a..fb0705c8c7 100644 --- a/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenubar.cpp +++ b/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenubar.cpp @@ -59,6 +59,8 @@ QDBusMenuBar::QDBusMenuBar() m_menuAdaptor, &QDBusMenuAdaptor::ItemsPropertiesUpdated); connect(m_menu, &QDBusPlatformMenu::updated, m_menuAdaptor, &QDBusMenuAdaptor::LayoutUpdated); + connect(m_menu, &QDBusPlatformMenu::popupRequested, + m_menuAdaptor, &QDBusMenuAdaptor::ItemActivationRequested); } QDBusMenuBar::~QDBusMenuBar() diff --git a/src/platformsupport/themes/genericunix/dbusmenu/qdbusplatformmenu.cpp b/src/platformsupport/themes/genericunix/dbusmenu/qdbusplatformmenu.cpp index 15440a03cd..c1ebbbf91b 100644 --- a/src/platformsupport/themes/genericunix/dbusmenu/qdbusplatformmenu.cpp +++ b/src/platformsupport/themes/genericunix/dbusmenu/qdbusplatformmenu.cpp @@ -39,6 +39,7 @@ #include "qdbusplatformmenu_p.h" +#include #include #include @@ -210,6 +211,8 @@ void QDBusPlatformMenu::removeMenuItem(QPlatformMenuItem *menuItem) this, &QDBusPlatformMenu::propertiesUpdated); disconnect(menu, &QDBusPlatformMenu::updated, this, &QDBusPlatformMenu::updated); + disconnect(menu, &QDBusPlatformMenu::popupRequested, + this, &QDBusPlatformMenu::popupRequested); } emitUpdated(); } @@ -222,6 +225,8 @@ void QDBusPlatformMenu::syncSubMenu(const QDBusPlatformMenu *menu) this, &QDBusPlatformMenu::propertiesUpdated, Qt::UniqueConnection); connect(menu, &QDBusPlatformMenu::updated, this, &QDBusPlatformMenu::updated, Qt::UniqueConnection); + connect(menu, &QDBusPlatformMenu::popupRequested, + this, &QDBusPlatformMenu::popupRequested, Qt::UniqueConnection); } void QDBusPlatformMenu::syncMenuItem(QPlatformMenuItem *menuItem) @@ -278,6 +283,15 @@ void QDBusPlatformMenu::setContainingMenuItem(QDBusPlatformMenuItem *item) m_containingMenuItem = item; } +void QDBusPlatformMenu::showPopup(const QWindow *parentWindow, const QRect &targetRect, const QPlatformMenuItem *item) +{ + Q_UNUSED(parentWindow); + Q_UNUSED(targetRect); + Q_UNUSED(item); + setVisible(true); + emit popupRequested(m_containingMenuItem->dbusID(), QDateTime::currentMSecsSinceEpoch()); +} + QPlatformMenuItem *QDBusPlatformMenu::menuItemAt(int position) const { return m_items.value(position); diff --git a/src/platformsupport/themes/genericunix/dbusmenu/qdbusplatformmenu_p.h b/src/platformsupport/themes/genericunix/dbusmenu/qdbusplatformmenu_p.h index 38c27e8051..2e6e04d28d 100644 --- a/src/platformsupport/themes/genericunix/dbusmenu/qdbusplatformmenu_p.h +++ b/src/platformsupport/themes/genericunix/dbusmenu/qdbusplatformmenu_p.h @@ -161,13 +161,7 @@ public: void setMenuType(MenuType type) Q_DECL_OVERRIDE { Q_UNUSED(type); } void setContainingMenuItem(QDBusPlatformMenuItem *item); - void showPopup(const QWindow *parentWindow, const QRect &targetRect, const QPlatformMenuItem *item) Q_DECL_OVERRIDE - { - Q_UNUSED(parentWindow); - Q_UNUSED(targetRect); - Q_UNUSED(item); - setVisible(true); - } + void showPopup(const QWindow *parentWindow, const QRect &targetRect, const QPlatformMenuItem *item) Q_DECL_OVERRIDE; void dismiss() Q_DECL_OVERRIDE { } // Closes this and all its related menu popups @@ -187,6 +181,7 @@ public: signals: void updated(uint revision, int dbusId); void propertiesUpdated(QDBusMenuItemList updatedProps, QDBusMenuItemKeysList removedProps); + void popupRequested(int id, uint timestamp); private: quintptr m_tag; -- cgit v1.2.3 From 287f548d4c7cc594ffecc9c050dc5ec9fdaa6d37 Mon Sep 17 00:00:00 2001 From: Dmitry Shachnev Date: Wed, 2 Nov 2016 10:51:39 +0300 Subject: Make shortcuts work for platform menu bars MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When a platform menu bar is used, the QMenuBar is hidden, so shortcuts for QActions attached only to it do not work. Extend the macOS-specific code to treat such menubars as visible to other platforms, to make the shortcuts work. The exception is made for internal QMenuBar shortcuts, which are forwarded to the platform menu. A follow-up change will add support for this to QDBusPlatformMenu. The updateGeometries() method is called for platform menu bars too to make sure the internal shortcuts are registered even if the global menu is in use. Add two cases to the tst_QMenuBar::activatedCount() test to test both native and non-native menu bars when possible (it now passes with native menu bars too). Change-Id: I2d7128512719ac199cd3f8f7ba28333d04d84ed4 Reviewed-by: Tor Arne Vestbø --- src/widgets/kernel/qshortcut.cpp | 8 +++++--- src/widgets/widgets/qmenubar.cpp | 13 +++++++++++-- 2 files changed, 16 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/widgets/kernel/qshortcut.cpp b/src/widgets/kernel/qshortcut.cpp index 6eec5ff7e8..be5788274e 100644 --- a/src/widgets/kernel/qshortcut.cpp +++ b/src/widgets/kernel/qshortcut.cpp @@ -141,9 +141,11 @@ bool qWidgetShortcutContextMatcher(QObject *object, Qt::ShortcutContext context) static bool correctWidgetContext(Qt::ShortcutContext context, QWidget *w, QWidget *active_window) { bool visible = w->isVisible(); -#if defined(Q_OS_DARWIN) && !defined(QT_NO_MENUBAR) - if (!qApp->testAttribute(Qt::AA_DontUseNativeMenuBar) && qobject_cast(w)) - visible = true; +#ifndef QT_NO_MENUBAR + if (QMenuBar *menuBar = qobject_cast(w)) { + if (menuBar->isNativeMenuBar()) + visible = true; + } #endif if (!visible || !w->isEnabled()) diff --git a/src/widgets/widgets/qmenubar.cpp b/src/widgets/widgets/qmenubar.cpp index 63fe09f77e..2588f41468 100644 --- a/src/widgets/widgets/qmenubar.cpp +++ b/src/widgets/widgets/qmenubar.cpp @@ -1271,10 +1271,12 @@ void QMenuBar::actionEvent(QActionEvent *e) } else if(e->type() == QEvent::ActionRemoved) { e->action()->disconnect(this); } - if (isVisible()) { + // updateGeometries() is also needed for native menu bars because + // it updates shortcutIndexMap + if (isVisible() || isNativeMenuBar()) d->updateGeometries(); + if (isVisible()) update(); - } } /*! @@ -1686,6 +1688,13 @@ void QMenuBarPrivate::_q_internalShortcutActivated(int id) { Q_Q(QMenuBar); QAction *act = actions.at(id); + if (act && act->menu()) { + if (QPlatformMenu *platformMenu = act->menu()->platformMenu()) { + platformMenu->showPopup(q->windowHandle(), actionRects.at(id), Q_NULLPTR); + return; + } + } + setCurrentAction(act, true, true); if (act && !act->menu()) { activateAction(act, QAction::Trigger); -- cgit v1.2.3 From a300330203790b41a12a27dc4341b57ae81fd29e Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Wed, 7 Dec 2016 13:13:47 +0100 Subject: Make sure we call glClearDepth(double) on desktop GL Task-number: QTBUG-56798 Change-Id: I028510c0f75df5c7d2dce539c32ea503009467db Reviewed-by: Laszlo Agocs Reviewed-by: Bruno de Oliveira Abinader --- src/gui/opengl/qopenglfunctions.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/gui/opengl/qopenglfunctions.cpp b/src/gui/opengl/qopenglfunctions.cpp index e4e7c6d1b5..ad8b19a2bc 100644 --- a/src/gui/opengl/qopenglfunctions.cpp +++ b/src/gui/opengl/qopenglfunctions.cpp @@ -2196,9 +2196,10 @@ QOpenGLFunctionsPrivate::QOpenGLFunctionsPrivate(QOpenGLContext *c) #ifndef QT_OPENGL_ES_2 // setup fallbacks in case some methods couldn't get resolved - if (!f.ClearDepthf) + bool es = QOpenGLContext::currentContext()->isOpenGLES(); + if (!f.ClearDepthf || !es) f.ClearDepthf = qopenglfSpecialClearDepthf; - if (!f.DepthRangef) + if (!f.DepthRangef || !es) f.DepthRangef = qopenglfSpecialDepthRangef; if (!f.GetShaderPrecisionFormat) f.GetShaderPrecisionFormat = qopenglfSpecialGetShaderPrecisionFormat; -- cgit v1.2.3 From 814a2c8ddf48347612a61a7f7155796f766d67d3 Mon Sep 17 00:00:00 2001 From: Sergio Martins Date: Thu, 17 Nov 2016 10:49:29 +0000 Subject: docs: Mention that QWidget::ensurePolished() also affects children Change-Id: I083d1c503039010024c89db59003fb6fca050c26 Reviewed-by: David Faure Reviewed-by: Martin Smith --- src/widgets/kernel/qwidget.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index ace50f13ee..1c79e4ea92 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -9993,8 +9993,8 @@ bool QWidget::nativeEvent(const QByteArray &eventType, void *message, long *resu } /*! - Ensures that the widget has been polished by QStyle (i.e., has a - proper font and palette). + Ensures that the widget and its children have been polished by + QStyle (i.e., have a proper font and palette). QWidget calls this function after it has been fully constructed but before it is shown the very first time. You can call this -- cgit v1.2.3 From 3edeb5c909a4ec62440e2075b9d49ec256a1ba68 Mon Sep 17 00:00:00 2001 From: Oleg Yadrov Date: Wed, 18 Jan 2017 11:09:37 -0800 Subject: Cocoa: fix regression preventing windows from showing up The regression was introduced by 593ab638609 which fixed another bug related to window modality. To determine whether the window needs to be (made key and ordered front) or just (ordered front), instead of calling currentModalSession() which might change internal state of event dispatcher we just check if cocoaModalSessionStack is empty or not. Task-number: QTBUG-57991 Task-number: QTBUG-56166 Change-Id: I6c4f92860d8c93decd44e572af1690ed7be6f1f0 Reviewed-by: Timur Pocheptsov --- src/plugins/platforms/cocoa/qcocoawindow.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index 602da0a175..40666772c5 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -695,7 +695,7 @@ void QCocoaWindow::setVisible(bool visible) if (cocoaEventDispatcher) cocoaEventDispatcherPrivate = static_cast(QObjectPrivate::get(cocoaEventDispatcher)); - if (!(cocoaEventDispatcherPrivate && cocoaEventDispatcherPrivate->currentModalSession())) + if (cocoaEventDispatcherPrivate && cocoaEventDispatcherPrivate->cocoaModalSessionStack.isEmpty()) [m_nsWindow makeKeyAndOrderFront:nil]; else [m_nsWindow orderFront:nil]; -- cgit v1.2.3 From b934572b30ca64ea0f85dffaeb9ff3c30add1e7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Fri, 13 Jan 2017 17:40:56 +0100 Subject: QDBusTrayIcon: always save the temp icon in Unity We enforce the check of saving the icon when the indicator process name isn't available (as we might be running in a confined world), but we're running in Unity. Change-Id: I80d3be1a8c6eba8c391364260746e78cf89a5b98 Reviewed-by: Dmitry Shachnev Reviewed-by: Shawn Rutledge --- src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src') diff --git a/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp b/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp index 5c4157c206..b55ace357a 100644 --- a/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp +++ b/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp @@ -171,6 +171,12 @@ QTemporaryFile *QDBusTrayIcon::tempIcon(const QIcon &icon) uint pid = session.interface()->servicePid(KDEWatcherService).value(); QString processName = QLockFilePrivate::processNameByPid(pid); necessary = processName.endsWith(QLatin1String("indicator-application-service")); + if (!necessary && QGuiApplication::desktopSettingsAware()) { + // Accessing to process name might be not allowed if the application + // is confined, thus we can just rely on the current desktop in use + const QPlatformServices *services = QGuiApplicationPrivate::platformIntegration()->services(); + necessary = services->desktopEnvironment().split(':').contains("UNITY"); + } necessity_checked = true; } if (!necessary) -- cgit v1.2.3 From 7780ee9e5f20f80ab9e053058d0b6d92586cf876 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 16 Jan 2017 13:26:09 +0100 Subject: Windows QPA: Call InvalidateRect() in WM_PAINT/GL Software rendering Bring back the call to InvalidateRect() removed by change 6086c81e4d999d88ce4d412 since it seems that GL Software rendering requires it (also for single buffer mode). Task-number: QTBUG-58178 Change-Id: I197a1b3c3906c4afa43943db30dbc07dfb656cc7 Reviewed-by: Joerg Bornemann --- src/plugins/platforms/windows/qwindowswindow.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp index a9b061ad73..6894062d61 100644 --- a/src/plugins/platforms/windows/qwindowswindow.cpp +++ b/src/plugins/platforms/windows/qwindowswindow.cpp @@ -43,7 +43,7 @@ #include "qwindowsscreen.h" #include "qwindowsintegration.h" #include "qwindowsnativeinterface.h" -#include "qwindowsopenglcontext.h" +#include "qwindowsglcontext.h" #ifdef QT_NO_CURSOR # include "qwindowscursor.h" #endif @@ -1582,6 +1582,16 @@ bool QWindowsWindow::handleWmPaint(HWND hwnd, UINT message, return false; PAINTSTRUCT ps; +#if QT_CONFIG(dynamicgl) + // QTBUG-58178: GL software rendering needs InvalidateRect() to suppress + // artifacts while resizing. + if (testFlag(OpenGLSurface) + && QOpenGLStaticContext::opengl32.moduleIsNotOpengl32() + && QOpenGLContext::openGLModuleType() == QOpenGLContext::LibGL) { + InvalidateRect(hwnd, 0, false); + } +#endif // dynamicgl + BeginPaint(hwnd, &ps); // Observed painting problems with Aero style disabled (QTBUG-7865). -- cgit v1.2.3 From 4dcfd90e4fd7d4c49138038dbbcbda8794a9fbff Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Tue, 10 Jan 2017 14:18:02 +0100 Subject: fix parallel builds with -qt-freetype -system-libpng freetype has no dependency on gui, so it needs to pull in gui's configuration manually, as that's where the system libpng is found. Task-number: QTBUG-58038 Change-Id: I881495f7d2a8f7c1a45d7d4c9e7698ff1d30f2a9 Reviewed-by: Joerg Bornemann Reviewed-by: Joni Poikelin --- src/3rdparty/freetype/freetype.pro | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/3rdparty/freetype/freetype.pro b/src/3rdparty/freetype/freetype.pro index 5b1eb92e32..390a6da749 100644 --- a/src/3rdparty/freetype/freetype.pro +++ b/src/3rdparty/freetype/freetype.pro @@ -69,6 +69,7 @@ DEFINES += FT_CONFIG_OPTION_SYSTEM_ZLIB include(../zlib_dependency.pri) DEFINES += FT_CONFIG_OPTION_USE_PNG +include($$OUT_PWD/../../gui/qtgui-config.pri) QMAKE_USE_PRIVATE += libpng DEFINES += TT_CONFIG_OPTION_SUBPIXEL_HINTING -- cgit v1.2.3 From 6b070340a818089cb5cc2d01c155d1696c8e392b Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Fri, 13 Jan 2017 18:29:25 +0100 Subject: fix detection of statically built system-libpng it has a dependency on zlib, which needs to be explicitly linked when linking statically. Task-number: QTBUG-56163 Change-Id: I4564844e8a35686db48c429b259e78558d312819 Reviewed-by: Tim Blechmann Reviewed-by: Oswald Buddenhagen --- src/gui/configure.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/gui/configure.json b/src/gui/configure.json index 154ba63f00..6f87eb5aed 100644 --- a/src/gui/configure.json +++ b/src/gui/configure.json @@ -159,8 +159,8 @@ "test": "unix/libpng", "sources": [ { "type": "pkgConfig", "args": "libpng" }, - { "libs": "-llibpng", "condition": "config.msvc" }, - { "libs": "-lpng", "condition": "!config.msvc" } + { "libs": "-llibpng -lzdll", "condition": "config.msvc" }, + { "libs": "-lpng -lz", "condition": "!config.msvc" } ] }, "mirclient": { -- cgit v1.2.3 From d22579f51ef342a54937cb99dab62331afa0ff91 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Thu, 19 Jan 2017 15:08:27 -0800 Subject: QWidget::winId(): Remove documentation bit about macOS MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Carbon port has been removed since 5.0, so there's only one framework against which we can build Qt. Change-Id: I38ce410f50cd4eda7abcc50ac4c4c7a23b3e1f45 Reviewed-by: Tor Arne Vestbø --- src/widgets/kernel/qwidget.cpp | 4 ---- 1 file changed, 4 deletions(-) (limited to 'src') diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index 1c79e4ea92..cf90df6b9b 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -2526,10 +2526,6 @@ QWidget *QWidget::find(WId id) If a widget is non-native (alien) and winId() is invoked on it, that widget will be provided a native handle. - On \macos, the type returned depends on which framework Qt was linked - against. If Qt is using Carbon, the {WId} is actually an HIViewRef. If Qt - is using Cocoa, {WId} is a pointer to an NSView. - This value may change at run-time. An event with type QEvent::WinIdChange will be sent to the widget following a change in window system identifier. -- cgit v1.2.3 From a41677d04c3835eb12a30cf546c0b0804592325d Mon Sep 17 00:00:00 2001 From: Oleg Yadrov Date: Mon, 16 Jan 2017 15:39:32 -0800 Subject: QQuickWidget: fix drag and drop QQuickWidget did not receive mouse release events after drag and drop because the logic was so: 1) QWidgetWindow::handleMouseEvent() was called on press and qt_button_down was set to the corresponding QQuickWidget; 2) After drag started, qt_button_down was set to 0 in QApplicationPrivate::notifyDragStarted(); 3) On mouse release QWidgetWindow::handleMouseEvent() was called again, but because qt_button_down was 0 QApplicationPrivate::pickMouseReceiver() returned 0 and as a result QWidgetWindow ignored the event and did not propagate it to QQuickWidget for further processing. The step 2 is a widgets-specific fix for QTBUG-26145 that does not work for QQuickWidget (QtQuick has its own focus system). Note that because Widgets and QtQuick do not share the sources, there is no possibility to cast the pointer to check whether qt_button_down is a QQuickWidget or some other QWidget-derived class object, so we have to use QObject::inherits() method to check that. Task-number: QTBUG-56713 Change-Id: I599b843e903c64329e6178752e0dc49f674bb890 Reviewed-by: Friedemann Kleint --- src/widgets/kernel/qapplication.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index 128b5dc2b8..5908d3036b 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -4501,9 +4501,13 @@ void QApplicationPrivate::notifyThemeChanged() #ifndef QT_NO_DRAGANDDROP void QApplicationPrivate::notifyDragStarted(const QDrag *drag) { - // Prevent pickMouseReceiver() from using the widget where the drag was started after a drag operation. QGuiApplicationPrivate::notifyDragStarted(drag); - qt_button_down = 0; + // QTBUG-26145 + // Prevent pickMouseReceiver() from using the widget where the drag was started after a drag operation... + // QTBUG-56713 + // ...only if qt_button_down is not a QQuickWidget + if (qt_button_down && !qt_button_down->inherits("QQuickWidget")) + qt_button_down = nullptr; } #endif // QT_NO_DRAGANDDROP -- cgit v1.2.3 From 4d49f94060e20c5e47a587cc630a40718d91e62c Mon Sep 17 00:00:00 2001 From: Oleg Yadrov Date: Thu, 19 Jan 2017 14:25:12 -0800 Subject: Cocoa: fix bug when left mouse button release event delivered as right The regression was introduced during refactoring by 820e69d6c and the initial change that added this logic is adc3ef97d. This condition had become redundant and wrong after refactoring because m_sendUpAsRightButton flag is set in the proper way in QNSView::mouseDown() which later calls QNSView::handleMouseEvent() anyway. Task-number: QTBUG-58219 Change-Id: I1951cf4067af6f0c1837c1c15b8a09dfe7939493 Reviewed-by: Timur Pocheptsov Reviewed-by: Pavol Markovic --- src/plugins/platforms/cocoa/qnsview.mm | 3 --- 1 file changed, 3 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm index ba91d3e40e..970ce9e785 100644 --- a/src/plugins/platforms/cocoa/qnsview.mm +++ b/src/plugins/platforms/cocoa/qnsview.mm @@ -853,9 +853,6 @@ static bool _q_dontOverrideCtrlLMB = false; if (masked) return false; - if (button == Qt::RightButton) - m_sendUpAsRightButton = true; - m_buttons |= button; [self handleMouseEvent:theEvent]; -- cgit v1.2.3 From ebffedb11dbce9391982dd3646b5466103aa5705 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Wed, 18 Jan 2017 13:07:56 +0100 Subject: Avoid trashing other contexts' VAOs in destroy() The following is safe: QOpenGLVertexArrayObject *vao = ... vao->create(); switch the current context delete vao; because the QOpenGLVAO dtor recognizes that the wrong context is current, and will temporarily restore the VAO's associated one in order to safely destroy the vao object. However, the following has been problematic: vao.create(); switch the current context vao.destroy(); simply because all the logic was in the dtor and destroy() blindly deleted the vao object in whatever context was current. This can lead to releasing a completely unrelated vao object that happens to have the same name in another context. The expectation is for context-dependent wrappers is that a ctor-create-dtor-ctor-create-dtor-... sequence is equivalent to create-destroy-create-destroy-..., so move the safe cleanup logic from the dtor to destroy(). Change-Id: Ie3bddbf4bfeb8629948c4783cc88422c9df03e65 Reviewed-by: Allan Sandfeld Jensen --- src/gui/opengl/qopenglvertexarrayobject.cpp | 94 ++++++++++++++--------------- 1 file changed, 45 insertions(+), 49 deletions(-) (limited to 'src') diff --git a/src/gui/opengl/qopenglvertexarrayobject.cpp b/src/gui/opengl/qopenglvertexarrayobject.cpp index babe52aa83..0262538250 100644 --- a/src/gui/opengl/qopenglvertexarrayobject.cpp +++ b/src/gui/opengl/qopenglvertexarrayobject.cpp @@ -197,33 +197,59 @@ void QOpenGLVertexArrayObjectPrivate::destroy() { Q_Q(QOpenGLVertexArrayObject); + QOpenGLContext *ctx = QOpenGLContext::currentContext(); + QOpenGLContext *oldContext = 0; + QSurface *oldContextSurface = 0; + QScopedPointer offscreenSurface; + if (context && context != ctx) { + oldContext = ctx; + oldContextSurface = ctx ? ctx->surface() : 0; + // Cannot just make the current surface current again with another context. + // The format may be incompatible and some platforms (iOS) may impose + // restrictions on using a window with different contexts. Create an + // offscreen surface (a pbuffer or a hidden window) instead to be safe. + offscreenSurface.reset(new QOffscreenSurface); + offscreenSurface->setFormat(context->format()); + offscreenSurface->create(); + if (context->makeCurrent(offscreenSurface.data())) { + ctx = context; + } else { + qWarning("QOpenGLVertexArrayObject::destroy() failed to make VAO's context current"); + ctx = 0; + } + } + if (context) { QObject::disconnect(context, SIGNAL(aboutToBeDestroyed()), q, SLOT(_q_contextAboutToBeDestroyed())); context = 0; } - if (!vao) - return; - - switch (vaoFuncsType) { + if (vao) { + switch (vaoFuncsType) { #ifndef QT_OPENGL_ES_2 - case Core_3_2: - vaoFuncs.core_3_2->glDeleteVertexArrays(1, &vao); - break; - case Core_3_0: - vaoFuncs.core_3_0->glDeleteVertexArrays(1, &vao); - break; + case Core_3_2: + vaoFuncs.core_3_2->glDeleteVertexArrays(1, &vao); + break; + case Core_3_0: + vaoFuncs.core_3_0->glDeleteVertexArrays(1, &vao); + break; #endif - case ARB: - case APPLE: - case OES: - vaoFuncs.helper->glDeleteVertexArrays(1, &vao); - break; - default: - break; + case ARB: + case APPLE: + case OES: + vaoFuncs.helper->glDeleteVertexArrays(1, &vao); + break; + default: + break; + } + + vao = 0; } - vao = 0; + if (oldContext && oldContextSurface) { + if (!oldContext->makeCurrent(oldContextSurface)) + qWarning("QOpenGLVertexArrayObject::destroy() failed to restore current context"); + } } /*! @@ -354,37 +380,7 @@ QOpenGLVertexArrayObject::QOpenGLVertexArrayObject(QOpenGLVertexArrayObjectPriva */ QOpenGLVertexArrayObject::~QOpenGLVertexArrayObject() { - QOpenGLContext* ctx = QOpenGLContext::currentContext(); - - Q_D(QOpenGLVertexArrayObject); - QOpenGLContext *oldContext = 0; - QSurface *oldContextSurface = 0; - QScopedPointer offscreenSurface; - if (d->context && ctx && d->context != ctx) { - oldContext = ctx; - oldContextSurface = ctx->surface(); - // Cannot just make the current surface current again with another context. - // The format may be incompatible and some platforms (iOS) may impose - // restrictions on using a window with different contexts. Create an - // offscreen surface (a pbuffer or a hidden window) instead to be safe. - offscreenSurface.reset(new QOffscreenSurface); - offscreenSurface->setFormat(d->context->format()); - offscreenSurface->create(); - if (d->context->makeCurrent(offscreenSurface.data())) { - ctx = d->context; - } else { - qWarning("QOpenGLVertexArrayObject::~QOpenGLVertexArrayObject() failed to make VAO's context current"); - ctx = 0; - } - } - - if (ctx) - destroy(); - - if (oldContext) { - if (!oldContext->makeCurrent(oldContextSurface)) - qWarning("QOpenGLVertexArrayObject::~QOpenGLVertexArrayObject() failed to restore current context"); - } + destroy(); } /*! -- cgit v1.2.3 From 2597d27732e5e256d967d8a1db396c339b5afd3f Mon Sep 17 00:00:00 2001 From: Topi Reinio Date: Mon, 14 Nov 2016 10:11:05 +0100 Subject: Doc: Remove specific mention of 'Qt 4' from Model/View documentation Change-Id: If2101124d1bc772c9412c3d09d2d7753d9b51569 Reviewed-by: Leena Miettinen --- src/widgets/doc/src/modelview.qdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/widgets/doc/src/modelview.qdoc b/src/widgets/doc/src/modelview.qdoc index 4a53ea5cbd..1c0bb5195a 100644 --- a/src/widgets/doc/src/modelview.qdoc +++ b/src/widgets/doc/src/modelview.qdoc @@ -83,7 +83,7 @@ Model/View is a technology used to separate data from views in widgets that handle data sets. Standard widgets are not designed for separating data - from views and this is why Qt 4 has two different types of widgets. Both + from views and this is why Qt has two different types of widgets. Both types of widgets look the same, but they interact with data differently. \table -- cgit v1.2.3 From 92eafefb5abaa7f5ef41c3e85f22d8dd69486297 Mon Sep 17 00:00:00 2001 From: Tasuku Suzuki Date: Sat, 21 Jan 2017 15:10:12 +0900 Subject: Fix build without features.textcodec Change-Id: Ia9636db509270db93c2f9e46adaf1def0f157344 Reviewed-by: Lars Knoll --- src/corelib/configure.json | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/corelib/configure.json b/src/corelib/configure.json index c170b38977..66bf0dac92 100644 --- a/src/corelib/configure.json +++ b/src/corelib/configure.json @@ -305,6 +305,7 @@ "label": "Mimetype handling", "purpose": "Provides MIME type handling.", "section": "Utilities", + "condition": "features.textcodec", "output": [ "publicFeature", "feature" ] }, "system-pcre": { -- cgit v1.2.3 From ecf025f613e5f59a8653ffd2d3d4aa6f47b668df Mon Sep 17 00:00:00 2001 From: Jesus Fernandez Date: Tue, 19 Apr 2016 10:16:42 +0200 Subject: Fix dereference before null check in QOpenGLExtensionMatcher QOpenGLContext pointer was dereferenced before checking if it valid. Coverity-Id: 11370 Change-Id: I87d83a87d88ad7c055f3ed32096bfda036224ca9 Reviewed-by: Laszlo Agocs --- src/gui/opengl/qopengl.cpp | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/gui/opengl/qopengl.cpp b/src/gui/opengl/qopengl.cpp index eb08492254..384cd0bd13 100644 --- a/src/gui/opengl/qopengl.cpp +++ b/src/gui/opengl/qopengl.cpp @@ -64,6 +64,10 @@ typedef const GLubyte * (QOPENGLF_APIENTRYP qt_glGetStringi)(GLenum, GLuint); QOpenGLExtensionMatcher::QOpenGLExtensionMatcher() { QOpenGLContext *ctx = QOpenGLContext::currentContext(); + if (!ctx) { + qWarning("QOpenGLExtensionMatcher::QOpenGLExtensionMatcher: No context"); + return; + } QOpenGLFunctions *funcs = ctx->functions(); const char *extensionStr = 0; @@ -79,19 +83,17 @@ QOpenGLExtensionMatcher::QOpenGLExtensionMatcher() // clear error state while (funcs->glGetError()) {} - if (ctx) { - qt_glGetStringi glGetStringi = (qt_glGetStringi)ctx->getProcAddress("glGetStringi"); + qt_glGetStringi glGetStringi = (qt_glGetStringi)ctx->getProcAddress("glGetStringi"); - if (!glGetStringi) - return; + if (!glGetStringi) + return; - GLint numExtensions = 0; - funcs->glGetIntegerv(GL_NUM_EXTENSIONS, &numExtensions); + GLint numExtensions = 0; + funcs->glGetIntegerv(GL_NUM_EXTENSIONS, &numExtensions); - for (int i = 0; i < numExtensions; ++i) { - const char *str = reinterpret_cast(glGetStringi(GL_EXTENSIONS, i)); - m_extensions.insert(str); - } + for (int i = 0; i < numExtensions; ++i) { + const char *str = reinterpret_cast(glGetStringi(GL_EXTENSIONS, i)); + m_extensions.insert(str); } #endif // QT_OPENGL_3 } -- cgit v1.2.3 From 4d7313a466dd775e58705924f72525d4838c70fe Mon Sep 17 00:00:00 2001 From: Aleksei Timofeyev Date: Fri, 22 Apr 2016 17:00:27 +0500 Subject: QLocalSocket/Win: Fix access to deleted pipeWriter waitForWrite can emit a signal outside QLocalSocket and pipeWriter could be deleted there. Change-Id: Ic35ec6455bd05402fd38fb3e1b219aa4534a0ff6 Reviewed-by: Joerg Bornemann --- src/network/socket/qlocalsocket_win.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/network/socket/qlocalsocket_win.cpp b/src/network/socket/qlocalsocket_win.cpp index bed4355aa9..312c934632 100644 --- a/src/network/socket/qlocalsocket_win.cpp +++ b/src/network/socket/qlocalsocket_win.cpp @@ -309,10 +309,8 @@ bool QLocalSocket::flush() { Q_D(QLocalSocket); bool written = false; - if (d->pipeWriter) { - while (d->pipeWriter->waitForWrite(0)) - written = true; - } + while (d->pipeWriter && d->pipeWriter->waitForWrite(0)) + written = true; return written; } -- cgit v1.2.3 From 4b1d825ddcd1c116b158039e4772ee41c9785104 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 20 Dec 2016 09:10:55 +0100 Subject: QGuiApplication: Send QEvent::Window(Un)blocked to embedded window, too Change 333f641622c795a4b826d2d48aeabd5b5eab6e90 modified QGuiApplication::topLevelWindows() to no longer include embedded windows. This causes the blocked handling in Active Qt to no longer be triggered. Fix this by iterating over the list using the same condition as before, avoiding the construction of a temporary list as a side effect. Task-number: QTBUG-18099 Change-Id: I06a1a4e324fea9f543ceb5274bb064734f8d56af Reviewed-by: Miikka Heikkinen Reviewed-by: Andy Shaw --- src/gui/kernel/qguiapplication.cpp | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index 98cdecc444..71f27db6b7 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -759,6 +759,14 @@ void QGuiApplicationPrivate::updateBlockedStatus(QWindow *window) updateBlockedStatusRecursion(window, shouldBeBlocked); } +// Return whether the window needs to be notified about window blocked events. +// As opposed to QGuiApplication::topLevelWindows(), embedded windows are +// included in this list (QTBUG-18099). +static inline bool needsWindowBlockedEvent(const QWindow *w) +{ + return w->isTopLevel() && w->type() != Qt::Desktop; +} + void QGuiApplicationPrivate::showModalWindow(QWindow *modal) { self->modalWindowList.prepend(modal); @@ -776,10 +784,8 @@ void QGuiApplicationPrivate::showModalWindow(QWindow *modal) } } - QWindowList windows = QGuiApplication::topLevelWindows(); - for (int i = 0; i < windows.count(); ++i) { - QWindow *window = windows.at(i); - if (!window->d_func()->blockedByModalWindow) + for (QWindow *window : qAsConst(QGuiApplicationPrivate::window_list)) { + if (needsWindowBlockedEvent(window) && !window->d_func()->blockedByModalWindow) updateBlockedStatus(window); } @@ -790,10 +796,8 @@ void QGuiApplicationPrivate::hideModalWindow(QWindow *window) { self->modalWindowList.removeAll(window); - QWindowList windows = QGuiApplication::topLevelWindows(); - for (int i = 0; i < windows.count(); ++i) { - QWindow *window = windows.at(i); - if (window->d_func()->blockedByModalWindow) + for (QWindow *window : qAsConst(QGuiApplicationPrivate::window_list)) { + if (needsWindowBlockedEvent(window) && window->d_func()->blockedByModalWindow) updateBlockedStatus(window); } } -- cgit v1.2.3 From 186a5af82bd302a85aec3652fadc4ef376468713 Mon Sep 17 00:00:00 2001 From: Dmitry Shachnev Date: Mon, 23 Jan 2017 11:58:37 +0300 Subject: Doc: do not break the values list by blank lines in qnamespace.qdoc There should be no blank lines in \value content, otherwise qdoc ends the list and starts a new one. Change-Id: Idddc7992317894487445aea36397136df40b9691 Reviewed-by: Martin Smith --- src/corelib/global/qnamespace.qdoc | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'src') diff --git a/src/corelib/global/qnamespace.qdoc b/src/corelib/global/qnamespace.qdoc index 11044cef88..48aaf34dcd 100644 --- a/src/corelib/global/qnamespace.qdoc +++ b/src/corelib/global/qnamespace.qdoc @@ -123,16 +123,14 @@ \value AA_PluginApplication Indicates that Qt is used to author a plugin. Depending on the operating system, it suppresses specific initializations that do not necessarily make sense in the plugin case. - For example on OS X, this includes avoiding loading our nib for the main menu and not taking possession of the native menu bar. Setting this attribute to true will also set the AA_DontUseNativeMenuBar attribute to true. It also disables native event filters. - This attribute has been added in Qt 5.7. It must be set before \l {QGuiApplication}{Q(Gui)Application} is constructed. - \value AA_MacPluginApplication This attribute has been deprecated. + \value AA_MacPluginApplication This attribute has been deprecated. Use AA_PluginApplication instead. \value AA_DontUseNativeMenuBar All menubars created while this attribute is @@ -166,7 +164,6 @@ \value AA_UseHighDpiPixmaps Make QIcon::pixmap() generate high-dpi pixmaps that can be larger than the requested size. Such pixmaps will have \l {QPixmap::devicePixelRatio}{devicePixelRatio()} set to a value higher than 1. - After setting this attribute, application code that uses pixmap sizes in layout geometry calculations should typically divide by \l {QPixmap::devicePixelRatio}{devicePixelRatio()} to get device-independent layout geometry. -- cgit v1.2.3 From 79352528a1726b4551ea4d9285dd2394dd0d43da Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 16 Nov 2016 10:53:44 +0100 Subject: Windows QPA: Prevent usage of child windows as transient parent When using foreign window integrations such as MFC/winmigrate, it is possible that a child window is found which can cause issues with modality. Loop up to top level. Task-number: QTSOLBUG-71 Task-number: QTBUG-57159 Change-Id: Ib36e0f8f4f6b1e22ba1240013871facef2c0c1ab Reviewed-by: Andy Shaw --- src/plugins/platforms/windows/qwindowswindow.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src') diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp index 6894062d61..b5522c1f90 100644 --- a/src/plugins/platforms/windows/qwindowswindow.cpp +++ b/src/plugins/platforms/windows/qwindowswindow.cpp @@ -1273,6 +1273,12 @@ void QWindowsWindow::updateTransientParent() const if (const QWindowsWindow *tw = QWindowsWindow::windowsWindowOf(tp)) if (!tw->testFlag(WithinDestroy)) // Prevent destruction by parent window (QTBUG-35499, QTBUG-36666) newTransientParent = tw->handle(); + + // QTSOLBUG-71: When using the MFC/winmigrate solution, it is possible that a child + // window is found, which can cause issues with modality. Loop up to top level. + while (newTransientParent && (GetWindowLongPtr(newTransientParent, GWL_STYLE) & WS_CHILD) != 0) + newTransientParent = GetParent(newTransientParent); + if (newTransientParent != oldTransientParent) SetWindowLongPtr(m_data.hwnd, GWL_HWNDPARENT, LONG_PTR(newTransientParent)); } -- cgit v1.2.3