From b465fe759695bb7e1de693c3d4d20acfd2c49779 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 30 May 2016 10:21:54 +0200 Subject: QSystemTrayIcon/Windows: Use large icon for balloon message. Use larger system metric SM_CXICON instead of SM_CXSMICON and set NIIF_LARGE_ICON in the NOTIFYICONDATA. De-inline function iconFlag() and set NIIF_USER for user icons for NIIF_LARGE_ICON to take effect. Task-number: QTBUG-53591 Change-Id: I47c8e0a020ef94241403b1fbae76d5ef2e074301 Reviewed-by: Oliver Wolff --- src/widgets/util/qsystemtrayicon_win.cpp | 43 +++++++++++++++++--------------- 1 file changed, 23 insertions(+), 20 deletions(-) (limited to 'src') diff --git a/src/widgets/util/qsystemtrayicon_win.cpp b/src/widgets/util/qsystemtrayicon_win.cpp index 7e0212a233..221d040599 100644 --- a/src/widgets/util/qsystemtrayicon_win.cpp +++ b/src/widgets/util/qsystemtrayicon_win.cpp @@ -230,22 +230,9 @@ void QSystemTrayIconSys::setIconContents(NOTIFYICONDATA &tnd) qStringToLimitedWCharArray(tip, tnd.szTip, sizeof(tnd.szTip)/sizeof(wchar_t)); } -static int iconFlag( QSystemTrayIcon::MessageIcon icon ) -{ - switch (icon) { - case QSystemTrayIcon::Information: - return NIIF_INFO; - case QSystemTrayIcon::Warning: - return NIIF_WARNING; - case QSystemTrayIcon::Critical: - return NIIF_ERROR; - case QSystemTrayIcon::NoIcon: - return NIIF_NONE; - default: - Q_ASSERT_X(false, "QSystemTrayIconSys::showMessage", "Invalid QSystemTrayIcon::MessageIcon value"); - return NIIF_NONE; - } -} +#ifndef NIIF_LARGE_ICON +# define NIIF_LARGE_ICON 0x00000020 +#endif bool QSystemTrayIconSys::showMessage(const QString &title, const QString &message, QSystemTrayIcon::MessageIcon type, uint uSecs) { @@ -255,7 +242,22 @@ bool QSystemTrayIconSys::showMessage(const QString &title, const QString &messag qStringToLimitedWCharArray(title, tnd.szInfoTitle, 64); tnd.uID = q_uNOTIFYICONID; - tnd.dwInfoFlags = iconFlag(type); + switch (type) { + case QSystemTrayIcon::Information: + tnd.dwInfoFlags = NIIF_INFO; + break; + case QSystemTrayIcon::Warning: + tnd.dwInfoFlags = NIIF_WARNING; + break; + case QSystemTrayIcon::Critical: + tnd.dwInfoFlags = NIIF_ERROR; + break; + case QSystemTrayIcon::NoIcon: + tnd.dwInfoFlags = hIcon ? NIIF_USER : NIIF_NONE; + break; + } + if (QSysInfo::windowsVersion() >= QSysInfo::WV_VISTA) + tnd.dwInfoFlags |= NIIF_LARGE_ICON; tnd.cbSize = notifyIconSize; tnd.hWnd = m_hwnd; tnd.uTimeout = uSecs; @@ -296,9 +298,10 @@ HICON QSystemTrayIconSys::createIcon() const QIcon icon = q->icon(); if (icon.isNull()) return oldIcon; - const int iconSizeX = GetSystemMetrics(SM_CXSMICON); - const int iconSizeY = GetSystemMetrics(SM_CYSMICON); - const QSize size = icon.actualSize(QSize(iconSizeX, iconSizeY)); + const QSize requestedSize = QSysInfo::windowsVersion() >= QSysInfo::WV_VISTA + ? QSize(GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON)) + : QSize(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON)); + const QSize size = icon.actualSize(requestedSize); const QPixmap pm = icon.pixmap(size); if (pm.isNull()) return oldIcon; -- cgit v1.2.3 From 50d70fd1e374d04d8c1d0d9d78b572c4650e7320 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 8 Jun 2016 18:51:53 -0700 Subject: Fix warning when compiling x86 with SSE2 but no AVX2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit qstring.cpp:595:13: error: unused variable ‘nullmask’ [-Werror=unused-variable] Change-Id: I1cc7601489634e96833cfffd1456474a529a79ed Reviewed-by: Allan Sandfeld Jensen Reviewed-by: Erik Verbruggen --- src/corelib/tools/qstring.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index be1ca8ba95..8eadc9330d 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -594,6 +594,7 @@ static int ucstrncmp(const QChar *a, const uchar *c, int l) } # else // 32-bit, we can't do MOVQ to load 8 bytes + Q_UNUSED(nullmask); enum { MaxTailLength = 15 }; # endif -- cgit v1.2.3 From d4e98a9a3856d60d52d54870af8dcefa907acf92 Mon Sep 17 00:00:00 2001 From: James McDonnell Date: Thu, 11 Feb 2016 10:10:21 -0500 Subject: Move __cpp_constexpr check inside Q_COMPILER_CONSTEXPR check Q_COMPILER_CONSTEXPR can be undefined (or not defined at all) to indicate that constexpr should not be used regardless of the compiler's ability to support it. This is done for QNX because some C library floating point functions used in the Dinkumware C++ library aren't constexpr functions; i.e., the library doesn't have proper constexpr support even though the compiler does. (cherry picked from commit d87242968fc56ba09243f642ce70a85084619de0) Change-Id: If0bdeb2180710dd9ccd97d79fa91cf9ff42f7990 Reviewed-by: Thiago Macieira --- src/corelib/global/qcompilerdetection.h | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/corelib/global/qcompilerdetection.h b/src/corelib/global/qcompilerdetection.h index 01b3a298af..2d9e0463b7 100644 --- a/src/corelib/global/qcompilerdetection.h +++ b/src/corelib/global/qcompilerdetection.h @@ -1010,16 +1010,18 @@ # define Q_COMPILER_DEFAULT_DELETE_MEMBERS #endif -#if defined(__cpp_constexpr) && __cpp_constexpr-0 >= 201304 -# define Q_DECL_CONSTEXPR constexpr -# define Q_DECL_RELAXED_CONSTEXPR constexpr -# define Q_CONSTEXPR constexpr -# define Q_RELAXED_CONSTEXPR constexpr -#elif defined Q_COMPILER_CONSTEXPR -# define Q_DECL_CONSTEXPR constexpr -# define Q_DECL_RELAXED_CONSTEXPR -# define Q_CONSTEXPR constexpr -# define Q_RELAXED_CONSTEXPR const +#if defined Q_COMPILER_CONSTEXPR +# if defined(__cpp_constexpr) && __cpp_constexpr-0 >= 201304 +# define Q_DECL_CONSTEXPR constexpr +# define Q_DECL_RELAXED_CONSTEXPR constexpr +# define Q_CONSTEXPR constexpr +# define Q_RELAXED_CONSTEXPR constexpr +# else +# define Q_DECL_CONSTEXPR constexpr +# define Q_DECL_RELAXED_CONSTEXPR +# define Q_CONSTEXPR constexpr +# define Q_RELAXED_CONSTEXPR const +# endif #else # define Q_DECL_CONSTEXPR # define Q_DECL_RELAXED_CONSTEXPR -- cgit v1.2.3 From 0f6ededb157b3739b95c470f8dbf7b8bbb5a61cc Mon Sep 17 00:00:00 2001 From: Oliver Wolff Date: Fri, 3 Jun 2016 10:39:46 +0200 Subject: WinRT: Proper error handling in socket engine's "bind" runOnXamlThread should always return S_OK (causes exceptions otherwise) so we need another way of error reporting to the outside (hr reference). A failed hr is reported to the outside (of the lambda) and interpreted as an unknown error. Specific error cases like the given address not being a local address or the given address being in use already are handled inside the lambda. The specificErrorSet variable is necessary in these cases so that the error is not overwritten by unknownError. Change-Id: I198d66fe97726d5127bf31e50c7eff3363d5259c Reviewed-by: Maurice Kalinowski --- src/network/socket/qnativesocketengine_winrt.cpp | 47 +++++++++++++++++++----- 1 file changed, 37 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/network/socket/qnativesocketengine_winrt.cpp b/src/network/socket/qnativesocketengine_winrt.cpp index 3a4ef4b400..b926583c46 100644 --- a/src/network/socket/qnativesocketengine_winrt.cpp +++ b/src/network/socket/qnativesocketengine_winrt.cpp @@ -342,19 +342,21 @@ bool QNativeSocketEngine::bind(const QHostAddress &address, quint16 port) { Q_D(QNativeSocketEngine); HRESULT hr; - hr = QEventDispatcherWinRT::runOnXamlThread([address, d, port, this]() { - HRESULT hr; + // runOnXamlThread may only return S_OK (will assert otherwise) so no need to check its result. + // hr is set inside the lambda though. If an error occurred hr will point that out. + bool specificErrorSet = false; + QEventDispatcherWinRT::runOnXamlThread([address, d, &hr, port, &specificErrorSet, this]() { ComPtr hostAddress; if (address != QHostAddress::Any && address != QHostAddress::AnyIPv4 && address != QHostAddress::AnyIPv6) { ComPtr hostNameFactory; hr = GetActivationFactory(HString::MakeReference(RuntimeClass_Windows_Networking_HostName).Get(), &hostNameFactory); - RETURN_HR_IF_FAILED("QNativeSocketEngine::bind: Could not obtain hostname factory"); + RETURN_OK_IF_FAILED("QNativeSocketEngine::bind: Could not obtain hostname factory"); const QString addressString = address.toString(); HStringReference addressRef(reinterpret_cast(addressString.utf16())); hr = hostNameFactory->CreateHostName(addressRef.Get(), &hostAddress); - RETURN_HR_IF_FAILED("QNativeSocketEngine::bind: Could not create hostname."); + RETURN_OK_IF_FAILED("QNativeSocketEngine::bind: Could not create hostname."); } QString portQString = port ? QString::number(port) : QString(); @@ -365,13 +367,13 @@ bool QNativeSocketEngine::bind(const QHostAddress &address, quint16 port) if (!d->tcpListener) { hr = RoActivateInstance(HString::MakeReference(RuntimeClass_Windows_Networking_Sockets_StreamSocketListener).Get(), &d->tcpListener); - RETURN_HR_IF_FAILED("QNativeSocketEngine::bind: Could not create tcp listener"); + RETURN_OK_IF_FAILED("QNativeSocketEngine::bind: Could not create tcp listener"); } hr = d->tcpListener->add_ConnectionReceived( Callback(d, &QNativeSocketEnginePrivate::handleClientConnection).Get(), &d->connectionToken); - RETURN_HR_IF_FAILED("QNativeSocketEngine::bind: Could not register client connection callback"); + RETURN_OK_IF_FAILED("QNativeSocketEngine::bind: Could not register client connection callback"); hr = d->tcpListener->BindEndpointAsync(hostAddress.Get(), portString.Get(), &op); } else if (d->socketType == QAbstractSocket::UdpSocket) { hr = d->udpSocket()->BindEndpointAsync(hostAddress.Get(), portString.Get(), &op); @@ -379,15 +381,40 @@ bool QNativeSocketEngine::bind(const QHostAddress &address, quint16 port) if (hr == E_ACCESSDENIED) { qErrnoWarning(hr, "Unable to bind socket (%s:%hu/%s). Please check your manifest capabilities.", qPrintable(address.toString()), port, socketDescription(this).constData()); - return hr; + d->setError(QAbstractSocket::SocketAccessError, + QNativeSocketEnginePrivate::AccessErrorString); + d->socketState = QAbstractSocket::UnconnectedState; + specificErrorSet = true; + return S_OK; } - RETURN_HR_IF_FAILED("QNativeSocketEngine::bind: Unable to bind socket"); + RETURN_OK_IF_FAILED("QNativeSocketEngine::bind: Unable to bind socket"); hr = QWinRTFunctions::await(op); - RETURN_HR_IF_FAILED("QNativeSocketEngine::bind: Could not wait for bind to finish"); + if (hr == 0x80072741) { // The requested address is not valid in its context + d->setError(QAbstractSocket::SocketAddressNotAvailableError, + QNativeSocketEnginePrivate::AddressNotAvailableErrorString); + d->socketState = QAbstractSocket::UnconnectedState; + specificErrorSet = true; + return S_OK; + // Only one usage of each socket address (protocol/network address/port) is normally permitted + } else if (hr == 0x80072740) { + d->setError(QAbstractSocket::AddressInUseError, + QNativeSocketEnginePrivate::AddressInuseErrorString); + d->socketState = QAbstractSocket::UnconnectedState; + specificErrorSet = true; + return S_OK; + } + RETURN_OK_IF_FAILED("QNativeSocketEngine::bind: Could not wait for bind to finish"); return S_OK; }); - Q_ASSERT_SUCCEEDED(hr); + if (FAILED(hr)) { + if (!specificErrorSet) { + d->setError(QAbstractSocket::UnknownSocketError, + QNativeSocketEnginePrivate::UnknownSocketErrorString); + d->socketState = QAbstractSocket::UnconnectedState; + } + return false; + } d->socketState = QAbstractSocket::BoundState; return d->fetchConnectionParameters(); -- cgit v1.2.3 From c111abe0605c95b50eb4362df2a68953f3e0da1e Mon Sep 17 00:00:00 2001 From: Oliver Wolff Date: Fri, 3 Jun 2016 10:58:51 +0200 Subject: WinRT: fixed error reporting of QNativeSocketEngine::initialize If runOnXamlThread returns anything but S_OK an exception is thrown which might cause the application to terminate. So we give the lambda a reference to hr and check that reference instead of runOnXamlThread's return value for errors. Change-Id: I1188ea720c63f6fdf43400f2f3ff928b72afc58e Reviewed-by: Maurice Kalinowski --- src/network/socket/qnativesocketengine_winrt.cpp | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/network/socket/qnativesocketengine_winrt.cpp b/src/network/socket/qnativesocketengine_winrt.cpp index b926583c46..4547a0cbe4 100644 --- a/src/network/socket/qnativesocketengine_winrt.cpp +++ b/src/network/socket/qnativesocketengine_winrt.cpp @@ -253,31 +253,23 @@ bool QNativeSocketEngine::initialize(qintptr socketDescriptor, QAbstractSocket:: // Start processing incoming data if (d->socketType == QAbstractSocket::TcpSocket) { HRESULT hr; - hr = QEventDispatcherWinRT::runOnXamlThread([d, socket, this]() { + QEventDispatcherWinRT::runOnXamlThread([d, &hr, socket, this]() { ComPtr buffer; HRESULT hr = g->bufferFactory->Create(READ_BUFFER_SIZE, &buffer); - RETURN_HR_IF_FAILED("initialize(): Could not create buffer"); - + RETURN_OK_IF_FAILED("initialize(): Could not create buffer"); ComPtr stream; hr = socket->get_InputStream(&stream); - RETURN_HR_IF_FAILED("initialize(): Could not obtain input stream"); + RETURN_OK_IF_FAILED("initialize(): Could not obtain input stream"); hr = stream->ReadAsync(buffer.Get(), READ_BUFFER_SIZE, InputStreamOptions_Partial, d->readOp.GetAddressOf()); - if (FAILED(hr)) { - qErrnoWarning(hr, "initialize(): Failed to read from the socket buffer (%s).", + RETURN_OK_IF_FAILED_WITH_ARGS("initialize(): Failed to read from the socket buffer (%s).", socketDescription(this).constData()); - return E_FAIL; - } hr = d->readOp->put_Completed(Callback(d, &QNativeSocketEnginePrivate::handleReadyRead).Get()); - if (FAILED(hr)) { - qErrnoWarning(hr, "initialize(): Failed to set socket read callback (%s).", + RETURN_OK_IF_FAILED_WITH_ARGS("initialize(): Failed to set socket read callback (%s).", socketDescription(this).constData()); - return E_FAIL; - } return S_OK; }); - if (hr == E_FAIL) + if (FAILED(hr)) return false; - Q_ASSERT_SUCCEEDED(hr); } d->socketState = socketState; -- cgit v1.2.3 From 6fa74764d91e876162e2a992a4087aaf4082c001 Mon Sep 17 00:00:00 2001 From: Oliver Wolff Date: Fri, 3 Jun 2016 12:07:46 +0200 Subject: WinRT: Avoid asserts in socket function with bool return values There is no need for the functions to assert. By returning false they show that something went wrong and the error will be handled gracefully. Change-Id: Ib026adf5c6fb23b5e6b5598533caec3b3669220c Reviewed-by: Maurice Kalinowski --- src/network/socket/qnativesocketengine_winrt.cpp | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/network/socket/qnativesocketengine_winrt.cpp b/src/network/socket/qnativesocketengine_winrt.cpp index 4547a0cbe4..58f0668854 100644 --- a/src/network/socket/qnativesocketengine_winrt.cpp +++ b/src/network/socket/qnativesocketengine_winrt.cpp @@ -321,11 +321,14 @@ bool QNativeSocketEngine::connectToHostByName(const QString &name, quint16 port) Q_ASSERT_SUCCEEDED(hr); d->socketState = QAbstractSocket::ConnectingState; - hr = QEventDispatcherWinRT::runOnXamlThread([d]() { - return d->connectOp->put_Completed(Callback( + QEventDispatcherWinRT::runOnXamlThread([d, &hr]() { + hr = d->connectOp->put_Completed(Callback( d, &QNativeSocketEnginePrivate::handleConnectOpFinished).Get()); + RETURN_OK_IF_FAILED("connectToHostByName: Could not register \"connectOp\" callback"); + return S_OK; }); - Q_ASSERT_SUCCEEDED(hr); + if (FAILED(hr)) + return false; return d->socketState == QAbstractSocket::ConnectedState; } @@ -865,20 +868,22 @@ bool QNativeSocketEnginePrivate::createNewSocket(QAbstractSocket::SocketType soc case QAbstractSocket::TcpSocket: { ComPtr socket; hr = RoActivateInstance(HString::MakeReference(RuntimeClass_Windows_Networking_Sockets_StreamSocket).Get(), &socket); - Q_ASSERT_SUCCEEDED(hr); + RETURN_FALSE_IF_FAILED("createNewSocket: Could not create socket instance"); socketDescriptor = qintptr(socket.Detach()); break; } case QAbstractSocket::UdpSocket: { ComPtr socket; hr = RoActivateInstance(HString::MakeReference(RuntimeClass_Windows_Networking_Sockets_DatagramSocket).Get(), &socket); - Q_ASSERT_SUCCEEDED(hr); + RETURN_FALSE_IF_FAILED("createNewSocket: Could not create socket instance"); socketDescriptor = qintptr(socket.Detach()); - hr = QEventDispatcherWinRT::runOnXamlThread([this]() { - HRESULT hr = udpSocket()->add_MessageReceived(Callback(this, &QNativeSocketEnginePrivate::handleNewDatagram).Get(), &connectionToken); - return hr; + QEventDispatcherWinRT::runOnXamlThread([&hr, this]() { + hr = udpSocket()->add_MessageReceived(Callback(this, &QNativeSocketEnginePrivate::handleNewDatagram).Get(), &connectionToken); + RETURN_OK_IF_FAILED("createNewSocket: Could not add \"message received\" callback") + return S_OK; }); - Q_ASSERT_SUCCEEDED(hr); + if (FAILED(hr)) + return false; break; } default: -- cgit v1.2.3 From 3394d97edfd6d1f5f4311868212831bb3ae03dfb Mon Sep 17 00:00:00 2001 From: Maurice Kalinowski Date: Thu, 9 Jun 2016 10:22:58 +0200 Subject: winrt: Add privateNetworkClientServer to default capabilities Contrary to our initial assumption, this should be added by default to allow full functionality during development by default. Developers need to decide which capabilities to use during the publishing step already, hence improve DX by adding this. Task-number: QTBUG-50847 Change-Id: I36e0214f7bcf8610d31851eea172aba3944cfd99 Reviewed-by: Oliver Wolff Reviewed-by: Friedemann Kleint --- src/network/network.pro | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/network/network.pro b/src/network/network.pro index fed14616af..ae81132b52 100644 --- a/src/network/network.pro +++ b/src/network/network.pro @@ -34,7 +34,8 @@ ANDROID_PERMISSIONS += \ MODULE_WINRT_CAPABILITIES = \ internetClient \ - internetClientServer + internetClientServer \ + privateNetworkClientServer MODULE_PLUGIN_TYPES = \ bearer -- cgit v1.2.3 From 038c57f4b3aca1b35244fb9fbb0ae81c53279c6f Mon Sep 17 00:00:00 2001 From: Maurice Kalinowski Date: Wed, 8 Jun 2016 14:42:09 +0200 Subject: winrt: Close IAsyncInfo manually in case of error In case QEventDispatcherWinRT::runOnXamlThread returns an error the runtime sets the status of IAsyncInfo to Error. At the point when the IAsyncInfo destructor is invoked, an unhandled exception is thrown indicating the error has not been handled, causing any application to just crash deep inside the Windows platform libraries. Hence, in case runOnXamlThread returns non-S_OK we have to manually invoke Close() of the IAsyncInfo to tell the system we have taken care of everything. Change-Id: I3ac1e2ec2726f42e44f4f9a92191e454711120dd Reviewed-by: Oliver Wolff --- src/corelib/kernel/qfunctions_winrt.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src') diff --git a/src/corelib/kernel/qfunctions_winrt.h b/src/corelib/kernel/qfunctions_winrt.h index dc1cbe0ade..9af5a08a01 100644 --- a/src/corelib/kernel/qfunctions_winrt.h +++ b/src/corelib/kernel/qfunctions_winrt.h @@ -203,6 +203,9 @@ static inline HRESULT _await_impl(const Microsoft::WRL::ComPtr &asyncOp, Awai if (FAILED(hr) || status != Completed) { HRESULT ec; hr = asyncInfo->get_ErrorCode(&ec); + if (FAILED(hr)) + return hr; + hr = asyncInfo->Close(); if (FAILED(hr)) return hr; return ec; -- cgit v1.2.3 From 27e94bd9d1ac5faaa8b1e4ee5d57f820675194b1 Mon Sep 17 00:00:00 2001 From: Maurice Kalinowski Date: Tue, 17 May 2016 16:35:04 +0200 Subject: winrt: Fix potential crash in QCoreApplication GetModuleFileName exists for Windows 10 and upwards, hence use the generic version from the win32 mkspec. This allows to create a QCoreApplication object with nullptr argv, as the application filename is identified via the binary itself and not via arguments. A couple of auto-tests use this method to create multiple application objects during runtime. Unfortunately we cannot apply this for msvc2013, even though MSDN states the GetModuleFileName exists, it fails to compile for Windows Phone 8.1. Change-Id: I2b8b988107487ef3785462f8ca40b0a6e0623e32 Reviewed-by: Thiago Macieira Reviewed-by: Oliver Wolff --- src/corelib/kernel/qcoreapplication_win.cpp | 59 ++++++++++++++++------------- 1 file changed, 33 insertions(+), 26 deletions(-) (limited to 'src') diff --git a/src/corelib/kernel/qcoreapplication_win.cpp b/src/corelib/kernel/qcoreapplication_win.cpp index 324b664a1a..1af1d44f2e 100644 --- a/src/corelib/kernel/qcoreapplication_win.cpp +++ b/src/corelib/kernel/qcoreapplication_win.cpp @@ -49,7 +49,10 @@ QT_BEGIN_NAMESPACE int appCmdShow = 0; -#if defined(Q_OS_WINRT) +// GetModuleFileName only exists for MSVC2015 and upwards for WinRT, meaning +// Windows 10 (Mobile). Hence take the first argument passed to the +// QCoreApplication contructor for older versions as a fallback on older platforms. +#if defined(Q_OS_WINRT) && _MSC_VER < 1900 Q_CORE_EXPORT QString qAppFileName() { @@ -61,31 +64,7 @@ QString QCoreApplicationPrivate::appName() const return QFileInfo(QCoreApplication::arguments().first()).baseName(); } -#else - -Q_CORE_EXPORT HINSTANCE qWinAppInst() // get Windows app handle -{ - return GetModuleHandle(0); -} - -Q_CORE_EXPORT HINSTANCE qWinAppPrevInst() // get Windows prev app handle -{ - return 0; -} - -Q_CORE_EXPORT int qWinAppCmdShow() // get main window show command -{ -#if defined(Q_OS_WINCE) - return appCmdShow; -#else - STARTUPINFO startupInfo; - GetStartupInfo(&startupInfo); - - return (startupInfo.dwFlags & STARTF_USESHOWWINDOW) - ? startupInfo.wShowWindow - : SW_SHOWDEFAULT; -#endif -} +#else // !(defined(Q_OS_WINRT) && _MSC_VER < 1900) Q_CORE_EXPORT QString qAppFileName() // get application file name { @@ -133,6 +112,34 @@ QString QCoreApplicationPrivate::appName() const return QFileInfo(qAppFileName()).baseName(); } +#endif // !(defined(Q_OS_WINRT) && _MSC_VER < 1900) + +#ifndef Q_OS_WINRT + +Q_CORE_EXPORT HINSTANCE qWinAppInst() // get Windows app handle +{ + return GetModuleHandle(0); +} + +Q_CORE_EXPORT HINSTANCE qWinAppPrevInst() // get Windows prev app handle +{ + return 0; +} + +Q_CORE_EXPORT int qWinAppCmdShow() // get main window show command +{ +#if defined(Q_OS_WINCE) + return appCmdShow; +#else + STARTUPINFO startupInfo; + GetStartupInfo(&startupInfo); + + return (startupInfo.dwFlags & STARTF_USESHOWWINDOW) + ? startupInfo.wShowWindow + : SW_SHOWDEFAULT; +#endif +} + /***************************************************************************** qWinMain() - Initializes Windows. Called from WinMain() in qtmain_win.cpp *****************************************************************************/ -- cgit v1.2.3 From e969e6d2ca5636b87b3de963ebd8dac993275617 Mon Sep 17 00:00:00 2001 From: James McDonnell Date: Thu, 9 Jun 2016 12:13:08 -0400 Subject: Fix cast warnings when pthread_t is smaller than a pointer Push conversions from pthread_t to Qt::HANDLE and back into functions. The casts that were being used didn't work for the unusual 64-bit pointer/32-bit int combination that QNX is using for 7.0. HANDLE ends up as a 64-bit pointer and pthread_t ends up as a 32-bit integer. g++ considers the precision loss when converting from the 64-bit pointer to the 32-bit integer an error. Better to have the casts hidden in functions so it's easier to adjust them for unusual combinations such as this. Change-Id: Ia156b26224a0f7edc1c31e3d1ee8b21191381698 Reviewed-by: Thiago Macieira --- src/corelib/thread/qthread_unix.cpp | 55 ++++++++++++++++++++++++++----------- 1 file changed, 39 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/corelib/thread/qthread_unix.cpp b/src/corelib/thread/qthread_unix.cpp index 3fc0ebfbb6..8c35d49aa3 100644 --- a/src/corelib/thread/qthread_unix.cpp +++ b/src/corelib/thread/qthread_unix.cpp @@ -105,7 +105,7 @@ QT_BEGIN_NAMESPACE #ifndef QT_NO_THREAD -Q_STATIC_ASSERT(sizeof(pthread_t) == sizeof(Qt::HANDLE)); +Q_STATIC_ASSERT(sizeof(pthread_t) <= sizeof(Qt::HANDLE)); enum { ThreadPriorityResetFlag = 0x80000000 }; @@ -205,6 +205,30 @@ static void clear_thread_data() pthread_setspecific(current_thread_data_key, 0); } +template +static typename QtPrivate::QEnableIf::isIntegral, Qt::HANDLE>::Type to_HANDLE(T id) +{ + return reinterpret_cast(static_cast(id)); +} + +template +static typename QtPrivate::QEnableIf::isIntegral, T>::Type from_HANDLE(Qt::HANDLE id) +{ + return static_cast(reinterpret_cast(id)); +} + +template +static typename QtPrivate::QEnableIf::isPointer, Qt::HANDLE>::Type to_HANDLE(T id) +{ + return id; +} + +template +static typename QtPrivate::QEnableIf::isPointer, T>::Type from_HANDLE(Qt::HANDLE id) +{ + return static_cast(id); +} + void QThreadData::clearCurrentThreadData() { clear_thread_data(); @@ -226,7 +250,7 @@ QThreadData *QThreadData::current(bool createIfNecessary) } data->deref(); data->isAdopted = true; - data->threadId = (Qt::HANDLE)pthread_self(); + data->threadId = to_HANDLE(pthread_self()); if (!QCoreApplicationPrivate::theMainThread) QCoreApplicationPrivate::theMainThread = data->thread.load(); } @@ -308,7 +332,7 @@ void *QThreadPrivate::start(void *arg) thr->d_func()->setPriority(QThread::Priority(thr->d_func()->priority & ~ThreadPriorityResetFlag)); } - data->threadId = (Qt::HANDLE)pthread_self(); + data->threadId = to_HANDLE(pthread_self()); set_thread_data(data); data->ref(); @@ -325,7 +349,7 @@ void *QThreadPrivate::start(void *arg) // sets the name of the current thread. QString objectName = thr->objectName(); - pthread_t thread_id = reinterpret_cast(data->threadId); + pthread_t thread_id = from_HANDLE(data->threadId); if (Q_LIKELY(objectName.isEmpty())) setCurrentThreadName(thread_id, thr->metaObject()->className()); else @@ -388,7 +412,7 @@ void QThreadPrivate::finish(void *arg) Qt::HANDLE QThread::currentThreadId() Q_DECL_NOTHROW { // requires a C cast here otherwise we run into trouble on AIX - return (Qt::HANDLE)pthread_self(); + return to_HANDLE(pthread_self()); } #if defined(QT_LINUXBASE) && !defined(_SC_NPROCESSORS_ONLN) @@ -614,18 +638,17 @@ void QThread::start(Priority priority) } } - int code = - pthread_create(reinterpret_cast(&d->data->threadId), &attr, - QThreadPrivate::start, this); + pthread_t threadId; + int code = pthread_create(&threadId, &attr, QThreadPrivate::start, this); if (code == EPERM) { // caller does not have permission to set the scheduling // parameters/policy #if defined(QT_HAS_THREAD_PRIORITY_SCHEDULING) pthread_attr_setinheritsched(&attr, PTHREAD_INHERIT_SCHED); #endif - code = pthread_create(reinterpret_cast(&d->data->threadId), &attr, - QThreadPrivate::start, this); + code = pthread_create(&threadId, &attr, QThreadPrivate::start, this); } + d->data->threadId = to_HANDLE(threadId); pthread_attr_destroy(&attr); @@ -647,7 +670,7 @@ void QThread::terminate() if (!d->data->threadId) return; - int code = pthread_cancel(reinterpret_cast(d->data->threadId)); + int code = pthread_cancel(from_HANDLE(d->data->threadId)); if (code) { qWarning("QThread::start: Thread termination error: %s", qPrintable(qt_error_string((code)))); @@ -660,7 +683,7 @@ bool QThread::wait(unsigned long time) Q_D(QThread); QMutexLocker locker(&d->mutex); - if (reinterpret_cast(d->data->threadId) == pthread_self()) { + if (from_HANDLE(d->data->threadId) == pthread_self()) { qWarning("QThread::wait: Thread tried to wait on itself"); return false; } @@ -702,7 +725,7 @@ void QThreadPrivate::setPriority(QThread::Priority threadPriority) int sched_policy; sched_param param; - if (pthread_getschedparam(reinterpret_cast(data->threadId), &sched_policy, ¶m) != 0) { + if (pthread_getschedparam(from_HANDLE(data->threadId), &sched_policy, ¶m) != 0) { // failed to get the scheduling policy, don't bother setting // the priority qWarning("QThread::setPriority: Cannot get scheduler parameters"); @@ -718,15 +741,15 @@ void QThreadPrivate::setPriority(QThread::Priority threadPriority) } param.sched_priority = prio; - int status = pthread_setschedparam(reinterpret_cast(data->threadId), sched_policy, ¶m); + int status = pthread_setschedparam(from_HANDLE(data->threadId), sched_policy, ¶m); # ifdef SCHED_IDLE // were we trying to set to idle priority and failed? if (status == -1 && sched_policy == SCHED_IDLE && errno == EINVAL) { // reset to lowest priority possible - pthread_getschedparam(reinterpret_cast(data->threadId), &sched_policy, ¶m); + pthread_getschedparam(from_HANDLE(data->threadId), &sched_policy, ¶m); param.sched_priority = sched_get_priority_min(sched_policy); - pthread_setschedparam(reinterpret_cast(data->threadId), sched_policy, ¶m); + pthread_setschedparam(from_HANDLE(data->threadId), sched_policy, ¶m); } # else Q_UNUSED(status); -- cgit v1.2.3 From 23173c725ce8b1c5b03498c9fa2bb334d40ec6f4 Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov Date: Thu, 9 Jun 2016 10:36:50 +0200 Subject: QSslSocket (OpenSSL) - handle abort/close on sslErrors emitted If a user's code, attached to sslErrors signal, calls abort/close or disconnectFromHost but our SSL socket was configured not to verify a peer, no need to continue handshake after calling checkSslErrors (and finally crashing on invalid 'ssl' pointer). Task-number: QTBUG-53906 Change-Id: I7f185511d278f9d6f16e7d6c5ba424707141459c Reviewed-by: Edward Welbourne Reviewed-by: Timur Pocheptsov --- src/network/ssl/qsslsocket_openssl.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src') diff --git a/src/network/ssl/qsslsocket_openssl.cpp b/src/network/ssl/qsslsocket_openssl.cpp index 57cedf2c22..82644c155c 100644 --- a/src/network/ssl/qsslsocket_openssl.cpp +++ b/src/network/ssl/qsslsocket_openssl.cpp @@ -1240,6 +1240,11 @@ bool QSslSocketBackendPrivate::startHandshake() #endif if (!checkSslErrors()) return false; + // A slot, attached to sslErrors signal can call + // abort/close/disconnetFromHost/etc; no need to + // continue handshake then. + if (q->state() != QAbstractSocket::ConnectedState) + return false; } else { sslErrors.clear(); } -- cgit v1.2.3 From fe97ecf408da60931fc49b502a223d59b5f93f99 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Thu, 9 Jun 2016 14:03:22 +0200 Subject: Make it possible to create distance fields with any height Assuming a certain max height for glyphs would make it impossible to render certain fonts. The follow up to this change is in Qt Quick, where the code must also be adapted to make it work. Task-number: QTBUG-52389 Change-Id: Iabebb2de21a92d1537b2965aa6603529c1d5d587 Reviewed-by: Yoann Lopes --- src/gui/text/qdistancefield.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/gui/text/qdistancefield.cpp b/src/gui/text/qdistancefield.cpp index 6a7019bc3c..c493ca1dad 100644 --- a/src/gui/text/qdistancefield.cpp +++ b/src/gui/text/qdistancefield.cpp @@ -799,8 +799,9 @@ QDistanceFieldData *QDistanceFieldData::create(const QPainterPath &path, bool do { int dfMargin = QT_DISTANCEFIELD_RADIUS(doubleResolution) / QT_DISTANCEFIELD_SCALE(doubleResolution); int glyphWidth = qCeil(path.boundingRect().width() / QT_DISTANCEFIELD_SCALE(doubleResolution)) + dfMargin * 2; + int glyphHeight = qCeil(path.boundingRect().height() / QT_DISTANCEFIELD_SCALE(doubleResolution)) + dfMargin * 2; - QDistanceFieldData *data = create(QSize(glyphWidth, QT_DISTANCEFIELD_TILESIZE(doubleResolution))); + QDistanceFieldData *data = create(QSize(glyphWidth, glyphHeight)); makeDistanceField(data, path, -- cgit v1.2.3 From c2d3c2b9f97cd842f2cbcc28acbc7a140b45222f Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Fri, 10 Jun 2016 13:38:31 +0200 Subject: Fix crash when creating distance field for large glyph Do the multiplication of the normal components in floating point to avoid integer overflows. Also add an assert, since a scale of 0 here will cause a normal of (0, 0) which will assert further into the drawRectangle() function, and the cause is not immediately clear. Task-number: QTBUG-51956 Change-Id: If7187d56af28eaa149f8f362050a587da5adb262 Reviewed-by: Yoann Lopes --- src/gui/text/qdistancefield.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/gui/text/qdistancefield.cpp b/src/gui/text/qdistancefield.cpp index c493ca1dad..efe4cc9928 100644 --- a/src/gui/text/qdistancefield.cpp +++ b/src/gui/text/qdistancefield.cpp @@ -544,7 +544,9 @@ static void makeDistanceField(QDistanceFieldData *data, const QPainterPath &path QPoint n(to.y() - from.y(), from.x() - to.x()); if (n.x() == 0 && n.y() == 0) continue; - int scale = qRound((offs << 16) / qSqrt(qreal(n.x() * n.x() + n.y() * n.y()))); // 8:16 + int scale = qRound((offs << 16) / qSqrt(qreal(n.x()) * n.x() + qreal(n.y()) * n.y())); // 8:16 + Q_ASSERT(scale != 0); + n.rx() = n.x() * scale >> 8; n.ry() = n.y() * scale >> 8; normals.append(n); -- cgit v1.2.3 From e5e93345c5befc1d0891bdf53db4d7d2ccfc8cd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Wed, 8 Jun 2016 16:47:31 +0200 Subject: UIKit: Don't populate font families with no matching fonts [UIFont familyNames] will return a list of fonts that include the fonts Telugu Sangam MN, Heiti SC, Heiti TC, and Bangla Sangam MN, but when calling [UIFont fontNamesForFamilyName:] for these fonts we get an empty list. The problem appeared when we tried to then populate these fonts, as CTFontDescriptorCreateMatchingFontDescriptors() would return a list of font descriptors from the PingFang SC font when called with NSFontFamilyAttribute = "Heiti SC". This is due to PingFang being a replacement for Heiti in later iOS versions. Task-number: QTBUG-50624 Change-Id: I22684e247d472c30775321b6976b3aeb6ea579f5 Reviewed-by: Jake Petroules --- src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src') diff --git a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm index c75bf4cf02..0b9e7a7fe0 100644 --- a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm +++ b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm @@ -206,6 +206,12 @@ void QCoreTextFontDatabase::populateFontDatabase() if (familyName.startsWith(QLatin1Char('.')) || familyName == QLatin1String("LastResort")) continue; +#if defined(Q_OS_IOS) || defined(Q_OS_TVOS) + // Skip font families with no corresponding fonts + if (![UIFont fontNamesForFamilyName:(NSString*)familyNameRef].count) + continue; +#endif + QPlatformFontDatabase::registerFontFamily(familyName); #if defined(Q_OS_OSX) -- cgit v1.2.3 From 8e889378115c69508b050a511621ac8e30ec4158 Mon Sep 17 00:00:00 2001 From: Jesus Fernandez Date: Mon, 13 Jun 2016 19:09:15 +0200 Subject: Fix UNSIGNED values in QMYSQL The unsigned flag in columns was ignored when creating the list of bound values in a mysql table. So the result iteration with QSqlQuery::next stops after the first wrong truncated value. [ChangeLog][QtSql] Fixed QSqlQuery::prepare value truncation error when using UNSIGNED values in a MySQL database. Task-number: QTBUG-53969 Task-number: QTBUG-53237 Change-Id: I10d977993445f2794f1dd8c88b2e83517ef524f3 Reviewed-by: Milian Wolff --- src/sql/drivers/mysql/qsql_mysql.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/sql/drivers/mysql/qsql_mysql.cpp b/src/sql/drivers/mysql/qsql_mysql.cpp index 96bdcc42fa..55bf499e42 100644 --- a/src/sql/drivers/mysql/qsql_mysql.cpp +++ b/src/sql/drivers/mysql/qsql_mysql.cpp @@ -387,6 +387,7 @@ bool QMYSQLResultPrivate::bindInValues() bind->buffer_length = f.bufLength = fieldInfo->length + 1; bind->is_null = &f.nullIndicator; bind->length = &f.bufLength; + bind->is_unsigned = fieldInfo->flags & UNSIGNED_FLAG ? 1 : 0; f.outField=field; ++i; -- cgit v1.2.3 From 3e2bde35786f503c9031c34454b741a02426bb9a Mon Sep 17 00:00:00 2001 From: Jake Petroules Date: Fri, 10 Jun 2016 21:13:35 -0700 Subject: Update for the newest Darwin-family operating systems. - Adapt to the OS X => macOS rename in Q_OS_ macros/docs, qmake scopes, file selectors, etc. - Add new QSysInfo values and MAC_OS_X / __MAC_ / __IPHONE_ values for macOS 10.12 and iOS 9.1 through 10.0. - Update prettyProductName with new macOS "Sierra" codename. Change-Id: Id976530beeafa01b648ebaa16f4a8f0613fcaf75 Reviewed-by: Thiago Macieira --- src/corelib/global/qglobal.cpp | 41 +++++++++++++++++++++++++---------- src/corelib/global/qsysinfo.h | 8 ++++++- src/corelib/global/qsystemdetection.h | 26 ++++++++++++++++++---- src/corelib/io/qfileselector.cpp | 6 ++++- 4 files changed, 64 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp index 77724d2a0d..8b6d8745f8 100644 --- a/src/corelib/global/qglobal.cpp +++ b/src/corelib/global/qglobal.cpp @@ -1134,6 +1134,7 @@ bool qSharedBuild() Q_DECL_NOTHROW \value MV_10_9 OS X 10.9 \value MV_10_10 OS X 10.10 \value MV_10_11 OS X 10.11 + \value MV_10_12 macOS 10.12 \value MV_Unknown An unknown and currently unsupported platform \value MV_CHEETAH Apple codename for MV_10_0 @@ -1148,6 +1149,7 @@ bool qSharedBuild() Q_DECL_NOTHROW \value MV_MAVERICKS Apple codename for MV_10_9 \value MV_YOSEMITE Apple codename for MV_10_10 \value MV_ELCAPITAN Apple codename for MV_10_11 + \value MV_SIERRA Apple codename for MV_10_12 \value MV_IOS iOS (any) \value MV_IOS_4_3 iOS 4.3 @@ -1163,6 +1165,10 @@ bool qSharedBuild() Q_DECL_NOTHROW \value MV_IOS_8_3 iOS 8.3 \value MV_IOS_8_4 iOS 8.4 \value MV_IOS_9_0 iOS 9.0 + \value MV_IOS_9_1 iOS 9.1 + \value MV_IOS_9_2 iOS 9.2 + \value MV_IOS_9_3 iOS 9.3 + \value MV_IOS_10_0 iOS 10.0 \value MV_None Not a Darwin operating system @@ -1173,23 +1179,28 @@ bool qSharedBuild() Q_DECL_NOTHROW \macro Q_OS_DARWIN \relates - Defined on Darwin-based operating systems such as OS X and iOS, - including any open source version(s) of Darwin. + Defined on Darwin-based operating systems such as OS X and iOS. */ /*! \macro Q_OS_MAC \relates - Defined on Darwin-based operating systems distributed by Apple, which - currently includes OS X and iOS, but not the open source versions of Darwin. + Deprecated synonym for \c Q_OS_DARWIN. Do not use. */ /*! \macro Q_OS_OSX \relates - Defined on OS X. + Deprecated synonym for \c Q_OS_MACOS. Do not use. + */ + +/*! + \macro Q_OS_MACOS + \relates + + Defined on macOS. */ /*! @@ -2573,10 +2584,12 @@ QString QSysInfo::kernelVersion() running the BlackBerry userspace, but "qnx" for all other QNX-based systems. - \b{Darwin, OS X and iOS note}: this function returns "osx" for OS X + \b{Darwin, OS X and iOS note}: this function returns "macos" for macOS systems, "ios" for iOS systems and "darwin" in case the system could not be determined. + \b{OS X note}: this function returns "osx" for versions of macOS prior to 10.12. + \b{FreeBSD note}: this function returns "debian" for Debian/kFreeBSD and "unknown" otherwise. @@ -2610,8 +2623,11 @@ QString QSysInfo::productType() #elif defined(Q_OS_IOS) return QStringLiteral("ios"); -#elif defined(Q_OS_OSX) - return QStringLiteral("osx"); +#elif defined(Q_OS_MACOS) + const QAppleOperatingSystemVersion version = qt_apple_os_version(); + if (version.major == 10 && version.minor < 12) + return QStringLiteral("osx"); + return QStringLiteral("macos"); #elif defined(Q_OS_DARWIN) return QStringLiteral("darwin"); @@ -2700,7 +2716,7 @@ QString QSysInfo::prettyProductName() { #if defined(Q_OS_IOS) return QLatin1String("iOS ") + productVersion(); -#elif defined(Q_OS_OSX) +#elif defined(Q_OS_MACOS) // get the known codenames const char *basename = 0; switch (int(MacintoshVersion)) { @@ -2734,12 +2750,15 @@ QString QSysInfo::prettyProductName() case MV_ELCAPITAN: basename = "OS X El Capitan ("; break; + case MV_SIERRA: + basename = "macOS Sierra ("; + break; } if (basename) return QLatin1String(basename) + productVersion() + QLatin1Char(')'); - // a future version of OS X - return QLatin1String("OS X ") + productVersion(); + // a future version of macOS + return QLatin1String("macOS ") + productVersion(); #elif defined(Q_OS_WINPHONE) return QLatin1String("Windows Phone ") + QLatin1String(winVer_helper()); #elif defined(Q_OS_WIN) diff --git a/src/corelib/global/qsysinfo.h b/src/corelib/global/qsysinfo.h index 27a285fd36..4b25db310f 100644 --- a/src/corelib/global/qsysinfo.h +++ b/src/corelib/global/qsysinfo.h @@ -138,6 +138,7 @@ public: MV_10_9 = Q_MV_OSX(10, 9), MV_10_10 = Q_MV_OSX(10, 10), MV_10_11 = Q_MV_OSX(10, 11), + MV_10_12 = Q_MV_OSX(10, 12), /* codenames */ MV_CHEETAH = MV_10_0, @@ -152,6 +153,7 @@ public: MV_MAVERICKS = MV_10_9, MV_YOSEMITE = MV_10_10, MV_ELCAPITAN = MV_10_11, + MV_SIERRA = MV_10_12, /* iOS */ MV_IOS = 1 << 8, @@ -167,7 +169,11 @@ public: MV_IOS_8_2 = Q_MV_IOS(8, 2), MV_IOS_8_3 = Q_MV_IOS(8, 3), MV_IOS_8_4 = Q_MV_IOS(8, 4), - MV_IOS_9_0 = Q_MV_IOS(9, 0) + MV_IOS_9_0 = Q_MV_IOS(9, 0), + MV_IOS_9_1 = Q_MV_IOS(9, 1), + MV_IOS_9_2 = Q_MV_IOS(9, 2), + MV_IOS_9_3 = Q_MV_IOS(9, 3), + MV_IOS_10_0 = Q_MV_IOS(10, 0) }; #if defined(Q_OS_MAC) static const MacVersion MacintoshVersion; diff --git a/src/corelib/global/qsystemdetection.h b/src/corelib/global/qsystemdetection.h index b6a7835ef2..de95ae391e 100644 --- a/src/corelib/global/qsystemdetection.h +++ b/src/corelib/global/qsystemdetection.h @@ -42,8 +42,7 @@ The operating system, must be one of: (Q_OS_x) DARWIN - Any Darwin system - MAC - OS X and iOS - OSX - OS X + MACOS - macOS IOS - iOS MSDOS - MS-DOS and Windows OS2 - OS/2 @@ -199,7 +198,8 @@ # if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE # define Q_OS_IOS # elif defined(TARGET_OS_MAC) && TARGET_OS_MAC -# define Q_OS_OSX +# define Q_OS_MACOS +# define Q_OS_OSX // compatibility synonym # define Q_OS_MACX // compatibility synonym # endif #endif @@ -214,7 +214,7 @@ # include # include # -# ifdef Q_OS_OSX +# ifdef Q_OS_MACOS # if !defined(__MAC_OS_X_VERSION_MIN_REQUIRED) || __MAC_OS_X_VERSION_MIN_REQUIRED < __MAC_10_6 # undef __MAC_OS_X_VERSION_MIN_REQUIRED # define __MAC_OS_X_VERSION_MIN_REQUIRED __MAC_10_6 @@ -243,6 +243,9 @@ # if !defined(__MAC_10_11) # define __MAC_10_11 101100 # endif +# if !defined(__MAC_10_12) +# define __MAC_10_12 101200 +# endif # if !defined(MAC_OS_X_VERSION_10_7) # define MAC_OS_X_VERSION_10_7 1070 # endif @@ -258,6 +261,9 @@ # if !defined(MAC_OS_X_VERSION_10_11) # define MAC_OS_X_VERSION_10_11 101100 # endif +# if !defined(MAC_OS_X_VERSION_10_12) +# define MAC_OS_X_VERSION_10_12 101200 +# endif # # if !defined(__IPHONE_4_3) # define __IPHONE_4_3 40300 @@ -298,6 +304,18 @@ # if !defined(__IPHONE_9_0) # define __IPHONE_9_0 90000 # endif +# if !defined(__IPHONE_9_1) +# define __IPHONE_9_1 90100 +# endif +# if !defined(__IPHONE_9_2) +# define __IPHONE_9_2 90200 +# endif +# if !defined(__IPHONE_9_3) +# define __IPHONE_9_3 90300 +# endif +# if !defined(__IPHONE_10_0) +# define __IPHONE_10_0 100000 +# endif #endif #ifdef __LSB_VERSION__ diff --git a/src/corelib/io/qfileselector.cpp b/src/corelib/io/qfileselector.cpp index 52ac414645..645d0fdc46 100644 --- a/src/corelib/io/qfileselector.cpp +++ b/src/corelib/io/qfileselector.cpp @@ -383,8 +383,12 @@ QStringList QFileSelectorPrivate::platformSelectors() # endif # endif QString productName = QSysInfo::productType(); +# ifdef Q_OS_MACOS + if (productName != QStringLiteral("osx")) + ret << QStringLiteral("osx"); // compatibility +# endif if (productName != QLatin1String("unknown")) - ret << productName; // "opensuse", "fedora", "osx", "ios", "blackberry", "android" + ret << productName; // "opensuse", "fedora", "macos", "ios", "blackberry", "android" #endif return ret; } -- cgit v1.2.3 From e85e7f4b81b285efa5875a3ebf239d2f7f4523d7 Mon Sep 17 00:00:00 2001 From: Oliver Wolff Date: Mon, 13 Jun 2016 13:36:38 +0200 Subject: Fixed developer build for MinGW 0 must not be used as a null pointer constant Change-Id: I082d0e99c105fb02980b9cf390e7f6e4c9ad0869 Reviewed-by: Thiago Macieira --- src/corelib/kernel/qabstracteventdispatcher.h | 3 ++- src/corelib/kernel/qmetaobject.h | 2 +- src/gui/image/qimage.h | 2 +- src/widgets/graphicsview/qgraphicsscene.h | 4 ++-- 4 files changed, 6 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/corelib/kernel/qabstracteventdispatcher.h b/src/corelib/kernel/qabstracteventdispatcher.h index eb357cefe5..27a4c1bdcb 100644 --- a/src/corelib/kernel/qabstracteventdispatcher.h +++ b/src/corelib/kernel/qabstracteventdispatcher.h @@ -105,7 +105,8 @@ public: void removeNativeEventFilter(QAbstractNativeEventFilter *filterObj); bool filterNativeEvent(const QByteArray &eventType, void *message, long *result); #if QT_DEPRECATED_SINCE(5, 0) - QT_DEPRECATED bool filterEvent(void *message) { return filterNativeEvent("", message, 0); } + QT_DEPRECATED bool filterEvent(void *message) + { return filterNativeEvent("", message, Q_NULLPTR); } #endif Q_SIGNALS: diff --git a/src/corelib/kernel/qmetaobject.h b/src/corelib/kernel/qmetaobject.h index 1a282d3261..d467ea9d68 100644 --- a/src/corelib/kernel/qmetaobject.h +++ b/src/corelib/kernel/qmetaobject.h @@ -181,7 +181,7 @@ private: // signature() has been renamed to methodSignature() in Qt 5. // Warning, that function returns a QByteArray; check the life time if // you convert to char*. - char *signature(struct renamedInQt5_warning_checkTheLifeTime * = 0) Q_DECL_EQ_DELETE; + char *signature(struct renamedInQt5_warning_checkTheLifeTime * = Q_NULLPTR) Q_DECL_EQ_DELETE; #endif static QMetaMethod fromSignalImpl(const QMetaObject *, void **); diff --git a/src/gui/image/qimage.h b/src/gui/image/qimage.h index d05044c44b..97c191c6c4 100644 --- a/src/gui/image/qimage.h +++ b/src/gui/image/qimage.h @@ -315,7 +315,7 @@ public: static QImage::Format toImageFormat(QPixelFormat format) Q_DECL_NOTHROW; #if QT_DEPRECATED_SINCE(5, 0) - QT_DEPRECATED inline QString text(const char* key, const char* lang=0) const; + QT_DEPRECATED inline QString text(const char *key, const char *lang = Q_NULLPTR) const; QT_DEPRECATED inline QList textList() const; QT_DEPRECATED inline QStringList textLanguages() const; QT_DEPRECATED inline QString text(const QImageTextKeyLang&) const; diff --git a/src/widgets/graphicsview/qgraphicsscene.h b/src/widgets/graphicsview/qgraphicsscene.h index c93db20716..89de5bedc5 100644 --- a/src/widgets/graphicsview/qgraphicsscene.h +++ b/src/widgets/graphicsview/qgraphicsscene.h @@ -153,7 +153,7 @@ public: #if QT_DEPRECATED_SINCE(5, 0) QT_DEPRECATED inline QGraphicsItem *itemAt(const QPointF &position) const { QList itemsAtPoint = items(position); - return itemsAtPoint.isEmpty() ? 0 : itemsAtPoint.first(); + return itemsAtPoint.isEmpty() ? Q_NULLPTR : itemsAtPoint.first(); } #endif QGraphicsItem *itemAt(const QPointF &pos, const QTransform &deviceTransform) const; @@ -167,7 +167,7 @@ public: #if QT_DEPRECATED_SINCE(5, 0) QT_DEPRECATED inline QGraphicsItem *itemAt(qreal x, qreal y) const { QList itemsAtPoint = items(QPointF(x, y)); - return itemsAtPoint.isEmpty() ? 0 : itemsAtPoint.first(); + return itemsAtPoint.isEmpty() ? Q_NULLPTR : itemsAtPoint.first(); } #endif inline QGraphicsItem *itemAt(qreal x, qreal y, const QTransform &deviceTransform) const -- cgit v1.2.3 From 5eda3cff5e18308f8d78d438e5aeb4e685c5f974 Mon Sep 17 00:00:00 2001 From: Palo Kisa Date: Fri, 20 May 2016 15:08:00 +0200 Subject: QIconLoader: Fix typo in directoryMatchesSize() For QIconDirInfo::Scalable directories condition for directoryMatchesSize was mistyped. In particular only the minSize was considered which could lead to false positive checks. [ChangeLog][QtGui][QIconLoaderEngine] Fixed theme lookup for scalable entries Change-Id: Ic7e06cc0a2e4be69e6633847cef8c2c5686378ea Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/gui/image/qiconloader.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/gui/image/qiconloader.cpp b/src/gui/image/qiconloader.cpp index 3ead72dfbb..c7f1f2beb4 100644 --- a/src/gui/image/qiconloader.cpp +++ b/src/gui/image/qiconloader.cpp @@ -403,7 +403,7 @@ static bool directoryMatchesSize(const QIconDirInfo &dir, int iconsize) return dir.size == iconsize; } else if (dir.type == QIconDirInfo::Scalable) { - return dir.size <= dir.maxSize && + return iconsize <= dir.maxSize && iconsize >= dir.minSize; } else if (dir.type == QIconDirInfo::Threshold) { -- cgit v1.2.3 From c165cbaef2ccff52225836baf3c3db64ebe128dc Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Thu, 9 Jun 2016 14:05:16 +0200 Subject: Remove unused macro: QT_DISTANCEFIELD_DEFAULT_TILESIZE Usage of this macro has been removed, and so can the macro. Task-number: QTBUG-52389 Change-Id: I28a5459e577b78f0f9907612893d6850848f405d Reviewed-by: Yoann Lopes --- src/gui/text/qdistancefield_p.h | 4 ---- 1 file changed, 4 deletions(-) (limited to 'src') diff --git a/src/gui/text/qdistancefield_p.h b/src/gui/text/qdistancefield_p.h index c376e93abe..85662d6ca6 100644 --- a/src/gui/text/qdistancefield_p.h +++ b/src/gui/text/qdistancefield_p.h @@ -52,7 +52,6 @@ QT_BEGIN_NAMESPACE #define QT_DISTANCEFIELD_DEFAULT_BASEFONTSIZE 54 -#define QT_DISTANCEFIELD_DEFAULT_TILESIZE 64 #define QT_DISTANCEFIELD_DEFAULT_SCALE 16 #define QT_DISTANCEFIELD_DEFAULT_RADIUS 80 #define QT_DISTANCEFIELD_HIGHGLYPHCOUNT 2000 @@ -60,9 +59,6 @@ QT_BEGIN_NAMESPACE #define QT_DISTANCEFIELD_BASEFONTSIZE(NarrowOutlineFont) \ (NarrowOutlineFont ? QT_DISTANCEFIELD_DEFAULT_BASEFONTSIZE * 2 : \ QT_DISTANCEFIELD_DEFAULT_BASEFONTSIZE) -#define QT_DISTANCEFIELD_TILESIZE(NarrowOutlineFont) \ - (NarrowOutlineFont ? QT_DISTANCEFIELD_DEFAULT_TILESIZE * 2 : \ - QT_DISTANCEFIELD_DEFAULT_TILESIZE) #define QT_DISTANCEFIELD_SCALE(NarrowOutlineFont) \ (NarrowOutlineFont ? QT_DISTANCEFIELD_DEFAULT_SCALE / 2 : \ QT_DISTANCEFIELD_DEFAULT_SCALE) -- cgit v1.2.3 From c2b7841843f05fe902e6a94aee2c3f33b169009e Mon Sep 17 00:00:00 2001 From: Eirik Aavitsland Date: Tue, 7 Jun 2016 16:52:13 +0200 Subject: Finally fix crash in inplace-modified data-constructed images Avoid all inplace modification of images using external data buffers. Since the QImage methods are documented to create a (modified) copy, there is afterwards no API requirement on the lifetime of the data buffer. This patch supersedes 509bc7e59c69937900cf258e64889a6e88edbcf0 Task-number: QTBUG-53721 Change-Id: I3ccc01619eb61d8630104449394e0b76df0af695 Reviewed-by: Friedemann Kleint Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/gui/image/qimage.cpp | 6 +++++- src/gui/image/qimage_conversions.cpp | 19 +++++++++---------- 2 files changed, 14 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp index 59a83a6750..d9f9c1a7ad 100644 --- a/src/gui/image/qimage.cpp +++ b/src/gui/image/qimage.cpp @@ -3115,6 +3115,8 @@ void QImage::mirrored_inplace(bool horizontal, bool vertical) return; detach(); + if (!d->own_data) + *this = copy(); do_mirror(d, d, horizontal, vertical); } @@ -3261,6 +3263,8 @@ void QImage::rgbSwapped_inplace() return; detach(); + if (!d->own_data) + *this = copy(); switch (d->format) { case Format_Invalid: @@ -4745,7 +4749,7 @@ bool QImageData::convertInPlace(QImage::Format newFormat, Qt::ImageConversionFla return true; // No in-place conversion if we have to detach - if (ref.load() > 1 || ro_data) + if (ref.load() > 1 || !own_data) return false; InPlace_Image_Converter converter = qimage_inplace_converter_map[format][newFormat]; diff --git a/src/gui/image/qimage_conversions.cpp b/src/gui/image/qimage_conversions.cpp index cc79e73534..7b8d88ba72 100644 --- a/src/gui/image/qimage_conversions.cpp +++ b/src/gui/image/qimage_conversions.cpp @@ -763,8 +763,8 @@ static bool convert_A2RGB30_PM_to_ARGB_inplace(QImageData *data, Qt::ImageConver static bool convert_indexed8_to_ARGB_PM_inplace(QImageData *data, Qt::ImageConversionFlags) { Q_ASSERT(data->format == QImage::Format_Indexed8); - if (!data->own_data) - return false; + Q_ASSERT(data->own_data); + const int depth = 32; const int dst_bytes_per_line = ((data->width * depth + 31) >> 5) << 2; @@ -817,8 +817,8 @@ static bool convert_indexed8_to_ARGB_PM_inplace(QImageData *data, Qt::ImageConve static bool convert_indexed8_to_ARGB_inplace(QImageData *data, Qt::ImageConversionFlags) { Q_ASSERT(data->format == QImage::Format_Indexed8); - if (!data->own_data) - return false; + Q_ASSERT(data->own_data); + const int depth = 32; const int dst_bytes_per_line = ((data->width * depth + 31) >> 5) << 2; @@ -868,8 +868,7 @@ static bool convert_indexed8_to_ARGB_inplace(QImageData *data, Qt::ImageConversi static bool convert_indexed8_to_RGB_inplace(QImageData *data, Qt::ImageConversionFlags flags) { Q_ASSERT(data->format == QImage::Format_Indexed8); - if (!data->own_data) - return false; + Q_ASSERT(data->own_data); if (data->has_alpha_clut) { for (int i = 0; i < data->colortable.size(); ++i) @@ -886,8 +885,8 @@ static bool convert_indexed8_to_RGB_inplace(QImageData *data, Qt::ImageConversio static bool convert_indexed8_to_RGB16_inplace(QImageData *data, Qt::ImageConversionFlags) { Q_ASSERT(data->format == QImage::Format_Indexed8); - if (!data->own_data) - return false; + Q_ASSERT(data->own_data); + const int depth = 16; const int dst_bytes_per_line = ((data->width * depth + 31) >> 5) << 2; @@ -943,8 +942,8 @@ static bool convert_indexed8_to_RGB16_inplace(QImageData *data, Qt::ImageConvers static bool convert_RGB_to_RGB16_inplace(QImageData *data, Qt::ImageConversionFlags) { Q_ASSERT(data->format == QImage::Format_RGB32); - if (!data->own_data) - return false; + Q_ASSERT(data->own_data); + const int depth = 16; const int dst_bytes_per_line = ((data->width * depth + 31) >> 5) << 2; -- cgit v1.2.3 From b07736c0bc5507e663463ff8f3e3bbb905e1acc9 Mon Sep 17 00:00:00 2001 From: James McDonnell Date: Thu, 9 Jun 2016 12:15:09 -0400 Subject: Correct a type mismatch in the QNX PPS code It's a problem when building for 64-bit where the two types no longer match. Change-Id: I8c31915caf81a60d635c79816a3a2d5d36742ff9 Reviewed-by: Dan Cape Reviewed-by: Oswald Buddenhagen Reviewed-by: Thiago Macieira --- src/corelib/kernel/qppsobject.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/corelib/kernel/qppsobject.cpp b/src/corelib/kernel/qppsobject.cpp index 76508f12c5..230b7dcae0 100644 --- a/src/corelib/kernel/qppsobject.cpp +++ b/src/corelib/kernel/qppsobject.cpp @@ -169,7 +169,7 @@ QPpsAttribute QPpsObjectPrivate::decodeNumber(pps_decoder_t *decoder) // In order to support more number types, we have to do something stupid because the PPS // library won't let us work any other way. Basically, we have to probe the encoded type in // order to try to get exactly what we want. - long long llValue; + int64_t llValue; double dValue; int iValue; QPpsAttribute::Flags flags; @@ -187,7 +187,7 @@ QPpsAttribute QPpsObjectPrivate::decodeNumber(pps_decoder_t *decoder) return QPpsAttribute(); } flags = readFlags(decoder); - return QPpsAttributePrivate::createPpsAttribute(llValue, flags); + return QPpsAttributePrivate::createPpsAttribute(static_cast(llValue), flags); default: qWarning() << "QPpsObjectPrivate::decodeNumber: pps_decoder_get_int failed"; return QPpsAttribute(); -- cgit v1.2.3 From 797cd4b7bc8e9864c2d569c110b61e49e15c80c2 Mon Sep 17 00:00:00 2001 From: Vyacheslav Koscheev Date: Thu, 2 Jun 2016 16:23:29 +0600 Subject: Android: Don't send tabletEvent when it's not supported If QT_NO_TABLETEVENT defined, then there is no sense to create tablet events. Its better to create general touch events in this case. Task-number: QTBUG-53887 Change-Id: I2fabc2241158d54d6c39a2f6071ab874f7debd39 Reviewed-by: Shawn Rutledge --- src/android/jar/src/org/qtproject/qt5/android/QtNative.java | 7 ++++++- src/plugins/platforms/android/androidjniinput.cpp | 12 ++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/android/jar/src/org/qtproject/qt5/android/QtNative.java b/src/android/jar/src/org/qtproject/qt5/android/QtNative.java index 14da281a76..e602a6deba 100644 --- a/src/android/jar/src/org/qtproject/qt5/android/QtNative.java +++ b/src/android/jar/src/org/qtproject/qt5/android/QtNative.java @@ -84,6 +84,7 @@ public class QtNative private static final int m_moveThreshold = 0; private static ClipboardManager m_clipboardManager = null; private static Method m_checkSelfPermissionMethod = null; + private static Boolean m_tabletEventSupported = null; private static ClassLoader m_classLoader = null; public static ClassLoader classLoader() @@ -343,6 +344,9 @@ public class QtNative { int pointerType = 0; + if (m_tabletEventSupported == null) + m_tabletEventSupported = isTabletEventSupported(); + if (Build.VERSION.SDK_INT >= 14) { switch (event.getToolType(0)) { case MotionEvent.TOOL_TYPE_STYLUS: @@ -355,7 +359,7 @@ public class QtNative } } - if (pointerType != 0) { + if (m_tabletEventSupported && pointerType != 0) { tabletEvent(id, event.getDeviceId(), event.getEventTime(), event.getAction(), pointerType, event.getButtonState(), event.getX(), event.getY(), event.getPressure()); } else { @@ -685,6 +689,7 @@ public class QtNative // pointer methods // tablet methods + public static native boolean isTabletEventSupported(); public static native void tabletEvent(int winId, int deviceId, long time, int action, int pointerType, int buttonState, float x, float y, float pressure); // tablet methods diff --git a/src/plugins/platforms/android/androidjniinput.cpp b/src/plugins/platforms/android/androidjniinput.cpp index 9cc5e95378..1687f9b48a 100644 --- a/src/plugins/platforms/android/androidjniinput.cpp +++ b/src/plugins/platforms/android/androidjniinput.cpp @@ -246,9 +246,19 @@ namespace QtAndroidInput QWindowSystemInterface::handleTouchEvent(window, touchDevice, m_touchPoints); } + static bool isTabletEventSupported(JNIEnv */*env*/, jobject /*thiz*/) + { +#ifdef QT_NO_TABLETEVENT + return false; +#else + return true; +#endif // QT_NO_TABLETEVENT + } + static void tabletEvent(JNIEnv */*env*/, jobject /*thiz*/, jint /*winId*/, jint deviceId, jlong time, jint action, jint pointerType, jint buttonState, jfloat x, jfloat y, jfloat pressure) { +#ifndef QT_NO_TABLETEVENT QPointF globalPosF(x, y); QPoint globalPos((int)x, (int)y); QWindow *tlw = topLevelWindowAt(globalPos); @@ -290,6 +300,7 @@ namespace QtAndroidInput QWindowSystemInterface::handleTabletEvent(tlw, ulong(time), localPos, globalPosF, QTabletEvent::Stylus, pointerType, buttons, pressure, 0, 0, 0., 0., 0, deviceId, Qt::NoModifier); +#endif // QT_NO_TABLETEVENT } static int mapAndroidKey(int key) @@ -777,6 +788,7 @@ namespace QtAndroidInput {"mouseUp", "(III)V", (void *)mouseUp}, {"mouseMove", "(III)V", (void *)mouseMove}, {"longPress", "(III)V", (void *)longPress}, + {"isTabletEventSupported", "()Z", (void *)isTabletEventSupported}, {"tabletEvent", "(IIJIIIFFF)V", (void *)tabletEvent}, {"keyDown", "(IIIZ)V", (void *)keyDown}, {"keyUp", "(IIIZ)V", (void *)keyUp}, -- cgit v1.2.3 From 5d31c9831da42ffb5f720b147d99be6d9eb93e30 Mon Sep 17 00:00:00 2001 From: Kaligin Sergey Date: Wed, 11 May 2016 14:46:47 +0300 Subject: QTreeView: fix keyboard navigation when using the right arrow key MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The visual column index needs to be replaced by the logical column index in QModelIndex::sibling() call in QTreeView::moveCursor() method. [ChangeLog][QtWidgets][QTreeView] Fixed a key navigation bug when the columns were reordered. Task-number: QTBUG-52793 Change-Id: I4dc89a2705966a94b20edd7f9a4422f089bb670f Reviewed-by: Thorbjørn Lund Martsum --- src/widgets/itemviews/qtreeview.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/widgets/itemviews/qtreeview.cpp b/src/widgets/itemviews/qtreeview.cpp index 135c417f15..01ebae0848 100644 --- a/src/widgets/itemviews/qtreeview.cpp +++ b/src/widgets/itemviews/qtreeview.cpp @@ -2314,8 +2314,8 @@ QModelIndex QTreeView::moveCursor(CursorAction cursorAction, Qt::KeyboardModifie int visualColumn = d->header->visualIndex(current.column()) + 1; while (visualColumn < d->model->columnCount(current.parent()) && isColumnHidden(d->header->logicalIndex(visualColumn))) visualColumn++; - - QModelIndex next = current.sibling(current.row(), visualColumn); + const int newColumn = d->header->logicalIndex(visualColumn); + const QModelIndex next = current.sibling(current.row(), newColumn); if (next.isValid()) return next; } -- cgit v1.2.3 From d53d77e66bbe44e6aa341818c938b5fbc042417f Mon Sep 17 00:00:00 2001 From: Alexander Volkov Date: Thu, 16 Jun 2016 14:01:14 +0300 Subject: TuioTouch: Report empty touch areas for the cursor Currently TuioTouch plugin reports touch areas of size 1x1. It's inconsistent with the platform plugins which report empty touch areas when their size is unknown. Change-Id: Iea8ad38a5712b666126780411380d963877b0229 Reviewed-by: Shawn Rutledge Reviewed-by: Ariel Molina R Reviewed-by: Robin Burchell --- src/plugins/generic/tuiotouch/qtuiohandler.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'src') diff --git a/src/plugins/generic/tuiotouch/qtuiohandler.cpp b/src/plugins/generic/tuiotouch/qtuiohandler.cpp index 4b4d08441f..92a2d99262 100644 --- a/src/plugins/generic/tuiotouch/qtuiohandler.cpp +++ b/src/plugins/generic/tuiotouch/qtuiohandler.cpp @@ -299,7 +299,6 @@ QWindowSystemInterface::TouchPoint QTuioHandler::cursorToTouchPoint(const QTuioC tp.normalPosition = m_transform.map(tp.normalPosition); tp.state = tc.state(); - tp.area = QRectF(0, 0, 1, 1); // we map the touch to the size of the window. we do this, because frankly, // trying to figure out which part of the screen to hit in order to press an -- cgit v1.2.3 From fc1092cfad06a843c24b64afeb0d928e4e318372 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Mon, 30 May 2016 10:30:51 +0200 Subject: correctly link xcb-static lib this apparently makes no difference except for not creating bogus .prl files - presumably, the correct path is coming from somewhere else already. Change-Id: Ia3f3c44e506ba14b533ff097f05acecf1e86cfb3 Reviewed-by: Laszlo Agocs --- .../platforms/xcb/gl_integrations/gl_integrations_plugin_base.pri | 2 +- src/plugins/platforms/xcb/xcb_qpa_lib.pro | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/xcb/gl_integrations/gl_integrations_plugin_base.pri b/src/plugins/platforms/xcb/gl_integrations/gl_integrations_plugin_base.pri index e859865687..c2d3849d8e 100644 --- a/src/plugins/platforms/xcb/gl_integrations/gl_integrations_plugin_base.pri +++ b/src/plugins/platforms/xcb/gl_integrations/gl_integrations_plugin_base.pri @@ -31,7 +31,7 @@ contains(QT_CONFIG, xcb-qt) { DEFINES += XCB_USE_RENDER XCB_DIR = $$clean_path($$PWD/../../../../3rdparty/xcb) INCLUDEPATH += $$XCB_DIR/include $$XCB_DIR/include/xcb $$XCB_DIR/sysinclude - LIBS += -lxcb -L$$OUT_PWD/xcb-static -lxcb-static + LIBS += -lxcb -L$$MODULE_BASE_OUTDIR/lib -lxcb-static$$qtPlatformTargetSuffix() } else { LIBS += -lxcb -lxcb-image -lxcb-icccm -lxcb-sync -lxcb-xfixes -lxcb-shm -lxcb-randr -lxcb-shape -lxcb-keysyms !contains(DEFINES, QT_NO_XKB):LIBS += -lxcb-xkb diff --git a/src/plugins/platforms/xcb/xcb_qpa_lib.pro b/src/plugins/platforms/xcb/xcb_qpa_lib.pro index f4a4e5a78a..db9ea32cd8 100644 --- a/src/plugins/platforms/xcb/xcb_qpa_lib.pro +++ b/src/plugins/platforms/xcb/xcb_qpa_lib.pro @@ -88,7 +88,7 @@ contains(QT_CONFIG, xcb-qt) { DEFINES += XCB_USE_RENDER XCB_DIR = ../../../3rdparty/xcb INCLUDEPATH += $$XCB_DIR/include $$XCB_DIR/sysinclude - LIBS += -lxcb -L$$OUT_PWD/xcb-static -lxcb-static + LIBS += -lxcb -L$$MODULE_BASE_OUTDIR/lib -lxcb-static$$qtPlatformTargetSuffix() } else { LIBS += -lxcb -lxcb-image -lxcb-icccm -lxcb-sync -lxcb-xfixes -lxcb-shm -lxcb-randr -lxcb-shape -lxcb-keysyms -lxcb-xinerama !contains(DEFINES, QT_NO_XKB):LIBS += -lxcb-xkb -- cgit v1.2.3 From 80a4f8b8678e1811bd6b8631d653d3bf54048df9 Mon Sep 17 00:00:00 2001 From: Anton Kudryavtsev Date: Fri, 17 Jun 2016 10:17:29 +0300 Subject: Fix compile QtGui with png support Add corresponding dependency to QtGui module. Task-number: QTBUG-53660 Change-Id: I719f0ff3d6a0208ad69139a8f64358536a718eed Reviewed-by: Oswald Buddenhagen --- src/src.pro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/src.pro b/src/src.pro index 585767361e..3d185408f8 100644 --- a/src/src.pro +++ b/src/src.pro @@ -170,7 +170,7 @@ contains(QT_CONFIG, concurrent):SUBDIRS += src_concurrent contains(QT_CONFIG, png) { SUBDIRS += src_3rdparty_libpng src_3rdparty_freetype.depends += src_3rdparty_libpng - src_plugins.depends += src_3rdparty_libpng + src_gui.depends += src_3rdparty_libpng } contains(QT_CONFIG, freetype) { SUBDIRS += src_3rdparty_freetype -- cgit v1.2.3 From 0b6adbcd234724edef747df4d17aa7a5bcf4381b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Wed, 1 Jun 2016 13:29:28 +0200 Subject: uikit: Deliver update requests via CADisplayLink callback Improves performance over the default timer-implementation, and allows us to control the rate and paused state of the display link. Change-Id: I05761b6eb48f5e91af35735e2faa477427cd8440 Reviewed-by: Richard Moe Gustavsen --- src/plugins/platforms/ios/qiosscreen.h | 5 +++ src/plugins/platforms/ios/qiosscreen.mm | 58 +++++++++++++++++++++++++++++++++ src/plugins/platforms/ios/qioswindow.h | 2 ++ src/plugins/platforms/ios/qioswindow.mm | 5 +++ 4 files changed, 70 insertions(+) (limited to 'src') diff --git a/src/plugins/platforms/ios/qiosscreen.h b/src/plugins/platforms/ios/qiosscreen.h index d6627c78cb..87e1cfb23f 100644 --- a/src/plugins/platforms/ios/qiosscreen.h +++ b/src/plugins/platforms/ios/qiosscreen.h @@ -65,9 +65,13 @@ public: UIScreen *uiScreen() const; UIWindow *uiWindow() const; + void setUpdatesPaused(bool); + void updateProperties(); private: + void deliverUpdateRequests() const; + UIScreen *m_uiScreen; UIWindow *m_uiWindow; QRect m_geometry; @@ -76,6 +80,7 @@ private: uint m_physicalDpi; QSizeF m_physicalSize; QIOSOrientationListener *m_orientationListener; + CADisplayLink *m_displayLink; }; QT_END_NAMESPACE diff --git a/src/plugins/platforms/ios/qiosscreen.mm b/src/plugins/platforms/ios/qiosscreen.mm index d9ec7008d3..4018a02f8d 100644 --- a/src/plugins/platforms/ios/qiosscreen.mm +++ b/src/plugins/platforms/ios/qiosscreen.mm @@ -40,8 +40,31 @@ #include "qiosviewcontroller.h" #include "quiview.h" +#include + #include +// ------------------------------------------------------------------------- + +typedef void (^DisplayLinkBlock)(CADisplayLink *displayLink); + +@implementation UIScreen (DisplayLinkBlock) +- (CADisplayLink*)displayLinkWithBlock:(DisplayLinkBlock)block +{ + return [self displayLinkWithTarget:[[block copy] autorelease] + selector:@selector(invokeDisplayLinkBlock:)]; +} +@end + +@implementation NSObject (DisplayLinkBlock) +- (void)invokeDisplayLinkBlock:(CADisplayLink *)sender +{ + DisplayLinkBlock block = static_cast(self); + block(sender); +} +@end + + // ------------------------------------------------------------------------- static QIOSScreen* qtPlatformScreenFor(UIScreen *uiScreen) @@ -208,10 +231,16 @@ QIOSScreen::QIOSScreen(UIScreen *screen) } updateProperties(); + + m_displayLink = [m_uiScreen displayLinkWithBlock:^(CADisplayLink *) { deliverUpdateRequests(); }]; + m_displayLink.paused = YES; // Enabled when clients call QWindow::requestUpdate() + [m_displayLink addToRunLoop:[NSRunLoop mainRunLoop] forMode:NSDefaultRunLoopMode]; } QIOSScreen::~QIOSScreen() { + [m_displayLink invalidate]; + [m_orientationListener release]; [m_uiWindow release]; } @@ -291,6 +320,35 @@ void QIOSScreen::updateProperties() QWindowSystemInterface::handleScreenGeometryChange(screen(), m_geometry, m_availableGeometry); } +void QIOSScreen::setUpdatesPaused(bool paused) +{ + m_displayLink.paused = paused; +} + +void QIOSScreen::deliverUpdateRequests() const +{ + bool pauseUpdates = true; + + QList windows = QGuiApplication::allWindows(); + for (int i = 0; i < windows.size(); ++i) { + if (platformScreenForWindow(windows.at(i)) != this) + continue; + + QWindowPrivate *wp = static_cast(QObjectPrivate::get(windows.at(i))); + if (!wp->updateRequestPending) + continue; + + wp->deliverUpdateRequest(); + + // Another update request was triggered, keep the display link running + if (wp->updateRequestPending) + pauseUpdates = false; + } + + // Pause the display link if there are no pending update requests + m_displayLink.paused = pauseUpdates; +} + QRect QIOSScreen::geometry() const { return m_geometry; diff --git a/src/plugins/platforms/ios/qioswindow.h b/src/plugins/platforms/ios/qioswindow.h index 0c65cf8aa5..c1c4cad01a 100644 --- a/src/plugins/platforms/ios/qioswindow.h +++ b/src/plugins/platforms/ios/qioswindow.h @@ -82,6 +82,8 @@ public: QSurfaceFormat format() const Q_DECL_OVERRIDE; + void requestUpdate() Q_DECL_OVERRIDE; + private: void applicationStateChanged(Qt::ApplicationState state); void applyGeometry(const QRect &rect); diff --git a/src/plugins/platforms/ios/qioswindow.mm b/src/plugins/platforms/ios/qioswindow.mm index 3045a15380..42609fd983 100644 --- a/src/plugins/platforms/ios/qioswindow.mm +++ b/src/plugins/platforms/ios/qioswindow.mm @@ -371,6 +371,11 @@ void QIOSWindow::clearAccessibleCache() [m_view clearAccessibleCache]; } +void QIOSWindow::requestUpdate() +{ + static_cast(screen())->setUpdatesPaused(false); +} + #include "moc_qioswindow.cpp" QT_END_NAMESPACE -- cgit v1.2.3 From 655687d84d6a5914227f2580889e20b7e1b31095 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Wed, 1 Jun 2016 13:29:24 +0200 Subject: UIKit: Don't reallocate renderbuffer on QIOSContext::swapBuffers() During device rotation, the backing CEAGLLayer of our custom UIView is resized by the system. Normally this is the time where we would then reconfigure the corresponding renderbuffer that we render to, which shares memory with the CEAGLLayer, but we chose a lazy approach where we'd defer the reconfigure until client code actually called makeCurrent. This caused problems because not only did we implement the lazy reconfig in makeCurrent, but in every QIOSContext function that operated on the default FBO, including swapBuffers(). When using threaded rendering, such as in Qt Quick, the render thread may be half way in rendering a new frame when the system resizes the CEAGLLayer, and we pick up that resize on the swapBuffer call and allocate a new renderbuffer, before flushing the queued up GL commands that were operating on another renderbuffer of a different size. This resulted in the following crash: 0 - gpus_ReturnObjectErrorKillClient() 1 - gpusSubmitDataBuffers() 2 - glrFlushContextToken() 3 - flush(__GLIContextRec*)() 4 - QIOSContext::swapBuffers(QPlatformSurface*) ... We solve this by still being lazy in how we reconfigure, but limit the reconfigure to makeCurrent(). If the CEAGLLayer is resized in between two frames, we skip the half-drawn frame. The old frame will then be scaled to match the new size by the system, but this is preferable to flushing a new frame that may have been drawn with two conflicting window geometries. Task-number: QTBUG-50017 Change-Id: Ie229f26d156dfbfc7ed8d9efd0eb5e992eee73f1 Reviewed-by: Richard Moe Gustavsen --- src/plugins/platforms/ios/qioscontext.h | 5 +- src/plugins/platforms/ios/qioscontext.mm | 154 ++++++++++++++++++------------- src/plugins/platforms/ios/qioswindow.h | 2 + src/plugins/platforms/ios/qioswindow.mm | 6 ++ 4 files changed, 100 insertions(+), 67 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/ios/qioscontext.h b/src/plugins/platforms/ios/qioscontext.h index ec678fee44..a95856aee1 100644 --- a/src/plugins/platforms/ios/qioscontext.h +++ b/src/plugins/platforms/ios/qioscontext.h @@ -34,6 +34,7 @@ #ifndef QIOSCONTEXT_H #define QIOSCONTEXT_H +#include #include @class EAGLContext; @@ -83,7 +84,9 @@ private: static void deleteBuffers(const FramebufferObject &framebufferObject); FramebufferObject &backingFramebufferObjectFor(QPlatformSurface *) const; - mutable QHash m_framebufferObjects; + mutable QHash m_framebufferObjects; + + bool needsRenderbufferResize(QPlatformSurface *) const; }; QT_END_NAMESPACE diff --git a/src/plugins/platforms/ios/qioscontext.mm b/src/plugins/platforms/ios/qioscontext.mm index 8bdb4bcdb3..e76a2b9902 100644 --- a/src/plugins/platforms/ios/qioscontext.mm +++ b/src/plugins/platforms/ios/qioscontext.mm @@ -42,6 +42,8 @@ #import #import +Q_LOGGING_CATEGORY(lcQpaGLContext, "qt.qpa.glcontext"); + QIOSContext::QIOSContext(QOpenGLContext *context) : QPlatformOpenGLContext() , m_sharedContext(static_cast(context->shareHandle())) @@ -75,6 +77,8 @@ QIOSContext::QIOSContext(QOpenGLContext *context) // could take advantage of the unchanged buffer, but this means clients (and Qt) // will also assume that swapBufferes() is not needed, which is _not_ the case. m_format.setSwapBehavior(QSurfaceFormat::DoubleBuffer); + + qCDebug(lcQpaGLContext) << "created context with format" << m_format << "shared with" << m_sharedContext; } QIOSContext::~QIOSContext() @@ -117,10 +121,12 @@ static QString fboStatusString(GLenum status) } } +#define Q_ASSERT_IS_GL_SURFACE(surface) \ + Q_ASSERT(surface && (surface->surface()->surfaceType() & (QSurface::OpenGLSurface | QSurface::RasterGLSurface))) + bool QIOSContext::makeCurrent(QPlatformSurface *surface) { - Q_ASSERT(surface && (surface->surface()->surfaceType() == QSurface::OpenGLSurface - || surface->surface()->surfaceType() == QSurface::RasterGLSurface)); + Q_ASSERT_IS_GL_SURFACE(surface); [EAGLContext setCurrentContext:m_eaglContext]; @@ -128,54 +134,11 @@ bool QIOSContext::makeCurrent(QPlatformSurface *surface) if (surface->surface()->surfaceClass() == QSurface::Offscreen) return true; + Q_ASSERT(surface->surface()->surfaceClass() == QSurface::Window); FramebufferObject &framebufferObject = backingFramebufferObjectFor(surface); - // We bind the default FBO even if it's incomplete, so that clients who - // call glCheckFramebufferStatus as a result of this function returning - // false will get a matching error code. - glBindFramebuffer(GL_FRAMEBUFFER, framebufferObject.handle); - - return framebufferObject.isComplete; -} - -void QIOSContext::doneCurrent() -{ - [EAGLContext setCurrentContext:nil]; -} - -void QIOSContext::swapBuffers(QPlatformSurface *surface) -{ - Q_ASSERT(surface && (surface->surface()->surfaceType() == QSurface::OpenGLSurface - || surface->surface()->surfaceType() == QSurface::RasterGLSurface)); - - if (surface->surface()->surfaceClass() == QSurface::Offscreen) - return; // Nothing to do - - FramebufferObject &framebufferObject = backingFramebufferObjectFor(surface); - - [EAGLContext setCurrentContext:m_eaglContext]; - glBindRenderbuffer(GL_RENDERBUFFER, framebufferObject.colorRenderbuffer); - [m_eaglContext presentRenderbuffer:GL_RENDERBUFFER]; -} - -QIOSContext::FramebufferObject &QIOSContext::backingFramebufferObjectFor(QPlatformSurface *surface) const -{ - // We keep track of default-FBOs in the root context of a share-group. This assumes - // that the contexts form a tree, where leaf nodes are always destroyed before their - // parents. If that assumption (based on the current implementation) doesn't hold we - // should probably use QOpenGLMultiGroupSharedResource to track the shared default-FBOs. - if (m_sharedContext) - return m_sharedContext->backingFramebufferObjectFor(surface); - - Q_ASSERT(surface && surface->surface()->surfaceClass() == QSurface::Window); - QIOSWindow *window = static_cast(surface); - - FramebufferObject &framebufferObject = m_framebufferObjects[window]; - - // Set up an FBO for the window if it hasn't been created yet if (!framebufferObject.handle) { - [EAGLContext setCurrentContext:m_eaglContext]; - + // Set up an FBO for the window if it hasn't been created yet glGenFramebuffers(1, &framebufferObject.handle); glBindFramebuffer(GL_FRAMEBUFFER, framebufferObject.handle); @@ -195,17 +158,17 @@ QIOSContext::FramebufferObject &QIOSContext::backingFramebufferObjectFor(QPlatfo framebufferObject.depthRenderbuffer); } - connect(window, SIGNAL(destroyed(QObject*)), this, SLOT(windowDestroyed(QObject*))); + connect(static_cast(surface), SIGNAL(destroyed(QObject*)), this, SLOT(windowDestroyed(QObject*))); + } else { + glBindFramebuffer(GL_FRAMEBUFFER, framebufferObject.handle); } - // Ensure that the FBO's buffers match the size of the layer - UIView *view = reinterpret_cast(window->winId()); - CAEAGLLayer *layer = static_cast(view.layer); - if (framebufferObject.renderbufferWidth != (layer.frame.size.width * layer.contentsScale) || - framebufferObject.renderbufferHeight != (layer.frame.size.height * layer.contentsScale)) { - - [EAGLContext setCurrentContext:m_eaglContext]; - glBindFramebuffer(GL_FRAMEBUFFER, framebufferObject.handle); + if (needsRenderbufferResize(surface)) { + // Ensure that the FBO's buffers match the size of the layer + CAEAGLLayer *layer = static_cast(surface)->eaglLayer(); + qCDebug(lcQpaGLContext, "Reallocating renderbuffer storage - current: %dx%d, layer: %gx%g", + framebufferObject.renderbufferWidth, framebufferObject.renderbufferHeight, + layer.frame.size.width * layer.contentsScale, layer.frame.size.height * layer.contentsScale); glBindRenderbuffer(GL_RENDERBUFFER, framebufferObject.colorRenderbuffer); [m_eaglContext renderbufferStorage:GL_RENDERBUFFER fromDrawable:layer]; @@ -228,12 +191,49 @@ QIOSContext::FramebufferObject &QIOSContext::backingFramebufferObjectFor(QPlatfo framebufferObject.isComplete = glCheckFramebufferStatus(GL_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE; if (!framebufferObject.isComplete) { - qWarning("QIOSContext failed to make complete framebuffer object (%s)", + qCWarning(lcQpaGLContext, "QIOSContext failed to make complete framebuffer object (%s)", qPrintable(fboStatusString(glCheckFramebufferStatus(GL_FRAMEBUFFER)))); } } - return framebufferObject; + return framebufferObject.isComplete; +} + +void QIOSContext::doneCurrent() +{ + [EAGLContext setCurrentContext:nil]; +} + +void QIOSContext::swapBuffers(QPlatformSurface *surface) +{ + Q_ASSERT_IS_GL_SURFACE(surface); + + if (surface->surface()->surfaceClass() == QSurface::Offscreen) + return; // Nothing to do + + FramebufferObject &framebufferObject = backingFramebufferObjectFor(surface); + Q_ASSERT_X(framebufferObject.isComplete, "QIOSContext", "swapBuffers on incomplete FBO"); + + if (needsRenderbufferResize(surface)) { + qCWarning(lcQpaGLContext, "CAEAGLLayer was resized between makeCurrent and swapBuffers, skipping flush"); + return; + } + + [EAGLContext setCurrentContext:m_eaglContext]; + glBindRenderbuffer(GL_RENDERBUFFER, framebufferObject.colorRenderbuffer); + [m_eaglContext presentRenderbuffer:GL_RENDERBUFFER]; +} + +QIOSContext::FramebufferObject &QIOSContext::backingFramebufferObjectFor(QPlatformSurface *surface) const +{ + // We keep track of default-FBOs in the root context of a share-group. This assumes + // that the contexts form a tree, where leaf nodes are always destroyed before their + // parents. If that assumption (based on the current implementation) doesn't hold we + // should probably use QOpenGLMultiGroupSharedResource to track the shared default-FBOs. + if (m_sharedContext) + return m_sharedContext->backingFramebufferObjectFor(surface); + else + return m_framebufferObjects[surface]; } GLuint QIOSContext::defaultFramebufferObject(QPlatformSurface *surface) const @@ -245,19 +245,41 @@ GLuint QIOSContext::defaultFramebufferObject(QPlatformSurface *surface) const return 0; } - return backingFramebufferObjectFor(surface).handle; + FramebufferObject &framebufferObject = backingFramebufferObjectFor(surface); + Q_ASSERT_X(framebufferObject.handle, "QIOSContext", "can't resolve default FBO before makeCurrent"); + + return framebufferObject.handle; +} + +bool QIOSContext::needsRenderbufferResize(QPlatformSurface *surface) const +{ + Q_ASSERT(surface->surface()->surfaceClass() == QSurface::Window); + + FramebufferObject &framebufferObject = backingFramebufferObjectFor(surface); + CAEAGLLayer *layer = static_cast(surface)->eaglLayer(); + + if (framebufferObject.renderbufferWidth != (layer.frame.size.width * layer.contentsScale)) + return true; + + if (framebufferObject.renderbufferHeight != (layer.frame.size.height * layer.contentsScale)) + return true; + + return false; } void QIOSContext::windowDestroyed(QObject *object) { QIOSWindow *window = static_cast(object); - if (m_framebufferObjects.contains(window)) { - EAGLContext *originalContext = [EAGLContext currentContext]; - [EAGLContext setCurrentContext:m_eaglContext]; - deleteBuffers(m_framebufferObjects[window]); - m_framebufferObjects.remove(window); - [EAGLContext setCurrentContext:originalContext]; - } + if (!m_framebufferObjects.contains(window)) + return; + + qCDebug(lcQpaGLContext) << object << "destroyed, deleting corresponding FBO"; + + EAGLContext *originalContext = [EAGLContext currentContext]; + [EAGLContext setCurrentContext:m_eaglContext]; + deleteBuffers(m_framebufferObjects[window]); + m_framebufferObjects.remove(window); + [EAGLContext setCurrentContext:originalContext]; } QFunctionPointer QIOSContext::getProcAddress(const QByteArray& functionName) diff --git a/src/plugins/platforms/ios/qioswindow.h b/src/plugins/platforms/ios/qioswindow.h index c1c4cad01a..8d8a1fd0f7 100644 --- a/src/plugins/platforms/ios/qioswindow.h +++ b/src/plugins/platforms/ios/qioswindow.h @@ -84,6 +84,8 @@ public: void requestUpdate() Q_DECL_OVERRIDE; + CAEAGLLayer *eaglLayer() const; + private: void applicationStateChanged(Qt::ApplicationState state); void applyGeometry(const QRect &rect); diff --git a/src/plugins/platforms/ios/qioswindow.mm b/src/plugins/platforms/ios/qioswindow.mm index 42609fd983..6723181c34 100644 --- a/src/plugins/platforms/ios/qioswindow.mm +++ b/src/plugins/platforms/ios/qioswindow.mm @@ -376,6 +376,12 @@ void QIOSWindow::requestUpdate() static_cast(screen())->setUpdatesPaused(false); } +CAEAGLLayer *QIOSWindow::eaglLayer() const +{ + Q_ASSERT([m_view.layer isKindOfClass:[CAEAGLLayer class]]); + return static_cast(m_view.layer); +} + #include "moc_qioswindow.cpp" QT_END_NAMESPACE -- cgit v1.2.3 From 3e4f885f0c8f9d4e951241459d310ed977936806 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Thu, 16 Jun 2016 15:39:33 +0200 Subject: UIKit: Ensure that Qt's application state is initialized at startup Using dispatch_async to deliver the initial application state at startup was broken, as that would leave the application in the default application state, inactive, until the next runloop pass. This became a problem when an application was started backgrounded, eg. in response to location updates or a Bluetooth accessory waking it up, as it would have a small window of time at startup where it would think it was able to render content (since the window was exposed), while in fact the application was running in the background. iOS will in these situations kill the app for doing background rendering. Change-Id: I1ab4a6af08a154d8625c6451b4b5c8f4453e6b43 Reviewed-by: Richard Moe Gustavsen --- src/plugins/platforms/ios/qiosapplicationstate.h | 7 +- src/plugins/platforms/ios/qiosapplicationstate.mm | 134 +++++++--------------- 2 files changed, 46 insertions(+), 95 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/ios/qiosapplicationstate.h b/src/plugins/platforms/ios/qiosapplicationstate.h index 0564533043..710621c65b 100644 --- a/src/plugins/platforms/ios/qiosapplicationstate.h +++ b/src/plugins/platforms/ios/qiosapplicationstate.h @@ -35,10 +35,11 @@ #define QIOSAPPLICATIONSTATE_H #include +#include -QT_BEGIN_NAMESPACE +Q_FORWARD_DECLARE_OBJC_CLASS(NSObject); -@class QIOSApplicationStateListener; +QT_BEGIN_NAMESPACE class QIOSApplicationState { @@ -46,7 +47,7 @@ public: QIOSApplicationState(); ~QIOSApplicationState(); private: - QIOSApplicationStateListener *m_listener; + QVector m_observers; }; QT_END_NAMESPACE diff --git a/src/plugins/platforms/ios/qiosapplicationstate.mm b/src/plugins/platforms/ios/qiosapplicationstate.mm index 7a37e213bd..70a4c8a507 100644 --- a/src/plugins/platforms/ios/qiosapplicationstate.mm +++ b/src/plugins/platforms/ios/qiosapplicationstate.mm @@ -36,100 +36,21 @@ #include #include -#import - -@interface QIOSApplicationStateListener : NSObject -@end +#include -@implementation QIOSApplicationStateListener - -- (id)init -{ - self = [super init]; - if (self) { - // Listen for application state changes. - // Note: We use notifications rather than application delegate callbacks to - // also support hybrid applications were QIOSApplicationDelegate is not in use. - [[NSNotificationCenter defaultCenter] - addObserver:self - selector:@selector(applicationDidBecomeActive) - name:UIApplicationDidBecomeActiveNotification - object:nil]; - [[NSNotificationCenter defaultCenter] - addObserver:self - selector:@selector(applicationWillResignActive) - name:UIApplicationWillResignActiveNotification - object:nil]; - [[NSNotificationCenter defaultCenter] - addObserver:self - selector:@selector(applicationDidEnterBackground) - name:UIApplicationDidEnterBackgroundNotification - object:nil]; - - // Update the current state now, since we have missed all the updates - // posted from AppKit so far. But let QPA finish initialization first. - dispatch_async(dispatch_get_main_queue(), ^{ - [self handleApplicationStateChanged:[UIApplication sharedApplication].applicationState]; - }); - } - return self; -} - -- (void)dealloc -{ - [[NSNotificationCenter defaultCenter] - removeObserver:self - name:UIApplicationDidBecomeActiveNotification - object:nil]; - [[NSNotificationCenter defaultCenter] - removeObserver:self - name:UIApplicationWillResignActiveNotification - object:nil]; - [[NSNotificationCenter defaultCenter] - removeObserver:self - name:UIApplicationDidEnterBackgroundNotification - object:nil]; - [super dealloc]; -} - -- (void)applicationDidBecomeActive -{ - [self handleApplicationStateChanged:UIApplicationStateActive]; -} - -- (void)applicationWillResignActive -{ - // Note that UIApplication is still UIApplicationStateActive at this - // point, but since there is no separate notification for the inactive - // state, we report UIApplicationStateInactive now: - [self handleApplicationStateChanged:UIApplicationStateInactive]; -} - -- (void)applicationDidEnterBackground -{ - [self handleApplicationStateChanged:UIApplicationStateBackground]; -} +#import -- (void)handleApplicationStateChanged:(UIApplicationState)uiApplicationState +static Qt::ApplicationState qtApplicationState(UIApplicationState uiApplicationState) { - // We may receive application state changes after QCoreApplication has - // gone down, as the block we schedule on the main queue keeps the - // listener alive. In that case we just ignore the notification. - if (!qApp) - return; - - Qt::ApplicationState state; switch (uiApplicationState) { case UIApplicationStateActive: - // The application is visible in front, and receiving events: - state = Qt::ApplicationActive; - break; + // The application is visible in front, and receiving events + return Qt::ApplicationActive; case UIApplicationStateInactive: // The app is running in the foreground but is not receiving events. This // typically happens while transitioning to/from active/background, like - // upon app launch or when receiving incoming calls: - state = Qt::ApplicationInactive; - break; + // upon app launch or when receiving incoming calls. + return Qt::ApplicationInactive; case UIApplicationStateBackground: // Normally the app would enter this state briefly before it gets // suspeded (you have five seconds, according to Apple). @@ -138,25 +59,54 @@ // API for doing that yet, we handle this state as "about to be suspended". // Note: A screen-shot for the SpringBoard will also be taken after this // call returns. - state = Qt::ApplicationSuspended; - break; + return Qt::ApplicationSuspended; } +} + +static void handleApplicationStateChanged(UIApplicationState uiApplicationState) +{ + Qt::ApplicationState state = qtApplicationState(uiApplicationState); QWindowSystemInterface::handleApplicationStateChanged(state); QWindowSystemInterface::flushWindowSystemEvents(); } -@end - QT_BEGIN_NAMESPACE QIOSApplicationState::QIOSApplicationState() - : m_listener([[QIOSApplicationStateListener alloc] init]) { + NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; + + m_observers.push_back([notificationCenter addObserverForName:UIApplicationDidBecomeActiveNotification + object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *) { + handleApplicationStateChanged(UIApplicationStateActive); + } + ]); + + m_observers.push_back([notificationCenter addObserverForName:UIApplicationWillResignActiveNotification + object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *) { + // Note: UIApplication is still UIApplicationStateActive at this point, + // but since there is no separate notification for the inactive state, + // we report UIApplicationStateInactive now. + handleApplicationStateChanged(UIApplicationStateInactive); + } + ]); + + m_observers.push_back([notificationCenter addObserverForName:UIApplicationDidEnterBackgroundNotification + object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *) { + handleApplicationStateChanged(UIApplicationStateBackground); + } + ]); + + // Initialize correct startup state, which may not be the Qt default (inactive) + UIApplicationState startupState = [UIApplication sharedApplication].applicationState; + QGuiApplicationPrivate::applicationState = qtApplicationState(startupState); } QIOSApplicationState::~QIOSApplicationState() { - [m_listener release]; + NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; + foreach (const NSObject* observer, m_observers) + [notificationCenter removeObserver:observer]; } QT_END_NAMESPACE -- cgit v1.2.3 From d2bffe0fc9461f7cbbaf639bfc76050f4de8a46f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Thu, 16 Jun 2016 16:28:20 +0200 Subject: UIKit: Detect swapBuffers on non-exposed windows and skip flush When using threaded rendering the render-thread might be half-way into rendering a frame when the application is backgrounded, resulting in the following swap happening on a non-exposed window. This may result in the system killing the application, as rendering is not supposed to happen when an application is backgrounded, so we skip the flush. Change-Id: I9ab8f2c4617391fd827558af9fb473f1734b3688 Reviewed-by: Richard Moe Gustavsen --- src/plugins/platforms/ios/qioscontext.mm | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src') diff --git a/src/plugins/platforms/ios/qioscontext.mm b/src/plugins/platforms/ios/qioscontext.mm index e76a2b9902..eeb07b2796 100644 --- a/src/plugins/platforms/ios/qioscontext.mm +++ b/src/plugins/platforms/ios/qioscontext.mm @@ -211,6 +211,11 @@ void QIOSContext::swapBuffers(QPlatformSurface *surface) if (surface->surface()->surfaceClass() == QSurface::Offscreen) return; // Nothing to do + if (!static_cast(surface)->isExposed()) { + qCWarning(lcQpaGLContext, "Detected swapBuffers on a non-exposed window, skipping flush"); + return; + } + FramebufferObject &framebufferObject = backingFramebufferObjectFor(surface); Q_ASSERT_X(framebufferObject.isComplete, "QIOSContext", "swapBuffers on incomplete FBO"); -- cgit v1.2.3 From 2a6961f188bd8c9da38c76c121ca3b1bfc6c51bf Mon Sep 17 00:00:00 2001 From: Liang Qi Date: Fri, 17 Jun 2016 16:18:06 +0200 Subject: eglfs_kms_egldevice: fix warnings about -Werror=maybe-uninitialized MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldeviceintegration.cpp: In member function ‘bool QEglFSKmsEglDeviceIntegration::setup_kms()’: src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldeviceintegration.cpp:391:28: error: ‘encoder’ may be used uninitialized in this function [-Werror=maybe-uninitialized] m_drm_encoder = encoder; ^ src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldeviceintegration.cpp:392:29: error: ‘connector’ may be used uninitialized in this function [-Werror=maybe-uninitialized] m_drm_mode = connector->modes[0]; ^ cc1plus: all warnings being treated as errors Change-Id: Ic444450d06a6dd8047bd6871febb08a4a3fde6f9 Reviewed-by: Simon Hausmann --- .../eglfs_kms_egldevice/qeglfskmsegldeviceintegration.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldeviceintegration.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldeviceintegration.cpp index 5c7b9fe96d..ffb701f8ea 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldeviceintegration.cpp +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldeviceintegration.cpp @@ -337,8 +337,8 @@ bool QEglFSKmsEglDeviceIntegration::supportsSurfacelessContexts() const bool QEglFSKmsEglDeviceIntegration::setup_kms() { drmModeRes *resources; - drmModeConnector *connector; - drmModeEncoder *encoder; + drmModeConnector *connector = Q_NULLPTR; + drmModeEncoder *encoder = Q_NULLPTR; quint32 crtc = 0; int i; -- cgit v1.2.3 From 3238b435976f33791f46fd4a24e201fd3ce929e7 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 15 Jun 2016 16:05:48 -0700 Subject: Fix build on macOS: Apple changed their minds if null is allowed qcorewlanengine.mm:88:37: error: null passed to a callee that requires a non-null argument [-Werror,-Wnonnull] currentInterface = [CWInterface interfaceWithName:nil]; ^ ~~~ Change-Id: Ie7d159a97176ca53161423cfcddba547e735d5b3 Reviewed-by: Jake Petroules Reviewed-by: Thiago Macieira --- src/plugins/bearer/corewlan/qcorewlanengine.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/plugins/bearer/corewlan/qcorewlanengine.mm b/src/plugins/bearer/corewlan/qcorewlanengine.mm index d89078465b..7fdb91edae 100644 --- a/src/plugins/bearer/corewlan/qcorewlanengine.mm +++ b/src/plugins/bearer/corewlan/qcorewlanengine.mm @@ -79,7 +79,7 @@ extern "C" { // Otherwise it won't find CWKeychain* symbols at link time [locker lock]; QMacAutoReleasePool pool; notificationCenter = [NSNotificationCenter defaultCenter]; - currentInterface = [CWInterface interfaceWithName:nil]; + currentInterface = [CWInterface interface]; [notificationCenter addObserver:self selector:@selector(notificationHandler:) name:CWPowerDidChangeNotification object:nil]; [locker unlock]; return self; -- cgit v1.2.3 From 691b8678954c64b1b371d782703fc6ebdfc37a68 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 16 Jun 2016 17:14:07 -0700 Subject: Fix warning about non-void function not returning anything Found by ICC 17 Beta on Windows. Change-Id: Ib57b52598e2f452985e9fffd1458b6990b70837a Reviewed-by: Robin Burchell --- src/corelib/kernel/qcoreapplication.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'src') diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index 7bb2e7a78c..78ec004fc9 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -2144,7 +2144,6 @@ QString QCoreApplication::applicationFilePath() QCoreApplicationPrivate::setApplicationFilePath(fi.canonicalFilePath()); return *QCoreApplicationPrivate::cachedApplicationFilePath; } - return QString(); } #endif #if defined( Q_OS_UNIX ) @@ -2190,9 +2189,8 @@ QString QCoreApplication::applicationFilePath() } } - return QString(); #endif - Q_UNREACHABLE(); + return QString(); } /*! -- cgit v1.2.3 From 6da32c780622385e5844e82e5ce6c09f7203b7bf Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 16 Jun 2016 16:57:41 -0700 Subject: Fix compiler warning about missing return statement in non-void function MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Found by ICC 17 Beta on Windows. This commit also removes the "default" cause from the switch, which will make compilers let us know if we add another enum but don't handle it in the switch. Change-Id: Ib57b52598e2f452985e9fffd1458b5b39b238db7 Reviewed-by: Tor Arne Vestbø --- src/gui/kernel/qshortcutmap.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/gui/kernel/qshortcutmap.cpp b/src/gui/kernel/qshortcutmap.cpp index 3b40aba49e..6c19eab287 100644 --- a/src/gui/kernel/qshortcutmap.cpp +++ b/src/gui/kernel/qshortcutmap.cpp @@ -353,9 +353,9 @@ bool QShortcutMap::tryShortcut(QKeyEvent *e) // shouldn't say that we handled the event. return identicalMatches > 0; } - default: - Q_UNREACHABLE(); } + Q_UNREACHABLE(); + return false; } /*! \internal -- cgit v1.2.3 From ee2eed350f95285b65e3dd9647e5f366e16fd5a4 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Fri, 17 Jun 2016 11:53:05 +0200 Subject: Remove overload tag from QByteArray QIODevice::readAll() This does not seem to be a function that is overloaded. Change-Id: Icf8942dfb1e78a2ddb38cbd1c49657f745a61989 Reviewed-by: Alex Trotsenko Reviewed-by: Thiago Macieira --- src/corelib/io/qiodevice.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'src') diff --git a/src/corelib/io/qiodevice.cpp b/src/corelib/io/qiodevice.cpp index 3c7a7d69e4..eba38d06d6 100644 --- a/src/corelib/io/qiodevice.cpp +++ b/src/corelib/io/qiodevice.cpp @@ -971,8 +971,6 @@ QByteArray QIODevice::read(qint64 maxSize) } /*! - \overload - Reads all remaining data from the device, and returns it as a byte array. -- cgit v1.2.3 From ffe8db538f9d190c84bf56f024b876de518affa5 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 17 Jun 2016 14:51:29 -0700 Subject: Fix ICC warning about comparing pointers of different types error #3781: comparing a pointer to void and a pointer to a function is nonstandard Change-Id: Ib57b52598e2f452985e9fffd1458fd651d3985d2 Reviewed-by: Lars Knoll --- src/plugins/platforms/windows/qwindowsglcontext.cpp | 16 ++++++++-------- src/plugins/platforms/windows/qwindowsglcontext.h | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/windows/qwindowsglcontext.cpp b/src/plugins/platforms/windows/qwindowsglcontext.cpp index cc2f05b6d1..0a2d30319e 100644 --- a/src/plugins/platforms/windows/qwindowsglcontext.cpp +++ b/src/plugins/platforms/windows/qwindowsglcontext.cpp @@ -149,12 +149,12 @@ QT_BEGIN_NAMESPACE QWindowsOpengl32DLL QOpenGLStaticContext::opengl32; -void *QWindowsOpengl32DLL::resolve(const char *name) +PROC QWindowsOpengl32DLL::resolve(const char *name) { #ifndef Q_OS_WINCE - void *proc = m_lib ? (void *) ::GetProcAddress(m_lib, name) : 0; + PROC proc = m_lib ? ::GetProcAddress(m_lib, name) : 0; #else - void *proc = m_lib ? (void *) ::GetProcAddress(m_lib, (const wchar_t *) QString::fromLatin1(name).utf16()) : 0; + PROC proc = m_lib ? ::GetProcAddress(m_lib, (const wchar_t *) QString::fromLatin1(name).utf16()) : 0; #endif return proc; @@ -1339,21 +1339,21 @@ QFunctionPointer QWindowsGLContext::getProcAddress(const char *procName) // Even though we use QFunctionPointer, it does not mean the function can be called. // It will need to be cast to the proper function type with the correct calling // convention. QFunctionPointer is nothing more than a glorified void* here. - QFunctionPointer procAddress = reinterpret_cast(QOpenGLStaticContext::opengl32.wglGetProcAddress(procName)); + PROC procAddress = QOpenGLStaticContext::opengl32.wglGetProcAddress(procName); // We support AllGLFunctionsQueryable, which means this function must be able to // return a function pointer even for functions that are in GL.h and exported // normally from opengl32.dll. wglGetProcAddress() is not guaranteed to work for such // functions, however in QT_OPENGL_DYNAMIC builds QOpenGLFunctions will just blindly // call into here for _any_ OpenGL function. - if (!procAddress || procAddress == reinterpret_cast(0x1) || procAddress == reinterpret_cast(0x2) - || procAddress == reinterpret_cast(0x3) || procAddress == reinterpret_cast(-1)) - procAddress = reinterpret_cast(QOpenGLStaticContext::opengl32.resolve(procName)); + if (!procAddress || procAddress == reinterpret_cast(0x1) || procAddress == reinterpret_cast(0x2) + || procAddress == reinterpret_cast(0x3) || procAddress == reinterpret_cast(-1)) + procAddress = QOpenGLStaticContext::opengl32.resolve(procName); if (QWindowsContext::verbose > 1) qCDebug(lcQpaGl) << __FUNCTION__ << procName << QOpenGLStaticContext::opengl32.wglGetCurrentContext() << "returns" << procAddress; - return procAddress; + return reinterpret_cast(procAddress); } QT_END_NAMESPACE diff --git a/src/plugins/platforms/windows/qwindowsglcontext.h b/src/plugins/platforms/windows/qwindowsglcontext.h index e8c78860f2..2944ab7192 100644 --- a/src/plugins/platforms/windows/qwindowsglcontext.h +++ b/src/plugins/platforms/windows/qwindowsglcontext.h @@ -122,7 +122,7 @@ struct QWindowsOpengl32DLL void (APIENTRY * glGetIntegerv)(GLenum pname, GLint* params); const GLubyte * (APIENTRY * glGetString)(GLenum name); - void *resolve(const char *name); + PROC resolve(const char *name); private: HMODULE m_lib; bool m_nonOpengl32; -- cgit v1.2.3 From 683c30074e4b7c9048e9970de1851e5d9a6deeb4 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 8 Jun 2016 16:00:54 -0700 Subject: Add "-softfloat" to archdetect.cpp and clarify what to use when Change-Id: I1cc7601489634e96833cfffd14563e033c85ff6d Reviewed-by: Oswald Buddenhagen Reviewed-by: Thiago Macieira --- src/corelib/global/archdetect.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src') diff --git a/src/corelib/global/archdetect.cpp b/src/corelib/global/archdetect.cpp index 8a88c2f5c8..6c1a026fa8 100644 --- a/src/corelib/global/archdetect.cpp +++ b/src/corelib/global/archdetect.cpp @@ -121,7 +121,12 @@ # define ARCH_ABI1 "" #endif #if defined(__ARM_PCS_VFP) || defined(__mips_hard_float) +// Use "-hardfloat" for platforms that usually have no FPUs +// (and for the platforms which had "-hardfloat" before we established the rule) # define ARCH_ABI2 "-hardfloat" +#elif defined(_SOFT_FLOAT) +// Use "-softfloat" for architectures that usually have FPUs +# define ARCH_ABI2 "-softfloat" #else # define ARCH_ABI2 "" #endif -- cgit v1.2.3