Merge remote-tracking branch 'origin/5.15' into dev

Conflicts:
	tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp

Change-Id: I4d3041fa291a918c774ffa5eb5c8792a0966451d
This commit is contained in:
Qt Forward Merge Bot 2020-01-13 01:01:03 +01:00 committed by Simon Hausmann
commit cccc9d0b95
89 changed files with 791 additions and 423 deletions

View File

@ -3,7 +3,7 @@
dita.metadata.default.author = Qt Project dita.metadata.default.author = Qt Project
dita.metadata.default.permissions = all dita.metadata.default.permissions = all
dita.metadata.default.publisher = Qt Project dita.metadata.default.publisher = Qt Project
dita.metadata.default.copyryear = 2019 dita.metadata.default.copyryear = 2020
dita.metadata.default.copyrholder = The Qt Company Ltd dita.metadata.default.copyrholder = The Qt Company Ltd
dita.metadata.default.audience = programmer dita.metadata.default.audience = programmer

View File

@ -78,7 +78,7 @@ HTML.footer += \
" <ul id=\"menu-footer-submenu\" class=\"right clearfix\"><li id=\"menu-item-1795\" class=\"menu-item menu-item-type-custom menu-item-object-custom menu-item-1795\"><a title=\"Sign into your account.\" href=\"https://account.qt.io/login\">Sign In</a></li>\n" \ " <ul id=\"menu-footer-submenu\" class=\"right clearfix\"><li id=\"menu-item-1795\" class=\"menu-item menu-item-type-custom menu-item-object-custom menu-item-1795\"><a title=\"Sign into your account.\" href=\"https://account.qt.io/login\">Sign In</a></li>\n" \
" <li id=\"menu-item-10375\" class=\"menu-item menu-item-type-custom menu-item-object-custom menu-item-10375\"><a href=\"mailto:feedback@theqtcompany.com?Subject=Feedback%20about%20doc.qt.io%20site\">Feedback</a></li>\n" \ " <li id=\"menu-item-10375\" class=\"menu-item menu-item-type-custom menu-item-object-custom menu-item-10375\"><a href=\"mailto:feedback@theqtcompany.com?Subject=Feedback%20about%20doc.qt.io%20site\">Feedback</a></li>\n" \
" <li id=\"menu-item-1494\" class=\"menu-item menu-item-type-post_type menu-item-object-page menu-item-1494\"><a href=\"http://qt.io/contact-us/\">Contact us</a></li>\n" \ " <li id=\"menu-item-1494\" class=\"menu-item menu-item-type-post_type menu-item-object-page menu-item-1494\"><a href=\"http://qt.io/contact-us/\">Contact us</a></li>\n" \
" <li id=\"menu-item-4472\" class=\"menu-item menu-item-type-custom menu-item-object-custom menu-item-4472\"><a href=\"http://qt.io/about-us/\">© 2019 The Qt Company</a></li>\n" \ " <li id=\"menu-item-4472\" class=\"menu-item menu-item-type-custom menu-item-object-custom menu-item-4472\"><a href=\"http://qt.io/about-us/\">© 2020 The Qt Company</a></li>\n" \
" </ul>\n" \ " </ul>\n" \
"</div>\n" \ "</div>\n" \
"</div>\n" \ "</div>\n" \

View File

@ -8,7 +8,7 @@ HTML.footer = \
"</div>\n" \ "</div>\n" \
"<div class=\"footer\">\n" \ "<div class=\"footer\">\n" \
" <p>\n" \ " <p>\n" \
" <acronym title=\"Copyright\">&copy;</acronym> 2019 The Qt Company Ltd.\n" \ " <acronym title=\"Copyright\">&copy;</acronym> 2020 The Qt Company Ltd.\n" \
" Documentation contributions included herein are the copyrights of\n" \ " Documentation contributions included herein are the copyrights of\n" \
" their respective owners.<br/>" \ " their respective owners.<br/>" \
" The documentation provided herein is licensed under the terms of the" \ " The documentation provided herein is licensed under the terms of the" \

View File

@ -5,7 +5,7 @@
HTML.footer = \ HTML.footer = \
" </div>\n" \ " </div>\n" \
" <p class=\"copy-notice\">\n" \ " <p class=\"copy-notice\">\n" \
" <acronym title=\"Copyright\">&copy;</acronym> 2019 The Qt Company Ltd.\n" \ " <acronym title=\"Copyright\">&copy;</acronym> 2020 The Qt Company Ltd.\n" \
" Documentation contributions included herein are the copyrights of\n" \ " Documentation contributions included herein are the copyrights of\n" \
" their respective owners. " \ " their respective owners. " \
" The documentation provided herein is licensed under the terms of the" \ " The documentation provided herein is licensed under the terms of the" \

View File

@ -103,7 +103,7 @@ void FortuneThread::run()
//! [6] //! [8] //! [6] //! [8]
if (!socket.waitForConnected(Timeout)) { if (!socket.waitForConnected(Timeout)) {
emit error(socket.error(), socket.errorString()); emit error(socket.socketError(), socket.errorString());
return; return;
} }
//! [8] //! [11] //! [8] //! [11]
@ -115,7 +115,7 @@ void FortuneThread::run()
do { do {
if (!socket.waitForReadyRead(Timeout)) { if (!socket.waitForReadyRead(Timeout)) {
emit error(socket.error(), socket.errorString()); emit error(socket.socketError(), socket.errorString());
return; return;
} }

View File

@ -65,7 +65,7 @@ void FortuneThread::run()
QTcpSocket tcpSocket; QTcpSocket tcpSocket;
//! [1] //! [2] //! [1] //! [2]
if (!tcpSocket.setSocketDescriptor(socketDescriptor)) { if (!tcpSocket.setSocketDescriptor(socketDescriptor)) {
emit error(tcpSocket.error()); emit error(tcpSocket.socketError());
return; return;
} }
//! [2] //! [3] //! [2] //! [3]

View File

@ -867,7 +867,7 @@ void TorrentClient::removeClient()
// Remove the host from our list of known peers if the connection // Remove the host from our list of known peers if the connection
// failed. // failed.
if (client->peer() && client->error() == QAbstractSocket::ConnectionRefusedError) if (client->peer() && client->socketError() == QAbstractSocket::ConnectionRefusedError)
d->peers.removeAll(client->peer()); d->peers.removeAll(client->peer());
// Remove the client from RateController and all structures. // Remove the client from RateController and all structures.

View File

@ -182,6 +182,6 @@
In addition to the functions and slots discussed above, we have In addition to the functions and slots discussed above, we have
also implemented several convenience functions to simplify the also implemented several convenience functions to simplify the
constructor: \c createIconGroupBox(), \c createMessageGroupBox(), constructor: \c createIconGroupBox(), \c createMessageGroupBox(),
\c createActions() and \c createTrayIcon(). See the \l \c createActions() and \c createTrayIcon(). See the \c
{desktop/systray/window.cpp}{window.cpp} file for details. {desktop/systray/window.cpp} file for details.
*/ */

View File

@ -136,7 +136,7 @@
\section1 Defining the AddressBook Class \section1 Defining the AddressBook Class
The \l{tutorials/addressbook/part1/addressbook.h}{\c addressbook.h} file is The \c{tutorials/addressbook/part1/addressbook.h} file is
used to define the \c AddressBook class. used to define the \c AddressBook class.
We start by defining \c AddressBook as a QWidget subclass and declaring We start by defining \c AddressBook as a QWidget subclass and declaring

View File

@ -284,6 +284,6 @@
instance of the QStandardItemModel class, i.e., a generic model instance of the QStandardItemModel class, i.e., a generic model
for storing custom data typically used as a repository for for storing custom data typically used as a repository for
standard Qt data types. Each mail description is added to the standard Qt data types. Each mail description is added to the
model using \c addMail(), another convenience function. See \l model using \c addMail(), another convenience function. See \c
{itemviews/customsortfiltermodel/main.cpp}{main.cpp} for details. {itemviews/customsortfiltermodel/main.cpp} for details.
*/ */

View File

@ -320,8 +320,8 @@
The \c setupShapes() function is called from the constructor and The \c setupShapes() function is called from the constructor and
create the QPainterPath objects representing the shapes that are create the QPainterPath objects representing the shapes that are
used in the application. For construction details, see the \l used in the application. For construction details, see the \c
{painting/transformations/window.cpp}{window.cpp} example {painting/transformations/window.cpp} example
file. The shapes are stored in a QList. The QList::append() file. The shapes are stored in a QList. The QList::append()
function inserts the given shape at the end of the list. function inserts the given shape at the end of the list.

View File

@ -36,7 +36,8 @@ build_pass {
} }
} }
} else: contains(TEMPLATE, "lib"):!static:!QTDIR_build:android_install { } else: contains(TEMPLATE, "lib"):!static:!QTDIR_build:android_install {
!contains(TARGET, "_$${QT_ARCH}"): TARGET = $${TARGET}_$${QT_ARCH} tmpvar = $$str_member(TARGET, -$$str_size(QT_ARCH), -1)
!equals(tmpvar, $${QT_ARCH}): TARGET = $${TARGET}_$${QT_ARCH}
target.path = /libs/$$ANDROID_TARGET_ARCH/ target.path = /libs/$$ANDROID_TARGET_ARCH/
INSTALLS *= target INSTALLS *= target
} }

View File

@ -1,4 +1,4 @@
QMAKE_TARGET_COMPANY = The Qt Company Ltd. QMAKE_TARGET_COMPANY = The Qt Company Ltd.
isEmpty(QMAKE_TARGET_PRODUCT): QMAKE_TARGET_PRODUCT = Qt5 isEmpty(QMAKE_TARGET_PRODUCT): QMAKE_TARGET_PRODUCT = Qt5
isEmpty(QMAKE_TARGET_DESCRIPTION): QMAKE_TARGET_DESCRIPTION = C++ Application Development Framework isEmpty(QMAKE_TARGET_DESCRIPTION): QMAKE_TARGET_DESCRIPTION = C++ Application Development Framework
QMAKE_TARGET_COPYRIGHT = Copyright (C) 2019 The Qt Company Ltd. QMAKE_TARGET_COPYRIGHT = Copyright (C) 2020 The Qt Company Ltd.

View File

@ -40,3 +40,21 @@ win32|macx {
HEADERS += debugging.h HEADERS += debugging.h
} }
#! [4] #! [4]
#! [5]
if(win32|macos):CONFIG(debug, debug|release) {
# Do something on Windows and macOS,
# but only for the debug configuration.
}
win32|if(macos:CONFIG(debug, debug|release)) {
# Do something on Windows (regardless of debug or release)
# and on macOS (only for debug).
}
#! [5]
#! [6]
win32-* {
# Matches every mkspec starting with "win32-"
SOURCES += win32_specific.cpp
}
#! [6]

View File

@ -4418,6 +4418,20 @@
\snippet qmake/scopes.pro 4 \snippet qmake/scopes.pro 4
If you need to mix both operators, you can use the \c if function to specify
operator precedence.
\snippet qmake/scopes.pro 5
The condition accepts the wildcard character to match a family of \c{CONFIG}
values or mkspec names.
\snippet qmake/scopes.pro 6
\note Historically, checking the mkspec name with wildcards like above was
qmake's way to check for the platform. Nowadays, we recommend to use values
that are defined by the mkspec in the \c QMAKE_PLATFORM variable.
You can also provide alternative declarations to those within a scope by You can also provide alternative declarations to those within a scope by
using an \c else scope. Each \c else scope is processed if the conditions using an \c else scope. Each \c else scope is processed if the conditions
for the preceding scopes are false. for the preceding scopes are false.

View File

@ -586,6 +586,12 @@ static int create_pipe(int filedes[], int flags)
* descriptor. You probably want to set this flag, since forkfd() does not work * descriptor. You probably want to set this flag, since forkfd() does not work
* if the original parent process dies. * if the original parent process dies.
* *
* @li @C FFD_USE_FORK Tell forkfd() to actually call fork() instead of a
* different system implementation that may be available. On systems where a
* different implementation is available, its behavior may differ from that of
* fork(), such as not calling the functions registered with pthread_atfork().
* If that's necessary, pass this flag.
*
* The file descriptor returned by forkfd() supports the following operations: * The file descriptor returned by forkfd() supports the following operations:
* *
* @li read(2) When the child process exits, then the buffer supplied to * @li read(2) When the child process exits, then the buffer supplied to
@ -613,9 +619,11 @@ int forkfd(int flags, pid_t *ppid)
int efd; int efd;
#endif #endif
if ((flags & FFD_USE_FORK) == 0) {
fd = system_forkfd(flags, ppid, &ret); fd = system_forkfd(flags, ppid, &ret);
if (ret) if (ret)
return fd; return fd;
}
(void) pthread_once(&forkfd_initialization, forkfd_initialize); (void) pthread_once(&forkfd_initialization, forkfd_initialize);
@ -822,6 +830,8 @@ int forkfd_close(int ffd)
#if defined(__FreeBSD__) && __FreeBSD__ >= 9 #if defined(__FreeBSD__) && __FreeBSD__ >= 9
# include "forkfd_freebsd.c" # include "forkfd_freebsd.c"
#elif defined(__linux__)
# include "forkfd_linux.c"
#else #else
int system_has_forkfd() int system_has_forkfd()
{ {

View File

@ -40,6 +40,7 @@ extern "C" {
#define FFD_CLOEXEC 1 #define FFD_CLOEXEC 1
#define FFD_NONBLOCK 2 #define FFD_NONBLOCK 2
#define FFD_USE_FORK 4
#define FFD_CHILD_PROCESS (-2) #define FFD_CHILD_PROCESS (-2)

183
src/3rdparty/forkfd/forkfd_linux.c vendored Normal file
View File

@ -0,0 +1,183 @@
/****************************************************************************
**
** Copyright (C) 2019 Intel Corporation.
**
** Permission is hereby granted, free of charge, to any person obtaining a copy
** of this software and associated documentation files (the "Software"), to deal
** in the Software without restriction, including without limitation the rights
** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
** copies of the Software, and to permit persons to whom the Software is
** furnished to do so, subject to the following conditions:
**
** The above copyright notice and this permission notice shall be included in
** all copies or substantial portions of the Software.
**
** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
** THE SOFTWARE.
**
****************************************************************************/
#ifndef _GNU_SOURCE
# define _GNU_SOURCE
#endif
#include "forkfd.h"
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
#include <sched.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/resource.h>
#include <sys/syscall.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
#include "forkfd_atomic.h"
#ifndef CLONE_PIDFD
# define CLONE_PIDFD 0x00001000
#endif
#ifndef P_PIDFD
# define P_PIDFD 3
#endif
static ffd_atomic_int system_forkfd_state = FFD_ATOMIC_INIT(0);
static int sys_waitid(int which, int pid_or_pidfd, siginfo_t *infop, int options,
struct rusage *ru)
{
/* use the waitid raw system call, which has an extra parameter that glibc
* doesn't offer to us */
return syscall(__NR_waitid, which, pid_or_pidfd, infop, options, ru);
}
static int sys_clone(unsigned long cloneflags, int *ptid)
{
void *child_stack = NULL;
int *ctid = NULL;
unsigned long newtls = 0;
#if defined(__NR_clone2)
size_t stack_size = 0;
return syscall(__NR_clone2, cloneflags, child_stack, stack_size, ptid, ctid, newtls);
#elif defined(__cris__) || defined(__s390__)
/* a.k.a., CONFIG_CLONE_BACKWARDS2 architectures */
return syscall(__NR_clone, child_stack, cloneflags, ptid, newtls, ctid);
#elif defined(__microblaze__)
/* a.k.a., CONFIG_CLONE_BACKWARDS3 architectures */
size_t stack_size = 0;
return syscall(__NR_clone, cloneflags, child_stack, stack_size, ptid, newtls, ctid);
#elif defined(__arc__) || defined(__arm__) || defined(__aarch64__) || defined(__mips__) || \
defined(__nds32__) || defined(__hppa__) || defined(__powerpc__) || defined(__i386__) || \
defined(__x86_64__) || defined(__xtensa__) || defined(__alpha__)
/* ctid and newtls are inverted on CONFIG_CLONE_BACKWARDS architectures,
* but since both values are 0, there's no harm. */
return syscall(__NR_clone, cloneflags, child_stack, ptid, ctid, newtls);
#else
(void) child_stack;
(void) ctid;
(void) newtls;
errno = ENOSYS;
return -1;
#endif
}
static int detect_clone_pidfd_support()
{
/*
* Detect support for CLONE_PIDFD and P_PIDFD. Support was added in steps:
* - Linux 5.2 added CLONE_PIDFD support in clone(2) system call
* - Linux 5.2 added pidfd_send_signal(2)
* - Linux 5.3 added support for poll(2) on pidfds
* - Linux 5.3 added clone3(2)
* - Linux 5.4 added P_PIDFD support in waitid(2)
*
* We need CLONE_PIDFD and the poll(2) support. We could emulate the
* P_PIDFD support by reading the PID from /proc/self/fdinfo/n, which works
* in Linux 5.2, but without poll(2), we can't guarantee the functionality
* anyway.
*
* So we detect by trying to waitid(2) on a positive file descriptor that
* is definitely closed (INT_MAX). If P_PIDFD is supported, waitid(2) will
* return EBADF. If it isn't supported, it returns EINVAL (as it would for
* a negative file descriptor). This will succeed on Linux 5.4.
*
* We could have instead detected by the existence of the clone3(2) system
* call, but for that we would have needed to wait for __NR_clone3 to show
* up on the libcs. We choose to go via the waitid(2) route, which requires
* platform-independent constants only. It would have simplified the
* sys_clone() mess above...
*/
sys_waitid(P_PIDFD, INT_MAX, NULL, WEXITED|WNOHANG, NULL);
return errno == EBADF ? 1 : -1;
}
int system_has_forkfd()
{
return ffd_atomic_load(&system_forkfd_state, FFD_ATOMIC_RELAXED) > 0;
}
int system_forkfd(int flags, pid_t *ppid, int *system)
{
pid_t pid;
int pidfd;
int state = ffd_atomic_load(&system_forkfd_state, FFD_ATOMIC_RELAXED);
if (state == 0) {
state = detect_clone_pidfd_support();
ffd_atomic_store(&system_forkfd_state, state, FFD_ATOMIC_RELAXED);
}
if (state < 0) {
*system = 0;
return state;
}
*system = 1;
pid = sys_clone(CLONE_PIDFD, &pidfd);
if (ppid)
*ppid = pid;
if (pid == 0) {
/* Child process */
return FFD_CHILD_PROCESS;
}
/* parent process */
if ((flags & FFD_CLOEXEC) == 0) {
/* pidfd defaults to O_CLOEXEC */
fcntl(pidfd, F_SETFD, 0);
}
if (flags & FFD_NONBLOCK)
fcntl(pidfd, F_SETFL, fcntl(pidfd, F_GETFL) | O_NONBLOCK);
return pidfd;
}
int system_forkfd_wait(int ffd, struct forkfd_info *info, struct rusage *rusage)
{
siginfo_t si;
int options = WEXITED | __WALL;
int ret = fcntl(ffd, F_GETFL);
if (ret == -1)
return ret;
if (ret & O_NONBLOCK)
options |= WNOHANG;
ret = sys_waitid(P_PIDFD, ffd, &si, options, rusage);
if (ret == -1 && errno == ECHILD) {
errno = EWOULDBLOCK;
} else if (ret == 0 && info) {
info->code = si.si_code;
info->status = si.si_status;
}
return ret;
}

View File

@ -132,23 +132,6 @@ public class QtActivityLoader extends QtLoader {
return; return;
} }
if (Build.VERSION.SDK_INT < 21) {
// fatal error, show the error and quit
AlertDialog errorDialog = new AlertDialog.Builder(m_activity).create();
if (m_contextInfo.metaData.containsKey("android.app.unsupported_android_version"))
errorDialog.setMessage(m_contextInfo.metaData.getString("android.app.unsupported_android_version"));
else
errorDialog.setMessage("Unsupported Android version.");
errorDialog.setButton(m_activity.getResources().getString(android.R.string.ok), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
finish();
}
});
errorDialog.show();
return;
}
try { try {
m_activity.setTheme(Class.forName("android.R$style").getDeclaredField(QT_ANDROID_DEFAULT_THEME).getInt(null)); m_activity.setTheme(Class.forName("android.R$style").getDeclaredField(QT_ANDROID_DEFAULT_THEME).getInt(null));
} catch (Exception e) { } catch (Exception e) {

View File

@ -71,7 +71,7 @@ QTimer *timer = qobject_cast<QTimer *>(obj);
// timer == (QObject *)obj // timer == (QObject *)obj
QAbstractButton *button = qobject_cast<QAbstractButton *>(obj); QAbstractButton *button = qobject_cast<QAbstractButton *>(obj);
// button == 0 // button == nullptr
//! [3] //! [3]
@ -144,7 +144,7 @@ class MyObject : public QObject
Q_OBJECT Q_OBJECT
public: public:
MyObject(QObject *parent = 0); MyObject(QObject *parent = nullptr);
protected: protected:
void timerEvent(QTimerEvent *event) override; void timerEvent(QTimerEvent *event) override;
@ -322,7 +322,7 @@ QObject::connect: Cannot queue arguments of type 'MyType'
//! [26] //! [26]
disconnect(myObject, 0, 0, 0); disconnect(myObject, nullptr, nullptr, nullptr);
//! [26] //! [26]
@ -332,7 +332,7 @@ myObject->disconnect();
//! [28] //! [28]
disconnect(myObject, SIGNAL(mySignal()), 0, 0); disconnect(myObject, SIGNAL(mySignal()), nullptr, nullptr);
//! [28] //! [28]
@ -342,7 +342,7 @@ myObject->disconnect(SIGNAL(mySignal()));
//! [30] //! [30]
disconnect(myObject, 0, myReceiver, 0); disconnect(myObject, nullptr, myReceiver, nullptr);
//! [30] //! [30]
@ -391,7 +391,7 @@ class MyClass : public QObject
Q_OBJECT Q_OBJECT
public: public:
MyClass(QObject *parent = 0); MyClass(QObject *parent = nullptr);
~MyClass(); ~MyClass();
enum Priority { High, Low, VeryHigh, VeryLow }; enum Priority { High, Low, VeryHigh, VeryLow };
@ -467,7 +467,7 @@ QObject::connect(socket, &QTcpSocket::connected, [=] () {
//! [46] //! [46]
//! [47] //! [47]
disconnect(myObject, &MyObject::mySignal(), 0, 0); disconnect(myObject, &MyObject::mySignal(), nullptr, nullptr);
//! [47] //! [47]
//! [48] //! [48]
@ -505,7 +505,7 @@ class MyClass : public QWidget
Q_OBJECT Q_OBJECT
public: public:
MyClass(QWidget *parent = 0); MyClass(QWidget *parent = nullptr);
~MyClass(); ~MyClass();
bool event(QEvent* ev) override bool event(QEvent* ev) override

View File

@ -870,7 +870,6 @@
# define Q_COMPILER_DEFAULT_MEMBERS # define Q_COMPILER_DEFAULT_MEMBERS
# define Q_COMPILER_DELETE_MEMBERS # define Q_COMPILER_DELETE_MEMBERS
/* C++11 features supported in GCC 4.6: */ /* C++11 features supported in GCC 4.6: */
# define Q_COMPILER_CONSTEXPR
# define Q_COMPILER_NULLPTR # define Q_COMPILER_NULLPTR
# define Q_COMPILER_UNRESTRICTED_UNIONS # define Q_COMPILER_UNRESTRICTED_UNIONS
# define Q_COMPILER_RANGE_FOR # define Q_COMPILER_RANGE_FOR
@ -901,7 +900,11 @@
# define Q_COMPILER_REF_QUALIFIERS # define Q_COMPILER_REF_QUALIFIERS
# endif # endif
# endif # endif
/* C++11 features are complete as of GCC 4.8.1 */ # if Q_CC_GNU >= 500
/* GCC 4.6 introduces constexpr, but it's bugged (at least) in the whole
* 4.x series, see e.g. https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57694 */
# define Q_COMPILER_CONSTEXPR
# endif
# endif # endif
# if __cplusplus > 201103L # if __cplusplus > 201103L
# if Q_CC_GNU >= 409 # if Q_CC_GNU >= 409

View File

@ -451,8 +451,13 @@ void QProcessPrivate::startProcess()
} }
// Start the process manager, and fork off the child process. // Start the process manager, and fork off the child process.
// ### Qt6: revisit whether the change in behavior due to not using fork()
// is acceptable for derived classes.
int ffdflags = FFD_CLOEXEC;
if (typeid(*q) != typeid(QProcess))
ffdflags |= FFD_USE_FORK;
pid_t childPid; pid_t childPid;
forkfd = ::forkfd(FFD_CLOEXEC, &childPid); forkfd = ::forkfd(ffdflags , &childPid);
int lastForkErrno = errno; int lastForkErrno = errno;
if (forkfd != FFD_CHILD_PROCESS) { if (forkfd != FFD_CHILD_PROCESS) {
// Parent process. // Parent process.

View File

@ -1153,8 +1153,8 @@ QObjectPrivate::Connection::~Connection()
\relates QObject \relates QObject
Returns the given \a object cast to type T if the object is of type Returns the given \a object cast to type T if the object is of type
T (or of a subclass); otherwise returns 0. If \a object is 0 then T (or of a subclass); otherwise returns \nullptr. If \a object is
it will also return 0. \nullptr then it will also return \nullptr.
The class T must inherit (directly or indirectly) QObject and be The class T must inherit (directly or indirectly) QObject and be
declared with the \l Q_OBJECT macro. declared with the \l Q_OBJECT macro.
@ -1506,7 +1506,7 @@ QThread *QObject::thread() const
the thread affinity is changed. You can handle this event to the thread affinity is changed. You can handle this event to
perform any special processing. Note that any new events that are perform any special processing. Note that any new events that are
posted to this object will be handled in the \a targetThread, posted to this object will be handled in the \a targetThread,
provided it is non-null: when it is \nullptr, no event processing provided it is not \nullptr: when it is \nullptr, no event processing
for this object or its children can happen, as they are no longer for this object or its children can happen, as they are no longer
associated with any thread. associated with any thread.
@ -2311,7 +2311,7 @@ void QObject::deleteLater()
If the same \a sourceText is used in different roles within the If the same \a sourceText is used in different roles within the
same context, an additional identifying string may be passed in same context, an additional identifying string may be passed in
\a disambiguation (0 by default). In Qt 4.4 and earlier, this was \a disambiguation (\nullptr by default). In Qt 4.4 and earlier, this was
the preferred way to pass comments to translators. the preferred way to pass comments to translators.
Example: Example:
@ -2497,7 +2497,7 @@ QObject *QObject::sender() const
For signals with default parameters, this function will always return For signals with default parameters, this function will always return
the index with all parameters, regardless of which was used with the index with all parameters, regardless of which was used with
connect(). For example, the signal \c {destroyed(QObject *obj = 0)} connect(). For example, the signal \c {destroyed(QObject *obj = \nullptr)}
will have two different indexes (with and without the parameter), but will have two different indexes (with and without the parameter), but
this function will always return the index with a parameter. This does this function will always return the index with a parameter. This does
not apply when overloading signals with different parameters. not apply when overloading signals with different parameters.
@ -2638,7 +2638,7 @@ bool QObject::isSignalConnected(const QMetaMethod &signal) const
member in the specified class. member in the specified class.
\list \list
\li If member.mobj is 0 then both signalIndex and methodIndex are set to -1. \li If member.mobj is \nullptr then both signalIndex and methodIndex are set to -1.
\li If specified member is not a member of obj instance class (or one of \li If specified member is not a member of obj instance class (or one of
its parent classes) then both signalIndex and methodIndex are set to -1. its parent classes) then both signalIndex and methodIndex are set to -1.
@ -2777,10 +2777,10 @@ QMetaObject::Connection QObject::connect(const QObject *sender, const char *sign
{ {
if (sender == nullptr || receiver == nullptr || signal == nullptr || method == nullptr) { if (sender == nullptr || receiver == nullptr || signal == nullptr || method == nullptr) {
qWarning("QObject::connect: Cannot connect %s::%s to %s::%s", qWarning("QObject::connect: Cannot connect %s::%s to %s::%s",
sender ? sender->metaObject()->className() : "(null)", sender ? sender->metaObject()->className() : "(nullptr)",
(signal && *signal) ? signal+1 : "(null)", (signal && *signal) ? signal+1 : "(nullptr)",
receiver ? receiver->metaObject()->className() : "(null)", receiver ? receiver->metaObject()->className() : "(nullptr)",
(method && *method) ? method+1 : "(null)"); (method && *method) ? method+1 : "(nullptr)");
return QMetaObject::Connection(nullptr); return QMetaObject::Connection(nullptr);
} }
QByteArray tmp_signal_name; QByteArray tmp_signal_name;
@ -2918,9 +2918,9 @@ QMetaObject::Connection QObject::connect(const QObject *sender, const QMetaMetho
|| signal.methodType() != QMetaMethod::Signal || signal.methodType() != QMetaMethod::Signal
|| method.methodType() == QMetaMethod::Constructor) { || method.methodType() == QMetaMethod::Constructor) {
qWarning("QObject::connect: Cannot connect %s::%s to %s::%s", qWarning("QObject::connect: Cannot connect %s::%s to %s::%s",
sender ? sender->metaObject()->className() : "(null)", sender ? sender->metaObject()->className() : "(nullptr)",
signal.methodSignature().constData(), signal.methodSignature().constData(),
receiver ? receiver->metaObject()->className() : "(null)", receiver ? receiver->metaObject()->className() : "(nullptr)",
method.methodSignature().constData() ); method.methodSignature().constData() );
return QMetaObject::Connection(nullptr); return QMetaObject::Connection(nullptr);
} }
@ -3022,20 +3022,20 @@ QMetaObject::Connection QObject::connect(const QObject *sender, const QMetaMetho
\endlist \endlist
0 may be used as a wildcard, meaning "any signal", "any receiving \nullptr may be used as a wildcard, meaning "any signal", "any receiving
object", or "any slot in the receiving object", respectively. object", or "any slot in the receiving object", respectively.
The \a sender may never be \nullptr. (You cannot disconnect signals The \a sender may never be \nullptr. (You cannot disconnect signals
from more than one object in a single call.) from more than one object in a single call.)
If \a signal is 0, it disconnects \a receiver and \a method from If \a signal is \nullptr, it disconnects \a receiver and \a method from
any signal. If not, only the specified signal is disconnected. any signal. If not, only the specified signal is disconnected.
If \a receiver is 0, it disconnects anything connected to \a If \a receiver is \nullptr, it disconnects anything connected to \a
signal. If not, slots in objects other than \a receiver are not signal. If not, slots in objects other than \a receiver are not
disconnected. disconnected.
If \a method is 0, it disconnects anything that is connected to \a If \a method is \nullptr, it disconnects anything that is connected to \a
receiver. If not, only slots named \a method will be disconnected, receiver. If not, only slots named \a method will be disconnected,
and all other slots are left alone. The \a method must be \nullptr and all other slots are left alone. The \a method must be \nullptr
if \a receiver is left out, so you cannot disconnect a if \a receiver is left out, so you cannot disconnect a
@ -3047,7 +3047,7 @@ bool QObject::disconnect(const QObject *sender, const char *signal,
const QObject *receiver, const char *method) const QObject *receiver, const char *method)
{ {
if (sender == nullptr || (receiver == nullptr && method != nullptr)) { if (sender == nullptr || (receiver == nullptr && method != nullptr)) {
qWarning("QObject::disconnect: Unexpected null parameter"); qWarning("QObject::disconnect: Unexpected nullptr parameter");
return false; return false;
} }
@ -3173,8 +3173,8 @@ bool QObject::disconnect(const QObject *sender, const char *signal,
\endlist \endlist
QMetaMethod() may be used as wildcard in the meaning "any signal" or "any slot in receiving object". QMetaMethod() may be used as wildcard in the meaning "any signal" or "any slot in receiving object".
In the same way 0 can be used for \a receiver in the meaning "any receiving object". In this case In the same way \nullptr can be used for \a receiver in the meaning "any receiving object".
method should also be QMetaMethod(). \a sender parameter should be never 0. In this case method should also be QMetaMethod(). \a sender parameter should be never \nullptr.
\sa disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *method) \sa disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *method)
*/ */
@ -3182,7 +3182,7 @@ bool QObject::disconnect(const QObject *sender, const QMetaMethod &signal,
const QObject *receiver, const QMetaMethod &method) const QObject *receiver, const QMetaMethod &method)
{ {
if (sender == nullptr || (receiver == nullptr && method.mobj != nullptr)) { if (sender == nullptr || (receiver == nullptr && method.mobj != nullptr)) {
qWarning("QObject::disconnect: Unexpected null parameter"); qWarning("QObject::disconnect: Unexpected nullptr parameter");
return false; return false;
} }
if (signal.mobj) { if (signal.mobj) {
@ -3216,7 +3216,7 @@ bool QObject::disconnect(const QObject *sender, const QMetaMethod &signal,
QMetaObjectPrivate::memberIndexes(sender, signal, &signal_index, &dummy); QMetaObjectPrivate::memberIndexes(sender, signal, &signal_index, &dummy);
QMetaObjectPrivate::memberIndexes(receiver, method, &dummy, &method_index); QMetaObjectPrivate::memberIndexes(receiver, method, &dummy, &method_index);
} }
// If we are here sender is not null. If signal is not null while signal_index // If we are here sender is not nullptr. If signal is not nullptr while signal_index
// is -1 then this signal is not a member of sender. // is -1 then this signal is not a member of sender.
if (signal.mobj && signal_index == -1) { if (signal.mobj && signal_index == -1) {
qWarning("QObject::disconect: signal %s not found on class %s", qWarning("QObject::disconect: signal %s not found on class %s",
@ -3305,7 +3305,7 @@ void QObject::connectNotify(const QMetaMethod &signal)
\a signal with a specific signal. \a signal with a specific signal.
If all signals were disconnected from this object (e.g., the If all signals were disconnected from this object (e.g., the
signal argument to disconnect() was 0), disconnectNotify() signal argument to disconnect() was \nullptr), disconnectNotify()
is only called once, and the \a signal will be an invalid is only called once, and the \a signal will be an invalid
QMetaMethod (QMetaMethod::isValid() returns \c false). QMetaMethod (QMetaMethod::isValid() returns \c false).
@ -4853,7 +4853,7 @@ void qDeleteInEventHandler(QObject *o)
\a sender is the sender object \a sender is the sender object
\a signal is a pointer to a pointer to a member signal of the sender \a signal is a pointer to a pointer to a member signal of the sender
\a receiver is the receiver object, may not be null, will be equal to sender when \a receiver is the receiver object, may not be \nullptr, will be equal to sender when
connecting to a static function or a functor connecting to a static function or a functor
\a slot a pointer only used when using Qt::UniqueConnection \a slot a pointer only used when using Qt::UniqueConnection
\a type the Qt::ConnctionType passed as argument to connect \a type the Qt::ConnctionType passed as argument to connect
@ -4861,7 +4861,7 @@ void qDeleteInEventHandler(QObject *o)
to be used with queued connection to be used with queued connection
must stay valid at least for the whole time of the connection, this function must stay valid at least for the whole time of the connection, this function
do not take ownership. typically static data. do not take ownership. typically static data.
If null, then the types will be computed when the signal is emit in a queued If \nullptr, then the types will be computed when the signal is emit in a queued
connection from the types from the signature. connection from the types from the signature.
\a senderMetaObject is the metaobject used to lookup the signal, the signal must be in \a senderMetaObject is the metaobject used to lookup the signal, the signal must be in
this metaobject this metaobject
@ -4872,7 +4872,7 @@ QMetaObject::Connection QObject::connectImpl(const QObject *sender, void **signa
const int *types, const QMetaObject *senderMetaObject) const int *types, const QMetaObject *senderMetaObject)
{ {
if (!signal) { if (!signal) {
qWarning("QObject::connect: invalid null parameter"); qWarning("QObject::connect: invalid nullptr parameter");
if (slotObj) if (slotObj)
slotObj->destroyIfLastRef(); slotObj->destroyIfLastRef();
return QMetaObject::Connection(); return QMetaObject::Connection();
@ -4912,7 +4912,7 @@ QMetaObject::Connection QObjectPrivate::connectImpl(const QObject *sender, int s
: "Unknown"; : "Unknown";
const char *receiverString = receiver ? receiver->metaObject()->className() const char *receiverString = receiver ? receiver->metaObject()->className()
: "Unknown"; : "Unknown";
qWarning("QObject::connect(%s, %s): invalid null parameter", senderString, receiverString); qWarning("QObject::connect(%s, %s): invalid nullptr parameter", senderString, receiverString);
if (slotObj) if (slotObj)
slotObj->destroyIfLastRef(); slotObj->destroyIfLastRef();
return QMetaObject::Connection(); return QMetaObject::Connection();
@ -5045,20 +5045,20 @@ bool QObject::disconnect(const QMetaObject::Connection &connection)
\endlist \endlist
0 may be used as a wildcard, meaning "any signal", "any receiving \nullptr may be used as a wildcard, meaning "any signal", "any receiving
object", or "any slot in the receiving object", respectively. object", or "any slot in the receiving object", respectively.
The \a sender may never be \nullptr. (You cannot disconnect signals The \a sender may never be \nullptr. (You cannot disconnect signals
from more than one object in a single call.) from more than one object in a single call.)
If \a signal is 0, it disconnects \a receiver and \a method from If \a signal is \nullptr, it disconnects \a receiver and \a method from
any signal. If not, only the specified signal is disconnected. any signal. If not, only the specified signal is disconnected.
If \a receiver is 0, it disconnects anything connected to \a If \a receiver is \nullptr, it disconnects anything connected to \a
signal. If not, slots in objects other than \a receiver are not signal. If not, slots in objects other than \a receiver are not
disconnected. disconnected.
If \a method is 0, it disconnects anything that is connected to \a If \a method is \nullptr, it disconnects anything that is connected to \a
receiver. If not, only slots named \a method will be disconnected, receiver. If not, only slots named \a method will be disconnected,
and all other slots are left alone. The \a method must be \nullptr and all other slots are left alone. The \a method must be \nullptr
if \a receiver is left out, so you cannot disconnect a if \a receiver is left out, so you cannot disconnect a
@ -5075,7 +5075,7 @@ bool QObject::disconnect(const QMetaObject::Connection &connection)
bool QObject::disconnectImpl(const QObject *sender, void **signal, const QObject *receiver, void **slot, const QMetaObject *senderMetaObject) bool QObject::disconnectImpl(const QObject *sender, void **signal, const QObject *receiver, void **slot, const QMetaObject *senderMetaObject)
{ {
if (sender == nullptr || (receiver == nullptr && slot != nullptr)) { if (sender == nullptr || (receiver == nullptr && slot != nullptr)) {
qWarning("QObject::disconnect: Unexpected null parameter"); qWarning("QObject::disconnect: Unexpected nullptr parameter");
return false; return false;
} }
@ -5106,7 +5106,7 @@ bool QObject::disconnectImpl(const QObject *sender, void **signal, const QObject
QMetaObject::Connection QObjectPrivate::connect(const QObject *sender, int signal_index, QtPrivate::QSlotObjectBase *slotObj, Qt::ConnectionType type) QMetaObject::Connection QObjectPrivate::connect(const QObject *sender, int signal_index, QtPrivate::QSlotObjectBase *slotObj, Qt::ConnectionType type)
{ {
if (!sender) { if (!sender) {
qWarning("QObject::connect: invalid null parameter"); qWarning("QObject::connect: invalid nullptr parameter");
if (slotObj) if (slotObj)
slotObj->destroyIfLastRef(); slotObj->destroyIfLastRef();
return QMetaObject::Connection(); return QMetaObject::Connection();

View File

@ -332,9 +332,9 @@ private:
return Type(quint8(st) | SimpleType); return Type(quint8(st) | SimpleType);
} }
Q_DECL_CONSTEXPR static bool isTag_helper(Type t) Q_DECL_CONSTEXPR static bool isTag_helper(Type tt)
{ {
return t == Tag || t >= 0x10000; return tt == Tag || tt >= 0x10000;
} }
}; };
Q_DECLARE_SHARED(QCborValue) Q_DECLARE_SHARED(QCborValue)

View File

@ -1,6 +1,6 @@
/**************************************************************************** /****************************************************************************
** **
** Copyright (C) 2019 The Qt Company Ltd. ** Copyright (C) 2020 The Qt Company Ltd.
** Copyright (C) 2019 Intel Corporation. ** Copyright (C) 2019 Intel Corporation.
** Contact: https://www.qt.io/licensing/ ** Contact: https://www.qt.io/licensing/
** **
@ -651,7 +651,6 @@ int qt_repeatCount(QStringView s)
} }
static const QLocaleData *default_data = nullptr; static const QLocaleData *default_data = nullptr;
static QLocale::NumberOptions default_number_options = QLocale::DefaultNumberOptions;
static const QLocaleData *const c_data = locale_data; static const QLocaleData *const c_data = locale_data;
static QLocalePrivate *c_private() static QLocalePrivate *c_private()
@ -834,7 +833,7 @@ QDataStream &operator>>(QDataStream &ds, QLocale &l)
static const int locale_data_size = sizeof(locale_data)/sizeof(QLocaleData) - 1; static const int locale_data_size = sizeof(locale_data)/sizeof(QLocaleData) - 1;
Q_GLOBAL_STATIC_WITH_ARGS(QSharedDataPointer<QLocalePrivate>, defaultLocalePrivate, Q_GLOBAL_STATIC_WITH_ARGS(QSharedDataPointer<QLocalePrivate>, defaultLocalePrivate,
(QLocalePrivate::create(defaultData(), default_number_options))) (QLocalePrivate::create(defaultData())))
Q_GLOBAL_STATIC_WITH_ARGS(QExplicitlySharedDataPointer<QLocalePrivate>, systemLocalePrivate, Q_GLOBAL_STATIC_WITH_ARGS(QExplicitlySharedDataPointer<QLocalePrivate>, systemLocalePrivate,
(QLocalePrivate::create(systemData()))) (QLocalePrivate::create(systemData())))
@ -862,8 +861,9 @@ static QLocalePrivate *findLocalePrivate(QLocale::Language language, QLocale::Sc
QLocale::NumberOptions numberOptions = QLocale::DefaultNumberOptions; QLocale::NumberOptions numberOptions = QLocale::DefaultNumberOptions;
// If not found, should default to system // If not found, should default to system
if (data->m_language_id == QLocale::C && language != QLocale::C) { if (data->m_language_id == QLocale::C) {
numberOptions = default_number_options; if (defaultLocalePrivate.exists())
numberOptions = defaultLocalePrivate->data()->m_numberOptions;
data = defaultData(); data = defaultData();
} }
return QLocalePrivate::create(data, offset, numberOptions); return QLocalePrivate::create(data, offset, numberOptions);
@ -1048,6 +1048,8 @@ uint qHash(const QLocale &key, uint seed) noexcept
Sets the \a options related to number conversions for this Sets the \a options related to number conversions for this
QLocale instance. QLocale instance.
\sa numberOptions()
*/ */
void QLocale::setNumberOptions(NumberOptions options) void QLocale::setNumberOptions(NumberOptions options)
{ {
@ -1060,7 +1062,10 @@ void QLocale::setNumberOptions(NumberOptions options)
Returns the options related to number conversions for this Returns the options related to number conversions for this
QLocale instance. QLocale instance.
By default, no options are set for the standard locales. By default, no options are set for the standard locales, except
for the "C" locale, which has OmitGroupSeparator set by default.
\sa setNumberOptions(), toString(), groupSeparator()
*/ */
QLocale::NumberOptions QLocale::numberOptions() const QLocale::NumberOptions QLocale::numberOptions() const
{ {
@ -1170,12 +1175,9 @@ QString QLocale::createSeparatedList(const QStringList &list) const
void QLocale::setDefault(const QLocale &locale) void QLocale::setDefault(const QLocale &locale)
{ {
default_data = locale.d->m_data; default_data = locale.d->m_data;
default_number_options = locale.numberOptions();
if (defaultLocalePrivate.exists()) { if (defaultLocalePrivate.exists()) // update the cached private
// update the cached private
*defaultLocalePrivate = locale.d; *defaultLocalePrivate = locale.d;
}
} }
/*! /*!
@ -1962,7 +1964,7 @@ double QLocale::toDouble(QStringView s, bool *ok) const
/*! /*!
Returns a localized string representation of \a i. Returns a localized string representation of \a i.
\sa toLongLong() \sa toLongLong(), numberOptions(), zeroDigit(), positiveSign()
*/ */
QString QLocale::toString(qlonglong i) const QString QLocale::toString(qlonglong i) const
@ -1978,7 +1980,7 @@ QString QLocale::toString(qlonglong i) const
/*! /*!
\overload \overload
\sa toULongLong() \sa toULongLong(), numberOptions(), zeroDigit(), positiveSign()
*/ */
QString QLocale::toString(qulonglong i) const QString QLocale::toString(qulonglong i) const
@ -2525,6 +2527,12 @@ QDateTime QLocale::toDateTime(const QString &string, const QString &format, QCal
\since 4.1 \since 4.1
Returns the decimal point character of this locale. Returns the decimal point character of this locale.
\note This function shall change to return a QString instead of QChar in
Qt6. Callers are encouraged to exploit the QString(QChar) constructor to
convert early in preparation for this.
\sa groupSeparator(), toString()
*/ */
QChar QLocale::decimalPoint() const QChar QLocale::decimalPoint() const
{ {
@ -2535,6 +2543,12 @@ QChar QLocale::decimalPoint() const
\since 4.1 \since 4.1
Returns the group separator character of this locale. Returns the group separator character of this locale.
\note This function shall change to return a QString instead of QChar in
Qt6. Callers are encouraged to exploit the QString(QChar) constructor to
convert early in preparation for this.
\sa decimalPoint(), toString()
*/ */
QChar QLocale::groupSeparator() const QChar QLocale::groupSeparator() const
{ {
@ -2545,6 +2559,12 @@ QChar QLocale::groupSeparator() const
\since 4.1 \since 4.1
Returns the percent character of this locale. Returns the percent character of this locale.
\note This function shall change to return a QString instead of QChar in
Qt6. Callers are encouraged to exploit the QString(QChar) constructor to
convert early in preparation for this.
\sa toString()
*/ */
QChar QLocale::percent() const QChar QLocale::percent() const
{ {
@ -2555,6 +2575,12 @@ QChar QLocale::percent() const
\since 4.1 \since 4.1
Returns the zero digit character of this locale. Returns the zero digit character of this locale.
\note This function shall change to return a QString instead of QChar in
Qt6. Callers are encouraged to exploit the QString(QChar) constructor to
convert early in preparation for this.
\sa toString()
*/ */
QChar QLocale::zeroDigit() const QChar QLocale::zeroDigit() const
{ {
@ -2565,6 +2591,12 @@ QChar QLocale::zeroDigit() const
\since 4.1 \since 4.1
Returns the negative sign character of this locale. Returns the negative sign character of this locale.
\note This function shall change to return a QString instead of QChar in
Qt6. Callers are encouraged to exploit the QString(QChar) constructor to
convert early in preparation for this.
\sa positiveSign(), toString()
*/ */
QChar QLocale::negativeSign() const QChar QLocale::negativeSign() const
{ {
@ -2575,6 +2607,12 @@ QChar QLocale::negativeSign() const
\since 4.5 \since 4.5
Returns the positive sign character of this locale. Returns the positive sign character of this locale.
\note This function shall change to return a QString instead of QChar in
Qt6. Callers are encouraged to exploit the QString(QChar) constructor to
convert early in preparation for this.
\sa negativeSign(), toString()
*/ */
QChar QLocale::positiveSign() const QChar QLocale::positiveSign() const
{ {
@ -2584,7 +2622,14 @@ QChar QLocale::positiveSign() const
/*! /*!
\since 4.1 \since 4.1
Returns the exponential character of this locale. Returns the exponential character of this locale, used to separate exponent
from mantissa in some floating-point numeric representations.
\note This function shall change to return a QString instead of QChar in
Qt6. Callers are encouraged to exploit the QString(QChar) constructor to
convert early in preparation for this.
\sa toString(double, char, int)
*/ */
QChar QLocale::exponential() const QChar QLocale::exponential() const
{ {
@ -2609,7 +2654,7 @@ static char qToLower(char c)
\a f and \a prec have the same meaning as in QString::number(double, char, int). \a f and \a prec have the same meaning as in QString::number(double, char, int).
\sa toDouble() \sa toDouble(), numberOptions(), exponential(), decimalPoint(), zeroDigit(), positiveSign(), percent()
*/ */
QString QLocale::toString(double i, char f, int prec) const QString QLocale::toString(double i, char f, int prec) const

View File

@ -1,6 +1,6 @@
/**************************************************************************** /****************************************************************************
** **
** Copyright (C) 2019 The Qt Company Ltd. ** Copyright (C) 2020 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/ ** Contact: https://www.qt.io/licensing/
** **
** This file is part of the QtCore module of the Qt Toolkit. ** This file is part of the QtCore module of the Qt Toolkit.
@ -1044,8 +1044,8 @@ public:
QDateTime toDateTime(const QString &string, const QString &format, QCalendar cal) const; QDateTime toDateTime(const QString &string, const QString &format, QCalendar cal) const;
#endif #endif
// ### Qt 5: We need to return QString from these function since // ### Qt 6: We need to return QString from these function since
// unicode data contains several characters for these fields. // UTF-16 may need surrogate pairs to represent these fields.
QChar decimalPoint() const; QChar decimalPoint() const;
QChar groupSeparator() const; QChar groupSeparator() const;
QChar percent() const; QChar percent() const;

View File

@ -1,6 +1,6 @@
/**************************************************************************** /****************************************************************************
** **
** Copyright (C) 2016 The Qt Company Ltd. ** Copyright (C) 2020 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/ ** Contact: https://www.qt.io/licensing/
** **
** This file is part of the QtCore module of the Qt Toolkit. ** This file is part of the QtCore module of the Qt Toolkit.
@ -67,16 +67,16 @@ static QByteArray envVarLocale()
return lang; return lang;
} }
static QByteArray getMacLocaleName() static QString getMacLocaleName()
{ {
QByteArray result = envVarLocale(); QString result = QString::fromLocal8Bit(envVarLocale());
QString lang, script, cntry; QString lang, script, cntry;
if (result.isEmpty() if (result.isEmpty()
|| (result != "C" && !qt_splitLocaleName(QString::fromLocal8Bit(result), lang, script, cntry))) { || (result != QLatin1String("C") && !qt_splitLocaleName(result, lang, script, cntry))) {
QCFType<CFLocaleRef> l = CFLocaleCopyCurrent(); QCFType<CFLocaleRef> l = CFLocaleCopyCurrent();
CFStringRef locale = CFLocaleGetIdentifier(l); CFStringRef locale = CFLocaleGetIdentifier(l);
result = QString::fromCFString(locale).toUtf8(); result = QString::fromCFString(locale);
} }
return result; return result;
} }
@ -402,10 +402,10 @@ static QVariant macQuoteString(QSystemLocale::QueryType type, const QStringRef &
QLocale QSystemLocale::fallbackUiLocale() const QLocale QSystemLocale::fallbackUiLocale() const
{ {
return QLocale(QString::fromUtf8(getMacLocaleName().constData())); return QLocale(getMacLocaleName());
} }
QVariant QSystemLocale::query(QueryType type, QVariant in = QVariant()) const QVariant QSystemLocale::query(QueryType type, QVariant in) const
{ {
QMacAutoReleasePool pool; QMacAutoReleasePool pool;
switch(type) { switch(type) {

View File

@ -929,7 +929,7 @@ static int ucstrncmp(const QChar *a, const QChar *b, size_t l)
}; };
// we're going to read a[0..15] and b[0..15] (32 bytes) // we're going to read a[0..15] and b[0..15] (32 bytes)
for ( ; a + offset + 16 <= end; offset += 16) { for ( ; end - a >= offset + 16; offset += 16) {
#ifdef __AVX2__ #ifdef __AVX2__
__m256i a_data = _mm256_loadu_si256(reinterpret_cast<const __m256i *>(a + offset)); __m256i a_data = _mm256_loadu_si256(reinterpret_cast<const __m256i *>(a + offset));
__m256i b_data = _mm256_loadu_si256(reinterpret_cast<const __m256i *>(b + offset)); __m256i b_data = _mm256_loadu_si256(reinterpret_cast<const __m256i *>(b + offset));
@ -953,7 +953,7 @@ static int ucstrncmp(const QChar *a, const QChar *b, size_t l)
} }
// we're going to read a[0..7] and b[0..7] (16 bytes) // we're going to read a[0..7] and b[0..7] (16 bytes)
if (a + offset + 8 <= end) { if (end - a >= offset + 8) {
__m128i a_data = _mm_loadu_si128(reinterpret_cast<const __m128i *>(a + offset)); __m128i a_data = _mm_loadu_si128(reinterpret_cast<const __m128i *>(a + offset));
__m128i b_data = _mm_loadu_si128(reinterpret_cast<const __m128i *>(b + offset)); __m128i b_data = _mm_loadu_si128(reinterpret_cast<const __m128i *>(b + offset));
if (isDifferent(a_data, b_data)) if (isDifferent(a_data, b_data))
@ -963,7 +963,7 @@ static int ucstrncmp(const QChar *a, const QChar *b, size_t l)
} }
// we're going to read a[0..3] and b[0..3] (8 bytes) // we're going to read a[0..3] and b[0..3] (8 bytes)
if (a + offset + 4 <= end) { if (end - a >= offset + 4) {
__m128i a_data = _mm_loadl_epi64(reinterpret_cast<const __m128i *>(a + offset)); __m128i a_data = _mm_loadl_epi64(reinterpret_cast<const __m128i *>(a + offset));
__m128i b_data = _mm_loadl_epi64(reinterpret_cast<const __m128i *>(b + offset)); __m128i b_data = _mm_loadl_epi64(reinterpret_cast<const __m128i *>(b + offset));
if (isDifferent(a_data, b_data)) if (isDifferent(a_data, b_data))
@ -984,7 +984,7 @@ static int ucstrncmp(const QChar *a, const QChar *b, size_t l)
if (l >= 8) { if (l >= 8) {
const QChar *end = a + l; const QChar *end = a + l;
const uint16x8_t mask = { 1, 1 << 1, 1 << 2, 1 << 3, 1 << 4, 1 << 5, 1 << 6, 1 << 7 }; const uint16x8_t mask = { 1, 1 << 1, 1 << 2, 1 << 3, 1 << 4, 1 << 5, 1 << 6, 1 << 7 };
while (a + 7 < end) { while (end - a > 7) {
uint16x8_t da = vld1q_u16(reinterpret_cast<const uint16_t *>(a)); uint16x8_t da = vld1q_u16(reinterpret_cast<const uint16_t *>(a));
uint16x8_t db = vld1q_u16(reinterpret_cast<const uint16_t *>(b)); uint16x8_t db = vld1q_u16(reinterpret_cast<const uint16_t *>(b));

View File

@ -3293,12 +3293,8 @@ QPalette QGuiApplication::palette()
*/ */
void QGuiApplication::setPalette(const QPalette &pal) void QGuiApplication::setPalette(const QPalette &pal)
{ {
if (QGuiApplicationPrivate::app_pal && pal.isCopyOf(*QGuiApplicationPrivate::app_pal)) if (!QGuiApplicationPrivate::setPalette(pal))
return; return;
if (!QGuiApplicationPrivate::app_pal)
QGuiApplicationPrivate::app_pal = new QPalette(pal);
else
*QGuiApplicationPrivate::app_pal = pal;
QCoreApplication::setAttribute(Qt::AA_SetPalette); QCoreApplication::setAttribute(Qt::AA_SetPalette);
@ -3306,6 +3302,19 @@ void QGuiApplication::setPalette(const QPalette &pal)
qGuiApp->d_func()->sendApplicationPaletteChange(); qGuiApp->d_func()->sendApplicationPaletteChange();
} }
bool QGuiApplicationPrivate::setPalette(const QPalette &palette)
{
if (app_pal && palette.isCopyOf(*app_pal))
return false;
if (!app_pal)
app_pal = new QPalette(palette);
else
*app_pal = palette;
return true;
}
void QGuiApplicationPrivate::applyWindowGeometrySpecificationTo(QWindow *window) void QGuiApplicationPrivate::applyWindowGeometrySpecificationTo(QWindow *window)
{ {
windowGeometrySpecification.applyTo(window); windowGeometrySpecification.applyTo(window);

View File

@ -326,6 +326,8 @@ public:
static void resetCachedDevicePixelRatio(); static void resetCachedDevicePixelRatio();
static bool setPalette(const QPalette &palette);
protected: protected:
virtual void notifyThemeChanged(); virtual void notifyThemeChanged();
virtual void sendApplicationPaletteChange(bool toAllWidgets = false, const char *className = nullptr); virtual void sendApplicationPaletteChange(bool toAllWidgets = false, const char *className = nullptr);

View File

@ -69,7 +69,7 @@ public:
int deviceCount(QInputDeviceManager::DeviceType type) const; int deviceCount(QInputDeviceManager::DeviceType type) const;
void setDeviceCount(QInputDeviceManager::DeviceType type, int count); void setDeviceCount(QInputDeviceManager::DeviceType type, int count);
std::array<int, QInputDeviceManager::NumDeviceTypes> m_deviceCount; std::array<int, QInputDeviceManager::NumDeviceTypes> m_deviceCount = {};
Qt::KeyboardModifiers keyboardModifiers; Qt::KeyboardModifiers keyboardModifiers;
}; };

View File

@ -1330,6 +1330,7 @@ void QOpenGL2PaintEngineExPrivate::drawVertexArrays(const float *data, int *stop
QOpenGL2PaintEngineEx::QOpenGL2PaintEngineEx() QOpenGL2PaintEngineEx::QOpenGL2PaintEngineEx()
: QPaintEngineEx(*(new QOpenGL2PaintEngineExPrivate(this))) : QPaintEngineEx(*(new QOpenGL2PaintEngineExPrivate(this)))
{ {
gccaps &= ~QPaintEngine::RasterOpModes;
} }
QOpenGL2PaintEngineEx::~QOpenGL2PaintEngineEx() QOpenGL2PaintEngineEx::~QOpenGL2PaintEngineEx()

View File

@ -341,9 +341,10 @@ void QImageTextureGlyphCache::fillTexture(const Coord &c, glyph_t g, QFixed subP
} else if (m_format == QFontEngine::Format_Mono) { } else if (m_format == QFontEngine::Format_Mono) {
if (mask.depth() > 1) { if (mask.depth() > 1) {
// TODO optimize this // TODO optimize this
mask = mask.alphaChannel(); mask.convertTo(QImage::Format_Alpha8);
mask.reinterpretAsFormat(QImage::Format_Grayscale8);
mask.invertPixels(); mask.invertPixels();
mask = mask.convertToFormat(QImage::Format_Mono, Qt::ThresholdDither); mask.convertTo(QImage::Format_Mono, Qt::ThresholdDither);
} }
int mw = qMin(mask.width(), c.w); int mw = qMin(mask.width(), c.w);

View File

@ -3939,6 +3939,12 @@ void QRhiImplementation::textureFormatInfo(QRhiTexture::Format format, const QSi
case QRhiTexture::RGBA32F: case QRhiTexture::RGBA32F:
bpc = 16; bpc = 16;
break; break;
case QRhiTexture::R16F:
bpc = 2;
break;
case QRhiTexture::R32F:
bpc = 4;
break;
case QRhiTexture::D16: case QRhiTexture::D16:
bpc = 2; bpc = 2;

View File

@ -728,6 +728,8 @@ public:
RGBA16F, RGBA16F,
RGBA32F, RGBA32F,
R16F,
R32F,
D16, D16,
D32F, D32F,

View File

@ -630,9 +630,7 @@ void QRhiD3D11::setShaderResources(QRhiCommandBuffer *cb, QRhiShaderResourceBind
} }
break; break;
case QRhiShaderResourceBinding::ImageLoad: case QRhiShaderResourceBinding::ImageLoad:
Q_FALLTHROUGH();
case QRhiShaderResourceBinding::ImageStore: case QRhiShaderResourceBinding::ImageStore:
Q_FALLTHROUGH();
case QRhiShaderResourceBinding::ImageLoadStore: case QRhiShaderResourceBinding::ImageLoadStore:
{ {
QD3D11Texture *texD = QRHI_RES(QD3D11Texture, b->u.simage.tex); QD3D11Texture *texD = QRHI_RES(QD3D11Texture, b->u.simage.tex);
@ -644,9 +642,7 @@ void QRhiD3D11::setShaderResources(QRhiCommandBuffer *cb, QRhiShaderResourceBind
} }
break; break;
case QRhiShaderResourceBinding::BufferLoad: case QRhiShaderResourceBinding::BufferLoad:
Q_FALLTHROUGH();
case QRhiShaderResourceBinding::BufferStore: case QRhiShaderResourceBinding::BufferStore:
Q_FALLTHROUGH();
case QRhiShaderResourceBinding::BufferLoadStore: case QRhiShaderResourceBinding::BufferLoadStore:
{ {
QD3D11Buffer *bufD = QRHI_RES(QD3D11Buffer, b->u.sbuf.buf); QD3D11Buffer *bufD = QRHI_RES(QD3D11Buffer, b->u.sbuf.buf);
@ -1106,6 +1102,10 @@ static inline DXGI_FORMAT toD3DTextureFormat(QRhiTexture::Format format, QRhiTex
return DXGI_FORMAT_R16G16B16A16_FLOAT; return DXGI_FORMAT_R16G16B16A16_FLOAT;
case QRhiTexture::RGBA32F: case QRhiTexture::RGBA32F:
return DXGI_FORMAT_R32G32B32A32_FLOAT; return DXGI_FORMAT_R32G32B32A32_FLOAT;
case QRhiTexture::R16F:
return DXGI_FORMAT_R16_FLOAT;
case QRhiTexture::R32F:
return DXGI_FORMAT_R32_FLOAT;
case QRhiTexture::D16: case QRhiTexture::D16:
return DXGI_FORMAT_R16_TYPELESS; return DXGI_FORMAT_R16_TYPELESS;
@ -1128,39 +1128,24 @@ static inline DXGI_FORMAT toD3DTextureFormat(QRhiTexture::Format format, QRhiTex
return srgb ? DXGI_FORMAT_BC7_UNORM_SRGB : DXGI_FORMAT_BC7_UNORM; return srgb ? DXGI_FORMAT_BC7_UNORM_SRGB : DXGI_FORMAT_BC7_UNORM;
case QRhiTexture::ETC2_RGB8: case QRhiTexture::ETC2_RGB8:
Q_FALLTHROUGH();
case QRhiTexture::ETC2_RGB8A1: case QRhiTexture::ETC2_RGB8A1:
Q_FALLTHROUGH();
case QRhiTexture::ETC2_RGBA8: case QRhiTexture::ETC2_RGBA8:
qWarning("QRhiD3D11 does not support ETC2 textures"); qWarning("QRhiD3D11 does not support ETC2 textures");
return DXGI_FORMAT_R8G8B8A8_UNORM; return DXGI_FORMAT_R8G8B8A8_UNORM;
case QRhiTexture::ASTC_4x4: case QRhiTexture::ASTC_4x4:
Q_FALLTHROUGH();
case QRhiTexture::ASTC_5x4: case QRhiTexture::ASTC_5x4:
Q_FALLTHROUGH();
case QRhiTexture::ASTC_5x5: case QRhiTexture::ASTC_5x5:
Q_FALLTHROUGH();
case QRhiTexture::ASTC_6x5: case QRhiTexture::ASTC_6x5:
Q_FALLTHROUGH();
case QRhiTexture::ASTC_6x6: case QRhiTexture::ASTC_6x6:
Q_FALLTHROUGH();
case QRhiTexture::ASTC_8x5: case QRhiTexture::ASTC_8x5:
Q_FALLTHROUGH();
case QRhiTexture::ASTC_8x6: case QRhiTexture::ASTC_8x6:
Q_FALLTHROUGH();
case QRhiTexture::ASTC_8x8: case QRhiTexture::ASTC_8x8:
Q_FALLTHROUGH();
case QRhiTexture::ASTC_10x5: case QRhiTexture::ASTC_10x5:
Q_FALLTHROUGH();
case QRhiTexture::ASTC_10x6: case QRhiTexture::ASTC_10x6:
Q_FALLTHROUGH();
case QRhiTexture::ASTC_10x8: case QRhiTexture::ASTC_10x8:
Q_FALLTHROUGH();
case QRhiTexture::ASTC_10x10: case QRhiTexture::ASTC_10x10:
Q_FALLTHROUGH();
case QRhiTexture::ASTC_12x10: case QRhiTexture::ASTC_12x10:
Q_FALLTHROUGH();
case QRhiTexture::ASTC_12x12: case QRhiTexture::ASTC_12x12:
qWarning("QRhiD3D11 does not support ASTC textures"); qWarning("QRhiD3D11 does not support ASTC textures");
return DXGI_FORMAT_R8G8B8A8_UNORM; return DXGI_FORMAT_R8G8B8A8_UNORM;
@ -1201,7 +1186,6 @@ static inline bool isDepthTextureFormat(QRhiTexture::Format format)
{ {
switch (format) { switch (format) {
case QRhiTexture::Format::D16: case QRhiTexture::Format::D16:
Q_FALLTHROUGH();
case QRhiTexture::Format::D32F: case QRhiTexture::Format::D32F:
return true; return true;
@ -1867,9 +1851,7 @@ void QRhiD3D11::updateShaderResourceBindings(QD3D11ShaderResourceBindings *srbD)
} }
break; break;
case QRhiShaderResourceBinding::ImageLoad: case QRhiShaderResourceBinding::ImageLoad:
Q_FALLTHROUGH();
case QRhiShaderResourceBinding::ImageStore: case QRhiShaderResourceBinding::ImageStore:
Q_FALLTHROUGH();
case QRhiShaderResourceBinding::ImageLoadStore: case QRhiShaderResourceBinding::ImageLoadStore:
{ {
QD3D11Texture *texD = QRHI_RES(QD3D11Texture, b->u.simage.tex); QD3D11Texture *texD = QRHI_RES(QD3D11Texture, b->u.simage.tex);
@ -1885,9 +1867,7 @@ void QRhiD3D11::updateShaderResourceBindings(QD3D11ShaderResourceBindings *srbD)
} }
break; break;
case QRhiShaderResourceBinding::BufferLoad: case QRhiShaderResourceBinding::BufferLoad:
Q_FALLTHROUGH();
case QRhiShaderResourceBinding::BufferStore: case QRhiShaderResourceBinding::BufferStore:
Q_FALLTHROUGH();
case QRhiShaderResourceBinding::BufferLoadStore: case QRhiShaderResourceBinding::BufferLoadStore:
{ {
QD3D11Buffer *bufD = QRHI_RES(QD3D11Buffer, b->u.sbuf.buf); QD3D11Buffer *bufD = QRHI_RES(QD3D11Buffer, b->u.sbuf.buf);
@ -3356,11 +3336,9 @@ static inline D3D11_BLEND toD3DBlendFactor(QRhiGraphicsPipeline::BlendFactor f)
case QRhiGraphicsPipeline::OneMinusDstAlpha: case QRhiGraphicsPipeline::OneMinusDstAlpha:
return D3D11_BLEND_INV_DEST_ALPHA; return D3D11_BLEND_INV_DEST_ALPHA;
case QRhiGraphicsPipeline::ConstantColor: case QRhiGraphicsPipeline::ConstantColor:
Q_FALLTHROUGH();
case QRhiGraphicsPipeline::ConstantAlpha: case QRhiGraphicsPipeline::ConstantAlpha:
return D3D11_BLEND_BLEND_FACTOR; return D3D11_BLEND_BLEND_FACTOR;
case QRhiGraphicsPipeline::OneMinusConstantColor: case QRhiGraphicsPipeline::OneMinusConstantColor:
Q_FALLTHROUGH();
case QRhiGraphicsPipeline::OneMinusConstantAlpha: case QRhiGraphicsPipeline::OneMinusConstantAlpha:
return D3D11_BLEND_INV_BLEND_FACTOR; return D3D11_BLEND_INV_BLEND_FACTOR;
case QRhiGraphicsPipeline::SrcAlphaSaturate: case QRhiGraphicsPipeline::SrcAlphaSaturate:

View File

@ -165,6 +165,14 @@ QT_BEGIN_NAMESPACE
#define GL_RGBA16F 0x881A #define GL_RGBA16F 0x881A
#endif #endif
#ifndef GL_R16F
#define GL_R16F 0x822D
#endif
#ifndef GL_R32F
#define GL_R32F 0x822E
#endif
#ifndef GL_HALF_FLOAT #ifndef GL_HALF_FLOAT
#define GL_HALF_FLOAT 0x140B #define GL_HALF_FLOAT 0x140B
#endif #endif
@ -681,7 +689,6 @@ bool QRhiGles2::isTextureFormatSupported(QRhiTexture::Format format, QRhiTexture
switch (format) { switch (format) {
case QRhiTexture::D16: case QRhiTexture::D16:
Q_FALLTHROUGH();
case QRhiTexture::D32F: case QRhiTexture::D32F:
return caps.depthTexture; return caps.depthTexture;
@ -695,10 +702,13 @@ bool QRhiGles2::isTextureFormatSupported(QRhiTexture::Format format, QRhiTexture
return caps.r16Format; return caps.r16Format;
case QRhiTexture::RGBA16F: case QRhiTexture::RGBA16F:
Q_FALLTHROUGH();
case QRhiTexture::RGBA32F: case QRhiTexture::RGBA32F:
return caps.floatFormats; return caps.floatFormats;
case QRhiTexture::R16F:
case QRhiTexture::R32F:
return caps.floatFormats;
default: default:
break; break;
} }
@ -899,9 +909,7 @@ void QRhiGles2::setShaderResources(QRhiCommandBuffer *cb, QRhiShaderResourceBind
QRhiPassResourceTracker::toPassTrackerTextureStage(b->stage)); QRhiPassResourceTracker::toPassTrackerTextureStage(b->stage));
break; break;
case QRhiShaderResourceBinding::ImageLoad: case QRhiShaderResourceBinding::ImageLoad:
Q_FALLTHROUGH();
case QRhiShaderResourceBinding::ImageStore: case QRhiShaderResourceBinding::ImageStore:
Q_FALLTHROUGH();
case QRhiShaderResourceBinding::ImageLoadStore: case QRhiShaderResourceBinding::ImageLoadStore:
{ {
QGles2Texture *texD = QRHI_RES(QGles2Texture, b->u.simage.tex); QGles2Texture *texD = QRHI_RES(QGles2Texture, b->u.simage.tex);
@ -917,9 +925,7 @@ void QRhiGles2::setShaderResources(QRhiCommandBuffer *cb, QRhiShaderResourceBind
} }
break; break;
case QRhiShaderResourceBinding::BufferLoad: case QRhiShaderResourceBinding::BufferLoad:
Q_FALLTHROUGH();
case QRhiShaderResourceBinding::BufferStore: case QRhiShaderResourceBinding::BufferStore:
Q_FALLTHROUGH();
case QRhiShaderResourceBinding::BufferLoadStore: case QRhiShaderResourceBinding::BufferLoadStore:
{ {
QGles2Buffer *bufD = QRHI_RES(QGles2Buffer, b->u.sbuf.buf); QGles2Buffer *bufD = QRHI_RES(QGles2Buffer, b->u.sbuf.buf);
@ -1654,11 +1660,8 @@ static inline GLenum toGlBlendFactor(QRhiGraphicsPipeline::BlendFactor f)
case QRhiGraphicsPipeline::SrcAlphaSaturate: case QRhiGraphicsPipeline::SrcAlphaSaturate:
return GL_SRC_ALPHA_SATURATE; return GL_SRC_ALPHA_SATURATE;
case QRhiGraphicsPipeline::Src1Color: case QRhiGraphicsPipeline::Src1Color:
Q_FALLTHROUGH();
case QRhiGraphicsPipeline::OneMinusSrc1Color: case QRhiGraphicsPipeline::OneMinusSrc1Color:
Q_FALLTHROUGH();
case QRhiGraphicsPipeline::Src1Alpha: case QRhiGraphicsPipeline::Src1Alpha:
Q_FALLTHROUGH();
case QRhiGraphicsPipeline::OneMinusSrc1Alpha: case QRhiGraphicsPipeline::OneMinusSrc1Alpha:
qWarning("Unsupported blend factor %d", f); qWarning("Unsupported blend factor %d", f);
return GL_ZERO; return GL_ZERO;
@ -2573,9 +2576,7 @@ void QRhiGles2::bindShaderResources(QRhiGraphicsPipeline *maybeGraphicsPs, QRhiC
} }
break; break;
case QRhiShaderResourceBinding::ImageLoad: case QRhiShaderResourceBinding::ImageLoad:
Q_FALLTHROUGH();
case QRhiShaderResourceBinding::ImageStore: case QRhiShaderResourceBinding::ImageStore:
Q_FALLTHROUGH();
case QRhiShaderResourceBinding::ImageLoadStore: case QRhiShaderResourceBinding::ImageLoadStore:
{ {
QGles2Texture *texD = QRHI_RES(QGles2Texture, b->u.simage.tex); QGles2Texture *texD = QRHI_RES(QGles2Texture, b->u.simage.tex);
@ -2591,9 +2592,7 @@ void QRhiGles2::bindShaderResources(QRhiGraphicsPipeline *maybeGraphicsPs, QRhiC
} }
break; break;
case QRhiShaderResourceBinding::BufferLoad: case QRhiShaderResourceBinding::BufferLoad:
Q_FALLTHROUGH();
case QRhiShaderResourceBinding::BufferStore: case QRhiShaderResourceBinding::BufferStore:
Q_FALLTHROUGH();
case QRhiShaderResourceBinding::BufferLoadStore: case QRhiShaderResourceBinding::BufferLoadStore:
{ {
QGles2Buffer *bufD = QRHI_RES(QGles2Buffer, b->u.sbuf.buf); QGles2Buffer *bufD = QRHI_RES(QGles2Buffer, b->u.sbuf.buf);
@ -3397,6 +3396,18 @@ bool QGles2Texture::prepareBuild(QSize *adjustedSize)
glformat = GL_RGBA; glformat = GL_RGBA;
gltype = GL_FLOAT; gltype = GL_FLOAT;
break; break;
case QRhiTexture::R16F:
glintformat = GL_R16F;
glsizedintformat = glintformat;
glformat = GL_RED;
gltype = GL_HALF_FLOAT;
break;
case QRhiTexture::R32F:
glintformat = GL_R32F;
glsizedintformat = glintformat;
glformat = GL_RED;
gltype = GL_FLOAT;
break;
case QRhiTexture::D16: case QRhiTexture::D16:
glintformat = GL_DEPTH_COMPONENT16; glintformat = GL_DEPTH_COMPONENT16;
glsizedintformat = glintformat; glsizedintformat = glintformat;

View File

@ -664,15 +664,15 @@ static inline int mapBinding(int binding,
BindingType type) BindingType type)
{ {
const QShader::NativeResourceBindingMap *map = nativeResourceBindingMaps[stageIndex]; const QShader::NativeResourceBindingMap *map = nativeResourceBindingMaps[stageIndex];
if (!map) if (!map || map->isEmpty())
return binding; // old QShader versions do not have this map, assume 1:1 mapping then return binding; // old QShader versions do not have this map, assume 1:1 mapping then
auto it = map->constFind(binding); auto it = map->constFind(binding);
if (it != map->cend()) if (it != map->cend())
return type == BindingType::Sampler ? it->second : it->first; // may be -1, if the resource is inactive return type == BindingType::Sampler ? it->second : it->first; // may be -1, if the resource is inactive
// Hitting this path is normal too, is not given that the resource (e.g. a // Hitting this path is normal too. It is not given that the resource (for
// uniform block) is really present in the shaders for all the stages // example, a uniform block) is present in the shaders for all the stages
// specified by the visibility mask in the QRhiShaderResourceBinding. // specified by the visibility mask in the QRhiShaderResourceBinding.
return -1; return -1;
} }
@ -761,9 +761,7 @@ void QRhiMetal::enqueueShaderResourceBindings(QMetalShaderResourceBindings *srbD
} }
break; break;
case QRhiShaderResourceBinding::ImageLoad: case QRhiShaderResourceBinding::ImageLoad:
Q_FALLTHROUGH();
case QRhiShaderResourceBinding::ImageStore: case QRhiShaderResourceBinding::ImageStore:
Q_FALLTHROUGH();
case QRhiShaderResourceBinding::ImageLoadStore: case QRhiShaderResourceBinding::ImageLoadStore:
{ {
QMetalTexture *texD = QRHI_RES(QMetalTexture, b->u.simage.tex); QMetalTexture *texD = QRHI_RES(QMetalTexture, b->u.simage.tex);
@ -786,9 +784,7 @@ void QRhiMetal::enqueueShaderResourceBindings(QMetalShaderResourceBindings *srbD
} }
break; break;
case QRhiShaderResourceBinding::BufferLoad: case QRhiShaderResourceBinding::BufferLoad:
Q_FALLTHROUGH();
case QRhiShaderResourceBinding::BufferStore: case QRhiShaderResourceBinding::BufferStore:
Q_FALLTHROUGH();
case QRhiShaderResourceBinding::BufferLoadStore: case QRhiShaderResourceBinding::BufferLoadStore:
{ {
QMetalBuffer *bufD = QRHI_RES(QMetalBuffer, b->u.sbuf.buf); QMetalBuffer *bufD = QRHI_RES(QMetalBuffer, b->u.sbuf.buf);
@ -996,9 +992,7 @@ void QRhiMetal::setShaderResources(QRhiCommandBuffer *cb, QRhiShaderResourceBind
} }
break; break;
case QRhiShaderResourceBinding::ImageLoad: case QRhiShaderResourceBinding::ImageLoad:
Q_FALLTHROUGH();
case QRhiShaderResourceBinding::ImageStore: case QRhiShaderResourceBinding::ImageStore:
Q_FALLTHROUGH();
case QRhiShaderResourceBinding::ImageLoadStore: case QRhiShaderResourceBinding::ImageLoadStore:
{ {
QMetalTexture *texD = QRHI_RES(QMetalTexture, b->u.simage.tex); QMetalTexture *texD = QRHI_RES(QMetalTexture, b->u.simage.tex);
@ -1011,9 +1005,7 @@ void QRhiMetal::setShaderResources(QRhiCommandBuffer *cb, QRhiShaderResourceBind
} }
break; break;
case QRhiShaderResourceBinding::BufferLoad: case QRhiShaderResourceBinding::BufferLoad:
Q_FALLTHROUGH();
case QRhiShaderResourceBinding::BufferStore: case QRhiShaderResourceBinding::BufferStore:
Q_FALLTHROUGH();
case QRhiShaderResourceBinding::BufferLoadStore: case QRhiShaderResourceBinding::BufferLoadStore:
{ {
QMetalBuffer *bufD = QRHI_RES(QMetalBuffer, b->u.sbuf.buf); QMetalBuffer *bufD = QRHI_RES(QMetalBuffer, b->u.sbuf.buf);
@ -2328,6 +2320,10 @@ static inline MTLPixelFormat toMetalTextureFormat(QRhiTexture::Format format, QR
return MTLPixelFormatRGBA16Float; return MTLPixelFormatRGBA16Float;
case QRhiTexture::RGBA32F: case QRhiTexture::RGBA32F:
return MTLPixelFormatRGBA32Float; return MTLPixelFormatRGBA32Float;
case QRhiTexture::R16F:
return MTLPixelFormatR16Float;
case QRhiTexture::R32F:
return MTLPixelFormatR32Float;
case QRhiTexture::D16: case QRhiTexture::D16:
#ifdef Q_OS_MACOS #ifdef Q_OS_MACOS
@ -2928,9 +2924,7 @@ bool QMetalShaderResourceBindings::build()
} }
break; break;
case QRhiShaderResourceBinding::ImageLoad: case QRhiShaderResourceBinding::ImageLoad:
Q_FALLTHROUGH();
case QRhiShaderResourceBinding::ImageStore: case QRhiShaderResourceBinding::ImageStore:
Q_FALLTHROUGH();
case QRhiShaderResourceBinding::ImageLoadStore: case QRhiShaderResourceBinding::ImageLoadStore:
{ {
QMetalTexture *texD = QRHI_RES(QMetalTexture, b->u.simage.tex); QMetalTexture *texD = QRHI_RES(QMetalTexture, b->u.simage.tex);
@ -2939,9 +2933,7 @@ bool QMetalShaderResourceBindings::build()
} }
break; break;
case QRhiShaderResourceBinding::BufferLoad: case QRhiShaderResourceBinding::BufferLoad:
Q_FALLTHROUGH();
case QRhiShaderResourceBinding::BufferStore: case QRhiShaderResourceBinding::BufferStore:
Q_FALLTHROUGH();
case QRhiShaderResourceBinding::BufferLoadStore: case QRhiShaderResourceBinding::BufferLoadStore:
{ {
QMetalBuffer *bufD = QRHI_RES(QMetalBuffer, b->u.sbuf.buf); QMetalBuffer *bufD = QRHI_RES(QMetalBuffer, b->u.sbuf.buf);

View File

@ -767,6 +767,10 @@ static inline VkFormat toVkTextureFormat(QRhiTexture::Format format, QRhiTexture
return VK_FORMAT_R16G16B16A16_SFLOAT; return VK_FORMAT_R16G16B16A16_SFLOAT;
case QRhiTexture::RGBA32F: case QRhiTexture::RGBA32F:
return VK_FORMAT_R32G32B32A32_SFLOAT; return VK_FORMAT_R32G32B32A32_SFLOAT;
case QRhiTexture::R16F:
return VK_FORMAT_R16_SFLOAT;
case QRhiTexture::R32F:
return VK_FORMAT_R32_SFLOAT;
case QRhiTexture::D16: case QRhiTexture::D16:
return VK_FORMAT_D16_UNORM; return VK_FORMAT_D16_UNORM;
@ -864,7 +868,6 @@ static inline bool isDepthTextureFormat(QRhiTexture::Format format)
{ {
switch (format) { switch (format) {
case QRhiTexture::Format::D16: case QRhiTexture::Format::D16:
Q_FALLTHROUGH();
case QRhiTexture::Format::D32F: case QRhiTexture::Format::D32F:
return true; return true;
@ -2373,9 +2376,7 @@ void QRhiVulkan::updateShaderResourceBindings(QRhiShaderResourceBindings *srb, i
} }
break; break;
case QRhiShaderResourceBinding::ImageLoad: case QRhiShaderResourceBinding::ImageLoad:
Q_FALLTHROUGH();
case QRhiShaderResourceBinding::ImageStore: case QRhiShaderResourceBinding::ImageStore:
Q_FALLTHROUGH();
case QRhiShaderResourceBinding::ImageLoadStore: case QRhiShaderResourceBinding::ImageLoadStore:
{ {
QVkTexture *texD = QRHI_RES(QVkTexture, b->u.simage.tex); QVkTexture *texD = QRHI_RES(QVkTexture, b->u.simage.tex);
@ -2394,9 +2395,7 @@ void QRhiVulkan::updateShaderResourceBindings(QRhiShaderResourceBindings *srb, i
} }
break; break;
case QRhiShaderResourceBinding::BufferLoad: case QRhiShaderResourceBinding::BufferLoad:
Q_FALLTHROUGH();
case QRhiShaderResourceBinding::BufferStore: case QRhiShaderResourceBinding::BufferStore:
Q_FALLTHROUGH();
case QRhiShaderResourceBinding::BufferLoadStore: case QRhiShaderResourceBinding::BufferLoadStore:
{ {
QVkBuffer *bufD = QRHI_RES(QVkBuffer, b->u.sbuf.buf); QVkBuffer *bufD = QRHI_RES(QVkBuffer, b->u.sbuf.buf);
@ -3564,9 +3563,7 @@ static inline VkImageLayout toVkLayout(QRhiPassResourceTracker::TextureAccess ac
case QRhiPassResourceTracker::TexDepthOutput: case QRhiPassResourceTracker::TexDepthOutput:
return VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL; return VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
case QRhiPassResourceTracker::TexStorageLoad: case QRhiPassResourceTracker::TexStorageLoad:
Q_FALLTHROUGH();
case QRhiPassResourceTracker::TexStorageStore: case QRhiPassResourceTracker::TexStorageStore:
Q_FALLTHROUGH();
case QRhiPassResourceTracker::TexStorageLoadStore: case QRhiPassResourceTracker::TexStorageLoadStore:
return VK_IMAGE_LAYOUT_GENERAL; return VK_IMAGE_LAYOUT_GENERAL;
default: default:
@ -4045,9 +4042,7 @@ void QRhiVulkan::setShaderResources(QRhiCommandBuffer *cb, QRhiShaderResourceBin
} }
break; break;
case QRhiShaderResourceBinding::ImageLoad: case QRhiShaderResourceBinding::ImageLoad:
Q_FALLTHROUGH();
case QRhiShaderResourceBinding::ImageStore: case QRhiShaderResourceBinding::ImageStore:
Q_FALLTHROUGH();
case QRhiShaderResourceBinding::ImageLoadStore: case QRhiShaderResourceBinding::ImageLoadStore:
{ {
QVkTexture *texD = QRHI_RES(QVkTexture, b->u.simage.tex); QVkTexture *texD = QRHI_RES(QVkTexture, b->u.simage.tex);
@ -4072,9 +4067,7 @@ void QRhiVulkan::setShaderResources(QRhiCommandBuffer *cb, QRhiShaderResourceBin
} }
break; break;
case QRhiShaderResourceBinding::BufferLoad: case QRhiShaderResourceBinding::BufferLoad:
Q_FALLTHROUGH();
case QRhiShaderResourceBinding::BufferStore: case QRhiShaderResourceBinding::BufferStore:
Q_FALLTHROUGH();
case QRhiShaderResourceBinding::BufferLoadStore: case QRhiShaderResourceBinding::BufferLoadStore:
{ {
QVkBuffer *bufD = QRHI_RES(QVkBuffer, b->u.sbuf.buf); QVkBuffer *bufD = QRHI_RES(QVkBuffer, b->u.sbuf.buf);
@ -4863,16 +4856,12 @@ static inline VkDescriptorType toVkDescriptorType(const QRhiShaderResourceBindin
return VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; return VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
case QRhiShaderResourceBinding::ImageLoad: case QRhiShaderResourceBinding::ImageLoad:
Q_FALLTHROUGH();
case QRhiShaderResourceBinding::ImageStore: case QRhiShaderResourceBinding::ImageStore:
Q_FALLTHROUGH();
case QRhiShaderResourceBinding::ImageLoadStore: case QRhiShaderResourceBinding::ImageLoadStore:
return VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; return VK_DESCRIPTOR_TYPE_STORAGE_IMAGE;
case QRhiShaderResourceBinding::BufferLoad: case QRhiShaderResourceBinding::BufferLoad:
Q_FALLTHROUGH();
case QRhiShaderResourceBinding::BufferStore: case QRhiShaderResourceBinding::BufferStore:
Q_FALLTHROUGH();
case QRhiShaderResourceBinding::BufferLoadStore: case QRhiShaderResourceBinding::BufferLoadStore:
return VK_DESCRIPTOR_TYPE_STORAGE_BUFFER; return VK_DESCRIPTOR_TYPE_STORAGE_BUFFER;
@ -6356,17 +6345,11 @@ static inline bool isSrgbFormat(VkFormat format)
{ {
switch (format) { switch (format) {
case VK_FORMAT_R8_SRGB: case VK_FORMAT_R8_SRGB:
Q_FALLTHROUGH();
case VK_FORMAT_R8G8_SRGB: case VK_FORMAT_R8G8_SRGB:
Q_FALLTHROUGH();
case VK_FORMAT_R8G8B8_SRGB: case VK_FORMAT_R8G8B8_SRGB:
Q_FALLTHROUGH();
case VK_FORMAT_B8G8R8_SRGB: case VK_FORMAT_B8G8R8_SRGB:
Q_FALLTHROUGH();
case VK_FORMAT_R8G8B8A8_SRGB: case VK_FORMAT_R8G8B8A8_SRGB:
Q_FALLTHROUGH();
case VK_FORMAT_B8G8R8A8_SRGB: case VK_FORMAT_B8G8R8A8_SRGB:
Q_FALLTHROUGH();
case VK_FORMAT_A8B8G8R8_SRGB_PACK32: case VK_FORMAT_A8B8G8R8_SRGB_PACK32:
return true; return true;
default: default:

View File

@ -439,10 +439,19 @@ QShader QShader::fromSerialized(const QByteArray &data)
d->stage = Stage(intVal); d->stage = Stage(intVal);
QByteArray descBin; QByteArray descBin;
ds >> descBin; ds >> descBin;
if (d->qsbVersion > QShaderPrivate::QSB_VERSION_WITH_BINARY_JSON) if (d->qsbVersion > QShaderPrivate::QSB_VERSION_WITH_BINARY_JSON) {
d->desc = QShaderDescription::fromCbor(descBin); d->desc = QShaderDescription::fromCbor(descBin);
else } else {
#if QT_CONFIG(binaryjson) && QT_DEPRECATED_SINCE(5, 15)
QT_WARNING_PUSH
QT_WARNING_DISABLE_DEPRECATED
d->desc = QShaderDescription::fromBinaryJson(descBin); d->desc = QShaderDescription::fromBinaryJson(descBin);
QT_WARNING_POP
#else
qWarning("Cannot load QShaderDescription from binary JSON due to disabled binaryjson feature");
d->desc = QShaderDescription();
#endif
}
int count; int count;
ds >> count; ds >> count;
for (int i = 0; i < count; ++i) { for (int i = 0; i < count; ++i) {

View File

@ -102,8 +102,8 @@ QT_BEGIN_NAMESPACE
float \c opacity at offset 64. float \c opacity at offset 64.
All this is described by a QShaderDescription object. QShaderDescription All this is described by a QShaderDescription object. QShaderDescription
can also be serialized to JSON and binary JSON, and can be deserialized can also be serialized to JSON and CBOR, and can be deserialized
from binary JSON. In practice this is rarely needed since QShader from CBOR. In practice this is rarely needed since QShader
takes care of the associated QShaderDescription automatically, but if the takes care of the associated QShaderDescription automatically, but if the
QShaderDescription of the above shader would be written out as JSON, it QShaderDescription of the above shader would be written out as JSON, it
would look like the following: would look like the following:
@ -335,29 +335,11 @@ bool QShaderDescription::isValid() const
|| !d->combinedImageSamplers.isEmpty() || !d->storageImages.isEmpty(); || !d->combinedImageSamplers.isEmpty() || !d->storageImages.isEmpty();
} }
/*!
\return a serialized binary version of the data.
\sa toJson(), toCbor()
*/
QByteArray QShaderDescription::toBinaryJson() const
{
#if QT_CONFIG(binaryjson) && QT_DEPRECATED_SINCE(5, 15)
QT_WARNING_PUSH
QT_WARNING_DISABLE_DEPRECATED
return d->makeDoc().toBinaryData();
QT_WARNING_POP
#else
qWarning("Cannot generate binary JSON from QShaderDescription due to disabled binaryjson feature");
return QByteArray();
#endif
}
/*! /*!
\return a serialized binary version of the data in CBOR (Concise Binary \return a serialized binary version of the data in CBOR (Concise Binary
Object Representation) format. Object Representation) format.
\sa QCborValue, toBinaryJson(), toJson() \sa QCborValue, toJson()
*/ */
QByteArray QShaderDescription::toCbor() const QByteArray QShaderDescription::toCbor() const
{ {
@ -369,14 +351,17 @@ QByteArray QShaderDescription::toCbor() const
\note There is no deserialization method provided for JSON text. \note There is no deserialization method provided for JSON text.
\sa toBinaryJson(), toCbor() \sa toCbor()
*/ */
QByteArray QShaderDescription::toJson() const QByteArray QShaderDescription::toJson() const
{ {
return d->makeDoc().toJson(); return d->makeDoc().toJson();
} }
#if QT_CONFIG(binaryjson) && QT_DEPRECATED_SINCE(5, 15)
/*! /*!
\deprecated
Deserializes the given binary JSON \a data and returns a new Deserializes the given binary JSON \a data and returns a new
QShaderDescription. QShaderDescription.
@ -385,22 +370,16 @@ QByteArray QShaderDescription::toJson() const
QShaderDescription QShaderDescription::fromBinaryJson(const QByteArray &data) QShaderDescription QShaderDescription::fromBinaryJson(const QByteArray &data)
{ {
QShaderDescription desc; QShaderDescription desc;
#if QT_CONFIG(binaryjson) && QT_DEPRECATED_SINCE(5, 15)
QT_WARNING_PUSH QT_WARNING_PUSH
QT_WARNING_DISABLE_DEPRECATED QT_WARNING_DISABLE_DEPRECATED
QShaderDescriptionPrivate::get(&desc)->loadDoc(QJsonDocument::fromBinaryData(data)); QShaderDescriptionPrivate::get(&desc)->loadDoc(QJsonDocument::fromBinaryData(data));
QT_WARNING_POP QT_WARNING_POP
#else
Q_UNUSED(data);
qWarning("Cannot load QShaderDescription from binary JSON due to disabled binaryjson feature");
#endif
return desc; return desc;
} }
#endif
/*! /*!
Deserializes the given CBOR \a data and returns a new QShaderDescription. Deserializes the given CBOR \a data and returns a new QShaderDescription.
\sa fromBinaryJson()
*/ */
QShaderDescription QShaderDescription::fromCbor(const QByteArray &data) QShaderDescription QShaderDescription::fromCbor(const QByteArray &data)
{ {

View File

@ -68,11 +68,13 @@ public:
bool isValid() const; bool isValid() const;
QByteArray toBinaryJson() const;
QByteArray toCbor() const; QByteArray toCbor() const;
QByteArray toJson() const; QByteArray toJson() const;
#if QT_CONFIG(binaryjson) && QT_DEPRECATED_SINCE(5, 15)
QT_DEPRECATED_X("Use CBOR format instead")
static QShaderDescription fromBinaryJson(const QByteArray &data); static QShaderDescription fromBinaryJson(const QByteArray &data);
#endif
static QShaderDescription fromCbor(const QByteArray &data); static QShaderDescription fromCbor(const QByteArray &data);
enum VariableType { enum VariableType {

View File

@ -233,7 +233,7 @@ void QHttpProtocolHandler::_q_readyRead()
char c; char c;
qint64 ret = m_socket->peek(&c, 1); qint64 ret = m_socket->peek(&c, 1);
if (ret < 0) { if (ret < 0) {
m_channel->_q_error(m_socket->error()); m_channel->_q_error(m_socket->socketError());
// We still need to handle the reply so it emits its signals etc. // We still need to handle the reply so it emits its signals etc.
if (m_reply) if (m_reply)
_q_receiveReply(); _q_receiveReply();

View File

@ -242,9 +242,9 @@ void QNetworkAccessDebugPipeBackend::closeDownstreamChannel()
void QNetworkAccessDebugPipeBackend::socketError() void QNetworkAccessDebugPipeBackend::socketError()
{ {
qWarning("QNetworkAccessDebugPipeBackend::socketError() %d",socket.error()); qWarning("QNetworkAccessDebugPipeBackend::socketError() %d",socket.socketError());
QNetworkReply::NetworkError code; QNetworkReply::NetworkError code;
switch (socket.error()) { switch (socket.socketError()) {
case QAbstractSocket::RemoteHostClosedError: case QAbstractSocket::RemoteHostClosedError:
return; // socketDisconnected will be called return; // socketDisconnected will be called

View File

@ -215,7 +215,7 @@
connections, you will have to register it with Q_DECLARE_METATYPE() and connections, you will have to register it with Q_DECLARE_METATYPE() and
qRegisterMetaType(). qRegisterMetaType().
\sa error(), errorString(), {Creating Custom Qt Types} \sa socketError(), errorString(), {Creating Custom Qt Types}
*/ */
/*! /*!
@ -329,7 +329,7 @@
is non-blocking). is non-blocking).
\value UnknownSocketError An unidentified error occurred. \value UnknownSocketError An unidentified error occurred.
\sa QAbstractSocket::error() \sa QAbstractSocket::socketError()
*/ */
/*! /*!
@ -2094,7 +2094,7 @@ QVariant QAbstractSocket::socketOption(QAbstractSocket::SocketOption option)
Waits until the socket is connected, up to \a msecs Waits until the socket is connected, up to \a msecs
milliseconds. If the connection has been established, this milliseconds. If the connection has been established, this
function returns \c true; otherwise it returns \c false. In the case function returns \c true; otherwise it returns \c false. In the case
where it returns \c false, you can call error() to determine where it returns \c false, you can call socketError() to determine
the cause of the error. the cause of the error.
The following example waits up to one second for a connection The following example waits up to one second for a connection
@ -2873,7 +2873,7 @@ void QAbstractSocket::setReadBufferSize(qint64 size)
/*! /*!
Returns the state of the socket. Returns the state of the socket.
\sa error() \sa socketError()
*/ */
QAbstractSocket::SocketState QAbstractSocket::state() const QAbstractSocket::SocketState QAbstractSocket::state() const
{ {
@ -2900,16 +2900,35 @@ QAbstractSocket::SocketType QAbstractSocket::socketType() const
return d_func()->socketType; return d_func()->socketType;
} }
#if QT_DEPRECATED_SINCE(5, 15)
/*! /*!
\deprecated
Use socketError() instead.
Returns the type of error that last occurred.
\sa state(), errorString(), socketError()
*/
QAbstractSocket::SocketError QAbstractSocket::error() const
{
return socketError();
}
#endif // QT_DEPRECATED_SINCE(5, 15)
/*!
\since 5.15
Returns the type of error that last occurred. Returns the type of error that last occurred.
\sa state(), errorString() \sa state(), errorString()
*/ */
QAbstractSocket::SocketError QAbstractSocket::error() const QAbstractSocket::SocketError QAbstractSocket::socketError() const
{ {
return d_func()->socketError; return d_func()->socketError;
} }
/*! /*!
Sets the type of error that last occurred to \a socketError. Sets the type of error that last occurred to \a socketError.

View File

@ -180,7 +180,12 @@ public:
SocketType socketType() const; SocketType socketType() const;
SocketState state() const; SocketState state() const;
SocketError error() const;
#if QT_DEPRECATED_SINCE(5, 15)
QT_DEPRECATED_X("Use socketError()") SocketError error() const;
#endif // QT_DEPRECATED_SINCE(5, 15)
SocketError socketError() const;
// from QIODevice // from QIODevice
void close() override; void close() override;

View File

@ -370,8 +370,8 @@ bool QHttpSocketEngine::waitForRead(int msecs, bool *timedOut)
if (!d->socket->waitForReadyRead(qt_subtract_from_timeout(msecs, stopWatch.elapsed()))) { if (!d->socket->waitForReadyRead(qt_subtract_from_timeout(msecs, stopWatch.elapsed()))) {
if (d->socket->state() == QAbstractSocket::UnconnectedState) if (d->socket->state() == QAbstractSocket::UnconnectedState)
return true; return true;
setError(d->socket->error(), d->socket->errorString()); setError(d->socket->socketError(), d->socket->errorString());
if (timedOut && d->socket->error() == QAbstractSocket::SocketTimeoutError) if (timedOut && d->socket->socketError() == QAbstractSocket::SocketTimeoutError)
*timedOut = true; *timedOut = true;
return false; return false;
} }
@ -385,8 +385,8 @@ bool QHttpSocketEngine::waitForRead(int msecs, bool *timedOut)
// Report any error that may occur. // Report any error that may occur.
if (d->state != Connected) { if (d->state != Connected) {
setError(d->socket->error(), d->socket->errorString()); setError(d->socket->socketError(), d->socket->errorString());
if (timedOut && d->socket->error() == QAbstractSocket::SocketTimeoutError) if (timedOut && d->socket->socketError() == QAbstractSocket::SocketTimeoutError)
*timedOut = true; *timedOut = true;
return false; return false;
} }
@ -401,7 +401,7 @@ bool QHttpSocketEngine::waitForWrite(int msecs, bool *timedOut)
if (d->state == Connected) { if (d->state == Connected) {
if (d->socket->bytesToWrite()) { if (d->socket->bytesToWrite()) {
if (!d->socket->waitForBytesWritten(msecs)) { if (!d->socket->waitForBytesWritten(msecs)) {
if (d->socket->error() == QAbstractSocket::SocketTimeoutError && timedOut) if (d->socket->socketError() == QAbstractSocket::SocketTimeoutError && timedOut)
*timedOut = true; *timedOut = true;
return false; return false;
} }
@ -421,8 +421,7 @@ bool QHttpSocketEngine::waitForWrite(int msecs, bool *timedOut)
// Report any error that may occur. // Report any error that may occur.
if (d->state != Connected) { if (d->state != Connected) {
// setError(d->socket->error(), d->socket->errorString()); if (timedOut && d->socket->socketError() == QAbstractSocket::SocketTimeoutError)
if (timedOut && d->socket->error() == QAbstractSocket::SocketTimeoutError)
*timedOut = true; *timedOut = true;
} }

View File

@ -220,11 +220,25 @@ QT_BEGIN_NAMESPACE
/*! /*!
\fn QLocalSocket::LocalSocketError QLocalSocket::error() const \fn QLocalSocket::LocalSocketError QLocalSocket::error() const
\deprecated
Use socketError() instead.
Returns the type of error that last occurred.
\sa state(), errorString(), socketError()
*/
/*!
\fn QLocalSocket::LocalSocketError QLocalSocket::socketError() const
\since 5.15
Returns the type of error that last occurred. Returns the type of error that last occurred.
\sa state(), errorString() \sa state(), errorString()
*/ */
/*! /*!
\fn bool QLocalSocket::isValid() const \fn bool QLocalSocket::isValid() const
@ -272,7 +286,7 @@ QT_BEGIN_NAMESPACE
Waits until the socket is connected, up to \a msecs milliseconds. If the Waits until the socket is connected, up to \a msecs milliseconds. If the
connection has been established, this function returns \c true; otherwise connection has been established, this function returns \c true; otherwise
it returns \c false. In the case where it returns \c false, you can call it returns \c false. In the case where it returns \c false, you can call
error() to determine the cause of the error. socketError() to determine the cause of the error.
The following example waits up to one second for a connection The following example waits up to one second for a connection
to be established: to be established:
@ -291,7 +305,7 @@ QT_BEGIN_NAMESPACE
connection was successfully disconnected, this function returns \c true; connection was successfully disconnected, this function returns \c true;
otherwise it returns \c false (if the operation timed out, if an error otherwise it returns \c false (if the operation timed out, if an error
occurred, or if this QLocalSocket is already disconnected). In the case occurred, or if this QLocalSocket is already disconnected). In the case
where it returns \c false, you can call error() to determine the cause of where it returns \c false, you can call socketError() to determine the cause of
the error. the error.
The following example waits up to one second for a connection The following example waits up to one second for a connection
@ -337,7 +351,7 @@ QT_BEGIN_NAMESPACE
connections, you will have to register it with Q_DECLARE_METATYPE() and connections, you will have to register it with Q_DECLARE_METATYPE() and
qRegisterMetaType(). qRegisterMetaType().
\sa error(), errorString(), {Creating Custom Qt Types} \sa socketError(), errorString(), {Creating Custom Qt Types}
*/ */
/*! /*!
@ -446,7 +460,7 @@ QString QLocalSocket::fullServerName() const
/*! /*!
Returns the state of the socket. Returns the state of the socket.
\sa error() \sa socketError()
*/ */
QLocalSocket::LocalSocketState QLocalSocket::state() const QLocalSocket::LocalSocketState QLocalSocket::state() const
{ {
@ -466,7 +480,7 @@ bool QLocalSocket::isSequential() const
The LocalServerError enumeration represents the errors that can occur. The LocalServerError enumeration represents the errors that can occur.
The most recent error can be retrieved through a call to The most recent error can be retrieved through a call to
\l QLocalSocket::error(). \l QLocalSocket::socketError().
\value ConnectionRefusedError The connection was refused by \value ConnectionRefusedError The connection was refused by
the peer (or timed out). the peer (or timed out).

View File

@ -97,7 +97,12 @@ public:
virtual bool canReadLine() const override; virtual bool canReadLine() const override;
virtual bool open(OpenMode openMode = ReadWrite) override; virtual bool open(OpenMode openMode = ReadWrite) override;
virtual void close() override; virtual void close() override;
LocalSocketError error() const;
#if QT_DEPRECATED_SINCE(5, 15)
QT_DEPRECATED_X("Use socketError()") LocalSocketError error() const;
#endif // QT_DEPRECATED_SINCE(5, 15)
LocalSocketError socketError() const;
bool flush(); bool flush();
bool isValid() const; bool isValid() const;
qint64 readBufferSize() const; qint64 readBufferSize() const;

View File

@ -363,7 +363,14 @@ void QLocalSocket::disconnectFromServer()
d->tcpSocket->disconnectFromHost(); d->tcpSocket->disconnectFromHost();
} }
#if QT_DEPRECATED_SINCE(5, 15)
QLocalSocket::LocalSocketError QLocalSocket::error() const QLocalSocket::LocalSocketError QLocalSocket::error() const
{
return socketError();
}
#endif // QT_DEPRECATED_SINCE(5, 15)
QLocalSocket::LocalSocketError QLocalSocket::socketError() const
{ {
Q_D(const QLocalSocket); Q_D(const QLocalSocket);
switch (d->tcpSocket->error()) { switch (d->tcpSocket->error()) {

View File

@ -461,10 +461,17 @@ void QLocalSocket::disconnectFromServer()
d->unixSocket.disconnectFromHost(); d->unixSocket.disconnectFromHost();
} }
#if QT_DEPRECATED_SINCE(5, 15)
QLocalSocket::LocalSocketError QLocalSocket::error() const QLocalSocket::LocalSocketError QLocalSocket::error() const
{
return socketError();
}
#endif // QT_DEPRECATED_SINCE(5, 15)
QLocalSocket::LocalSocketError QLocalSocket::socketError() const
{ {
Q_D(const QLocalSocket); Q_D(const QLocalSocket);
switch (d->unixSocket.error()) { switch (d->unixSocket.socketError()) {
case QAbstractSocket::ConnectionRefusedError: case QAbstractSocket::ConnectionRefusedError:
return QLocalSocket::ConnectionRefusedError; return QLocalSocket::ConnectionRefusedError;
case QAbstractSocket::RemoteHostClosedError: case QAbstractSocket::RemoteHostClosedError:

View File

@ -330,7 +330,14 @@ void QLocalSocket::disconnectFromServer()
} }
} }
#if QT_DEPRECATED_SINCE(5, 15)
QLocalSocket::LocalSocketError QLocalSocket::error() const QLocalSocket::LocalSocketError QLocalSocket::error() const
{
return socketError();
}
#endif // QT_DEPRECATED_SINCE(5, 15)
QLocalSocket::LocalSocketError QLocalSocket::socketError() const
{ {
Q_D(const QLocalSocket); Q_D(const QLocalSocket);
return d->error; return d->error;

View File

@ -594,7 +594,7 @@ void QSocks5SocketEnginePrivate::setErrorState(Socks5State state, const QString
case ConnectError: case ConnectError:
case ControlSocketError: { case ControlSocketError: {
QAbstractSocket::SocketError controlSocketError = data->controlSocket->error(); QAbstractSocket::SocketError controlSocketError = data->controlSocket->socketError();
if (socks5State != Connected) { if (socks5State != Connected) {
switch (controlSocketError) { switch (controlSocketError) {
case QAbstractSocket::ConnectionRefusedError: case QAbstractSocket::ConnectionRefusedError:
@ -918,7 +918,7 @@ void QSocks5SocketEnginePrivate::_q_emitPendingReadNotification()
return; return;
// check if there needs to be a new zero read notification // check if there needs to be a new zero read notification
if (data && data->controlSocket->state() == QAbstractSocket::UnconnectedState if (data && data->controlSocket->state() == QAbstractSocket::UnconnectedState
&& data->controlSocket->error() == QAbstractSocket::RemoteHostClosedError) { && data->controlSocket->socketError() == QAbstractSocket::RemoteHostClosedError) {
connectData->readBuffer.clear(); connectData->readBuffer.clear();
emitReadNotification(); emitReadNotification();
} }
@ -1256,7 +1256,7 @@ void QSocks5SocketEnginePrivate::_q_controlSocketError(QAbstractSocket::SocketEr
data->controlSocket->close(); data->controlSocket->close();
emitConnectionNotification(); emitConnectionNotification();
} else { } else {
q_func()->setError(data->controlSocket->error(), data->controlSocket->errorString()); q_func()->setError(data->controlSocket->socketError(), data->controlSocket->errorString());
emitReadNotification(); emitReadNotification();
emitWriteNotification(); emitWriteNotification();
} }
@ -1348,7 +1348,7 @@ bool QSocks5SocketEngine::bind(const QHostAddress &addr, quint16 port)
if (d->mode == QSocks5SocketEnginePrivate::UdpAssociateMode) { if (d->mode == QSocks5SocketEnginePrivate::UdpAssociateMode) {
if (!d->udpData->udpSocket->bind(address, port)) { if (!d->udpData->udpSocket->bind(address, port)) {
QSOCKS5_Q_DEBUG << "local udp bind failed"; QSOCKS5_Q_DEBUG << "local udp bind failed";
setError(d->udpData->udpSocket->error(), d->udpData->udpSocket->errorString()); setError(d->udpData->udpSocket->socketError(), d->udpData->udpSocket->errorString());
return false; return false;
} }
d->localAddress = d->udpData->udpSocket->localAddress(); d->localAddress = d->udpData->udpSocket->localAddress();
@ -1656,8 +1656,8 @@ qint64 QSocks5SocketEngine::writeDatagram(const char *data, qint64 len, const QI
} }
if (d->udpData->udpSocket->writeDatagram(sealedBuf, d->udpData->associateAddress, d->udpData->associatePort) != sealedBuf.size()) { if (d->udpData->udpSocket->writeDatagram(sealedBuf, d->udpData->associateAddress, d->udpData->associatePort) != sealedBuf.size()) {
//### try frgamenting //### try frgamenting
if (d->udpData->udpSocket->error() == QAbstractSocket::DatagramTooLargeError) if (d->udpData->udpSocket->socketError() == QAbstractSocket::DatagramTooLargeError)
setError(d->udpData->udpSocket->error(), d->udpData->udpSocket->errorString()); setError(d->udpData->udpSocket->socketError(), d->udpData->udpSocket->errorString());
//### else maybe more serious error //### else maybe more serious error
return -1; return -1;
} }
@ -1727,7 +1727,7 @@ bool QSocks5SocketEnginePrivate::waitForConnected(int msecs, bool *timedOut)
return true; return true;
setErrorState(QSocks5SocketEnginePrivate::ControlSocketError); setErrorState(QSocks5SocketEnginePrivate::ControlSocketError);
if (timedOut && data->controlSocket->error() == QAbstractSocket::SocketTimeoutError) if (timedOut && data->controlSocket->socketError() == QAbstractSocket::SocketTimeoutError)
*timedOut = true; *timedOut = true;
return false; return false;
} }
@ -1765,8 +1765,8 @@ bool QSocks5SocketEngine::waitForRead(int msecs, bool *timedOut)
if (d->data->controlSocket->state() == QAbstractSocket::UnconnectedState) if (d->data->controlSocket->state() == QAbstractSocket::UnconnectedState)
return true; return true;
setError(d->data->controlSocket->error(), d->data->controlSocket->errorString()); setError(d->data->controlSocket->socketError(), d->data->controlSocket->errorString());
if (timedOut && d->data->controlSocket->error() == QAbstractSocket::SocketTimeoutError) if (timedOut && d->data->controlSocket->socketError() == QAbstractSocket::SocketTimeoutError)
*timedOut = true; *timedOut = true;
return false; return false;
} }
@ -1775,8 +1775,8 @@ bool QSocks5SocketEngine::waitForRead(int msecs, bool *timedOut)
} else { } else {
while (!d->readNotificationActivated) { while (!d->readNotificationActivated) {
if (!d->udpData->udpSocket->waitForReadyRead(qt_subtract_from_timeout(msecs, stopWatch.elapsed()))) { if (!d->udpData->udpSocket->waitForReadyRead(qt_subtract_from_timeout(msecs, stopWatch.elapsed()))) {
setError(d->udpData->udpSocket->error(), d->udpData->udpSocket->errorString()); setError(d->udpData->udpSocket->socketError(), d->udpData->udpSocket->errorString());
if (timedOut && d->udpData->udpSocket->error() == QAbstractSocket::SocketTimeoutError) if (timedOut && d->udpData->udpSocket->socketError() == QAbstractSocket::SocketTimeoutError)
*timedOut = true; *timedOut = true;
return false; return false;
} }

View File

@ -1125,7 +1125,7 @@ qint64 QDtlsPrivateOpenSSL::writeDatagramEncrypted(QUdpSocket *socket,
// some errors can be just ignored (it's UDP, not TCP after all). // some errors can be just ignored (it's UDP, not TCP after all).
// Unlike QSslSocket we do not abort though. // Unlike QSslSocket we do not abort though.
QString description(QSslSocketBackendPrivate::getErrorsFromOpenSsl()); QString description(QSslSocketBackendPrivate::getErrorsFromOpenSsl());
if (socket->error() != QAbstractSocket::UnknownSocketError && description.isEmpty()) { if (socket->socketError() != QAbstractSocket::UnknownSocketError && description.isEmpty()) {
setDtlsError(QDtlsError::UnderlyingSocketError, socket->errorString()); setDtlsError(QDtlsError::UnderlyingSocketError, socket->errorString());
} else { } else {
setDtlsError(QDtlsError::TlsFatalError, setDtlsError(QDtlsError::TlsFatalError,

View File

@ -357,7 +357,7 @@
If you want to continue connecting despite the errors that have occurred, If you want to continue connecting despite the errors that have occurred,
you must call QSslSocket::ignoreSslErrors() from inside a slot connected to you must call QSslSocket::ignoreSslErrors() from inside a slot connected to
this signal. If you need to access the error list at a later point, you this signal. If you need to access the error list at a later point, you
can call sslErrors() (without arguments). can call sslHandshakeErrors().
\a errors contains one or more errors that prevent QSslSocket from \a errors contains one or more errors that prevent QSslSocket from
verifying the identity of the peer. verifying the identity of the peer.
@ -659,7 +659,7 @@ bool QSslSocket::setSocketDescriptor(qintptr socketDescriptor, SocketState state
d->createPlainSocket(openMode); d->createPlainSocket(openMode);
bool retVal = d->plainSocket->setSocketDescriptor(socketDescriptor, state, openMode); bool retVal = d->plainSocket->setSocketDescriptor(socketDescriptor, state, openMode);
d->cachedSocketDescriptor = d->plainSocket->socketDescriptor(); d->cachedSocketDescriptor = d->plainSocket->socketDescriptor();
d->setError(d->plainSocket->error(), d->plainSocket->errorString()); d->setError(d->plainSocket->socketError(), d->plainSocket->errorString());
setSocketState(state); setSocketState(state);
setOpenMode(openMode); setOpenMode(openMode);
setLocalPort(d->plainSocket->localPort()); setLocalPort(d->plainSocket->localPort());
@ -1764,7 +1764,7 @@ bool QSslSocket::waitForConnected(int msecs)
bool retVal = d->plainSocket->waitForConnected(msecs); bool retVal = d->plainSocket->waitForConnected(msecs);
if (!retVal) { if (!retVal) {
setSocketState(d->plainSocket->state()); setSocketState(d->plainSocket->state());
d->setError(d->plainSocket->error(), d->plainSocket->errorString()); d->setError(d->plainSocket->socketError(), d->plainSocket->errorString());
} }
return retVal; return retVal;
} }
@ -1933,12 +1933,33 @@ bool QSslSocket::waitForDisconnected(int msecs)
bool retVal = d->plainSocket->waitForDisconnected(qt_subtract_from_timeout(msecs, stopWatch.elapsed())); bool retVal = d->plainSocket->waitForDisconnected(qt_subtract_from_timeout(msecs, stopWatch.elapsed()));
if (!retVal) { if (!retVal) {
setSocketState(d->plainSocket->state()); setSocketState(d->plainSocket->state());
d->setError(d->plainSocket->error(), d->plainSocket->errorString()); d->setError(d->plainSocket->socketError(), d->plainSocket->errorString());
} }
return retVal; return retVal;
} }
#if QT_DEPRECATED_SINCE(5, 15)
/*! /*!
\deprecated
Use sslHandshakeErrors() instead.
Returns a list of the last SSL errors that occurred. This is the
same list as QSslSocket passes via the sslErrors() signal. If the
connection has been encrypted with no errors, this function will
return an empty list.
\sa connectToHostEncrypted(), sslHandshakeErrors()
*/
QList<QSslError> QSslSocket::sslErrors() const
{
return sslHandshakeErrors();
}
#endif // QT_DEPRECATED_SINCE(5, 15)
/*!
\since 5.15
Returns a list of the last SSL errors that occurred. This is the Returns a list of the last SSL errors that occurred. This is the
same list as QSslSocket passes via the sslErrors() signal. If the same list as QSslSocket passes via the sslErrors() signal. If the
connection has been encrypted with no errors, this function will connection has been encrypted with no errors, this function will
@ -1946,7 +1967,7 @@ bool QSslSocket::waitForDisconnected(int msecs)
\sa connectToHostEncrypted() \sa connectToHostEncrypted()
*/ */
QList<QSslError> QSslSocket::sslErrors() const QList<QSslError> QSslSocket::sslHandshakeErrors() const
{ {
Q_D(const QSslSocket); Q_D(const QSslSocket);
return d->sslErrors; return d->sslErrors;
@ -2148,7 +2169,7 @@ void QSslSocket::ignoreSslErrors()
You can clear the list of errors you want to ignore by calling this You can clear the list of errors you want to ignore by calling this
function with an empty list. function with an empty list.
\sa sslErrors() \sa sslErrors(), sslHandshakeErrors()
*/ */
void QSslSocket::ignoreSslErrors(const QList<QSslError> &errors) void QSslSocket::ignoreSslErrors(const QList<QSslError> &errors)
{ {
@ -2813,7 +2834,7 @@ void QSslSocketPrivate::_q_errorSlot(QAbstractSocket::SocketError error)
readBufferMaxSize = tmpReadBufferMaxSize; readBufferMaxSize = tmpReadBufferMaxSize;
} }
setErrorAndEmit(plainSocket->error(), plainSocket->errorString()); setErrorAndEmit(plainSocket->socketError(), plainSocket->errorString());
} }
/*! /*!

View File

@ -235,7 +235,10 @@ public:
bool waitForBytesWritten(int msecs = 30000) override; bool waitForBytesWritten(int msecs = 30000) override;
bool waitForDisconnected(int msecs = 30000) override; bool waitForDisconnected(int msecs = 30000) override;
QList<QSslError> sslErrors() const; #if QT_DEPRECATED_SINCE(5, 15)
QT_DEPRECATED_X("Use sslHandshakeErrors()") QList<QSslError> sslErrors() const;
#endif // QT_DEPRECATED_SINCE(5, 15)
QList<QSslError> sslHandshakeErrors() const;
static bool supportsSsl(); static bool supportsSsl();
static long sslLibraryVersionNumber(); static long sslLibraryVersionNumber();

View File

@ -1109,7 +1109,7 @@ void QSslSocketBackendPrivate::transmit()
if (actualWritten < 0) { if (actualWritten < 0) {
//plain socket write fails if it was in the pending close state. //plain socket write fails if it was in the pending close state.
const ScopedBool bg(inSetAndEmitError, true); const ScopedBool bg(inSetAndEmitError, true);
setErrorAndEmit(plainSocket->error(), plainSocket->errorString()); setErrorAndEmit(plainSocket->socketError(), plainSocket->errorString());
return; return;
} }
transmitting = true; transmitting = true;

View File

@ -576,7 +576,7 @@ bool QSslSocketBackendPrivate::sendToken(void *token, unsigned long tokenLength,
if (written != qint64(tokenLength)) { if (written != qint64(tokenLength)) {
// Failed to write/buffer everything or an error occurred // Failed to write/buffer everything or an error occurred
if (emitError) if (emitError)
setErrorAndEmit(plainSocket->error(), plainSocket->errorString()); setErrorAndEmit(plainSocket->socketError(), plainSocket->errorString());
return false; return false;
} }
return true; return true;
@ -1286,7 +1286,7 @@ void QSslSocketBackendPrivate::transmit()
if (bytesWritten >= 0) { if (bytesWritten >= 0) {
totalBytesWritten += bytesWritten; totalBytesWritten += bytesWritten;
} else { } else {
setErrorAndEmit(plainSocket->error(), plainSocket->errorString()); setErrorAndEmit(plainSocket->socketError(), plainSocket->errorString());
return; return;
} }
} }

View File

@ -38,6 +38,7 @@
****************************************************************************/ ****************************************************************************/
#include "qlibinputtouch_p.h" #include "qlibinputtouch_p.h"
#include "qtouchoutputmapping_p.h"
#include <libinput.h> #include <libinput.h>
#include <QtGui/QGuiApplication> #include <QtGui/QGuiApplication>
#include <QtGui/QScreen> #include <QtGui/QScreen>
@ -45,6 +46,8 @@
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
Q_DECLARE_LOGGING_CATEGORY(qLcLibInput)
QWindowSystemInterface::TouchPoint *QLibInputTouch::DeviceState::point(int32_t slot) QWindowSystemInterface::TouchPoint *QLibInputTouch::DeviceState::point(int32_t slot)
{ {
const int id = qMax(0, slot); const int id = qMax(0, slot);
@ -62,12 +65,23 @@ QLibInputTouch::DeviceState *QLibInputTouch::deviceState(libinput_event_touch *e
return &m_devState[dev]; return &m_devState[dev];
} }
static inline QPointF getPos(libinput_event_touch *e) QPointF QLibInputTouch::getPos(libinput_event_touch *e)
{ {
// TODO Map to correct screen using QTouchOutputMapping. DeviceState *state = deviceState(e);
// Perhaps investigate libinput_device_get_output_name as well.
// For now just use the primary screen.
QScreen *screen = QGuiApplication::primaryScreen(); QScreen *screen = QGuiApplication::primaryScreen();
if (!state->m_screenName.isEmpty()) {
if (!m_screen) {
const QList<QScreen *> screens = QGuiApplication::screens();
for (QScreen *s : screens) {
if (s->name() == state->m_screenName) {
m_screen = s;
break;
}
}
}
if (m_screen)
screen = m_screen;
}
const QRect geom = QHighDpi::toNativePixels(screen->geometry(), screen); const QRect geom = QHighDpi::toNativePixels(screen->geometry(), screen);
const double x = libinput_event_touch_get_x_transformed(e, geom.width()); const double x = libinput_event_touch_get_x_transformed(e, geom.width());
const double y = libinput_event_touch_get_y_transformed(e, geom.height()); const double y = libinput_event_touch_get_y_transformed(e, geom.height());
@ -76,9 +90,25 @@ static inline QPointF getPos(libinput_event_touch *e)
void QLibInputTouch::registerDevice(libinput_device *dev) void QLibInputTouch::registerDevice(libinput_device *dev)
{ {
struct udev_device *udev_device;
udev_device = libinput_device_get_udev_device(dev);
QString devNode = QString::fromUtf8(udev_device_get_devnode(udev_device));
QString devName = QString::fromUtf8(libinput_device_get_name(dev));
qCDebug(qLcLibInput, "libinput: registerDevice %s - %s",
qPrintable(devNode), qPrintable(devName));
QTouchOutputMapping mapping;
if (mapping.load()) {
m_devState[dev].m_screenName = mapping.screenNameForDeviceNode(devNode);
if (!m_devState[dev].m_screenName.isEmpty())
qCDebug(qLcLibInput, "libinput: Mapping device %s to screen %s",
qPrintable(devNode), qPrintable(m_devState[dev].m_screenName));
}
QTouchDevice *&td = m_devState[dev].m_touchDevice; QTouchDevice *&td = m_devState[dev].m_touchDevice;
td = new QTouchDevice; td = new QTouchDevice;
td->setName(QString::fromUtf8(libinput_device_get_name(dev))); td->setName(devName);
td->setType(QTouchDevice::TouchScreen); td->setType(QTouchDevice::TouchScreen);
td->setCapabilities(QTouchDevice::Position | QTouchDevice::Area); td->setCapabilities(QTouchDevice::Position | QTouchDevice::Area);
QWindowSystemInterface::registerTouchDevice(td); QWindowSystemInterface::registerTouchDevice(td);

View File

@ -42,6 +42,7 @@
#include <QtCore/QHash> #include <QtCore/QHash>
#include <QtCore/QList> #include <QtCore/QList>
#include <QtCore/QPointer>
#include <qpa/qwindowsysteminterface.h> #include <qpa/qwindowsysteminterface.h>
// //
@ -60,6 +61,7 @@ struct libinput_device;
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
class QScreen;
class QLibInputTouch class QLibInputTouch
{ {
public: public:
@ -73,15 +75,18 @@ public:
private: private:
struct DeviceState { struct DeviceState {
DeviceState() : m_touchDevice(nullptr) { } DeviceState() : m_touchDevice(nullptr), m_screenName() { }
QWindowSystemInterface::TouchPoint *point(int32_t slot); QWindowSystemInterface::TouchPoint *point(int32_t slot);
QList<QWindowSystemInterface::TouchPoint> m_points; QList<QWindowSystemInterface::TouchPoint> m_points;
QTouchDevice *m_touchDevice; QTouchDevice *m_touchDevice;
QString m_screenName;
}; };
DeviceState *deviceState(libinput_event_touch *e); DeviceState *deviceState(libinput_event_touch *e);
QPointF getPos(libinput_event_touch *e);
QHash<libinput_device *, DeviceState> m_devState; QHash<libinput_device *, DeviceState> m_devState;
mutable QPointer<QScreen> m_screen;
}; };
QT_END_NAMESPACE QT_END_NAMESPACE

View File

@ -745,7 +745,11 @@
- (UITextPosition *)positionFromPosition:(UITextPosition *)position offset:(NSInteger)offset - (UITextPosition *)positionFromPosition:(UITextPosition *)position offset:(NSInteger)offset
{ {
int p = static_cast<QUITextPosition *>(position).index; int p = static_cast<QUITextPosition *>(position).index;
return [QUITextPosition positionWithIndex:p + offset]; const int posWithIndex = p + offset;
const int textLength = [self currentImeState:Qt::ImSurroundingText].toString().length();
if (posWithIndex < 0 || posWithIndex > textLength)
return nil;
return [QUITextPosition positionWithIndex:posWithIndex];
} }
- (UITextPosition *)positionFromPosition:(UITextPosition *)position inDirection:(UITextLayoutDirection)direction offset:(NSInteger)offset - (UITextPosition *)positionFromPosition:(UITextPosition *)position inDirection:(UITextLayoutDirection)direction offset:(NSInteger)offset

View File

@ -93,7 +93,7 @@ bool QXcbVulkanInstance::supportsPresent(VkPhysicalDevice physicalDevice,
VkSurfaceKHR QXcbVulkanInstance::createSurface(QXcbWindow *window) VkSurfaceKHR QXcbVulkanInstance::createSurface(QXcbWindow *window)
{ {
VkSurfaceKHR surface = nullptr; VkSurfaceKHR surface = VK_NULL_HANDLE;
if (!m_createSurface) { if (!m_createSurface) {
m_createSurface = reinterpret_cast<PFN_vkCreateXcbSurfaceKHR>( m_createSurface = reinterpret_cast<PFN_vkCreateXcbSurfaceKHR>(

View File

@ -43,7 +43,7 @@ QT_BEGIN_NAMESPACE
QXcbVulkanWindow::QXcbVulkanWindow(QWindow *window) QXcbVulkanWindow::QXcbVulkanWindow(QWindow *window)
: QXcbWindow(window), : QXcbWindow(window),
m_surface(nullptr) m_surface(VK_NULL_HANDLE)
{ {
} }

View File

@ -1365,6 +1365,7 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption
QWindowsStyle::drawControl(element, &copyOpt, painter, widget); QWindowsStyle::drawControl(element, &copyOpt, painter, widget);
} }
break; break;
#if QT_CONFIG(dockwidget)
case CE_DockWidgetTitle: case CE_DockWidgetTitle:
if (const QStyleOptionDockWidget *dwOpt = qstyleoption_cast<const QStyleOptionDockWidget *>(option)) { if (const QStyleOptionDockWidget *dwOpt = qstyleoption_cast<const QStyleOptionDockWidget *>(option)) {
const QDockWidget *dockWidget = qobject_cast<const QDockWidget *>(widget); const QDockWidget *dockWidget = qobject_cast<const QDockWidget *>(widget);
@ -1431,6 +1432,7 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption
} }
} }
break; break;
#endif // QT_CONFIG(dockwidget)
#if QT_CONFIG(itemviews) #if QT_CONFIG(itemviews)
case CE_ItemViewItem: case CE_ItemViewItem:
{ {
@ -2311,11 +2313,13 @@ void QWindowsVistaStyle::polish(QWidget *widget)
#endif // QT_CONFIG(lineedit) #endif // QT_CONFIG(lineedit)
if (qobject_cast<QGroupBox*>(widget)) if (qobject_cast<QGroupBox*>(widget))
widget->setAttribute(Qt::WA_Hover); widget->setAttribute(Qt::WA_Hover);
#if QT_CONFIG(commandlinkbutton)
else if (qobject_cast<QCommandLinkButton*>(widget)) { else if (qobject_cast<QCommandLinkButton*>(widget)) {
QFont buttonFont = widget->font(); QFont buttonFont = widget->font();
buttonFont.setFamily(QLatin1String("Segoe UI")); buttonFont.setFamily(QLatin1String("Segoe UI"));
widget->setFont(buttonFont); widget->setFont(buttonFont);
} }
#endif // QT_CONFIG(commandlinkbutton)
else if (widget->inherits("QTipLabel")){ else if (widget->inherits("QTipLabel")){
//note that since tooltips are not reused //note that since tooltips are not reused
//we do not have to care about unpolishing //we do not have to care about unpolishing
@ -2392,12 +2396,15 @@ void QWindowsVistaStyle::unpolish(QWidget *widget)
#endif // QT_CONFIG(inputdialog) #endif // QT_CONFIG(inputdialog)
else if (QTreeView *tree = qobject_cast<QTreeView *> (widget)) { else if (QTreeView *tree = qobject_cast<QTreeView *> (widget)) {
tree->viewport()->setAttribute(Qt::WA_Hover, false); tree->viewport()->setAttribute(Qt::WA_Hover, false);
} else if (qobject_cast<QCommandLinkButton*>(widget)) { }
#if QT_CONFIG(commandlinkbutton)
else if (qobject_cast<QCommandLinkButton*>(widget)) {
QFont font = QApplication::font("QCommandLinkButton"); QFont font = QApplication::font("QCommandLinkButton");
QFont widgetFont = widget->font(); QFont widgetFont = widget->font();
widgetFont.setFamily(font.family()); //Only family set by polish widgetFont.setFamily(font.family()); //Only family set by polish
widget->setFont(widgetFont); widget->setFont(widgetFont);
} }
#endif // QT_CONFIG(commandlinkbutton)
} }

View File

@ -106,7 +106,9 @@
#include <qtableview.h> #include <qtableview.h>
#endif #endif
#include <qdatetime.h> #include <qdatetime.h>
#if QT_CONFIG(commandlinkbutton)
#include <qcommandlinkbutton.h> #include <qcommandlinkbutton.h>
#endif
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE

View File

@ -270,7 +270,7 @@
When side-effects are unavoidable, ensure that the prior state is restored When side-effects are unavoidable, ensure that the prior state is restored
at the end of the test function, even if the test fails. This commonly at the end of the test function, even if the test fails. This commonly
requires use of an RAII (resource acquisition is initialization) class requires use of an RAII (resource acquisition is initialization) class
that restores state when the function returns, or a \l cleanup() method. that restores state when the function returns, or a \c cleanup() method.
Do not simply put the restoration code at the end of the test. If part of Do not simply put the restoration code at the end of the test. If part of
the test fails, such code will be skipped and the prior state will not be the test fails, such code will be skipped and the prior state will not be
restored. restored.

View File

@ -420,6 +420,7 @@ Options parseOptions()
} else if (argument.compare(QLatin1String("--aab"), Qt::CaseInsensitive) == 0) { } else if (argument.compare(QLatin1String("--aab"), Qt::CaseInsensitive) == 0) {
options.buildAAB = true; options.buildAAB = true;
options.build = true; options.build = true;
options.jarSigner = true;
} else if (options.buildAAB && argument.compare(QLatin1String("--no-build"), Qt::CaseInsensitive) == 0) { } else if (options.buildAAB && argument.compare(QLatin1String("--no-build"), Qt::CaseInsensitive) == 0) {
options.build = false; options.build = false;
} else if (argument.compare(QLatin1String("--install"), Qt::CaseInsensitive) == 0) { } else if (argument.compare(QLatin1String("--install"), Qt::CaseInsensitive) == 0) {

View File

@ -1,6 +1,6 @@
/**************************************************************************** /****************************************************************************
** **
** Copyright (C) 2016 The Qt Company Ltd. ** Copyright (C) 2020 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/ ** Contact: https://www.qt.io/licensing/
** **
** This file is part of the tools applications of the Qt Toolkit. ** This file is part of the tools applications of the Qt Toolkit.
@ -61,7 +61,7 @@ static const char docTypeHeader[] =
#define PROGRAMNAME "qdbuscpp2xml" #define PROGRAMNAME "qdbuscpp2xml"
#define PROGRAMVERSION "0.2" #define PROGRAMVERSION "0.2"
#define PROGRAMCOPYRIGHT "Copyright (C) 2019 The Qt Company Ltd." #define PROGRAMCOPYRIGHT "Copyright (C) 2020 The Qt Company Ltd."
static QString outputFile; static QString outputFile;
static int flags; static int flags;

View File

@ -1,6 +1,6 @@
/**************************************************************************** /****************************************************************************
** **
** Copyright (C) 2016 The Qt Company Ltd. ** Copyright (C) 2020 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/ ** Contact: https://www.qt.io/licensing/
** **
** This file is part of the tools applications of the Qt Toolkit. ** This file is part of the tools applications of the Qt Toolkit.
@ -46,7 +46,7 @@
#define PROGRAMNAME "qdbusxml2cpp" #define PROGRAMNAME "qdbusxml2cpp"
#define PROGRAMVERSION "0.8" #define PROGRAMVERSION "0.8"
#define PROGRAMCOPYRIGHT "Copyright (C) 2019 The Qt Company Ltd." #define PROGRAMCOPYRIGHT "Copyright (C) 2020 The Qt Company Ltd."
#define ANNOTATION_NO_WAIT "org.freedesktop.DBus.Method.NoReply" #define ANNOTATION_NO_WAIT "org.freedesktop.DBus.Method.NoReply"

View File

@ -1,6 +1,6 @@
/**************************************************************************** /****************************************************************************
** **
** Copyright (C) 2018 The Qt Company Ltd. ** Copyright (C) 2020 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/ ** Contact: https://www.qt.io/licensing/
** **
** This file is part of the QtWidgets module of the Qt Toolkit. ** This file is part of the QtWidgets module of the Qt Toolkit.
@ -1890,7 +1890,7 @@ void QMessageBox::aboutQt(QWidget *parent, const QString &title)
"<p>Qt and the Qt logo are trademarks of The Qt Company Ltd.</p>" "<p>Qt and the Qt logo are trademarks of The Qt Company Ltd.</p>"
"<p>Qt is The Qt Company Ltd product developed as an open source " "<p>Qt is The Qt Company Ltd product developed as an open source "
"project. See <a href=\"http://%3/\">%3</a> for more information.</p>" "project. See <a href=\"http://%3/\">%3</a> for more information.</p>"
).arg(QStringLiteral("2019"), ).arg(QStringLiteral("2020"),
QStringLiteral("qt.io/licensing"), QStringLiteral("qt.io/licensing"),
QStringLiteral("qt.io")); QStringLiteral("qt.io"));
QMessageBox *msgBox = new QMessageBox(parent); QMessageBox *msgBox = new QMessageBox(parent);

View File

@ -414,11 +414,9 @@ bool Q_WIDGETS_EXPORT qt_tab_all_widgets()
} }
// ######## move to QApplicationPrivate // ######## move to QApplicationPrivate
// Default application palettes and fonts (per widget type) // Default fonts (per widget type)
Q_GLOBAL_STATIC(PaletteHash, app_palettes)
Q_GLOBAL_STATIC(FontHash, app_fonts) Q_GLOBAL_STATIC(FontHash, app_fonts)
// Exported accessors for use outside of this file // Exported accessor for use outside of this file
PaletteHash *qt_app_palettes_hash() { return app_palettes(); }
FontHash *qt_app_fonts_hash() { return app_fonts(); } FontHash *qt_app_fonts_hash() { return app_fonts(); }
QWidgetList *QApplicationPrivate::popupWidgets = nullptr; // has keyboard input focus QWidgetList *QApplicationPrivate::popupWidgets = nullptr; // has keyboard input focus
@ -635,7 +633,7 @@ static void setPossiblePalette(const QPalette *palette, const char *className)
{ {
if (palette == nullptr) if (palette == nullptr)
return; return;
QApplicationPrivate::setPalette_helper(*palette, className, false); QApplicationPrivate::setPalette_helper(*palette, className);
} }
void QApplicationPrivate::initializeWidgetPaletteHash() void QApplicationPrivate::initializeWidgetPaletteHash()
@ -643,7 +641,8 @@ void QApplicationPrivate::initializeWidgetPaletteHash()
QPlatformTheme *platformTheme = QGuiApplicationPrivate::platformTheme(); QPlatformTheme *platformTheme = QGuiApplicationPrivate::platformTheme();
if (!platformTheme) if (!platformTheme)
return; return;
app_palettes()->clear();
widgetPalettes.clear();
setPossiblePalette(platformTheme->palette(QPlatformTheme::ToolButtonPalette), "QToolButton"); setPossiblePalette(platformTheme->palette(QPlatformTheme::ToolButtonPalette), "QToolButton");
setPossiblePalette(platformTheme->palette(QPlatformTheme::ButtonPalette), "QAbstractButton"); setPossiblePalette(platformTheme->palette(QPlatformTheme::ButtonPalette), "QAbstractButton");
@ -802,7 +801,7 @@ QApplication::~QApplication()
delete QApplicationPrivate::app_pal; delete QApplicationPrivate::app_pal;
QApplicationPrivate::app_pal = nullptr; QApplicationPrivate::app_pal = nullptr;
clearSystemPalette(); clearSystemPalette();
app_palettes()->clear(); QApplicationPrivate::widgetPalettes.clear();
delete QApplicationPrivate::sys_font; delete QApplicationPrivate::sys_font;
QApplicationPrivate::sys_font = nullptr; QApplicationPrivate::sys_font = nullptr;
@ -1315,6 +1314,8 @@ void QApplication::setGlobalStrut(const QSize& strut)
QApplicationPrivate::app_strut = strut; QApplicationPrivate::app_strut = strut;
} }
// Widget specific palettes
QApplicationPrivate::PaletteHash QApplicationPrivate::widgetPalettes;
/*! /*!
\fn QPalette QApplication::palette(const QWidget* widget) \fn QPalette QApplication::palette(const QWidget* widget)
@ -1329,15 +1330,13 @@ void QApplication::setGlobalStrut(const QSize& strut)
*/ */
QPalette QApplication::palette(const QWidget* w) QPalette QApplication::palette(const QWidget* w)
{ {
typedef PaletteHash::const_iterator PaletteHashConstIt; auto &widgetPalettes = QApplicationPrivate::widgetPalettes;
if (w && !widgetPalettes.isEmpty()) {
PaletteHash *hash = app_palettes(); auto it = widgetPalettes.constFind(w->metaObject()->className());
if (w && hash && hash->size()) { const auto cend = widgetPalettes.constEnd();
PaletteHashConstIt it = hash->constFind(w->metaObject()->className());
const PaletteHashConstIt cend = hash->constEnd();
if (it != cend) if (it != cend)
return *it; return *it;
for (it = hash->constBegin(); it != cend; ++it) { for (it = widgetPalettes.constBegin(); it != cend; ++it) {
if (w->inherits(it.key())) if (w->inherits(it.key()))
return it.value(); return it.value();
} }
@ -1354,17 +1353,17 @@ QPalette QApplication::palette(const QWidget* w)
*/ */
QPalette QApplication::palette(const char *className) QPalette QApplication::palette(const char *className)
{ {
PaletteHash *hash = app_palettes(); auto &widgetPalettes = QApplicationPrivate::widgetPalettes;
if (className && hash && hash->size()) { if (className && !widgetPalettes.isEmpty()) {
QHash<QByteArray, QPalette>::ConstIterator it = hash->constFind(className); auto it = widgetPalettes.constFind(className);
if (it != hash->constEnd()) if (it != widgetPalettes.constEnd())
return *it; return *it;
} }
return QGuiApplication::palette(); return QGuiApplication::palette();
} }
void QApplicationPrivate::setPalette_helper(const QPalette &palette, const char* className, bool clearWidgetPaletteHash) void QApplicationPrivate::setPalette_helper(const QPalette &palette, const char* className)
{ {
QPalette pal = palette; QPalette pal = palette;
@ -1372,25 +1371,19 @@ void QApplicationPrivate::setPalette_helper(const QPalette &palette, const char*
QApplicationPrivate::app_style->polish(pal); // NB: non-const reference QApplicationPrivate::app_style->polish(pal); // NB: non-const reference
bool all = false; bool all = false;
PaletteHash *hash = app_palettes();
if (!className) { if (!className) {
if (QApplicationPrivate::app_pal && pal.isCopyOf(*QApplicationPrivate::app_pal)) if (!QGuiApplicationPrivate::setPalette(pal))
return; return;
if (!QApplicationPrivate::app_pal)
QApplicationPrivate::app_pal = new QPalette(pal);
else
*QApplicationPrivate::app_pal = pal;
if (!QApplicationPrivate::sys_pal || !palette.isCopyOf(*QApplicationPrivate::sys_pal)) if (!QApplicationPrivate::sys_pal || !palette.isCopyOf(*QApplicationPrivate::sys_pal))
QCoreApplication::setAttribute(Qt::AA_SetPalette); QCoreApplication::setAttribute(Qt::AA_SetPalette);
if (hash && hash->size()) { if (!widgetPalettes.isEmpty()) {
all = true; all = true;
if (clearWidgetPaletteHash) widgetPalettes.clear();
hash->clear();
} }
} else if (hash) { } else {
hash->insert(className, pal); widgetPalettes.insert(className, pal);
} }
if (qApp) if (qApp)
@ -1422,7 +1415,7 @@ void QApplicationPrivate::setPalette_helper(const QPalette &palette, const char*
void QApplication::setPalette(const QPalette &palette, const char* className) void QApplication::setPalette(const QPalette &palette, const char* className)
{ {
QApplicationPrivate::setPalette_helper(palette, className, /*clearWidgetPaletteHash=*/ true); QApplicationPrivate::setPalette_helper(palette, className);
} }

View File

@ -94,9 +94,6 @@ extern QClipboard *qt_clipboard;
typedef QHash<QByteArray, QFont> FontHash; typedef QHash<QByteArray, QFont> FontHash;
Q_WIDGETS_EXPORT FontHash *qt_app_fonts_hash(); Q_WIDGETS_EXPORT FontHash *qt_app_fonts_hash();
typedef QHash<QByteArray, QPalette> PaletteHash;
PaletteHash *qt_app_palettes_hash();
#define QApplicationPrivateBase QGuiApplicationPrivate #define QApplicationPrivateBase QGuiApplicationPrivate
class Q_WIDGETS_EXPORT QApplicationPrivate : public QApplicationPrivateBase class Q_WIDGETS_EXPORT QApplicationPrivate : public QApplicationPrivateBase
@ -188,11 +185,14 @@ public:
static bool widgetCount; // Coupled with -widgetcount switch static bool widgetCount; // Coupled with -widgetcount switch
static void setSystemPalette(const QPalette &pal); static void setSystemPalette(const QPalette &pal);
static void setPalette_helper(const QPalette &palette, const char* className, bool clearWidgetPaletteHash); static void setPalette_helper(const QPalette &palette, const char* className);
static void initializeWidgetPaletteHash(); static void initializeWidgetPaletteHash();
static void initializeWidgetFontHash(); static void initializeWidgetFontHash();
static void setSystemFont(const QFont &font); static void setSystemFont(const QFont &font);
using PaletteHash = QHash<QByteArray, QPalette>;
static PaletteHash widgetPalettes;
static QApplicationPrivate *instance() { return self; } static QApplicationPrivate *instance() { return self; }
#ifdef QT_KEYPAD_NAVIGATION #ifdef QT_KEYPAD_NAVIGATION

View File

@ -219,7 +219,7 @@ QDateTimeEdit::~QDateTimeEdit()
/*! /*!
\property QDateTimeEdit::dateTime \property QDateTimeEdit::dateTime
\brief the QDateTime that is set in the QDateTimeEdit \brief The QDateTime that is set in the QDateTimeEdit.
When setting this property, the new QDateTime is converted to the timespec of When setting this property, the new QDateTime is converted to the timespec of
the QDateTimeEdit, which thus remains unchanged. the QDateTimeEdit, which thus remains unchanged.
@ -259,7 +259,7 @@ void QDateTimeEdit::setDateTime(const QDateTime &datetime)
/*! /*!
\property QDateTimeEdit::date \property QDateTimeEdit::date
\brief the QDate that is set in the widget \brief The QDate that is set in the widget.
By default, this property contains a date that refers to January 1, 2000. By default, this property contains a date that refers to January 1, 2000.
@ -296,7 +296,7 @@ void QDateTimeEdit::setDate(const QDate &date)
/*! /*!
\property QDateTimeEdit::time \property QDateTimeEdit::time
\brief the QTime that is set in the widget \brief The QTime that is set in the widget.
By default, this property contains a time of 00:00:00 and 0 milliseconds. By default, this property contains a time of 00:00:00 and 0 milliseconds.
@ -341,7 +341,8 @@ void QDateTimeEdit::setCalendar(QCalendar calendar)
/*! /*!
\since 4.4 \since 4.4
\property QDateTimeEdit::minimumDateTime \property QDateTimeEdit::minimumDateTime
\brief the minimum datetime of the date time edit
\brief The minimum datetime of the date time edit.
Changing this property implicitly updates the \l minimumDate and \l Changing this property implicitly updates the \l minimumDate and \l
minimumTime properties to the date and time parts of this property, minimumTime properties to the date and time parts of this property,
@ -382,7 +383,7 @@ void QDateTimeEdit::setMinimumDateTime(const QDateTime &dt)
\since 4.4 \since 4.4
\property QDateTimeEdit::maximumDateTime \property QDateTimeEdit::maximumDateTime
\brief the maximum datetime of the date time edit \brief The maximum datetime of the date time edit.
Changing this property implicitly updates the \l maximumDate and \l Changing this property implicitly updates the \l maximumDate and \l
maximumTime properties to the date and time parts of this property, maximumTime properties to the date and time parts of this property,
@ -450,7 +451,7 @@ void QDateTimeEdit::setDateTimeRange(const QDateTime &min, const QDateTime &max)
/*! /*!
\property QDateTimeEdit::minimumDate \property QDateTimeEdit::minimumDate
\brief the minimum date of the date time edit \brief The minimum date of the date time edit.
Changing this property updates the date of the \l minimumDateTime property Changing this property updates the date of the \l minimumDateTime property
while preserving the \l minimumTime property. When setting this property, while preserving the \l minimumTime property. When setting this property,
@ -490,7 +491,7 @@ void QDateTimeEdit::clearMinimumDate()
/*! /*!
\property QDateTimeEdit::maximumDate \property QDateTimeEdit::maximumDate
\brief the maximum date of the date time edit \brief The maximum date of the date time edit.
Changing this property updates the date of the \l maximumDateTime property Changing this property updates the date of the \l maximumDateTime property
while preserving the \l maximumTime property. When setting this property, the while preserving the \l maximumTime property. When setting this property, the
@ -529,7 +530,7 @@ void QDateTimeEdit::clearMaximumDate()
/*! /*!
\property QDateTimeEdit::minimumTime \property QDateTimeEdit::minimumTime
\brief the minimum time of the date time edit \brief The minimum time of the date time edit.
Changing this property updates the time of the \l minimumDateTime property Changing this property updates the time of the \l minimumDateTime property
while preserving the \l minimumDate and \l maximumDate properties. If those while preserving the \l minimumDate and \l maximumDate properties. If those
@ -568,7 +569,7 @@ void QDateTimeEdit::clearMinimumTime()
/*! /*!
\property QDateTimeEdit::maximumTime \property QDateTimeEdit::maximumTime
\brief the maximum time of the date time edit \brief The maximum time of the date time edit.
Changing this property updates the time of the \l maximumDateTime property Changing this property updates the time of the \l maximumDateTime property
while preserving the \l minimumDate and \l maximumDate properties. If those while preserving the \l minimumDate and \l maximumDate properties. If those
@ -671,7 +672,7 @@ void QDateTimeEdit::setTimeRange(const QTime &min, const QTime &max)
/*! /*!
\property QDateTimeEdit::displayedSections \property QDateTimeEdit::displayedSections
\brief the currently displayed fields of the date time edit \brief The currently displayed fields of the date time edit.
Returns a bit set of the displayed sections for this format. Returns a bit set of the displayed sections for this format.
\a setDisplayFormat(), displayFormat() \a setDisplayFormat(), displayFormat()
@ -686,7 +687,7 @@ QDateTimeEdit::Sections QDateTimeEdit::displayedSections() const
/*! /*!
\property QDateTimeEdit::currentSection \property QDateTimeEdit::currentSection
\brief the current section of the spinbox \brief The current section of the spinbox.
\a setCurrentSection() \a setCurrentSection()
*/ */
@ -745,7 +746,7 @@ QDateTimeEdit::Section QDateTimeEdit::sectionAt(int index) const
\property QDateTimeEdit::sectionCount \property QDateTimeEdit::sectionCount
\brief the number of sections displayed. \brief The number of sections displayed.
If the format is 'yyyy/yy/yyyy', sectionCount returns 3 If the format is 'yyyy/yy/yyyy', sectionCount returns 3
*/ */
@ -761,7 +762,7 @@ int QDateTimeEdit::sectionCount() const
\property QDateTimeEdit::currentSectionIndex \property QDateTimeEdit::currentSectionIndex
\brief the current section index of the spinbox \brief The current section index of the spinbox.
If the format is 'yyyy/MM/dd', the displayText is '2001/05/21', and If the format is 'yyyy/MM/dd', the displayText is '2001/05/21', and
the cursorPosition is 5, currentSectionIndex returns 1. If the the cursorPosition is 5, currentSectionIndex returns 1. If the
@ -885,7 +886,7 @@ QString QDateTimeEdit::sectionText(Section section) const
/*! /*!
\property QDateTimeEdit::displayFormat \property QDateTimeEdit::displayFormat
\brief the format used to display the time/date of the date time edit \brief The format used to display the time/date of the date time edit.
This format is described in QDateTime::toString() and QDateTime::fromString() This format is described in QDateTime::toString() and QDateTime::fromString()
@ -957,7 +958,7 @@ void QDateTimeEdit::setDisplayFormat(const QString &format)
/*! /*!
\property QDateTimeEdit::calendarPopup \property QDateTimeEdit::calendarPopup
\brief the current calendar pop-up show mode. \brief The current calendar pop-up show mode.
\since 4.2 \since 4.2
The calendar pop-up will be shown upon clicking the arrow button. The calendar pop-up will be shown upon clicking the arrow button.
@ -989,7 +990,7 @@ void QDateTimeEdit::setCalendarPopup(bool enable)
/*! /*!
\property QDateTimeEdit::timeSpec \property QDateTimeEdit::timeSpec
\brief the current timespec used by the date time edit. \brief The current timespec used by the date time edit.
\since 4.4 \since 4.4
*/ */

View File

@ -823,7 +823,7 @@ void QTextBrowser::setSource(const QUrl &url)
/*! /*!
Attempts to load the document at the given \a url with the specified \a type. Attempts to load the document at the given \a url with the specified \a type.
If \a type is \l {QTextDocument::ResourceType::UnknownResource}{UnknownResource} If \a type is \l {QTextDocument::UnknownResource}{UnknownResource}
(the default), the document type will be detected: that is, if the url ends (the default), the document type will be detected: that is, if the url ends
with an extension of \c{.md}, \c{.mkd} or \c{.markdown}, the document will be with an extension of \c{.md}, \c{.mkd} or \c{.markdown}, the document will be
loaded via \l QTextDocument::setMarkdown(); otherwise it will be loaded via loaded via \l QTextDocument::setMarkdown(); otherwise it will be loaded via

View File

@ -1,6 +1,6 @@
/**************************************************************************** /****************************************************************************
** **
** Copyright (C) 2016 The Qt Company Ltd. ** Copyright (C) 2020 The Qt Company Ltd.
** Copyright (C) 2014 Olivier Goffart <ogoffart@woboq.com> ** Copyright (C) 2014 Olivier Goffart <ogoffart@woboq.com>
** Contact: https://www.qt.io/licensing/ ** Contact: https://www.qt.io/licensing/
** **
@ -767,18 +767,18 @@ void tst_qmessagehandler::qMessagePattern_data()
QTest::qWait(10000); QTest::qWait(10000);
QTest::newRow("time") << "/%{time yyyy - MM - d}/%{message}" QTest::newRow("time") << "/%{time yyyy - MM - d}/%{message}"
<< true << (QList<QByteArray>() << true << (QList<QByteArray>()
<< ('/' + QDateTime::currentDateTime().toString("yyyy - MM - d").toUtf8() + "/qDebug")); << ('/' + QDateTime::currentDateTime().toString("yyyy - MM - d").toLocal8Bit() + "/qDebug"));
QTest::newRow("time-time") << "/%{time yyyy - MM - d}/%{time dd-MM-yy}/%{message}" QTest::newRow("time-time") << "/%{time yyyy - MM - d}/%{time dd-MM-yy}/%{message}"
<< true << (QList<QByteArray>() << true << (QList<QByteArray>()
<< ('/' + QDateTime::currentDateTime().toString("yyyy - MM - d").toUtf8() << ('/' + QDateTime::currentDateTime().toString("yyyy - MM - d").toLocal8Bit()
+ '/' + QDateTime::currentDateTime().toString("dd-MM-yy").toUtf8() + '/' + QDateTime::currentDateTime().toString("dd-MM-yy").toLocal8Bit()
+ "/qDebug")); + "/qDebug"));
QTest::newRow("skipped-time-shown-time") QTest::newRow("skipped-time-shown-time")
<< "/%{if-warning}%{time yyyy - MM - d}%{endif}%{if-debug}%{time dd-MM-yy}%{endif}/%{message}" << "/%{if-warning}%{time yyyy - MM - d}%{endif}%{if-debug}%{time dd-MM-yy}%{endif}/%{message}"
<< true << (QList<QByteArray>() << true << (QList<QByteArray>()
<< ('/' + QDateTime::currentDateTime().toString("dd-MM-yy").toUtf8() + "/qDebug")); << ('/' + QDateTime::currentDateTime().toString("dd-MM-yy").toLocal8Bit() + "/qDebug"));
// %{time} should have a padding of 6 so if it takes less than 10 seconds to show // %{time} should have a padding of 6 so if it takes less than 10 seconds to show
// the first message, there should be 5 spaces // the first message, there should be 5 spaces

View File

@ -1,6 +1,6 @@
/**************************************************************************** /****************************************************************************
** **
** Copyright (C) 2016 The Qt Company Ltd. ** Copyright (C) 2020 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/ ** Contact: https://www.qt.io/licensing/
** **
** This file is part of the test suite of the Qt Toolkit. ** This file is part of the test suite of the Qt Toolkit.
@ -65,7 +65,7 @@ void tst_QNoDebug::noDebugOutput() const
void tst_QNoDebug::streaming() const void tst_QNoDebug::streaming() const
{ {
QDateTime dt(QDate(1,2,3),QTime(4,5,6)); QDateTime dt(QDate(1,2,3),QTime(4,5,6));
const QByteArray debugString = dt.toString(u"yyyy-MM-dd HH:mm:ss.zzz t").toLatin1(); const QByteArray debugString = dt.toString(u"yyyy-MM-dd HH:mm:ss.zzz t").toLocal8Bit();
const QByteArray message = "QDateTime(" + debugString + " Qt::LocalTime)"; const QByteArray message = "QDateTime(" + debugString + " Qt::LocalTime)";
QTest::ignoreMessage(QtWarningMsg, message.constData()); QTest::ignoreMessage(QtWarningMsg, message.constData());
qWarning() << dt; qWarning() << dt;

View File

@ -6671,16 +6671,16 @@ void tst_QObject::connectWarnings()
ReceiverObject r1; ReceiverObject r1;
r1.reset(); r1.reset();
QTest::ignoreMessage(QtWarningMsg, "QObject::connect(SenderObject, ReceiverObject): invalid null parameter"); QTest::ignoreMessage(QtWarningMsg, "QObject::connect(SenderObject, ReceiverObject): invalid nullptr parameter");
connect(static_cast<const SenderObject *>(nullptr), &SubSender::signal1, &r1, &ReceiverObject::slot1); connect(static_cast<const SenderObject *>(nullptr), &SubSender::signal1, &r1, &ReceiverObject::slot1);
QTest::ignoreMessage(QtWarningMsg, "QObject::connect(SubSender, Unknown): invalid null parameter"); QTest::ignoreMessage(QtWarningMsg, "QObject::connect(SubSender, Unknown): invalid nullptr parameter");
connect(&sub, &SubSender::signal1, static_cast<ReceiverObject *>(nullptr), &ReceiverObject::slot1); connect(&sub, &SubSender::signal1, static_cast<ReceiverObject *>(nullptr), &ReceiverObject::slot1);
QTest::ignoreMessage(QtWarningMsg, "QObject::connect(SenderObject, ReceiverObject): invalid null parameter"); QTest::ignoreMessage(QtWarningMsg, "QObject::connect(SenderObject, ReceiverObject): invalid nullptr parameter");
connect(static_cast<const SenderObject *>(nullptr), &SenderObject::signal1, &r1, &ReceiverObject::slot1); connect(static_cast<const SenderObject *>(nullptr), &SenderObject::signal1, &r1, &ReceiverObject::slot1);
QTest::ignoreMessage(QtWarningMsg, "QObject::connect(SenderObject, Unknown): invalid null parameter"); QTest::ignoreMessage(QtWarningMsg, "QObject::connect(SenderObject, Unknown): invalid nullptr parameter");
connect(&obj, &SenderObject::signal1, static_cast<ReceiverObject *>(nullptr), &ReceiverObject::slot1); connect(&obj, &SenderObject::signal1, static_cast<ReceiverObject *>(nullptr), &ReceiverObject::slot1);
} }

View File

@ -174,7 +174,7 @@ public:
if (!s.peerAddress().isNull()) if (!s.peerAddress().isNull())
debug << ", peer=" << s.peerAddress().toString() << ':' << s.peerPort(); debug << ", peer=" << s.peerAddress().toString() << ':' << s.peerPort();
debug << ", type=" << s.socketType() << ", state=" << s.state() debug << ", type=" << s.socketType() << ", state=" << s.state()
<< ", error=" << s.error() << ": " << s.errorString(); << ", error=" << s.socketError() << ": " << s.errorString();
return result.toLocal8Bit(); return result.toLocal8Bit();
} }
#endif // QT_NETWORK_LIB #endif // QT_NETWORK_LIB

View File

@ -1111,7 +1111,7 @@ protected:
// get the "request" packet // get the "request" packet
if (!client->waitForReadyRead(2000)) { if (!client->waitForReadyRead(2000)) {
qDebug() << "FastSender:" << client->error() << "waiting for \"request\" packet"; qDebug() << "FastSender:" << client->socketError() << "waiting for \"request\" packet";
return; return;
} }
client->readAll(); // we're not interested in the actual contents (e.g. HTTP request) client->readAll(); // we're not interested in the actual contents (e.g. HTTP request)
@ -1148,7 +1148,7 @@ protected:
while (client->bytesToWrite() > 0) { while (client->bytesToWrite() > 0) {
qDebug() << "Still having" << client->bytesToWrite() << "bytes to write, doing that now"; qDebug() << "Still having" << client->bytesToWrite() << "bytes to write, doing that now";
if (!client->waitForBytesWritten(10000)) { if (!client->waitForBytesWritten(10000)) {
qDebug() << "ERROR: FastSender:" << client->error() << "cleaning up residue"; qDebug() << "ERROR: FastSender:" << client->socketError() << "cleaning up residue";
return; return;
} }
} }
@ -1168,7 +1168,7 @@ protected:
while (client->bytesToWrite() > 0) { while (client->bytesToWrite() > 0) {
if (!client->waitForBytesWritten(10000)) { if (!client->waitForBytesWritten(10000)) {
qDebug() << "ERROR: FastSender:" << client->error() << "during blocking write"; qDebug() << "ERROR: FastSender:" << client->socketError() << "during blocking write";
return; return;
} }
} }

View File

@ -274,7 +274,7 @@ void tst_QHttpSocketEngine::errorTest()
QTestEventLoop::instance().enterLoop(30); QTestEventLoop::instance().enterLoop(30);
QVERIFY(!QTestEventLoop::instance().timeout()); QVERIFY(!QTestEventLoop::instance().timeout());
QCOMPARE(int(socket.error()), expectedError); QCOMPARE(int(socket.socketError()), expectedError);
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------

View File

@ -65,8 +65,8 @@ bool runServer(int numberOfConnections)
return false; return false;
} }
printf("server: data written\n"); printf("server: data written\n");
if (socket->error() != QLocalSocket::UnknownSocketError) { if (socket->socketError() != QLocalSocket::UnknownSocketError) {
fprintf(stderr, "server: socket error %d\n", socket->error()); fprintf(stderr, "server: socket error %d\n", socket->socketError());
return false; return false;
} }
} }
@ -83,8 +83,8 @@ bool runClient()
socket.connectToServer(serverName, QLocalSocket::ReadWrite); socket.connectToServer(serverName, QLocalSocket::ReadWrite);
if (socket.waitForConnected()) if (socket.waitForConnected())
break; break;
if (socket.error() == QLocalSocket::ServerNotFoundError if (socket.socketError() == QLocalSocket::ServerNotFoundError
|| socket.error() == QLocalSocket::ConnectionRefusedError) { || socket.socketError() == QLocalSocket::ConnectionRefusedError) {
if (connectTimer.elapsed() > 5000) { if (connectTimer.elapsed() > 5000) {
fprintf(stderr, "client: server not found or connection refused. Giving up.\n"); fprintf(stderr, "client: server not found or connection refused. Giving up.\n");
return false; return false;

View File

@ -195,7 +195,7 @@ private slots:
void slotError(QLocalSocket::LocalSocketError newError) void slotError(QLocalSocket::LocalSocketError newError)
{ {
QVERIFY(errorString() != QLatin1String("Unknown error")); QVERIFY(errorString() != QLatin1String("Unknown error"));
QCOMPARE(error(), newError); QCOMPARE(socketError(), newError);
} }
void slotStateChanged(QLocalSocket::LocalSocketState newState) void slotStateChanged(QLocalSocket::LocalSocketState newState)
{ {
@ -256,7 +256,7 @@ void tst_QLocalSocket::socket_basic()
QCOMPARE(socket.canReadLine(), false); QCOMPARE(socket.canReadLine(), false);
socket.close(); socket.close();
socket.disconnectFromServer(); socket.disconnectFromServer();
QCOMPARE(QLocalSocket::UnknownSocketError, socket.error()); QCOMPARE(QLocalSocket::UnknownSocketError, socket.socketError());
QVERIFY(!socket.errorString().isEmpty()); QVERIFY(!socket.errorString().isEmpty());
QCOMPARE(socket.flush(), false); QCOMPARE(socket.flush(), false);
QCOMPARE(socket.isValid(), false); QCOMPARE(socket.isValid(), false);
@ -375,13 +375,13 @@ void tst_QLocalSocket::listenAndConnect()
QVERIFY(socket->waitForConnected()); QVERIFY(socket->waitForConnected());
QVERIFY(socket->isValid()); QVERIFY(socket->isValid());
QCOMPARE(socket->errorString(), QString("Unknown error")); QCOMPARE(socket->errorString(), QString("Unknown error"));
QCOMPARE(socket->error(), QLocalSocket::UnknownSocketError); QCOMPARE(socket->socketError(), QLocalSocket::UnknownSocketError);
QCOMPARE(socket->state(), QLocalSocket::ConnectedState); QCOMPARE(socket->state(), QLocalSocket::ConnectedState);
//QVERIFY(socket->socketDescriptor() != -1); //QVERIFY(socket->socketDescriptor() != -1);
QCOMPARE(spyError.count(), 0); QCOMPARE(spyError.count(), 0);
} else { } else {
QVERIFY(!socket->errorString().isEmpty()); QVERIFY(!socket->errorString().isEmpty());
QVERIFY(socket->error() != QLocalSocket::UnknownSocketError); QVERIFY(socket->socketError() != QLocalSocket::UnknownSocketError);
QCOMPARE(socket->state(), QLocalSocket::UnconnectedState); QCOMPARE(socket->state(), QLocalSocket::UnconnectedState);
//QCOMPARE(socket->socketDescriptor(), -1); //QCOMPARE(socket->socketDescriptor(), -1);
QCOMPARE(qvariant_cast<QLocalSocket::LocalSocketError>(spyError.first()[0]), QCOMPARE(qvariant_cast<QLocalSocket::LocalSocketError>(spyError.first()[0]),

View File

@ -287,7 +287,7 @@ void tst_QSocks5SocketEngine::errorTest()
QTestEventLoop::instance().enterLoop(10); QTestEventLoop::instance().enterLoop(10);
QVERIFY(!QTestEventLoop::instance().timeout()); QVERIFY(!QTestEventLoop::instance().timeout());
QCOMPARE(int(socket.error()), expectedError); QCOMPARE(int(socket.socketError()), expectedError);
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
@ -1010,7 +1010,7 @@ void tst_QSocks5SocketEngine::incomplete()
QTestEventLoop::instance().enterLoop(70); QTestEventLoop::instance().enterLoop(70);
QVERIFY(!QTestEventLoop::instance().timeout()); QVERIFY(!QTestEventLoop::instance().timeout());
QCOMPARE(socket.error(), QAbstractSocket::ProxyConnectionClosedError); QCOMPARE(socket.socketError(), QAbstractSocket::ProxyConnectionClosedError);
} }
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------

View File

@ -492,7 +492,7 @@ void tst_QTcpSocket::constructing()
QCOMPARE(socket->peerAddress(), QHostAddress()); QCOMPARE(socket->peerAddress(), QHostAddress());
QCOMPARE(socket->readChannelCount(), 0); QCOMPARE(socket->readChannelCount(), 0);
QCOMPARE(socket->writeChannelCount(), 0); QCOMPARE(socket->writeChannelCount(), 0);
QCOMPARE(socket->error(), QTcpSocket::UnknownSocketError); QCOMPARE(socket->socketError(), QTcpSocket::UnknownSocketError);
QCOMPARE(socket->errorString(), QString("Unknown error")); QCOMPARE(socket->errorString(), QString("Unknown error"));
// Check the state of the socket layer? // Check the state of the socket layer?
@ -596,7 +596,7 @@ void tst_QTcpSocket::bind()
} }
bool bindSuccess = socket->bind(addr, port); bool bindSuccess = socket->bind(addr, port);
if (!bindSuccess && randomPort && socket->error() == QTcpSocket::AddressInUseError) { if (!bindSuccess && randomPort && socket->socketError() == QTcpSocket::AddressInUseError) {
// we may have been unlucky and hit an already open port, so try another // we may have been unlucky and hit an already open port, so try another
--attemptsLeft; --attemptsLeft;
continue; continue;
@ -708,7 +708,7 @@ void tst_QTcpSocket::setInvalidSocketDescriptor()
QVERIFY(!socket->setSocketDescriptor(-5, QTcpSocket::UnconnectedState)); QVERIFY(!socket->setSocketDescriptor(-5, QTcpSocket::UnconnectedState));
QCOMPARE(socket->socketDescriptor(), (qintptr)-1); QCOMPARE(socket->socketDescriptor(), (qintptr)-1);
QCOMPARE(socket->error(), QTcpSocket::UnsupportedSocketOperationError); QCOMPARE(socket->socketError(), QTcpSocket::UnsupportedSocketOperationError);
delete socket; delete socket;
} }
@ -871,7 +871,7 @@ void tst_QTcpSocket::hostNotFound()
"when we expect 404", Continue); "when we expect 404", Continue);
} }
#endif #endif
QCOMPARE(int(socket->error()), int(QTcpSocket::HostNotFoundError)); QCOMPARE(int(socket->socketError()), int(QTcpSocket::HostNotFoundError));
delete socket; delete socket;
} }
@ -897,7 +897,7 @@ void tst_QTcpSocket::timeoutConnect()
QVERIFY(timer.elapsed() < 150); QVERIFY(timer.elapsed() < 150);
QVERIFY(!socket->waitForConnected(1000)); //200ms is too short when using SOCKS proxy authentication QVERIFY(!socket->waitForConnected(1000)); //200ms is too short when using SOCKS proxy authentication
QCOMPARE(socket->state(), QTcpSocket::UnconnectedState); QCOMPARE(socket->state(), QTcpSocket::UnconnectedState);
QCOMPARE(int(socket->error()), int(QTcpSocket::SocketTimeoutError)); QCOMPARE(int(socket->socketError()), int(QTcpSocket::SocketTimeoutError));
QCOMPARE(socket->readChannelCount(), 0); QCOMPARE(socket->readChannelCount(), 0);
QCOMPARE(socket->writeChannelCount(), 0); QCOMPARE(socket->writeChannelCount(), 0);
@ -1216,7 +1216,7 @@ void tst_QTcpSocket::openCloseOpenClose()
QCOMPARE(socket->localAddress(), QHostAddress()); QCOMPARE(socket->localAddress(), QHostAddress());
QCOMPARE((int) socket->peerPort(), 0); QCOMPARE((int) socket->peerPort(), 0);
QCOMPARE(socket->peerAddress(), QHostAddress()); QCOMPARE(socket->peerAddress(), QHostAddress());
QCOMPARE(socket->error(), QTcpSocket::UnknownSocketError); QCOMPARE(socket->socketError(), QTcpSocket::UnknownSocketError);
QCOMPARE(socket->errorString(), QString("Unknown error")); QCOMPARE(socket->errorString(), QString("Unknown error"));
QCOMPARE(socket->state(), QTcpSocket::UnconnectedState); QCOMPARE(socket->state(), QTcpSocket::UnconnectedState);
@ -1370,7 +1370,7 @@ protected:
while (!quit) { while (!quit) {
if (socket->waitForDisconnected(500)) if (socket->waitForDisconnected(500))
break; break;
if (socket->error() != QAbstractSocket::SocketTimeoutError) if (socket->socketError() != QAbstractSocket::SocketTimeoutError)
return; return;
} }
@ -1606,8 +1606,8 @@ void tst_QTcpSocket::readLine()
QVERIFY(!socket->waitForReadyRead(100)); QVERIFY(!socket->waitForReadyRead(100));
QCOMPARE(socket->readLine(buffer, sizeof(buffer)), qint64(0)); QCOMPARE(socket->readLine(buffer, sizeof(buffer)), qint64(0));
QVERIFY(socket->error() == QAbstractSocket::SocketTimeoutError QVERIFY(socket->socketError() == QAbstractSocket::SocketTimeoutError
|| socket->error() == QAbstractSocket::RemoteHostClosedError); || socket->socketError() == QAbstractSocket::RemoteHostClosedError);
QCOMPARE(socket->bytesAvailable(), qint64(0)); QCOMPARE(socket->bytesAvailable(), qint64(0));
socket->close(); socket->close();
@ -1756,11 +1756,11 @@ void tst_QTcpSocket::dontCloseOnTimeout()
QTcpSocket *socket = newSocket(); QTcpSocket *socket = newSocket();
socket->connectToHost(serverAddress, server.serverPort()); socket->connectToHost(serverAddress, server.serverPort());
QVERIFY(!socket->waitForReadyRead(100)); QVERIFY(!socket->waitForReadyRead(100));
QCOMPARE(socket->error(), QTcpSocket::SocketTimeoutError); QCOMPARE(socket->socketError(), QTcpSocket::SocketTimeoutError);
QVERIFY(socket->isOpen()); QVERIFY(socket->isOpen());
QVERIFY(!socket->waitForDisconnected(100)); QVERIFY(!socket->waitForDisconnected(100));
QCOMPARE(socket->error(), QTcpSocket::SocketTimeoutError); QCOMPARE(socket->socketError(), QTcpSocket::SocketTimeoutError);
QVERIFY(socket->isOpen()); QVERIFY(socket->isOpen());
delete socket; delete socket;
@ -2012,7 +2012,7 @@ void tst_QTcpSocket::remoteCloseError()
QCOMPARE(disconnectedSpy.count(), 1); QCOMPARE(disconnectedSpy.count(), 1);
QCOMPARE(errorSpy.count(), 1); QCOMPARE(errorSpy.count(), 1);
QCOMPARE(clientSocket->error(), QAbstractSocket::RemoteHostClosedError); QCOMPARE(clientSocket->socketError(), QAbstractSocket::RemoteHostClosedError);
delete serverSocket; delete serverSocket;
@ -2380,7 +2380,7 @@ void tst_QTcpSocket::zeroAndMinusOneReturns()
socket->write("GET / HTTP/1.0\r\n\r\n"); socket->write("GET / HTTP/1.0\r\n\r\n");
QVERIFY(socket->waitForDisconnected(15000)); QVERIFY(socket->waitForDisconnected(15000));
QCOMPARE(socket->error(), QAbstractSocket::RemoteHostClosedError); QCOMPARE(socket->socketError(), QAbstractSocket::RemoteHostClosedError);
QCOMPARE(socket->write("BLUBBER"), qint64(-1)); QCOMPARE(socket->write("BLUBBER"), qint64(-1));
QVERIFY(socket->getChar(c)); QVERIFY(socket->getChar(c));
@ -2429,7 +2429,7 @@ void tst_QTcpSocket::connectionRefused()
QVERIFY2(!timeout(), "Network timeout"); QVERIFY2(!timeout(), "Network timeout");
QCOMPARE(socket->state(), QAbstractSocket::UnconnectedState); QCOMPARE(socket->state(), QAbstractSocket::UnconnectedState);
QCOMPARE(socket->error(), QAbstractSocket::ConnectionRefusedError); QCOMPARE(socket->socketError(), QAbstractSocket::ConnectionRefusedError);
QCOMPARE(stateSpy.count(), 3); QCOMPARE(stateSpy.count(), 3);
QCOMPARE(qvariant_cast<QAbstractSocket::SocketState>(stateSpy.at(0).at(0)), QAbstractSocket::HostLookupState); QCOMPARE(qvariant_cast<QAbstractSocket::SocketState>(stateSpy.at(0).at(0)), QAbstractSocket::HostLookupState);
@ -2552,7 +2552,7 @@ void tst_QTcpSocket::connectToMultiIP()
socket->connectToHost("multi.dev.qt-project.org", 81); socket->connectToHost("multi.dev.qt-project.org", 81);
QVERIFY(!socket->waitForConnected(2000)); QVERIFY(!socket->waitForConnected(2000));
QVERIFY(stopWatch.elapsed() < 2000); QVERIFY(stopWatch.elapsed() < 2000);
QCOMPARE(socket->error(), QAbstractSocket::SocketTimeoutError); QCOMPARE(socket->socketError(), QAbstractSocket::SocketTimeoutError);
delete socket; delete socket;
#endif #endif
@ -2738,7 +2738,7 @@ void tst_QTcpSocket::taskQtBug5799ConnectionErrorWaitForConnected()
socket.waitForConnected(10000); socket.waitForConnected(10000);
QVERIFY2(timer.elapsed() < 9900, "Connection to closed port timed out instead of refusing, something is wrong"); QVERIFY2(timer.elapsed() < 9900, "Connection to closed port timed out instead of refusing, something is wrong");
QVERIFY2(socket.state() == QAbstractSocket::UnconnectedState, "Socket connected unexpectedly!"); QVERIFY2(socket.state() == QAbstractSocket::UnconnectedState, "Socket connected unexpectedly!");
QVERIFY2(socket.error() == QAbstractSocket::ConnectionRefusedError, QVERIFY2(socket.socketError() == QAbstractSocket::ConnectionRefusedError,
QString("Could not reach server: %1").arg(socket.errorString()).toLocal8Bit()); QString("Could not reach server: %1").arg(socket.errorString()).toLocal8Bit());
} }
@ -2757,7 +2757,7 @@ void tst_QTcpSocket::taskQtBug5799ConnectionErrorEventLoop()
QTestEventLoop::instance().enterLoop(10); QTestEventLoop::instance().enterLoop(10);
QVERIFY2(!QTestEventLoop::instance().timeout(), "Connection to closed port timed out instead of refusing, something is wrong"); QVERIFY2(!QTestEventLoop::instance().timeout(), "Connection to closed port timed out instead of refusing, something is wrong");
QVERIFY2(socket.state() == QAbstractSocket::UnconnectedState, "Socket connected unexpectedly!"); QVERIFY2(socket.state() == QAbstractSocket::UnconnectedState, "Socket connected unexpectedly!");
QVERIFY2(socket.error() == QAbstractSocket::ConnectionRefusedError, QVERIFY2(socket.socketError() == QAbstractSocket::ConnectionRefusedError,
QString("Could not reach server: %1").arg(socket.errorString()).toLocal8Bit()); QString("Could not reach server: %1").arg(socket.errorString()).toLocal8Bit());
} }
@ -2767,12 +2767,12 @@ void tst_QTcpSocket::taskQtBug7054TimeoutErrorResetting()
socket->connectToHost(QtNetworkSettings::httpServerName(), 443); socket->connectToHost(QtNetworkSettings::httpServerName(), 443);
QVERIFY(socket->waitForConnected(5*1000)); QVERIFY(socket->waitForConnected(5*1000));
QCOMPARE(socket->error(), QAbstractSocket::UnknownSocketError); QCOMPARE(socket->socketError(), QAbstractSocket::UnknownSocketError);
// We connected to the HTTPS port. Wait two seconds to receive data. We will receive // We connected to the HTTPS port. Wait two seconds to receive data. We will receive
// nothing because we would need to start the SSL handshake // nothing because we would need to start the SSL handshake
QVERIFY(!socket->waitForReadyRead(2*1000)); QVERIFY(!socket->waitForReadyRead(2*1000));
QCOMPARE(socket->error(), QAbstractSocket::SocketTimeoutError); QCOMPARE(socket->socketError(), QAbstractSocket::SocketTimeoutError);
// Now write some crap to make the server disconnect us. 4 lines are enough. // Now write some crap to make the server disconnect us. 4 lines are enough.
socket->write("a\r\nb\r\nc\r\nd\r\n"); socket->write("a\r\nb\r\nc\r\nd\r\n");
@ -2782,7 +2782,7 @@ void tst_QTcpSocket::taskQtBug7054TimeoutErrorResetting()
// should get a better error since the server disconnected us // should get a better error since the server disconnected us
QVERIFY(!socket->waitForReadyRead(2*1000)); QVERIFY(!socket->waitForReadyRead(2*1000));
// It must NOT be the SocketTimeoutError that had been set before // It must NOT be the SocketTimeoutError that had been set before
QCOMPARE(socket->error(), QAbstractSocket::RemoteHostClosedError); QCOMPARE(socket->socketError(), QAbstractSocket::RemoteHostClosedError);
} }
#ifndef QT_NO_NETWORKPROXY #ifndef QT_NO_NETWORKPROXY
@ -2840,7 +2840,7 @@ void tst_QTcpSocket::invalidProxy()
// note: the following test is not a hard failure. // note: the following test is not a hard failure.
// Sometimes, error codes change for the better // Sometimes, error codes change for the better
QTEST(int(socket->error()), "expectedError"); QTEST(int(socket->socketError()), "expectedError");
delete socket; delete socket;
} }
@ -2960,7 +2960,7 @@ void tst_QTcpSocket::proxyFactory()
// note: the following test is not a hard failure. // note: the following test is not a hard failure.
// Sometimes, error codes change for the better // Sometimes, error codes change for the better
QTEST(int(socket->error()), "expectedError"); QTEST(int(socket->socketError()), "expectedError");
delete socket; delete socket;
} }

View File

@ -337,7 +337,7 @@ void tst_QUdpSocket::constructing()
QCOMPARE(socket.canReadLine(), false); QCOMPARE(socket.canReadLine(), false);
QCOMPARE(socket.readLine(), QByteArray()); QCOMPARE(socket.readLine(), QByteArray());
QCOMPARE(socket.socketDescriptor(), (qintptr)-1); QCOMPARE(socket.socketDescriptor(), (qintptr)-1);
QCOMPARE(socket.error(), QUdpSocket::UnknownSocketError); QCOMPARE(socket.socketError(), QUdpSocket::UnknownSocketError);
QCOMPARE(socket.errorString(), QString("Unknown error")); QCOMPARE(socket.errorString(), QString("Unknown error"));
// Check the state of the socket api // Check the state of the socket api
@ -575,7 +575,7 @@ void tst_QUdpSocket::ipv6Loop()
int paulPort; int paulPort;
if (!peter.bind(QHostAddress(QHostAddress::LocalHostIPv6), 0)) { if (!peter.bind(QHostAddress(QHostAddress::LocalHostIPv6), 0)) {
QCOMPARE(peter.error(), QUdpSocket::UnsupportedSocketOperationError); QCOMPARE(peter.socketError(), QUdpSocket::UnsupportedSocketOperationError);
return; return;
} }
@ -897,7 +897,7 @@ void tst_QUdpSocket::writeDatagram()
QCOMPARE(errorspy.count(), 1); QCOMPARE(errorspy.count(), 1);
QCOMPARE(*static_cast<const int *>(errorspy.at(0).at(0).constData()), QCOMPARE(*static_cast<const int *>(errorspy.at(0).at(0).constData()),
int(QUdpSocket::DatagramTooLargeError)); int(QUdpSocket::DatagramTooLargeError));
QCOMPARE(client.error(), QUdpSocket::DatagramTooLargeError); QCOMPARE(client.socketError(), QUdpSocket::DatagramTooLargeError);
break; break;
} }
QCOMPARE(bytesspy.count(), 1); QCOMPARE(bytesspy.count(), 1);
@ -1054,14 +1054,14 @@ void tst_QUdpSocket::writeToNonExistingPeer()
// the second one should fail! // the second one should fail!
QTest::qSleep(1000); // do not process events QTest::qSleep(1000); // do not process events
QCOMPARE(sConnected.write("", 1), qint64(-1)); QCOMPARE(sConnected.write("", 1), qint64(-1));
QCOMPARE(int(sConnected.error()), int(QUdpSocket::ConnectionRefusedError)); QCOMPARE(int(sConnected.socketError()), int(QUdpSocket::ConnectionRefusedError));
// the third one will succeed... // the third one will succeed...
QCOMPARE(sConnected.write("", 1), qint64(1)); QCOMPARE(sConnected.write("", 1), qint64(1));
QTestEventLoop::instance().enterLoop(1); QTestEventLoop::instance().enterLoop(1);
QCOMPARE(sConnectedReadyReadSpy.count(), 0); QCOMPARE(sConnectedReadyReadSpy.count(), 0);
QCOMPARE(sConnectedErrorSpy.count(), 1); QCOMPARE(sConnectedErrorSpy.count(), 1);
QCOMPARE(int(sConnected.error()), int(QUdpSocket::ConnectionRefusedError)); QCOMPARE(int(sConnected.socketError()), int(QUdpSocket::ConnectionRefusedError));
// we should now get a read error // we should now get a read error
QCOMPARE(sConnected.write("", 1), qint64(1)); QCOMPARE(sConnected.write("", 1), qint64(1));
@ -1071,12 +1071,12 @@ void tst_QUdpSocket::writeToNonExistingPeer()
QCOMPARE(sConnected.bytesAvailable(), Q_INT64_C(0)); QCOMPARE(sConnected.bytesAvailable(), Q_INT64_C(0));
QCOMPARE(sConnected.pendingDatagramSize(), Q_INT64_C(-1)); QCOMPARE(sConnected.pendingDatagramSize(), Q_INT64_C(-1));
QCOMPARE(sConnected.readDatagram(buf, 2), Q_INT64_C(-1)); QCOMPARE(sConnected.readDatagram(buf, 2), Q_INT64_C(-1));
QCOMPARE(int(sConnected.error()), int(QUdpSocket::ConnectionRefusedError)); QCOMPARE(int(sConnected.socketError()), int(QUdpSocket::ConnectionRefusedError));
QCOMPARE(sConnected.write("", 1), qint64(1)); QCOMPARE(sConnected.write("", 1), qint64(1));
QTest::qSleep(1000); // do not process events QTest::qSleep(1000); // do not process events
QCOMPARE(sConnected.read(buf, 2), Q_INT64_C(0)); QCOMPARE(sConnected.read(buf, 2), Q_INT64_C(0));
QCOMPARE(int(sConnected.error()), int(QUdpSocket::ConnectionRefusedError)); QCOMPARE(int(sConnected.socketError()), int(QUdpSocket::ConnectionRefusedError));
// we should still be connected // we should still be connected
QCOMPARE(int(sConnected.state()), int(QUdpSocket::ConnectedState)); QCOMPARE(int(sConnected.state()), int(QUdpSocket::ConnectedState));

View File

@ -430,14 +430,14 @@ private:
}; };
#define QCOMPARE_SINGLE_ERROR(sslSocket, expectedError) \ #define QCOMPARE_SINGLE_ERROR(sslSocket, expectedError) \
const auto &tlsErrors = sslSocket.sslErrors(); \ const auto &tlsErrors = sslSocket.sslHandshakeErrors(); \
QCOMPARE(tlsErrors.size(), 1); \ QCOMPARE(tlsErrors.size(), 1); \
QCOMPARE(tlsErrors[0].error(), expectedError) QCOMPARE(tlsErrors[0].error(), expectedError)
#define QVERIFY_HANDSHAKE_WITHOUT_ERRORS(sslSocket) \ #define QVERIFY_HANDSHAKE_WITHOUT_ERRORS(sslSocket) \
QVERIFY(sslSocket.isEncrypted()); \ QVERIFY(sslSocket.isEncrypted()); \
QCOMPARE(sslSocket.state(), QAbstractSocket::ConnectedState); \ QCOMPARE(sslSocket.state(), QAbstractSocket::ConnectedState); \
QVERIFY(sslSocket.sslErrors().isEmpty()) QVERIFY(sslSocket.sslHandshakeErrors().isEmpty())
#define QDECLARE_CHAIN(object, chainFileName) \ #define QDECLARE_CHAIN(object, chainFileName) \
CertificateChain object = QSslCertificate::fromPath(certDirPath + QLatin1String(chainFileName)); \ CertificateChain object = QSslCertificate::fromPath(certDirPath + QLatin1String(chainFileName)); \
@ -605,7 +605,7 @@ void tst_QOcsp::malformedResponse()
loop.enterLoopMSecs(handshakeTimeoutMS); loop.enterLoopMSecs(handshakeTimeoutMS);
QVERIFY(!clientSocket.isEncrypted()); QVERIFY(!clientSocket.isEncrypted());
QCOMPARE(clientSocket.error(), QAbstractSocket::SslHandshakeFailedError); QCOMPARE(clientSocket.socketError(), QAbstractSocket::SslHandshakeFailedError);
} }
void tst_QOcsp::expiredResponse_data() void tst_QOcsp::expiredResponse_data()
@ -721,7 +721,7 @@ void tst_QOcsp::wrongCertificateInResponse()
loop.enterLoopMSecs(handshakeTimeoutMS); loop.enterLoopMSecs(handshakeTimeoutMS);
QVERIFY(!clientSocket.isEncrypted()); QVERIFY(!clientSocket.isEncrypted());
QVERIFY(containsError(clientSocket.sslErrors(), expectedError)); QVERIFY(containsError(clientSocket.sslHandshakeErrors(), expectedError));
} }
void tst_QOcsp::untrustedResponder() void tst_QOcsp::untrustedResponder()
@ -746,7 +746,7 @@ void tst_QOcsp::untrustedResponder()
loop.enterLoopMSecs(handshakeTimeoutMS); loop.enterLoopMSecs(handshakeTimeoutMS);
QVERIFY(!clientSocket.isEncrypted()); QVERIFY(!clientSocket.isEncrypted());
QVERIFY(containsError(clientSocket.sslErrors(), expectedError)); QVERIFY(containsError(clientSocket.sslHandshakeErrors(), expectedError));
} }
void tst_QOcsp::setupOcspClient(QSslSocket &clientSocket, const CertificateChain &caCerts, const QString &name) void tst_QOcsp::setupOcspClient(QSslSocket &clientSocket, const CertificateChain &caCerts, const QString &name)

View File

@ -532,7 +532,7 @@ void tst_QSslSocket::constructing()
QCOMPARE(socket.write(0, 0), qint64(-1)); QCOMPARE(socket.write(0, 0), qint64(-1));
QTest::ignoreMessage(QtWarningMsg, writeNotOpenMessage); QTest::ignoreMessage(QtWarningMsg, writeNotOpenMessage);
QCOMPARE(socket.write(QByteArray()), qint64(-1)); QCOMPARE(socket.write(QByteArray()), qint64(-1));
QCOMPARE(socket.error(), QAbstractSocket::UnknownSocketError); QCOMPARE(socket.socketError(), QAbstractSocket::UnknownSocketError);
QVERIFY(!socket.flush()); QVERIFY(!socket.flush());
QVERIFY(!socket.isValid()); QVERIFY(!socket.isValid());
QCOMPARE(socket.localAddress(), QHostAddress()); QCOMPARE(socket.localAddress(), QHostAddress());
@ -738,7 +738,7 @@ void tst_QSslSocket::sslErrors()
// check the SSL errors contain HostNameMismatch and an error due to // check the SSL errors contain HostNameMismatch and an error due to
// the certificate being self-signed // the certificate being self-signed
SslErrorList sslErrors; SslErrorList sslErrors;
const auto socketSslErrors = socket->sslErrors(); const auto socketSslErrors = socket->sslHandshakeErrors();
for (const QSslError &err : socketSslErrors) for (const QSslError &err : socketSslErrors)
sslErrors << err.error(); sslErrors << err.error();
std::sort(sslErrors.begin(), sslErrors.end()); std::sort(sslErrors.begin(), sslErrors.end());
@ -1372,16 +1372,16 @@ void tst_QSslSocket::protocolServerSide()
QAbstractSocket::SocketState expectedState = (works) ? QAbstractSocket::ConnectedState : QAbstractSocket::UnconnectedState; QAbstractSocket::SocketState expectedState = (works) ? QAbstractSocket::ConnectedState : QAbstractSocket::UnconnectedState;
// Determine whether the client or the server caused the event loop // Determine whether the client or the server caused the event loop
// to quit due to a socket error, and investigate the culprit. // to quit due to a socket error, and investigate the culprit.
if (client.error() != QAbstractSocket::UnknownSocketError) { if (client.socketError() != QAbstractSocket::UnknownSocketError) {
// It can happen that the client, after TCP connection established, before // It can happen that the client, after TCP connection established, before
// incomingConnection() slot fired, hits TLS initialization error and stops // incomingConnection() slot fired, hits TLS initialization error and stops
// the loop, so the server socket is not created yet. // the loop, so the server socket is not created yet.
if (server.socket) if (server.socket)
QVERIFY(server.socket->error() == QAbstractSocket::UnknownSocketError); QVERIFY(server.socket->socketError() == QAbstractSocket::UnknownSocketError);
QCOMPARE(client.state(), expectedState); QCOMPARE(client.state(), expectedState);
} else if (server.socket->error() != QAbstractSocket::UnknownSocketError) { } else if (server.socket->socketError() != QAbstractSocket::UnknownSocketError) {
QVERIFY(client.error() == QAbstractSocket::UnknownSocketError); QVERIFY(client.socketError() == QAbstractSocket::UnknownSocketError);
QCOMPARE(server.socket->state(), expectedState); QCOMPARE(server.socket->state(), expectedState);
} }
@ -1993,7 +1993,7 @@ void tst_QSslSocket::setEmptyKey()
QTestEventLoop::instance().enterLoop(2); QTestEventLoop::instance().enterLoop(2);
QCOMPARE(socket.state(), QAbstractSocket::ConnectedState); QCOMPARE(socket.state(), QAbstractSocket::ConnectedState);
QCOMPARE(socket.error(), QAbstractSocket::UnknownSocketError); QCOMPARE(socket.socketError(), QAbstractSocket::UnknownSocketError);
} }
void tst_QSslSocket::spontaneousWrite() void tst_QSslSocket::spontaneousWrite()
@ -2415,7 +2415,7 @@ void tst_QSslSocket::verifyMode()
QList<QSslError> expectedErrors = QList<QSslError>() QList<QSslError> expectedErrors = QList<QSslError>()
<< QSslError(FLUKE_CERTIFICATE_ERROR, socket.peerCertificate()); << QSslError(FLUKE_CERTIFICATE_ERROR, socket.peerCertificate());
QCOMPARE(socket.sslErrors(), expectedErrors); QCOMPARE(socket.sslHandshakeErrors(), expectedErrors);
socket.abort(); socket.abort();
VerifyServer server; VerifyServer server;
@ -2431,7 +2431,7 @@ void tst_QSslSocket::verifyMode()
loop.exec(); loop.exec();
QVERIFY(clientSocket.isEncrypted()); QVERIFY(clientSocket.isEncrypted());
QVERIFY(server.socket->sslErrors().isEmpty()); QVERIFY(server.socket->sslHandshakeErrors().isEmpty());
} }
void tst_QSslSocket::verifyDepth() void tst_QSslSocket::verifyDepth()
@ -2765,11 +2765,11 @@ void tst_QSslSocket::writeBigChunk()
// no better way to do this right now since the error is the same as the default error. // no better way to do this right now since the error is the same as the default error.
if (socket->errorString().startsWith(QLatin1String("Unable to write data"))) if (socket->errorString().startsWith(QLatin1String("Unable to write data")))
{ {
qWarning() << socket->error() << socket->errorString(); qWarning() << socket->socketError() << socket->errorString();
QFAIL("Error while writing! Check if the OpenSSL BIO size is limited?!"); QFAIL("Error while writing! Check if the OpenSSL BIO size is limited?!");
} }
// also check the error string. If another error (than UnknownError) occurred, it should be different than before // also check the error string. If another error (than UnknownError) occurred, it should be different than before
QVERIFY2(errorBefore == errorAfter || socket->error() == QAbstractSocket::RemoteHostClosedError, QVERIFY2(errorBefore == errorAfter || socket->socketError() == QAbstractSocket::RemoteHostClosedError,
QByteArray("unexpected error: ").append(qPrintable(errorAfter))); QByteArray("unexpected error: ").append(qPrintable(errorAfter)));
// check that everything has been written to OpenSSL // check that everything has been written to OpenSSL
@ -2808,7 +2808,7 @@ void tst_QSslSocket::blacklistedCertificates()
connect(receiver, SIGNAL(sslErrors(QList<QSslError>)), SLOT(exitLoop())); connect(receiver, SIGNAL(sslErrors(QList<QSslError>)), SLOT(exitLoop()));
connect(receiver, SIGNAL(encrypted()), SLOT(exitLoop())); connect(receiver, SIGNAL(encrypted()), SLOT(exitLoop()));
enterLoop(1); enterLoop(1);
QList<QSslError> sslErrors = receiver->sslErrors(); QList<QSslError> sslErrors = receiver->sslHandshakeErrors();
QVERIFY(sslErrors.count() > 0); QVERIFY(sslErrors.count() > 0);
// there are more errors (self signed cert and hostname mismatch), but we only care about the blacklist error // there are more errors (self signed cert and hostname mismatch), but we only care about the blacklist error
QCOMPARE(sslErrors.at(0).error(), QSslError::CertificateBlacklisted); QCOMPARE(sslErrors.at(0).error(), QSslError::CertificateBlacklisted);
@ -2964,7 +2964,7 @@ void tst_QSslSocket::resume()
QCOMPARE(encryptedSpy.count(), 0); QCOMPARE(encryptedSpy.count(), 0);
QVERIFY(!socket.isEncrypted()); QVERIFY(!socket.isEncrypted());
QCOMPARE(errorSpy.count(), 1); QCOMPARE(errorSpy.count(), 1);
QCOMPARE(socket.error(), QAbstractSocket::SslHandshakeFailedError); QCOMPARE(socket.socketError(), QAbstractSocket::SslHandshakeFailedError);
} }
} }
@ -4332,9 +4332,9 @@ void tst_QSslSocket::unsupportedProtocols()
// early, preventing any real connection from ever starting. // early, preventing any real connection from ever starting.
QSslSocket socket; QSslSocket socket;
socket.setProtocol(unsupportedProtocol); socket.setProtocol(unsupportedProtocol);
QCOMPARE(socket.error(), QAbstractSocket::UnknownSocketError); QCOMPARE(socket.socketError(), QAbstractSocket::UnknownSocketError);
socket.connectToHostEncrypted(QStringLiteral("doesnotmatter.org"), 1010); socket.connectToHostEncrypted(QStringLiteral("doesnotmatter.org"), 1010);
QCOMPARE(socket.error(), QAbstractSocket::SslInvalidUserDataError); QCOMPARE(socket.socketError(), QAbstractSocket::SslInvalidUserDataError);
QCOMPARE(socket.state(), QAbstractSocket::UnconnectedState); QCOMPARE(socket.state(), QAbstractSocket::UnconnectedState);
} }
{ {
@ -4344,14 +4344,14 @@ void tst_QSslSocket::unsupportedProtocols()
QVERIFY(server.listen()); QVERIFY(server.listen());
QSslSocket socket; QSslSocket socket;
QCOMPARE(socket.error(), QAbstractSocket::UnknownSocketError); QCOMPARE(socket.socketError(), QAbstractSocket::UnknownSocketError);
socket.connectToHost(QHostAddress::LocalHost, server.serverPort()); socket.connectToHost(QHostAddress::LocalHost, server.serverPort());
QVERIFY(socket.waitForConnected(timeoutMS)); QVERIFY(socket.waitForConnected(timeoutMS));
socket.setProtocol(unsupportedProtocol); socket.setProtocol(unsupportedProtocol);
socket.startClientEncryption(); socket.startClientEncryption();
QCOMPARE(socket.error(), QAbstractSocket::SslInvalidUserDataError); QCOMPARE(socket.socketError(), QAbstractSocket::SslInvalidUserDataError);
} }
{ {
// 2. waitForEncrypted: client-side, blocking API plus requires from us // 2. waitForEncrypted: client-side, blocking API plus requires from us
@ -4375,7 +4375,7 @@ void tst_QSslSocket::unsupportedProtocols()
loop.enterLoopMSecs(timeoutMS); loop.enterLoopMSecs(timeoutMS);
QVERIFY(!loop.timeout()); QVERIFY(!loop.timeout());
QVERIFY(server.socket); QVERIFY(server.socket);
QCOMPARE(server.socket->error(), QAbstractSocket::SslInvalidUserDataError); QCOMPARE(server.socket->socketError(), QAbstractSocket::SslInvalidUserDataError);
} }
} }

View File

@ -428,7 +428,7 @@ void tst_NetworkSelfTest::serverReachability()
QVERIFY2(timer.elapsed() < 9900, "Connection to closed port timed out instead of refusing, something is wrong"); QVERIFY2(timer.elapsed() < 9900, "Connection to closed port timed out instead of refusing, something is wrong");
QVERIFY2(socket.state() == QAbstractSocket::UnconnectedState, "Socket connected unexpectedly!"); QVERIFY2(socket.state() == QAbstractSocket::UnconnectedState, "Socket connected unexpectedly!");
QVERIFY2(socket.error() == QAbstractSocket::ConnectionRefusedError, QVERIFY2(socket.socketError() == QAbstractSocket::ConnectionRefusedError,
QString("Could not reach server: %1").arg(socket.errorString()).toLocal8Bit()); QString("Could not reach server: %1").arg(socket.errorString()).toLocal8Bit());
} }
@ -458,7 +458,7 @@ void tst_NetworkSelfTest::remotePortsOpen()
socket.connectToHost(QtNetworkSettings::serverName(), portNumber); socket.connectToHost(QtNetworkSettings::serverName(), portNumber);
if (!socket.waitForConnected(10000)) { if (!socket.waitForConnected(10000)) {
if (socket.error() == QAbstractSocket::SocketTimeoutError) if (socket.socketError() == QAbstractSocket::SocketTimeoutError)
QFAIL(QString("Network timeout connecting to the server on port %1").arg(portNumber).toLocal8Bit()); QFAIL(QString("Network timeout connecting to the server on port %1").arg(portNumber).toLocal8Bit());
else else
QFAIL(QString("Error connecting to server on port %1: %2").arg(portNumber).arg(socket.errorString()).toLocal8Bit()); QFAIL(QString("Error connecting to server on port %1: %2").arg(portNumber).arg(socket.errorString()).toLocal8Bit());

View File

@ -545,7 +545,7 @@ bool BaselineProtocol::receiveBlock(Command *cmd, QByteArray *block)
QString BaselineProtocol::errorMessage() QString BaselineProtocol::errorMessage()
{ {
QString ret = errMsg; QString ret = errMsg;
if (socket.error() >= 0) if (socket.socketError() >= 0)
ret += QLS(" Socket state: ") + socket.errorString(); ret += QLS(" Socket state: ") + socket.errorString();
return ret; return ret;
} }