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

Conflicts:
	src/corelib/tools/qstring.cpp

Change-Id: I81dbf90fc936c9bf08197baefa071117bddb1c63
This commit is contained in:
Liang Qi 2019-05-13 08:04:58 +02:00
commit 388fe97f2a
108 changed files with 4750 additions and 4047 deletions

View File

@ -0,0 +1,52 @@
/****************************************************************************
**
** Copyright (C) 2019 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the documentation of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:FDL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU Free Documentation License Usage
** Alternatively, this file may be used under the terms of the GNU Free
** Documentation License version 1.3 as published by the Free Software
** Foundation and appearing in the file included in the packaging of
** this file. Please review the following information to ensure
** the GNU Free Documentation License version 1.3 requirements
** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
** $QT_END_LICENSE$
**
****************************************************************************/
//! [using qt module]
\section1 Using the Module
Using a Qt module requires linking against the module library, either
directly or through other dependencies. Several build tools have dedicated
support for this, including \l{CMake Documentation}{CMake} and
\l{qmake}.
\section2 Building with CMake
Use the \c{find_package()} command to locate the needed module components in
the \c{Qt5} package:
//! [using qt module]
//! [building with qmake]
\section2 Building with qmake
To configure the module for building with qmake, add the module as a value
of the \c QT variable in the project's .pro file:
//! [building with qmake]

View File

@ -18,6 +18,8 @@ HTML.extraimages += template/images/ico_out.png \
template/images/bullet_sq.png \ template/images/bullet_sq.png \
template/images/bgrContent.png template/images/bgrContent.png
sourcedirs += includes
#specify which files in the output directory should be packed into the qch file. #specify which files in the output directory should be packed into the qch file.
qhp.extraFiles += style/offline.css \ qhp.extraFiles += style/offline.css \
images/ico_out.png \ images/ico_out.png \

View File

@ -9,4 +9,5 @@ defines += onlinedocs
#uncomment if navigation bar is not wanted #uncomment if navigation bar is not wanted
#HTML.nonavigationbar = "true" #HTML.nonavigationbar = "true"
sourcedirs += includes-online sourcedirs += includes-online \
includes

View File

@ -69,6 +69,7 @@ QMAKE_LIBDIR_OPENGL =
QMAKE_LINK_SHLIB = $$QMAKE_LINK QMAKE_LINK_SHLIB = $$QMAKE_LINK
QMAKE_LFLAGS = --sysroot=$$ANDROID_PLATFORM_ROOT_PATH QMAKE_LFLAGS = --sysroot=$$ANDROID_PLATFORM_ROOT_PATH
equals(ANDROID_TARGET_ARCH, x86_64) QMAKE_LFLAGS += -L$$ANDROID_PLATFORM_ROOT_PATH/usr/lib64
QMAKE_LFLAGS_APP = -Wl,--no-undefined -Wl,-z,noexecstack -shared QMAKE_LFLAGS_APP = -Wl,--no-undefined -Wl,-z,noexecstack -shared
QMAKE_LFLAGS_SHLIB = -Wl,--no-undefined -Wl,-z,noexecstack -shared QMAKE_LFLAGS_SHLIB = -Wl,--no-undefined -Wl,-z,noexecstack -shared
QMAKE_LFLAGS_PLUGIN = $$QMAKE_LFLAGS_SHLIB QMAKE_LFLAGS_PLUGIN = $$QMAKE_LFLAGS_SHLIB

View File

@ -974,6 +974,9 @@
the compiler does not support C++17, or can't select the C++ standard. the compiler does not support C++17, or can't select the C++ standard.
By default, support is disabled. By default, support is disabled.
\row \li c++17 \li Same as c++1z. \row \li c++17 \li Same as c++1z.
\row \li c++2a \li C++2a support is enabled. This option has no effect if
the compiler does not support C++2a, or can't select the C++ standard.
By default, support is disabled.
\row \li strict_c++ \li Disables support for C++ compiler extensions. \row \li strict_c++ \li Disables support for C++ compiler extensions.
By default, they are enabled. By default, they are enabled.
\row \li depend_includepath \li Appending the value of INCLUDEPATH to \row \li depend_includepath \li Appending the value of INCLUDEPATH to
@ -1160,6 +1163,10 @@
\snippet code/doc_src_qmake-manual.pro 30 \snippet code/doc_src_qmake-manual.pro 30
\note The list of supported characters can depend on
the used build tool. In particular, parentheses do not
work with \c{make}.
\target DISTFILES \target DISTFILES
\section1 DISTFILES \section1 DISTFILES

View File

@ -837,7 +837,9 @@ bool QMakeSourceFileInfo::findDeps(SourceFile *file)
if(inc) { if(inc) {
if(!includes) if(!includes)
includes = new SourceFiles; includes = new SourceFiles;
SourceFile *dep = includes->lookupFile(inc); /* QTBUG-72383: Local includes "foo.h" must first be resolved relative to the
* sourceDir, only global includes <bar.h> are unique. */
SourceFile *dep = try_local ? nullptr : includes->lookupFile(inc);
if(!dep) { if(!dep) {
bool exists = false; bool exists = false;
QMakeLocalFileName lfn(inc); QMakeLocalFileName lfn(inc);
@ -876,7 +878,11 @@ bool QMakeSourceFileInfo::findDeps(SourceFile *file)
dep->file = lfn; dep->file = lfn;
dep->type = QMakeSourceFileInfo::TYPE_C; dep->type = QMakeSourceFileInfo::TYPE_C;
files->addFile(dep); files->addFile(dep);
includes->addFile(dep, inc, false); /* QTBUG-72383: Local includes "foo.h" are keyed by the resolved
* path (stored in dep itself), only global includes <bar.h> are
* unique keys immediately. */
const char *key = try_local ? nullptr : inc;
includes->addFile(dep, key, false);
} }
dep->exists = exists; dep->exists = exists;
} }

BIN
src/3rdparty/wasm/DejaVuSansMono.ttf vendored Normal file

Binary file not shown.

View File

@ -20,7 +20,7 @@
"Name": "DejaVu Fonts", "Name": "DejaVu Fonts",
"QDocModule": "qtgui", "QDocModule": "qtgui",
"QtUsage": "Used for WebAssembly platform.", "QtUsage": "Used for WebAssembly platform.",
"Files": "DejaVuSans.ttf", "Files": "DejaVuSans.ttf, DejaVuSansMono.ttf",
"Description": "The DejaVu fonts are a font family based on the Vera Fonts.", "Description": "The DejaVu fonts are a font family based on the Vera Fonts.",
"Homepage": "https://dejavu-fonts.github.io/", "Homepage": "https://dejavu-fonts.github.io/",

View File

@ -399,7 +399,7 @@ static QBasicMutex registeredInterpolatorsMutex;
Registers a custom interpolator \a func for the template type \c{T}. Registers a custom interpolator \a func for the template type \c{T}.
The interpolator has to be registered before the animation is constructed. The interpolator has to be registered before the animation is constructed.
To unregister (and use the default interpolator) set \a func to 0. To unregister (and use the default interpolator) set \a func to \nullptr.
*/ */
/*! /*!
@ -416,7 +416,7 @@ static QBasicMutex registeredInterpolatorsMutex;
* \internal * \internal
* Registers a custom interpolator \a func for the specific \a interpolationType. * Registers a custom interpolator \a func for the specific \a interpolationType.
* The interpolator has to be registered before the animation is constructed. * The interpolator has to be registered before the animation is constructed.
* To unregister (and use the default interpolator) set \a func to 0. * To unregister (and use the default interpolator) set \a func to \nullptr.
*/ */
void QVariantAnimation::registerInterpolator(QVariantAnimation::Interpolator func, int interpolationType) void QVariantAnimation::registerInterpolator(QVariantAnimation::Interpolator func, int interpolationType)
{ {

View File

@ -678,7 +678,7 @@ QList<int> QTextCodec::availableMibs()
\nonreentrant \nonreentrant
Set the codec to \a c; this will be returned by Set the codec to \a c; this will be returned by
codecForLocale(). If \a c is a null pointer, the codec is reset to codecForLocale(). If \a c is \nullptr, the codec is reset to
the default. the default.
This might be needed for some applications that want to use their This might be needed for some applications that want to use their

View File

@ -1,53 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the documentation of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** BSD License Usage
** Alternatively, you may use this file under the terms of the BSD license
** as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
** met:
** * Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** * Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
** * Neither the name of The Qt Company Ltd nor the names of its
** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
**
** $QT_END_LICENSE$
**
****************************************************************************/
//! [0]
#include <QtCore>
//! [0]

View File

@ -0,0 +1,2 @@
find_package(Qt5 COMPONENTS Core REQUIRED)
target_link_libraries(mytarget Qt5::Core)

View File

@ -1,6 +1,6 @@
/**************************************************************************** /****************************************************************************
** **
** Copyright (C) 2016 The Qt Company Ltd. ** Copyright (C) 2019 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/ ** Contact: https://www.qt.io/licensing/
** **
** This file is part of the documentation of the Qt Toolkit. ** This file is part of the documentation of the Qt Toolkit.
@ -31,17 +31,9 @@
\brief The Qt Core module is part of Qt's essential modules. \brief The Qt Core module is part of Qt's essential modules.
\section1 Getting Started
All other Qt modules rely on this module. To include the
definitions of the module's classes, use the following directive:
\snippet code/doc_src_qtcore.cpp 0
If you use \l qmake to build your projects, Qt Core is included by default.
\section1 Core Functionalities \section1 Core Functionalities
Qt adds these features to C++: Qt Core adds these features to C++:
\list \list
\li a very powerful mechanism for seamless object communication called \li a very powerful mechanism for seamless object communication called
@ -61,6 +53,15 @@
\li \l{Signals & Slots} \li \l{Signals & Slots}
\endlist \endlist
\include module-use.qdocinc using qt module
\quotefile overview/using-qt-core.cmake
See also the \l[QtDoc]{Building with CMake} overview.
\section2 Building with qmake
If you use \l qmake to build your projects, Qt5Core is linked by default.
\section1 Threading and Concurrent Programming \section1 Threading and Concurrent Programming
Qt provides thread support in the form of platform-independent \l{Threading Qt provides thread support in the form of platform-independent \l{Threading

View File

@ -33,12 +33,5 @@
\brief Provides core non-GUI functionality. \brief Provides core non-GUI functionality.
All other Qt modules rely on this module. To include the All other Qt modules rely on this module.
definitions of the module's classes, use the following directive:
\snippet code/doc_src_qtcore.cpp 0
If you use \l qmake to build your projects, \l{Qt Core} is included by
default.
*/ */

View File

@ -1425,6 +1425,13 @@ bool qSharedBuild() noexcept
\l Q_OS_WIN32, \l Q_OS_WIN64, or \l Q_OS_WINRT is defined. \l Q_OS_WIN32, \l Q_OS_WIN64, or \l Q_OS_WINRT is defined.
*/ */
/*!
\macro Q_OS_WINDOWS
\relates <QtGlobal>
This is a synonym for Q_OS_WIN.
*/
/*! /*!
\macro Q_OS_WIN32 \macro Q_OS_WIN32
\relates <QtGlobal> \relates <QtGlobal>

View File

@ -176,6 +176,7 @@
#endif #endif
#if defined(Q_OS_WIN32) || defined(Q_OS_WIN64) || defined(Q_OS_WINRT) #if defined(Q_OS_WIN32) || defined(Q_OS_WIN64) || defined(Q_OS_WINRT)
# define Q_OS_WINDOWS
# define Q_OS_WIN # define Q_OS_WIN
#endif #endif

View File

@ -2919,7 +2919,7 @@ void QSettings::setIniCodec(const char *codecName)
\since 4.5 \since 4.5
Returns the codec that is used for accessing INI files. By default, Returns the codec that is used for accessing INI files. By default,
no codec is used, so a null pointer is returned. no codec is used, so \nullptr is returned.
*/ */
QTextCodec *QSettings::iniCodec() const QTextCodec *QSettings::iniCodec() const

View File

@ -690,7 +690,7 @@ void QCoreApplicationPrivate::initLocale()
Returns a pointer to the application's QCoreApplication (or Returns a pointer to the application's QCoreApplication (or
QGuiApplication/QApplication) instance. QGuiApplication/QApplication) instance.
If no instance has been allocated, \c null is returned. If no instance has been allocated, \nullptr is returned.
*/ */
/*! /*!

View File

@ -48,6 +48,7 @@
#include "qmutex.h" #include "qmutex.h"
#include <private/qthread_p.h> #include <private/qthread_p.h>
#endif #endif
#include "qtextstream.h"
#include <ctype.h> #include <ctype.h>
#include <qt_windows.h> #include <qt_windows.h>
@ -480,6 +481,7 @@ static const char *findWMstr(uint msg)
{ 0x02DD, "WM_TABLET_FIRST + 29" }, { 0x02DD, "WM_TABLET_FIRST + 29" },
{ 0x02DE, "WM_TABLET_FIRST + 30" }, { 0x02DE, "WM_TABLET_FIRST + 30" },
{ 0x02DF, "WM_TABLET_LAST" }, { 0x02DF, "WM_TABLET_LAST" },
{ 0x02E0, "WM_DPICHANGED" },
{ 0x0300, "WM_CUT" }, { 0x0300, "WM_CUT" },
{ 0x0301, "WM_COPY" }, { 0x0301, "WM_COPY" },
{ 0x0302, "WM_PASTE" }, { 0x0302, "WM_PASTE" },
@ -765,6 +767,13 @@ QString decodeMSG(const MSG& msg)
case WM_DESTROY: case WM_DESTROY:
parameters = QLatin1String("Destroy hwnd ") + hwndS; parameters = QLatin1String("Destroy hwnd ") + hwndS;
break; break;
case 0x02E0u: { // WM_DPICHANGED
auto rect = reinterpret_cast<const RECT *>(lParam);
QTextStream(&parameters) << "DPI: " << HIWORD(wParam) << ','
<< LOWORD(wParam) << ' ' << (rect->right - rect->left) << 'x'
<< (rect->bottom - rect->top) << forcesign << rect->left << rect->top;
}
break;
case WM_IME_NOTIFY: case WM_IME_NOTIFY:
{ {
parameters = QLatin1String("Command("); parameters = QLatin1String("Command(");

View File

@ -39,18 +39,294 @@
#include "qdeadlinetimer.h" #include "qdeadlinetimer.h"
#include "qdeadlinetimer_p.h" #include "qdeadlinetimer_p.h"
#include "private/qnumeric_p.h"
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
Q_DECL_CONST_FUNCTION static inline QPair<qint64, qint64> toSecsAndNSecs(qint64 nsecs) namespace {
{ class TimeReference
qint64 secs = nsecs / (1000*1000*1000); {
if (nsecs < 0) enum : unsigned {
--secs; umega = 1000 * 1000,
nsecs -= secs * 1000*1000*1000; ugiga = umega * 1000
return qMakePair(secs, nsecs); };
enum : qint64 {
kilo = 1000,
mega = kilo * 1000,
giga = mega * 1000
};
public:
enum RoundingStrategy {
RoundDown,
RoundUp,
RoundDefault = RoundDown
};
static constexpr qint64 Min = std::numeric_limits<qint64>::min();
static constexpr qint64 Max = std::numeric_limits<qint64>::max();
inline TimeReference(qint64 = 0, unsigned = 0);
inline void updateTimer(qint64 &, unsigned &);
inline bool addNanoseconds(qint64);
inline bool addMilliseconds(qint64);
bool addSecsAndNSecs(qint64, qint64);
inline bool subtract(const qint64, const unsigned);
inline bool toMilliseconds(qint64 *, RoundingStrategy = RoundDefault) const;
inline bool toNanoseconds(qint64 *) const;
inline void saturate(bool toMax);
static bool sign(qint64, qint64);
private:
bool adjust(const qint64, const unsigned, qint64 = 0);
private:
qint64 secs;
unsigned nsecs;
};
} }
inline TimeReference::TimeReference(qint64 t1, unsigned t2)
: secs(t1), nsecs(t2)
{
}
inline void TimeReference::updateTimer(qint64 &t1, unsigned &t2)
{
t1 = secs;
t2 = nsecs;
}
inline void TimeReference::saturate(bool toMax)
{
secs = toMax ? Max : Min;
}
/*!
* \internal
*
* Determines the sign of a (seconds, nanoseconds) pair
* for differentiating overflow from underflow. It doesn't
* deal with equality as it shouldn't ever be called in that case.
*
* Returns true if the pair represents a positive time offset
* false otherwise.
*/
bool TimeReference::sign(qint64 secs, qint64 nsecs)
{
if (secs > 0) {
if (nsecs > 0)
return true;
} else {
if (nsecs < 0)
return false;
}
// They are different in sign
secs += nsecs / giga;
if (secs > 0)
return true;
else if (secs < 0)
return false;
// We should never get over|underflow out of
// the case: secs * giga == -nsecs
// So the sign of nsecs is the deciding factor
Q_ASSERT(nsecs % giga != 0);
return nsecs > 0;
}
#if defined(Q_OS_UNIX) && !defined(Q_OS_DARWIN)
inline bool TimeReference::addNanoseconds(qint64 arg)
{
return addSecsAndNSecs(arg / giga, arg % giga);
}
inline bool TimeReference::addMilliseconds(qint64 arg)
{
return addSecsAndNSecs(arg / kilo, (arg % kilo) * mega);
}
/*!
* \internal
*
* Adds \a t1 addSecs seconds and \a addNSecs nanoseconds to the
* time reference. The arguments are normalized to seconds (qint64)
* and nanoseconds (unsigned) before the actual calculation is
* delegated to adjust(). If the nanoseconds are negative the
* owed second used for the normalization is passed on to adjust()
* as third argument.
*
* Returns true if operation was successful, false on over|underflow
*/
bool TimeReference::addSecsAndNSecs(qint64 addSecs, qint64 addNSecs)
{
// Normalize the arguments
if (qAbs(addNSecs) >= giga) {
if (add_overflow<qint64>(addSecs, addNSecs / giga, &addSecs))
return false;
addNSecs %= giga;
}
if (addNSecs < 0)
return adjust(addSecs, ugiga - unsigned(-addNSecs), -1);
return adjust(addSecs, unsigned(addNSecs));
}
/*!
* \internal
*
* Adds \a t1 seconds and \a t2 nanoseconds to the internal members.
* Takes into account the additional \a carrySeconds we may owe or need to carry over.
*
* Returns true if operation was successful, false on over|underflow
*/
bool TimeReference::adjust(const qint64 t1, const unsigned t2, qint64 carrySeconds)
{
Q_STATIC_ASSERT(QDeadlineTimerNanosecondsInT2);
nsecs += t2;
if (nsecs >= ugiga) {
nsecs -= ugiga;
carrySeconds++;
}
// We don't worry about the order of addition, because the result returned by
// callers of this function is unchanged regardless of us over|underflowing.
// If we do, we do so by no more than a second, thus saturating the timer to
// Forever has the same effect as if we did the arithmetic exactly and salvaged
// the overflow.
return !add_overflow<qint64>(secs, t1, &secs) && !add_overflow<qint64>(secs, carrySeconds, &secs);
}
/*!
* \internal
*
* Subtracts \a t1 seconds and \a t2 nanoseconds from the time reference.
* When normalizing the nanoseconds to a positive number the owed seconds is
* passed as third argument to adjust() as the seconds may over|underflow
* if we do the calculation directly. There is little sense to check the
* seconds for over|underflow here in case we are going to need to carry
* over a second _after_ we add the nanoseconds.
*
* Returns true if operation was successful, false on over|underflow
*/
inline bool TimeReference::subtract(const qint64 t1, const unsigned t2)
{
Q_ASSERT(t2 < ugiga);
return adjust(-t1, ugiga - t2, -1);
}
/*!
* \internal
*
* Converts the time reference to milliseconds.
*
* Checks are done without making use of mul_overflow because it may
* not be implemented on some 32bit platforms.
*
* Returns true if operation was successful, false on over|underflow
*/
inline bool TimeReference::toMilliseconds(qint64 *result, RoundingStrategy rounding) const
{
static constexpr qint64 maxSeconds = Max / kilo;
static constexpr qint64 minSeconds = Min / kilo;
if (secs > maxSeconds || secs < minSeconds)
return false;
unsigned ns = rounding == RoundDown ? nsecs : nsecs + umega - 1;
return !add_overflow<qint64>(secs * kilo, ns / umega, result);
}
/*!
* \internal
*
* Converts the time reference to nanoseconds.
*
* Checks are done without making use of mul_overflow because it may
* not be implemented on some 32bit platforms.
*
* Returns true if operation was successful, false on over|underflow
*/
inline bool TimeReference::toNanoseconds(qint64 *result) const
{
static constexpr qint64 maxSeconds = Max / giga;
static constexpr qint64 minSeconds = Min / giga;
if (secs > maxSeconds || secs < minSeconds)
return false;
return !add_overflow<qint64>(secs * giga, nsecs, result);
}
#else
inline bool TimeReference::addNanoseconds(qint64 arg)
{
return adjust(arg, 0);
}
inline bool TimeReference::addMilliseconds(qint64 arg)
{
static constexpr qint64 maxMilliseconds = Max / mega;
if (qAbs(arg) > maxMilliseconds)
return false;
return addNanoseconds(arg * mega);
}
inline bool TimeReference::addSecsAndNSecs(qint64 addSecs, qint64 addNSecs)
{
static constexpr qint64 maxSeconds = Max / giga;
static constexpr qint64 minSeconds = Min / giga;
if (addSecs > maxSeconds || addSecs < minSeconds || add_overflow<qint64>(addSecs * giga, addNSecs, &addNSecs))
return false;
return addNanoseconds(addNSecs);
}
inline bool TimeReference::adjust(const qint64 t1, const unsigned t2, qint64 carrySeconds)
{
Q_STATIC_ASSERT(!QDeadlineTimerNanosecondsInT2);
Q_UNUSED(t2);
Q_UNUSED(carrySeconds);
return !add_overflow<qint64>(secs, t1, &secs);
}
inline bool TimeReference::subtract(const qint64 t1, const unsigned t2)
{
Q_UNUSED(t2);
return addNanoseconds(-t1);
}
inline bool TimeReference::toMilliseconds(qint64 *result, RoundingStrategy rounding) const
{
// Force QDeadlineTimer to treat the border cases as
// over|underflow and saturate the results returned to the user.
// We don't want to get valid milliseconds out of saturated timers.
if (secs == Max || secs == Min)
return false;
*result = secs / mega;
if (rounding == RoundUp && secs > *result * mega)
(*result)++;
return true;
}
inline bool TimeReference::toNanoseconds(qint64 *result) const
{
*result = secs;
return true;
}
#endif
/*! /*!
\class QDeadlineTimer \class QDeadlineTimer
\inmodule QtCore \inmodule QtCore
@ -262,10 +538,17 @@ QDeadlineTimer::QDeadlineTimer(qint64 msecs, Qt::TimerType type) noexcept
*/ */
void QDeadlineTimer::setRemainingTime(qint64 msecs, Qt::TimerType timerType) noexcept void QDeadlineTimer::setRemainingTime(qint64 msecs, Qt::TimerType timerType) noexcept
{ {
if (msecs == -1) if (msecs == -1) {
*this = QDeadlineTimer(Forever, timerType); *this = QDeadlineTimer(Forever, timerType);
else return;
setPreciseRemainingTime(0, msecs * 1000 * 1000, timerType); }
*this = current(timerType);
TimeReference ref(t1, t2);
if (!ref.addMilliseconds(msecs))
ref.saturate(msecs > 0);
ref.updateTimer(t1, t2);
} }
/*! /*!
@ -287,16 +570,10 @@ void QDeadlineTimer::setPreciseRemainingTime(qint64 secs, qint64 nsecs, Qt::Time
} }
*this = current(timerType); *this = current(timerType);
if (QDeadlineTimerNanosecondsInT2) { TimeReference ref(t1, t2);
t1 += secs + toSecsAndNSecs(nsecs).first; if (!ref.addSecsAndNSecs(secs, nsecs))
t2 += toSecsAndNSecs(nsecs).second; ref.saturate(TimeReference::sign(secs, nsecs));
if (t2 > 1000*1000*1000) { ref.updateTimer(t1, t2);
t2 -= 1000*1000*1000;
++t1;
}
} else {
t1 += secs * 1000 * 1000 * 1000 + nsecs;
}
} }
/*! /*!
@ -391,8 +668,22 @@ void QDeadlineTimer::setTimerType(Qt::TimerType timerType)
*/ */
qint64 QDeadlineTimer::remainingTime() const noexcept qint64 QDeadlineTimer::remainingTime() const noexcept
{ {
qint64 ns = remainingTimeNSecs(); if (isForever())
return ns <= 0 ? ns : (ns + 999999) / (1000 * 1000); return -1;
QDeadlineTimer now = current(timerType());
TimeReference ref(t1, t2);
qint64 msecs;
if (!ref.subtract(now.t1, now.t2))
return 0; // We can only underflow here
// If we fail the conversion, t1 < now.t1 means we underflowed,
// thus the deadline had long expired
if (!ref.toMilliseconds(&msecs, TimeReference::RoundUp))
return t1 < now.t1 ? 0 : -1;
return msecs < 0 ? 0 : msecs;
} }
/*! /*!
@ -414,14 +705,23 @@ qint64 QDeadlineTimer::remainingTimeNSecs() const noexcept
/*! /*!
\internal \internal
Same as remainingTimeNSecs, but may return negative remaining times. Does Same as remainingTimeNSecs, but may return negative remaining times. Does
not deal with Forever. not deal with Forever. In case of underflow the result is saturated to
the minimum possible value, on overflow - the maximum possible value.
*/ */
qint64 QDeadlineTimer::rawRemainingTimeNSecs() const noexcept qint64 QDeadlineTimer::rawRemainingTimeNSecs() const noexcept
{ {
QDeadlineTimer now = current(timerType()); QDeadlineTimer now = current(timerType());
if (QDeadlineTimerNanosecondsInT2) TimeReference ref(t1, t2);
return (t1 - now.t1) * (1000*1000*1000) + t2 - now.t2;
return t1 - now.t1; qint64 nsecs;
if (!ref.subtract(now.t1, now.t2))
return TimeReference::Min; // We can only underflow here
// If we fail the conversion, t1 < now.t1 means we underflowed,
// thus the deadline had long expired
if (!ref.toNanoseconds(&nsecs))
return t1 < now.t1 ? TimeReference::Min : TimeReference::Max;
return nsecs;
} }
/*! /*!
@ -447,8 +747,13 @@ qint64 QDeadlineTimer::rawRemainingTimeNSecs() const noexcept
qint64 QDeadlineTimer::deadline() const noexcept qint64 QDeadlineTimer::deadline() const noexcept
{ {
if (isForever()) if (isForever())
return t1; return TimeReference::Max;
return deadlineNSecs() / (1000 * 1000);
qint64 result;
if (!TimeReference(t1, t2).toMilliseconds(&result))
return t1 < 0 ? TimeReference::Min : TimeReference::Max;
return result;
} }
/*! /*!
@ -457,7 +762,8 @@ qint64 QDeadlineTimer::deadline() const noexcept
same as QElapsedTimer::msecsSinceReference(). The value will be in the past same as QElapsedTimer::msecsSinceReference(). The value will be in the past
if this QDeadlineTimer has expired. if this QDeadlineTimer has expired.
If this QDeadlineTimer never expires, this function returns If this QDeadlineTimer never expires or the number of nanoseconds until the
deadline can't be accommodated in the return type, this function returns
\c{std::numeric_limits<qint64>::max()}. \c{std::numeric_limits<qint64>::max()}.
This function can be used to calculate the amount of time a timer is This function can be used to calculate the amount of time a timer is
@ -474,10 +780,13 @@ qint64 QDeadlineTimer::deadline() const noexcept
qint64 QDeadlineTimer::deadlineNSecs() const noexcept qint64 QDeadlineTimer::deadlineNSecs() const noexcept
{ {
if (isForever()) if (isForever())
return t1; return TimeReference::Max;
if (QDeadlineTimerNanosecondsInT2)
return t1 * 1000 * 1000 * 1000 + t2; qint64 result;
return t1; if (!TimeReference(t1, t2).toNanoseconds(&result))
return t1 < 0 ? TimeReference::Min : TimeReference::Max;
return result;
} }
/*! /*!
@ -487,18 +796,25 @@ qint64 QDeadlineTimer::deadlineNSecs() const noexcept
timerType. If the value is in the past, this QDeadlineTimer will be marked timerType. If the value is in the past, this QDeadlineTimer will be marked
as expired. as expired.
If \a msecs is \c{std::numeric_limits<qint64>::max()}, this QDeadlineTimer If \a msecs is \c{std::numeric_limits<qint64>::max()} or the deadline is
will be set to never expire. beyond a representable point in the future, this QDeadlineTimer will be set
to never expire.
\sa setPreciseDeadline(), deadline(), deadlineNSecs(), setRemainingTime() \sa setPreciseDeadline(), deadline(), deadlineNSecs(), setRemainingTime()
*/ */
void QDeadlineTimer::setDeadline(qint64 msecs, Qt::TimerType timerType) noexcept void QDeadlineTimer::setDeadline(qint64 msecs, Qt::TimerType timerType) noexcept
{ {
if (msecs == (std::numeric_limits<qint64>::max)()) { if (msecs == TimeReference::Max) {
setPreciseDeadline(msecs, 0, timerType); // msecs == MAX implies Forever *this = QDeadlineTimer(Forever, timerType);
} else { return;
setPreciseDeadline(msecs / 1000, msecs % 1000 * 1000 * 1000, timerType);
} }
type = timerType;
TimeReference ref;
if (!ref.addMilliseconds(msecs))
ref.saturate(msecs > 0);
ref.updateTimer(t1, t2);
} }
/*! /*!
@ -516,14 +832,13 @@ void QDeadlineTimer::setDeadline(qint64 msecs, Qt::TimerType timerType) noexcept
void QDeadlineTimer::setPreciseDeadline(qint64 secs, qint64 nsecs, Qt::TimerType timerType) noexcept void QDeadlineTimer::setPreciseDeadline(qint64 secs, qint64 nsecs, Qt::TimerType timerType) noexcept
{ {
type = timerType; type = timerType;
if (secs == (std::numeric_limits<qint64>::max)() || nsecs == (std::numeric_limits<qint64>::max)()) {
*this = QDeadlineTimer(Forever, timerType); // We don't pass the seconds to the constructor, because we don't know
} else if (QDeadlineTimerNanosecondsInT2) { // at this point if t1 holds the seconds or nanoseconds; it's platform specific.
t1 = secs + toSecsAndNSecs(nsecs).first; TimeReference ref;
t2 = toSecsAndNSecs(nsecs).second; if (!ref.addSecsAndNSecs(secs, nsecs))
} else { ref.saturate(TimeReference::sign(secs, nsecs));
t1 = secs * (1000*1000*1000) + nsecs; ref.updateTimer(t1, t2);
}
} }
/*! /*!
@ -536,18 +851,14 @@ void QDeadlineTimer::setPreciseDeadline(qint64 secs, qint64 nsecs, Qt::TimerType
*/ */
QDeadlineTimer QDeadlineTimer::addNSecs(QDeadlineTimer dt, qint64 nsecs) noexcept QDeadlineTimer QDeadlineTimer::addNSecs(QDeadlineTimer dt, qint64 nsecs) noexcept
{ {
if (dt.isForever() || nsecs == (std::numeric_limits<qint64>::max)()) { if (dt.isForever())
dt = QDeadlineTimer(Forever, dt.timerType()); return dt;
} else if (QDeadlineTimerNanosecondsInT2) {
dt.t1 += toSecsAndNSecs(nsecs).first; TimeReference ref(dt.t1, dt.t2);
dt.t2 += toSecsAndNSecs(nsecs).second; if (!ref.addNanoseconds(nsecs))
if (dt.t2 > 1000*1000*1000) { ref.saturate(nsecs > 0);
dt.t2 -= 1000*1000*1000; ref.updateTimer(dt.t1, dt.t2);
++dt.t1;
}
} else {
dt.t1 += nsecs;
}
return dt; return dt;
} }
@ -656,6 +967,19 @@ QDeadlineTimer QDeadlineTimer::addNSecs(QDeadlineTimer dt, qint64 nsecs) noexcep
To add times of precision greater than 1 millisecond, use addNSecs(). To add times of precision greater than 1 millisecond, use addNSecs().
*/ */
QDeadlineTimer operator+(QDeadlineTimer dt, qint64 msecs)
{
if (dt.isForever())
return dt;
TimeReference ref(dt.t1, dt.t2);
if (!ref.addMilliseconds(msecs))
ref.saturate(msecs > 0);
ref.updateTimer(dt.t1, dt.t2);
return dt;
}
/*! /*!
\fn QDeadlineTimer operator+(qint64 msecs, QDeadlineTimer dt) \fn QDeadlineTimer operator+(qint64 msecs, QDeadlineTimer dt)
\relates QDeadlineTimer \relates QDeadlineTimer

View File

@ -108,8 +108,7 @@ public:
friend bool operator>=(QDeadlineTimer d1, QDeadlineTimer d2) noexcept friend bool operator>=(QDeadlineTimer d1, QDeadlineTimer d2) noexcept
{ return !(d1 < d2); } { return !(d1 < d2); }
friend QDeadlineTimer operator+(QDeadlineTimer dt, qint64 msecs) friend Q_CORE_EXPORT QDeadlineTimer operator+(QDeadlineTimer dt, qint64 msecs);
{ return QDeadlineTimer::addNSecs(dt, msecs * 1000 * 1000); }
friend QDeadlineTimer operator+(qint64 msecs, QDeadlineTimer dt) friend QDeadlineTimer operator+(qint64 msecs, QDeadlineTimer dt)
{ return dt + msecs; } { return dt + msecs; }
friend QDeadlineTimer operator-(QDeadlineTimer dt, qint64 msecs) friend QDeadlineTimer operator-(QDeadlineTimer dt, qint64 msecs)

View File

@ -836,7 +836,7 @@ static bool check_parent_thread(QObject *parent,
The destructor of a parent object destroys all child objects. The destructor of a parent object destroys all child objects.
Setting \a parent to 0 constructs an object with no parent. If the Setting \a parent to \nullptr constructs an object with no parent. If the
object is a widget, it will become a top-level window. object is a widget, it will become a top-level window.
\sa parent(), findChild(), findChildren() \sa parent(), findChild(), findChildren()
@ -3405,7 +3405,7 @@ bool QMetaObject::disconnectOne(const QObject *sender, int signal_index,
/*! /*!
\internal \internal
Helper function to remove the connection from the senders list and setting the receivers to 0 Helper function to remove the connection from the senders list and set the receivers to \nullptr
*/ */
bool QMetaObjectPrivate::disconnectHelper(QObjectPrivate::ConnectionData *connections, int signalIndex, bool QMetaObjectPrivate::disconnectHelper(QObjectPrivate::ConnectionData *connections, int signalIndex,
const QObject *receiver, int method_index, void **slot, const QObject *receiver, int method_index, void **slot,

View File

@ -45,7 +45,7 @@
\ingroup objectmodel \ingroup objectmodel
A guarded pointer, QPointer<T>, behaves like a normal C++ A guarded pointer, QPointer<T>, behaves like a normal C++
pointer \c{T *}, except that it is automatically set to 0 when the pointer \c{T *}, except that it is automatically cleared when the
referenced object is destroyed (unlike normal C++ pointers, which referenced object is destroyed (unlike normal C++ pointers, which
become "dangling pointers" in such cases). \c T must be a become "dangling pointers" in such cases). \c T must be a
subclass of QObject. subclass of QObject.
@ -79,7 +79,7 @@
\snippet pointer/pointer.cpp 2 \snippet pointer/pointer.cpp 2
If the QLabel is deleted in the meantime, the \c label variable If the QLabel is deleted in the meantime, the \c label variable
will hold 0 instead of an invalid address, and the last line will will hold \nullptr instead of an invalid address, and the last line will
never be executed. never be executed.
The functions and operators available with a QPointer are the The functions and operators available with a QPointer are the
@ -93,7 +93,7 @@
For creating guarded pointers, you can construct or assign to them For creating guarded pointers, you can construct or assign to them
from a T* or from another guarded pointer of the same type. You from a T* or from another guarded pointer of the same type. You
can compare them with each other using operator==() and can compare them with each other using operator==() and
operator!=(), or test for 0 with isNull(). You can dereference operator!=(), or test for \nullptr with isNull(). You can dereference
them using either the \c *x or the \c x->member notation. them using either the \c *x or the \c x->member notation.
A guarded pointer will automatically cast to a \c T *, so you can A guarded pointer will automatically cast to a \c T *, so you can
@ -113,7 +113,7 @@
/*! /*!
\fn template <class T> QPointer<T>::QPointer() \fn template <class T> QPointer<T>::QPointer()
Constructs a 0 guarded pointer. Constructs a guarded pointer with value \nullptr.
\sa isNull() \sa isNull()
*/ */

View File

@ -2411,7 +2411,7 @@ void QVariant::clear()
Converts the int representation of the storage type, \a typeId, to Converts the int representation of the storage type, \a typeId, to
its string representation. its string representation.
Returns a null pointer if the type is QMetaType::UnknownType or doesn't exist. Returns \nullptr if the type is QMetaType::UnknownType or doesn't exist.
*/ */
const char *QVariant::typeToName(int typeId) const char *QVariant::typeToName(int typeId)
{ {
@ -4147,7 +4147,7 @@ void* QVariant::data()
/*! /*!
Returns \c true if this is a null variant, false otherwise. A variant is Returns \c true if this is a null variant, false otherwise. A variant is
considered null if it contains no initialized value, or the contained value considered null if it contains no initialized value, or the contained value
is a null pointer or is an instance of a built-in type that has an isNull is \nullptr or is an instance of a built-in type that has an isNull
method, in which case the result would be the same as calling isNull on the method, in which case the result would be the same as calling isNull on the
wrapped object. wrapped object.
@ -4227,7 +4227,7 @@ QDebug operator<<(QDebug dbg, const QVariant::Type p)
If the QVariant contains a pointer to a type derived from QObject then If the QVariant contains a pointer to a type derived from QObject then
\c{T} may be any QObject type. If the pointer stored in the QVariant can be \c{T} may be any QObject type. If the pointer stored in the QVariant can be
qobject_cast to T, then that result is returned. Otherwise a null pointer is qobject_cast to T, then that result is returned. Otherwise \nullptr is
returned. Note that this only works for QObject subclasses which use the returned. Note that this only works for QObject subclasses which use the
Q_OBJECT macro. Q_OBJECT macro.

View File

@ -1033,8 +1033,7 @@ QDataStream &QDataStream::operator>>(char *&s)
\c{delete []} operator. \c{delete []} operator.
The \a l parameter is set to the length of the buffer. If the The \a l parameter is set to the length of the buffer. If the
string read is empty, \a l is set to 0 and \a s is set to string read is empty, \a l is set to 0 and \a s is set to \nullptr.
a null pointer.
The serialization format is a quint32 length specifier first, The serialization format is a quint32 length specifier first,
then \a l bytes of data. then \a l bytes of data.

View File

@ -285,7 +285,7 @@ QAbstractState *QState::errorState() const
/*! /*!
Sets this state's error state to be the given \a state. If the error state Sets this state's error state to be the given \a state. If the error state
is not set, or if it is set to 0, the state will inherit its parent's error is not set, or if it is set to \nullptr, the state will inherit its parent's error
state recursively. If no error state is set for the state itself or any of state recursively. If no error state is set for the state itself or any of
its ancestors, an error will cause the machine to stop executing and an error its ancestors, an error will cause the machine to stop executing and an error
will be printed to the console. will be printed to the console.

View File

@ -1038,8 +1038,8 @@ QByteArray qUncompress(const uchar* data, int nbytes)
\snippet code/src_corelib_tools_qbytearray.cpp 5 \snippet code/src_corelib_tools_qbytearray.cpp 5
All functions except isNull() treat null byte arrays the same as All functions except isNull() treat null byte arrays the same as
empty byte arrays. For example, data() returns a pointer to a empty byte arrays. For example, data() returns a valid pointer
'\\0' character for a null byte array (\e not a null pointer), (\e not nullptr) to a '\\0' character for a byte array
and QByteArray() compares equal to QByteArray(""). We recommend and QByteArray() compares equal to QByteArray(""). We recommend
that you always use isEmpty() and avoid isNull(). that you always use isEmpty() and avoid isNull().

View File

@ -1337,7 +1337,7 @@ uint QLocale::toUInt(const QString &s, bool *ok) const
If the conversion fails the function returns 0. If the conversion fails the function returns 0.
If \a ok is not \c nullptr, failure is reported by setting *\a{ok} If \a ok is not \nullptr, failure is reported by setting *\a{ok}
to \c false, and success by setting *\a{ok} to \c true. to \c false, and success by setting *\a{ok} to \c true.
This function ignores leading and trailing whitespace. This function ignores leading and trailing whitespace.
@ -1359,7 +1359,7 @@ long QLocale::toLong(const QString &s, bool *ok) const
If the conversion fails the function returns 0. If the conversion fails the function returns 0.
If \a ok is not \c nullptr, failure is reported by setting *\a{ok} If \a ok is not \nullptr, failure is reported by setting *\a{ok}
to \c false, and success by setting *\a{ok} to \c true. to \c false, and success by setting *\a{ok} to \c true.
This function ignores leading and trailing whitespace. This function ignores leading and trailing whitespace.
@ -1546,7 +1546,7 @@ uint QLocale::toUInt(const QStringRef &s, bool *ok) const
If the conversion fails the function returns 0. If the conversion fails the function returns 0.
If \a ok is not \c nullptr, failure is reported by setting *\a{ok} If \a ok is not \nullptr, failure is reported by setting *\a{ok}
to \c false, and success by setting *\a{ok} to \c true. to \c false, and success by setting *\a{ok} to \c true.
This function ignores leading and trailing whitespace. This function ignores leading and trailing whitespace.
@ -1568,7 +1568,7 @@ long QLocale::toLong(const QStringRef &s, bool *ok) const
If the conversion fails the function returns 0. If the conversion fails the function returns 0.
If \a ok is not \c nullptr, failure is reported by setting *\a{ok} If \a ok is not \nullptr, failure is reported by setting *\a{ok}
to \c false, and success by setting *\a{ok} to \c true. to \c false, and success by setting *\a{ok} to \c true.
This function ignores leading and trailing whitespace. This function ignores leading and trailing whitespace.
@ -1764,7 +1764,7 @@ uint QLocale::toUInt(QStringView s, bool *ok) const
If the conversion fails the function returns 0. If the conversion fails the function returns 0.
If \a ok is not \c nullptr, failure is reported by setting *\a{ok} If \a ok is not \nullptr, failure is reported by setting *\a{ok}
to \c false, and success by setting *\a{ok} to \c true. to \c false, and success by setting *\a{ok} to \c true.
This function ignores leading and trailing whitespace. This function ignores leading and trailing whitespace.
@ -1786,7 +1786,7 @@ long QLocale::toLong(QStringView s, bool *ok) const
If the conversion fails the function returns 0. If the conversion fails the function returns 0.
If \a ok is not \c nullptr, failure is reported by setting *\a{ok} If \a ok is not \nullptr, failure is reported by setting *\a{ok}
to \c false, and success by setting *\a{ok} to \c true. to \c false, and success by setting *\a{ok} to \c true.
This function ignores leading and trailing whitespace. This function ignores leading and trailing whitespace.

View File

@ -92,7 +92,7 @@
\note For the current keyboard input locale take a look at \note For the current keyboard input locale take a look at
QInputMethod::locale(). QInputMethod::locale().
QLocale's data is based on Common Locale Data Repository v34. QLocale's data is based on Common Locale Data Repository v35.1.
\sa QString::arg(), QString::toInt(), QString::toDouble(), \sa QString::arg(), QString::toInt(), QString::toDouble(),
QInputMethod::locale() QInputMethod::locale()

File diff suppressed because it is too large Load Diff

View File

@ -157,7 +157,7 @@ QT_BEGIN_NAMESPACE
Provides access to the scoped pointer's object. Provides access to the scoped pointer's object.
If the contained pointer is \c null, behavior is undefined. If the contained pointer is \nullptr, behavior is undefined.
\sa isNull() \sa isNull()
*/ */
@ -166,7 +166,7 @@ QT_BEGIN_NAMESPACE
Provides access to the scoped pointer's object. Provides access to the scoped pointer's object.
If the contained pointer is \c null, behavior is undefined. If the contained pointer is \nullptr, behavior is undefined.
\sa isNull() \sa isNull()
*/ */
@ -174,8 +174,8 @@ QT_BEGIN_NAMESPACE
/*! /*!
\fn template <typename T, typename Cleanup> QScopedPointer<T, Cleanup>::operator bool() const \fn template <typename T, typename Cleanup> QScopedPointer<T, Cleanup>::operator bool() const
Returns \c true if this object is not \c null. This function is suitable Returns \c true if the contained pointer is not \nullptr.
for use in \tt if-constructs, like: This function is suitable for use in \tt if-constructs, like:
\snippet code/src_corelib_tools_qscopedpointer.cpp 3 \snippet code/src_corelib_tools_qscopedpointer.cpp 3
@ -185,18 +185,14 @@ QT_BEGIN_NAMESPACE
/*! /*!
\fn template <typename T, typename Cleanup> bool operator==(const QScopedPointer<T, Cleanup> &lhs, const QScopedPointer<T, Cleanup> &rhs) \fn template <typename T, typename Cleanup> bool operator==(const QScopedPointer<T, Cleanup> &lhs, const QScopedPointer<T, Cleanup> &rhs)
Equality operator. Returns \c true if the scoped pointers Returns \c true if \a ptr1 and \a ptr2 refer to the same pointer.
\a lhs and \a rhs are pointing to the same object.
Otherwise returns \c false.
*/ */
/*! /*!
\fn template <typename T, typename Cleanup> bool operator!=(const QScopedPointer<T, Cleanup> &lhs, const QScopedPointer<T, Cleanup> &rhs) \fn template <typename T, typename Cleanup> bool operator!=(const QScopedPointer<T, Cleanup> &lhs, const QScopedPointer<T, Cleanup> &rhs)
Inequality operator. Returns \c true if the scoped pointers Returns \c true if \a lhs and \a rhs refer to distinct pointers.
\a lhs and \a rhs are \e not pointing to the same object.
Otherwise returns \c false.
*/ */
/*! /*!
@ -204,7 +200,7 @@ QT_BEGIN_NAMESPACE
\relates QScopedPointer \relates QScopedPointer
\since 5.8 \since 5.8
Returns \c true if the scoped pointer \a lhs is a null pointer. Returns \c true if \a lhs refers to \nullptr.
\sa QScopedPointer::isNull() \sa QScopedPointer::isNull()
*/ */
@ -214,7 +210,7 @@ QT_BEGIN_NAMESPACE
\relates QScopedPointer \relates QScopedPointer
\since 5.8 \since 5.8
Returns \c true if the scoped pointer \a rhs is a null pointer. Returns \c true if \a rhs refers to \nullptr.
\sa QScopedPointer::isNull() \sa QScopedPointer::isNull()
*/ */
@ -224,8 +220,7 @@ QT_BEGIN_NAMESPACE
\relates QScopedPointer \relates QScopedPointer
\since 5.8 \since 5.8
Returns \c true if the scoped pointer \a lhs is a valid (i.e. a non-null) Returns \c true if \a lhs refers to a valid (i.e. non-null) pointer.
pointer.
\sa QScopedPointer::isNull() \sa QScopedPointer::isNull()
*/ */
@ -235,8 +230,7 @@ QT_BEGIN_NAMESPACE
\relates QScopedPointer \relates QScopedPointer
\since 5.8 \since 5.8
Returns \c true if the scoped pointer \a rhs is a valid (i.e. a non-null) Returns \c true if \a rhs refers to a valid (i.e. non-null) pointer.
pointer.
\sa QScopedPointer::isNull() \sa QScopedPointer::isNull()
*/ */
@ -244,7 +238,7 @@ QT_BEGIN_NAMESPACE
/*! /*!
\fn template <typename T, typename Cleanup> bool QScopedPointer<T, Cleanup>::isNull() const \fn template <typename T, typename Cleanup> bool QScopedPointer<T, Cleanup>::isNull() const
Returns \c true if this object is holding a pointer that is \c null. Returns \c true if this object refers to \nullptr.
*/ */
/*! /*!
@ -262,15 +256,14 @@ QT_BEGIN_NAMESPACE
\fn template <typename T, typename Cleanup> T *QScopedPointer<T, Cleanup>::take() \fn template <typename T, typename Cleanup> T *QScopedPointer<T, Cleanup>::take()
Returns the value of the pointer referenced by this object. The pointer of this Returns the value of the pointer referenced by this object. The pointer of this
QScopedPointer object will be reset to \c null. QScopedPointer object will be reset to \nullptr.
Callers of this function take ownership of the pointer. Callers of this function take ownership of the pointer.
*/ */
/*! \fn template <typename T, typename Cleanup> bool QScopedPointer<T, Cleanup>::operator!() const /*! \fn template <typename T, typename Cleanup> bool QScopedPointer<T, Cleanup>::operator!() const
Returns \c true if the pointer referenced by this object is \c null, otherwise Returns \c true if this object refers to \nullptr.
returns \c false.
\sa isNull() \sa isNull()
*/ */
@ -325,7 +318,7 @@ QT_BEGIN_NAMESPACE
Provides access to entry \a i of the scoped pointer's array of Provides access to entry \a i of the scoped pointer's array of
objects. objects.
If the contained pointer is \c null, behavior is undefined. If the contained pointer is \nullptr, behavior is undefined.
\sa isNull() \sa isNull()
*/ */
@ -336,7 +329,7 @@ QT_BEGIN_NAMESPACE
Provides access to entry \a i of the scoped pointer's array of Provides access to entry \a i of the scoped pointer's array of
objects. objects.
If the contained pointer is \c null, behavior is undefined. If the contained pointer is \nullptr behavior is undefined.
\sa isNull() \sa isNull()
*/ */

View File

@ -321,7 +321,7 @@ QT_BEGIN_NAMESPACE
*/ */
/*! \fn template <class T> QSharedDataPointer<T>::QSharedDataPointer() /*! \fn template <class T> QSharedDataPointer<T>::QSharedDataPointer()
Constructs a QSharedDataPointer initialized with a null \e{d pointer}. Constructs a QSharedDataPointer initialized with \nullptr as \e{d pointer}.
*/ */
/*! /*!
@ -494,8 +494,8 @@ QT_BEGIN_NAMESPACE
*/ */
/*! \fn template <class T> QExplicitlySharedDataPointer<T>::QExplicitlySharedDataPointer() /*! \fn template <class T> QExplicitlySharedDataPointer<T>::QExplicitlySharedDataPointer()
Constructs a QExplicitlySharedDataPointer initialized with a null Constructs a QExplicitlySharedDataPointer initialized with \nullptr
\e{d pointer}. as \e{d pointer}.
*/ */
/*! \fn template <class T> QExplicitlySharedDataPointer<T>::~QExplicitlySharedDataPointer() /*! \fn template <class T> QExplicitlySharedDataPointer<T>::~QExplicitlySharedDataPointer()
@ -573,8 +573,8 @@ QT_BEGIN_NAMESPACE
*/ */
/*! \fn template <class T> void QExplicitlySharedDataPointer<T>::reset() /*! \fn template <class T> void QExplicitlySharedDataPointer<T>::reset()
Resets \e this to be null. i.e., this function sets the Resets \e this to be null - i.e., this function sets the
\e{d pointer} of \e this to 0, but first it decrements \e{d pointer} of \e this to \nullptr, but first it decrements
the reference count of the shared data object and deletes the reference count of the shared data object and deletes
the shared data object if the reference count became 0. the shared data object if the reference count became 0.
*/ */
@ -582,7 +582,7 @@ QT_BEGIN_NAMESPACE
/*! \fn template <class T> T *QExplicitlySharedDataPointer<T>::take() /*! \fn template <class T> T *QExplicitlySharedDataPointer<T>::take()
\since 5.12 \since 5.12
Returns a pointer to the shared object, and resets \e this to be null. Returns a pointer to the shared object, and resets \e this to be \nullptr.
That is, this function sets the \e{d pointer} of \e this to \nullptr. That is, this function sets the \e{d pointer} of \e this to \nullptr.
*/ */

View File

@ -401,7 +401,8 @@
/*! /*!
\fn template <class T> QSharedPointer<T>::QSharedPointer() \fn template <class T> QSharedPointer<T>::QSharedPointer()
Creates a QSharedPointer that points to null (0). Creates a QSharedPointer that is null (the object is holding
a reference to \nullptr).
*/ */
/*! /*!
@ -547,6 +548,7 @@
Provides access to the shared pointer's members. Provides access to the shared pointer's members.
If the contained pointer is \nullptr, behavior is undefined.
\sa isNull() \sa isNull()
*/ */
@ -555,21 +557,21 @@
Provides access to the shared pointer's members. Provides access to the shared pointer's members.
If the contained pointer is \nullptr, behavior is undefined.
\sa isNull() \sa isNull()
*/ */
/*! /*!
\fn template <class T> bool QSharedPointer<T>::isNull() const \fn template <class T> bool QSharedPointer<T>::isNull() const
Returns \c true if this object is holding a reference to a null Returns \c true if this object refers to \nullptr.
pointer.
*/ */
/*! /*!
\fn template <class T> QSharedPointer<T>::operator bool() const \fn template <class T> QSharedPointer<T>::operator bool() const
Returns \c true if this object is not null. This function is suitable Returns \c true if the contained pointer is not \nullptr.
for use in \tt if-constructs, like: This function is suitable for use in \tt if-constructs, like:
\snippet code/src_corelib_tools_qsharedpointer.cpp 4 \snippet code/src_corelib_tools_qsharedpointer.cpp 4
@ -579,8 +581,8 @@
/*! /*!
\fn template <class T> bool QSharedPointer<T>::operator !() const \fn template <class T> bool QSharedPointer<T>::operator !() const
Returns \c true if this object is \nullptr. This function is Returns \c true if this object refers to \nullptr.
suitable for use in \tt if-constructs, like: This function is suitable for use in \tt if-constructs, like:
\snippet code/src_corelib_tools_qsharedpointer.cpp 5 \snippet code/src_corelib_tools_qsharedpointer.cpp 5
@ -803,11 +805,10 @@
/*! /*!
\fn template <class T> bool QWeakPointer<T>::isNull() const \fn template <class T> bool QWeakPointer<T>::isNull() const
Returns \c true if this object is holding a reference to a null Returns \c true if this object refers to \nullptr.
pointer.
Note that, due to the nature of weak references, the pointer that Note that, due to the nature of weak references, the pointer that
QWeakPointer references can become null at any moment, so QWeakPointer references can become \nullptr at any moment, so
the value returned from this function can change from false to the value returned from this function can change from false to
true from one call to the next. true from one call to the next.
*/ */
@ -815,13 +816,13 @@
/*! /*!
\fn template <class T> QWeakPointer<T>::operator bool() const \fn template <class T> QWeakPointer<T>::operator bool() const
Returns \c true if this object is not null. This function is suitable Returns \c true if the contained pointer is not \nullptr.
for use in \tt if-constructs, like: This function is suitable for use in \tt if-constructs, like:
\snippet code/src_corelib_tools_qsharedpointer.cpp 8 \snippet code/src_corelib_tools_qsharedpointer.cpp 8
Note that, due to the nature of weak references, the pointer that Note that, due to the nature of weak references, the pointer that
QWeakPointer references can become null at any moment, so QWeakPointer references can become \nullptr at any moment, so
the value returned from this function can change from true to the value returned from this function can change from true to
false from one call to the next. false from one call to the next.
@ -831,13 +832,13 @@
/*! /*!
\fn template <class T> bool QWeakPointer<T>::operator !() const \fn template <class T> bool QWeakPointer<T>::operator !() const
Returns \c true if this object is \nullptr. This function is Returns \c true if this object refers to \nullptr.
suitable for use in \tt if-constructs, like: This function is suitable for use in \tt if-constructs, like:
\snippet code/src_corelib_tools_qsharedpointer.cpp 9 \snippet code/src_corelib_tools_qsharedpointer.cpp 9
Note that, due to the nature of weak references, the pointer that Note that, due to the nature of weak references, the pointer that
QWeakPointer references can become null at any moment, so QWeakPointer references can become \nullptr at any moment, so
the value returned from this function can change from false to the value returned from this function can change from false to
true from one call to the next. true from one call to the next.
@ -918,7 +919,7 @@
If \c this (that is, the subclass instance invoking this method) is being If \c this (that is, the subclass instance invoking this method) is being
managed by a QSharedPointer, returns a shared pointer instance pointing to managed by a QSharedPointer, returns a shared pointer instance pointing to
\c this; otherwise returns a QSharedPointer holding a null pointer. \c this; otherwise returns a null QSharedPointer.
*/ */
/*! /*!
@ -933,8 +934,7 @@
\fn template <class T> template <class X> bool operator==(const QSharedPointer<T> &ptr1, const QSharedPointer<X> &ptr2) \fn template <class T> template <class X> bool operator==(const QSharedPointer<T> &ptr1, const QSharedPointer<X> &ptr2)
\relates QSharedPointer \relates QSharedPointer
Returns \c true if the pointer referenced by \a ptr1 is the Returns \c true if \a ptr1 and \a ptr2 refer to the same pointer.
same pointer as that referenced by \a ptr2.
If \a ptr2's template parameter is different from \a ptr1's, If \a ptr2's template parameter is different from \a ptr1's,
QSharedPointer will attempt to perform an automatic \tt static_cast QSharedPointer will attempt to perform an automatic \tt static_cast
@ -947,8 +947,7 @@
\fn template <class T> template <class X> bool operator!=(const QSharedPointer<T> &ptr1, const QSharedPointer<X> &ptr2) \fn template <class T> template <class X> bool operator!=(const QSharedPointer<T> &ptr1, const QSharedPointer<X> &ptr2)
\relates QSharedPointer \relates QSharedPointer
Returns \c true if the pointer referenced by \a ptr1 is not the Returns \c true if \a ptr1 and \a ptr2 refer to distinct pointers.
same pointer as that referenced by \a ptr2.
If \a ptr2's template parameter is different from \a ptr1's, If \a ptr2's template parameter is different from \a ptr1's,
QSharedPointer will attempt to perform an automatic \tt static_cast QSharedPointer will attempt to perform an automatic \tt static_cast
@ -961,8 +960,7 @@
\fn template <class T> template <class X> bool operator==(const QSharedPointer<T> &ptr1, const X *ptr2) \fn template <class T> template <class X> bool operator==(const QSharedPointer<T> &ptr1, const X *ptr2)
\relates QSharedPointer \relates QSharedPointer
Returns \c true if the pointer referenced by \a ptr1 is the Returns \c true if \a ptr1 and \a ptr2 refer to the same pointer.
same pointer as \a ptr2.
If \a ptr2's type is different from \a ptr1's, If \a ptr2's type is different from \a ptr1's,
QSharedPointer will attempt to perform an automatic \tt static_cast QSharedPointer will attempt to perform an automatic \tt static_cast
@ -975,8 +973,7 @@
\fn template <class T> template <class X> bool operator!=(const QSharedPointer<T> &ptr1, const X *ptr2) \fn template <class T> template <class X> bool operator!=(const QSharedPointer<T> &ptr1, const X *ptr2)
\relates QSharedPointer \relates QSharedPointer
Returns \c true if the pointer referenced by \a ptr1 is not the Returns \c true if \a ptr1 and \a ptr2 refer to distinct pointers.
same pointer as \a ptr2.
If \a ptr2's type is different from \a ptr1's, If \a ptr2's type is different from \a ptr1's,
QSharedPointer will attempt to perform an automatic \tt static_cast QSharedPointer will attempt to perform an automatic \tt static_cast
@ -1017,8 +1014,7 @@
\fn template <class T> template <class X> bool operator==(const QSharedPointer<T> &ptr1, const QWeakPointer<X> &ptr2) \fn template <class T> template <class X> bool operator==(const QSharedPointer<T> &ptr1, const QWeakPointer<X> &ptr2)
\relates QWeakPointer \relates QWeakPointer
Returns \c true if the pointer referenced by \a ptr1 is the Returns \c true if \a ptr1 and \a ptr2 refer to the same pointer.
same pointer as that referenced by \a ptr2.
If \a ptr2's template parameter is different from \a ptr1's, If \a ptr2's template parameter is different from \a ptr1's,
QSharedPointer will attempt to perform an automatic \tt static_cast QSharedPointer will attempt to perform an automatic \tt static_cast
@ -1031,8 +1027,7 @@
\fn template <class T> template <class X> bool operator!=(const QSharedPointer<T> &ptr1, const QWeakPointer<X> &ptr2) \fn template <class T> template <class X> bool operator!=(const QSharedPointer<T> &ptr1, const QWeakPointer<X> &ptr2)
\relates QWeakPointer \relates QWeakPointer
Returns \c true if the pointer referenced by \a ptr1 is not the Returns \c true if \a ptr1 and \a ptr2 refer to distinct pointers.
same pointer as that referenced by \a ptr2.
If \a ptr2's template parameter is different from \a ptr1's, If \a ptr2's template parameter is different from \a ptr1's,
QSharedPointer will attempt to perform an automatic \tt static_cast QSharedPointer will attempt to perform an automatic \tt static_cast
@ -1045,8 +1040,7 @@
\fn template <class T> template <class X> bool operator==(const QWeakPointer<T> &ptr1, const QSharedPointer<X> &ptr2) \fn template <class T> template <class X> bool operator==(const QWeakPointer<T> &ptr1, const QSharedPointer<X> &ptr2)
\relates QWeakPointer \relates QWeakPointer
Returns \c true if the pointer referenced by \a ptr1 is the Returns \c true if \a ptr1 and \a ptr2 refer to the same pointer.
same pointer as that referenced by \a ptr2.
If \a ptr2's template parameter is different from \a ptr1's, If \a ptr2's template parameter is different from \a ptr1's,
QSharedPointer will attempt to perform an automatic \tt static_cast QSharedPointer will attempt to perform an automatic \tt static_cast
@ -1060,7 +1054,7 @@
\relates QSharedPointer \relates QSharedPointer
\since 5.8 \since 5.8
Returns \c true if the pointer referenced by \a lhs is a null pointer. Returns \c true if \a lhs refers to \nullptr.
\sa QSharedPointer::isNull() \sa QSharedPointer::isNull()
*/ */
@ -1070,7 +1064,7 @@
\relates QSharedPointer \relates QSharedPointer
\since 5.8 \since 5.8
Returns \c true if the pointer referenced by \a rhs is a null pointer. Returns \c true if \a rhs refers to \nullptr.
\sa QSharedPointer::isNull() \sa QSharedPointer::isNull()
*/ */
@ -1080,8 +1074,7 @@
\relates QSharedPointer \relates QSharedPointer
\since 5.8 \since 5.8
Returns \c true if the pointer referenced by \a lhs is a valid (i.e. Returns \c true if \a lhs refers to a valid (i.e. non-null) pointer.
non-null) pointer.
\sa QSharedPointer::isNull() \sa QSharedPointer::isNull()
*/ */
@ -1091,8 +1084,7 @@
\relates QSharedPointer \relates QSharedPointer
\since 5.8 \since 5.8
Returns \c true if the pointer referenced by \a rhs is a valid (i.e. Returns \c true if \a rhs refers to a valid (i.e. non-null) pointer.
non-null) pointer.
\sa QSharedPointer::isNull() \sa QSharedPointer::isNull()
*/ */
@ -1102,7 +1094,7 @@
\relates QWeakPointer \relates QWeakPointer
\since 5.8 \since 5.8
Returns \c true if the pointer referenced by \a lhs is a null pointer. Returns \c true if \a lhs refers to \nullptr.
\sa QWeakPointer::isNull() \sa QWeakPointer::isNull()
*/ */
@ -1112,7 +1104,7 @@
\relates QWeakPointer \relates QWeakPointer
\since 5.8 \since 5.8
Returns \c true if the pointer referenced by \a rhs is a null pointer. Returns \c true if \a rhs refers to \nullptr.
\sa QWeakPointer::isNull() \sa QWeakPointer::isNull()
*/ */
@ -1122,8 +1114,7 @@
\relates QWeakPointer \relates QWeakPointer
\since 5.8 \since 5.8
Returns \c true if the pointer referenced by \a lhs is a valid (i.e. Returns \c true if \a lhs refers to a valid (i.e. non-null) pointer.
non-null) pointer.
\sa QWeakPointer::isNull() \sa QWeakPointer::isNull()
*/ */
@ -1133,8 +1124,7 @@
\relates QWeakPointer \relates QWeakPointer
\since 5.8 \since 5.8
Returns \c true if the pointer referenced by \a rhs is a valid (i.e. Returns \c true if \a rhs refers to a valid (i.e. non-null) pointer.
non-null) pointer.
\sa QWeakPointer::isNull() \sa QWeakPointer::isNull()
*/ */
@ -1143,8 +1133,7 @@
\fn template <class T> template <class X> bool operator!=(const QWeakPointer<T> &ptr1, const QSharedPointer<X> &ptr2) \fn template <class T> template <class X> bool operator!=(const QWeakPointer<T> &ptr1, const QSharedPointer<X> &ptr2)
\relates QWeakPointer \relates QWeakPointer
Returns \c true if the pointer referenced by \a ptr1 is not the Returns \c true if \a ptr1 and \a ptr2 refer to distinct pointers.
same pointer as that referenced by \a ptr2.
If \a ptr2's template parameter is different from \a ptr1's, If \a ptr2's template parameter is different from \a ptr1's,
QSharedPointer will attempt to perform an automatic \tt static_cast QSharedPointer will attempt to perform an automatic \tt static_cast

View File

@ -1646,10 +1646,9 @@ const QString::Null QString::null = { };
\snippet qstring/main.cpp 8 \snippet qstring/main.cpp 8
All functions except isNull() treat null strings the same as empty All functions except isNull() treat null strings the same as empty
strings. For example, toUtf8().constData() returns a pointer to a strings. For example, toUtf8().constData() returns a valid pointer
'\\0' character for a null string (\e not a null pointer), and (\e not nullptr) to a '\\0' character for a null string. We
QString() compares equal to QString(""). We recommend that you recommend that you always use the isEmpty() function and avoid isNull().
always use the isEmpty() function and avoid isNull().
\section1 Argument Formats \section1 Argument Formats
@ -4466,7 +4465,7 @@ int QString::indexOf(const QRegularExpression& re, int from) const
expression \a re in the string, searching forward from index expression \a re in the string, searching forward from index
position \a from. Returns -1 if \a re didn't match anywhere. position \a from. Returns -1 if \a re didn't match anywhere.
If the match is successful and \a rmatch is not a null pointer, it also If the match is successful and \a rmatch is not \nullptr, it also
writes the results of the match into the QRegularExpressionMatch object writes the results of the match into the QRegularExpressionMatch object
pointed to by \a rmatch. pointed to by \a rmatch.
@ -4517,7 +4516,7 @@ int QString::lastIndexOf(const QRegularExpression &re, int from) const
expression \a re in the string, which starts before the index expression \a re in the string, which starts before the index
position \a from. Returns -1 if \a re didn't match anywhere. position \a from. Returns -1 if \a re didn't match anywhere.
If the match is successful and \a rmatch is not a null pointer, it also If the match is successful and \a rmatch is not \nullptr, it also
writes the results of the match into the QRegularExpressionMatch object writes the results of the match into the QRegularExpressionMatch object
pointed to by \a rmatch. pointed to by \a rmatch.
@ -4568,14 +4567,14 @@ bool QString::contains(const QRegularExpression &re) const
Returns \c true if the regular expression \a re matches somewhere in this Returns \c true if the regular expression \a re matches somewhere in this
string; otherwise returns \c false. string; otherwise returns \c false.
If the match is successful and \a match is not a null pointer, it also If the match is successful and \a rmatch is not \nullptr, it also
writes the results of the match into the QRegularExpressionMatch object writes the results of the match into the QRegularExpressionMatch object
pointed to by \a match. pointed to by \a rmatch.
\sa QRegularExpression::match() \sa QRegularExpression::match()
*/ */
bool QString::contains(const QRegularExpression &re, QRegularExpressionMatch *match) const bool QString::contains(const QRegularExpression &re, QRegularExpressionMatch *rmatch) const
{ {
if (!re.isValid()) { if (!re.isValid()) {
qWarning("QString::contains: invalid QRegularExpression object"); qWarning("QString::contains: invalid QRegularExpression object");
@ -4583,8 +4582,8 @@ bool QString::contains(const QRegularExpression &re, QRegularExpressionMatch *ma
} }
QRegularExpressionMatch m = re.match(*this); QRegularExpressionMatch m = re.match(*this);
bool hasMatch = m.hasMatch(); bool hasMatch = m.hasMatch();
if (hasMatch && match) if (hasMatch && rmatch)
*match = std::move(m); *rmatch = std::move(m);
return hasMatch; return hasMatch;
} }
@ -10269,8 +10268,8 @@ ownership of it, no memory is freed when instances are destroyed.
/*! /*!
\fn bool QStringRef::isNull() const \fn bool QStringRef::isNull() const
Returns \c true if string() returns a null pointer or a pointer to a Returns \c true if this string reference does not reference a string or if
null string; otherwise returns \c true. the string it references is null (i.e. QString::isNull() is true).
\sa size() \sa size()
*/ */

View File

@ -375,7 +375,7 @@ public:
int lastIndexOf(const QRegularExpression &re, int from = -1) const; int lastIndexOf(const QRegularExpression &re, int from = -1) const;
int lastIndexOf(const QRegularExpression &re, int from, QRegularExpressionMatch *rmatch) const; // ### Qt 6: merge overloads int lastIndexOf(const QRegularExpression &re, int from, QRegularExpressionMatch *rmatch) const; // ### Qt 6: merge overloads
bool contains(const QRegularExpression &re) const; bool contains(const QRegularExpression &re) const;
bool contains(const QRegularExpression &re, QRegularExpressionMatch *match) const; // ### Qt 6: merge overloads bool contains(const QRegularExpression &re, QRegularExpressionMatch *rmatch) const; // ### Qt 6: merge overloads
int count(const QRegularExpression &re) const; int count(const QRegularExpression &re) const;
#endif #endif

View File

@ -526,7 +526,7 @@ static void qAccessibleCleanup()
to it. to it.
If the key and the QObject does not have a corresponding If the key and the QObject does not have a corresponding
QAccessibleInterface, a null-pointer will be returned. QAccessibleInterface, \nullptr will be returned.
Installed factories are called by queryAccessibilityInterface() until Installed factories are called by queryAccessibilityInterface() until
one provides an interface. one provides an interface.

View File

@ -1,7 +1,3 @@
#! [0]
#include <QtGui>
#! [0]
#! [1] #! [1]
QT -= gui QT -= gui
#! [1] #! [1]

View File

@ -0,0 +1,2 @@
find_package(Qt5 COMPONENTS Gui REQUIRED)
target_link_libraries(mytarget Qt5::Gui)

View File

@ -40,18 +40,6 @@
These classes are used internally by Qt's user interface technologies These classes are used internally by Qt's user interface technologies
and can also be used directly, for instance to write applications using and can also be used directly, for instance to write applications using
low-level OpenGL ES graphics APIs. low-level OpenGL ES graphics APIs.
To include the definitions of the module's classes, use the
following directive:
\snippet code/doc_src_qtgui.pro 0
\if !defined(qtforpython)
If you use \l qmake to build your projects, \l{Qt GUI} is included by
default. To disable Qt GUI, add the following line to your \c .pro file:
\snippet code/doc_src_qtgui.pro 1
\endif
*/ */
/*! /*!
@ -69,14 +57,15 @@
higher level API's, like Qt Quick, that are much more suitable higher level API's, like Qt Quick, that are much more suitable
than the enablers found in the Qt GUI module. than the enablers found in the Qt GUI module.
\section1 Getting Started
To include the definitions of the module's classes, use the
following directive:
\snippet code/doc_src_qtgui.pro 0
\if !defined(qtforpython) \if !defined(qtforpython)
\include module-use.qdocinc using qt module
\quotefile overview/using-qt-gui.cmake
See also the \l[QtDoc]{Building with CMake} overview.
\section2 Building with qmake
If you use \l qmake to build your projects, Qt GUI is included by If you use \l qmake to build your projects, Qt GUI is included by
default. To disable Qt GUI, add the following line to your \c .pro file: default. To disable Qt GUI, add the following line to your \c .pro file:

View File

@ -1523,7 +1523,7 @@ QDebug operator<<(QDebug dbg, const QIcon &i)
foo@3x.png, then foo@2x, then fall back to foo.png if not found. foo@3x.png, then foo@2x, then fall back to foo.png if not found.
\a sourceDevicePixelRatio will be set to the value of N if the argument is \a sourceDevicePixelRatio will be set to the value of N if the argument is
a non-null pointer not \nullptr
*/ */
QString qt_findAtNxFile(const QString &baseFileName, qreal targetDevicePixelRatio, QString qt_findAtNxFile(const QString &baseFileName, qreal targetDevicePixelRatio,
qreal *sourceDevicePixelRatio) qreal *sourceDevicePixelRatio)

View File

@ -1486,8 +1486,8 @@ static QPictureHandler *get_picture_handler(const char *format)
\a format is used to select a handler to write a QPicture; \a header \a format is used to select a handler to write a QPicture; \a header
is used to select a handler to read an picture file. is used to select a handler to read an picture file.
If \a readPicture is a null pointer, the QPictureIO will not be able If \a readPicture is \nullptr, the QPictureIO will not be able
to read pictures in \a format. If \a writePicture is a null pointer, to read pictures in \a format. If \a writePicture is \nullptr,
the QPictureIO will not be able to write pictures in \a format. If the QPictureIO will not be able to write pictures in \a format. If
both are null, the QPictureIO object is valid but useless. both are null, the QPictureIO object is valid but useless.

View File

@ -1846,7 +1846,7 @@ bool QStandardItem::hasChildren() const
item) takes ownership of \a item. If necessary, the row count and column item) takes ownership of \a item. If necessary, the row count and column
count are increased to fit the item. count are increased to fit the item.
\note Passing a null pointer as \a item removes the item. \note Passing \nullptr as \a item removes the item.
\sa child() \sa child()
*/ */

View File

@ -787,7 +787,7 @@ QOpenGLExtraFunctions *QOpenGLContext::extraFunctions() const
to the non-template function. to the non-template function.
Note that requests for function objects of other versions or profiles can fail and Note that requests for function objects of other versions or profiles can fail and
in doing so will return a null pointer. Situations in which creation of the functions in doing so will return \nullptr. Situations in which creation of the functions
object can fail are if the request cannot be satisfied due to asking for functions object can fail are if the request cannot be satisfied due to asking for functions
that are not in the version or profile of this context. For example: that are not in the version or profile of this context. For example:
@ -1330,7 +1330,7 @@ bool QOpenGLContext::supportsThreadedOpenGL()
\since 5.5 \since 5.5
Returns the application-wide shared OpenGL context, if present. Returns the application-wide shared OpenGL context, if present.
Otherwise, returns a null pointer. Otherwise, returns \nullptr.
This is useful if you need to upload OpenGL objects (buffers, textures, This is useful if you need to upload OpenGL objects (buffers, textures,
etc.) before creating or showing a QOpenGLWidget or QQuickWidget. etc.) before creating or showing a QOpenGLWidget or QQuickWidget.

View File

@ -2867,7 +2867,7 @@ void QWindow::setVulkanInstance(QVulkanInstance *instance)
} }
/*! /*!
\return the associated Vulkan instance or \c null if there is none. \return the associated Vulkan instance if any was set, otherwise \nullptr.
*/ */
QVulkanInstance *QWindow::vulkanInstance() const QVulkanInstance *QWindow::vulkanInstance() const
{ {

View File

@ -77,8 +77,20 @@
#define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368 #define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368
#endif #endif
#ifndef GL_TEXTURE_SWIZZLE_RGBA #ifndef GL_TEXTURE_SWIZZLE_R
#define GL_TEXTURE_SWIZZLE_RGBA 0x8E46 #define GL_TEXTURE_SWIZZLE_R 0x8E42
#endif
#ifndef GL_TEXTURE_SWIZZLE_G
#define GL_TEXTURE_SWIZZLE_G 0x8E43
#endif
#ifndef GL_TEXTURE_SWIZZLE_B
#define GL_TEXTURE_SWIZZLE_B 0x8E44
#endif
#ifndef GL_TEXTURE_SWIZZLE_A
#define GL_TEXTURE_SWIZZLE_A 0x8E45
#endif #endif
#ifndef GL_SRGB #ifndef GL_SRGB
@ -128,11 +140,13 @@ qsizetype QOpenGLTextureUploader::textureImage(GLenum target, const QImage &imag
#endif #endif
} else if (funcs->hasOpenGLExtension(QOpenGLExtensions::TextureSwizzle)) { } else if (funcs->hasOpenGLExtension(QOpenGLExtensions::TextureSwizzle)) {
#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN #if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
GLint swizzle[4] = { GL_BLUE, GL_GREEN, GL_RED, GL_ALPHA }; funcs->glTexParameteri(target, GL_TEXTURE_SWIZZLE_R, GL_BLUE);
funcs->glTexParameteriv(target, GL_TEXTURE_SWIZZLE_RGBA, swizzle); funcs->glTexParameteri(target, GL_TEXTURE_SWIZZLE_B, GL_RED);
#else #else
GLint swizzle[4] = { GL_GREEN, GL_BLUE, GL_ALPHA, GL_RED }; funcs->glTexParameteri(target, GL_TEXTURE_SWIZZLE_R, GL_GREEN);
funcs->glTexParameteriv(target, GL_TEXTURE_SWIZZLE_RGBA, swizzle); funcs->glTexParameteri(target, GL_TEXTURE_SWIZZLE_G, GL_BLUE);
funcs->glTexParameteri(target, GL_TEXTURE_SWIZZLE_B, GL_ALPHA);
funcs->glTexParameteri(target, GL_TEXTURE_SWIZZLE_A, GL_RED);
#endif #endif
externalFormat = internalFormat = GL_RGBA; externalFormat = internalFormat = GL_RGBA;
pixelType = GL_UNSIGNED_BYTE; pixelType = GL_UNSIGNED_BYTE;
@ -164,12 +178,12 @@ qsizetype QOpenGLTextureUploader::textureImage(GLenum target, const QImage &imag
externalFormat = GL_BGRA; externalFormat = GL_BGRA;
internalFormat = GL_RGB10_A2; internalFormat = GL_RGB10_A2;
targetFormat = image.format(); targetFormat = image.format();
} else if (funcs->hasOpenGLExtension(QOpenGLExtensions::TextureSwizzle) && (isOpenGL12orBetter || isOpenGLES3orBetter)) { } else if (funcs->hasOpenGLExtension(QOpenGLExtensions::TextureSwizzle)) {
funcs->glTexParameteri(target, GL_TEXTURE_SWIZZLE_B, GL_RED);
funcs->glTexParameteri(target, GL_TEXTURE_SWIZZLE_R, GL_BLUE);
pixelType = GL_UNSIGNED_INT_2_10_10_10_REV; pixelType = GL_UNSIGNED_INT_2_10_10_10_REV;
externalFormat = GL_RGBA; externalFormat = GL_RGBA;
internalFormat = GL_RGB10_A2; internalFormat = GL_RGB10_A2;
GLint swizzle[4] = { GL_BLUE, GL_GREEN, GL_RED, GL_ALPHA };
funcs->glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzle);
targetFormat = image.format(); targetFormat = image.format();
} }
break; break;
@ -227,8 +241,10 @@ qsizetype QOpenGLTextureUploader::textureImage(GLenum target, const QImage &imag
pixelType = GL_UNSIGNED_BYTE; pixelType = GL_UNSIGNED_BYTE;
targetFormat = image.format(); targetFormat = image.format();
} else if (funcs->hasOpenGLExtension(QOpenGLExtensions::TextureSwizzle)) { } else if (funcs->hasOpenGLExtension(QOpenGLExtensions::TextureSwizzle)) {
GLint swizzle[4] = { GL_ZERO, GL_ZERO, GL_ZERO, GL_RED }; funcs->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_R, GL_ALPHA);
funcs->glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzle); funcs->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_G, GL_ZERO);
funcs->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_B, GL_ZERO);
funcs->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_A, GL_ZERO);
externalFormat = internalFormat = GL_RED; externalFormat = internalFormat = GL_RED;
pixelType = GL_UNSIGNED_BYTE; pixelType = GL_UNSIGNED_BYTE;
targetFormat = image.format(); targetFormat = image.format();
@ -247,8 +263,10 @@ qsizetype QOpenGLTextureUploader::textureImage(GLenum target, const QImage &imag
pixelType = GL_UNSIGNED_BYTE; pixelType = GL_UNSIGNED_BYTE;
targetFormat = image.format(); targetFormat = image.format();
} else if (funcs->hasOpenGLExtension(QOpenGLExtensions::TextureSwizzle)) { } else if (funcs->hasOpenGLExtension(QOpenGLExtensions::TextureSwizzle)) {
GLint swizzle[4] = { GL_RED, GL_RED, GL_RED, GL_ONE }; funcs->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_R, GL_RED);
funcs->glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzle); funcs->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_G, GL_RED);
funcs->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_B, GL_RED);
funcs->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_A, GL_ONE);
externalFormat = internalFormat = GL_RED; externalFormat = internalFormat = GL_RED;
pixelType = GL_UNSIGNED_BYTE; pixelType = GL_UNSIGNED_BYTE;
targetFormat = image.format(); targetFormat = image.format();
@ -267,8 +285,10 @@ qsizetype QOpenGLTextureUploader::textureImage(GLenum target, const QImage &imag
pixelType = GL_UNSIGNED_SHORT; pixelType = GL_UNSIGNED_SHORT;
targetFormat = image.format(); targetFormat = image.format();
} else if (funcs->hasOpenGLExtension(QOpenGLExtensions::TextureSwizzle)) { } else if (funcs->hasOpenGLExtension(QOpenGLExtensions::TextureSwizzle)) {
GLint swizzle[4] = { GL_RED, GL_RED, GL_RED, GL_ONE }; funcs->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_R, GL_RED);
funcs->glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzle); funcs->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_G, GL_RED);
funcs->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_B, GL_RED);
funcs->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_A, GL_ONE);
externalFormat = internalFormat = GL_RED; externalFormat = internalFormat = GL_RED;
pixelType = GL_UNSIGNED_SHORT; pixelType = GL_UNSIGNED_SHORT;
targetFormat = image.format(); targetFormat = image.format();

View File

@ -261,9 +261,9 @@ static ShiftResult good_offset(const QBezier *b1, const QBezier *b2, qreal offse
static ShiftResult shift(const QBezier *orig, QBezier *shifted, qreal offset, qreal threshold) static ShiftResult shift(const QBezier *orig, QBezier *shifted, qreal offset, qreal threshold)
{ {
int map[4]; int map[4];
bool p1_p2_equal = (orig->x1 == orig->x2 && orig->y1 == orig->y2); bool p1_p2_equal = qFuzzyCompare(orig->x1, orig->x2) && qFuzzyCompare(orig->y1, orig->y2);
bool p2_p3_equal = (orig->x2 == orig->x3 && orig->y2 == orig->y3); bool p2_p3_equal = qFuzzyCompare(orig->x2, orig->x3) && qFuzzyCompare(orig->y2, orig->y3);
bool p3_p4_equal = (orig->x3 == orig->x4 && orig->y3 == orig->y4); bool p3_p4_equal = qFuzzyCompare(orig->x3, orig->x4) && qFuzzyCompare(orig->y3, orig->y4);
QPointF points[4]; QPointF points[4];
int np = 0; int np = 0;

View File

@ -38,7 +38,7 @@
****************************************************************************/ ****************************************************************************/
#include "qfontdatabase.h" #include "qfontdatabase.h"
#include "qdebug.h" #include "qloggingcategory.h"
#include "qalgorithms.h" #include "qalgorithms.h"
#include "qguiapplication.h" #include "qguiapplication.h"
#include "qvarlengtharray.h" // here or earlier - workaround for VC++6 #include "qvarlengtharray.h" // here or earlier - workaround for VC++6
@ -59,25 +59,13 @@
#include <stdlib.h> #include <stdlib.h>
#include <algorithm> #include <algorithm>
// #define QFONTDATABASE_DEBUG
#ifdef QFONTDATABASE_DEBUG
# define FD_DEBUG qDebug
#else
# define FD_DEBUG if (false) qDebug
#endif
// #define FONT_MATCH_DEBUG
#ifdef FONT_MATCH_DEBUG
# define FM_DEBUG qDebug
#else
# define FM_DEBUG if (false) qDebug
#endif
#include <qtgui_tracepoints_p.h> #include <qtgui_tracepoints_p.h>
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
Q_LOGGING_CATEGORY(lcFontDb, "qt.text.font.db")
Q_LOGGING_CATEGORY(lcFontMatch, "qt.text.font.match")
#define SMOOTH_SCALABLE 0xffff #define SMOOTH_SCALABLE 0xffff
#if defined(QT_BUILD_INTERNAL) #if defined(QT_BUILD_INTERNAL)
@ -744,7 +732,7 @@ void qt_registerFont(const QString &familyName, const QString &stylename,
const QSupportedWritingSystems &writingSystems, void *handle) const QSupportedWritingSystems &writingSystems, void *handle)
{ {
QFontDatabasePrivate *d = privateDb(); QFontDatabasePrivate *d = privateDb();
// qDebug() << "Adding font" << familyName << weight << style << pixelSize << antialiased; qCDebug(lcFontDb) << "Adding font" << familyName << weight << style << pixelSize << "aa" << antialiased << "fixed" << fixedPitch;
QtFontStyle::Key styleKey; QtFontStyle::Key styleKey;
styleKey.style = style; styleKey.style = style;
styleKey.weight = weight; styleKey.weight = weight;
@ -1079,7 +1067,7 @@ static QtFontStyle *bestStyle(QtFontFoundry *foundry, const QtFontStyle::Key &st
} }
} }
FM_DEBUG( " best style has distance 0x%x", dist ); qCDebug(lcFontMatch, " best style has distance 0x%x", dist );
return foundry->styles[best]; return foundry->styles[best];
} }
@ -1098,20 +1086,20 @@ unsigned int bestFoundry(int script, unsigned int score, int styleStrategy,
desc->size = 0; desc->size = 0;
FM_DEBUG(" REMARK: looking for best foundry for family '%s' [%d]", family->name.toLatin1().constData(), family->count); qCDebug(lcFontMatch, " REMARK: looking for best foundry for family '%s' [%d]", family->name.toLatin1().constData(), family->count);
for (int x = 0; x < family->count; ++x) { for (int x = 0; x < family->count; ++x) {
QtFontFoundry *foundry = family->foundries[x]; QtFontFoundry *foundry = family->foundries[x];
if (!foundry_name.isEmpty() && foundry->name.compare(foundry_name, Qt::CaseInsensitive) != 0) if (!foundry_name.isEmpty() && foundry->name.compare(foundry_name, Qt::CaseInsensitive) != 0)
continue; continue;
FM_DEBUG(" looking for matching style in foundry '%s' %d", qCDebug(lcFontMatch, " looking for matching style in foundry '%s' %d",
foundry->name.isEmpty() ? "-- none --" : foundry->name.toLatin1().constData(), foundry->count); foundry->name.isEmpty() ? "-- none --" : foundry->name.toLatin1().constData(), foundry->count);
QtFontStyle *style = bestStyle(foundry, styleKey, styleName); QtFontStyle *style = bestStyle(foundry, styleKey, styleName);
if (!style->smoothScalable && (styleStrategy & QFont::ForceOutline)) { if (!style->smoothScalable && (styleStrategy & QFont::ForceOutline)) {
FM_DEBUG(" ForceOutline set, but not smoothly scalable"); qCDebug(lcFontMatch, " ForceOutline set, but not smoothly scalable");
continue; continue;
} }
@ -1122,7 +1110,7 @@ unsigned int bestFoundry(int script, unsigned int score, int styleStrategy,
if (!(styleStrategy & QFont::ForceOutline)) { if (!(styleStrategy & QFont::ForceOutline)) {
size = style->pixelSize(pixelSize); size = style->pixelSize(pixelSize);
if (size) { if (size) {
FM_DEBUG(" found exact size match (%d pixels)", size->pixelSize); qCDebug(lcFontMatch, " found exact size match (%d pixels)", size->pixelSize);
px = size->pixelSize; px = size->pixelSize;
} }
} }
@ -1131,7 +1119,7 @@ unsigned int bestFoundry(int script, unsigned int score, int styleStrategy,
if (!size && style->smoothScalable && ! (styleStrategy & QFont::PreferBitmap)) { if (!size && style->smoothScalable && ! (styleStrategy & QFont::PreferBitmap)) {
size = style->pixelSize(SMOOTH_SCALABLE); size = style->pixelSize(SMOOTH_SCALABLE);
if (size) { if (size) {
FM_DEBUG(" found smoothly scalable font (%d pixels)", pixelSize); qCDebug(lcFontMatch, " found smoothly scalable font (%d pixels)", pixelSize);
px = pixelSize; px = pixelSize;
} }
} }
@ -1140,7 +1128,7 @@ unsigned int bestFoundry(int script, unsigned int score, int styleStrategy,
if (!size && style->bitmapScalable && (styleStrategy & QFont::PreferMatch)) { if (!size && style->bitmapScalable && (styleStrategy & QFont::PreferMatch)) {
size = style->pixelSize(0); size = style->pixelSize(0);
if (size) { if (size) {
FM_DEBUG(" found bitmap scalable font (%d pixels)", pixelSize); qCDebug(lcFontMatch, " found bitmap scalable font (%d pixels)", pixelSize);
px = pixelSize; px = pixelSize;
} }
} }
@ -1164,12 +1152,12 @@ unsigned int bestFoundry(int script, unsigned int score, int styleStrategy,
if (d < distance) { if (d < distance) {
distance = d; distance = d;
size = style->pixelSizes + x; size = style->pixelSizes + x;
FM_DEBUG(" best size so far: %3d (%d)", size->pixelSize, pixelSize); qCDebug(lcFontMatch, " best size so far: %3d (%d)", size->pixelSize, pixelSize);
} }
} }
if (!size) { if (!size) {
FM_DEBUG(" no size supports the script we want"); qCDebug(lcFontMatch, " no size supports the script we want");
continue; continue;
} }
@ -1204,7 +1192,7 @@ unsigned int bestFoundry(int script, unsigned int score, int styleStrategy,
this_score += qAbs(px - pixelSize); this_score += qAbs(px - pixelSize);
if (this_score < score) { if (this_score < score) {
FM_DEBUG(" found a match: score %x best score so far %x", qCDebug(lcFontMatch, " found a match: score %x best score so far %x",
this_score, score); this_score, score);
score = this_score; score = this_score;
@ -1212,7 +1200,7 @@ unsigned int bestFoundry(int script, unsigned int score, int styleStrategy,
desc->style = style; desc->style = style;
desc->size = size; desc->size = size;
} else { } else {
FM_DEBUG(" score %x no better than best %x", this_score, score); qCDebug(lcFontMatch, " score %x no better than best %x", this_score, score);
} }
} }
@ -1245,7 +1233,7 @@ static int match(int script, const QFontDef &request,
char pitch = request.ignorePitch ? '*' : request.fixedPitch ? 'm' : 'p'; char pitch = request.ignorePitch ? '*' : request.fixedPitch ? 'm' : 'p';
FM_DEBUG("QFontDatabase::match\n" qCDebug(lcFontMatch, "QFontDatabase::match\n"
" request:\n" " request:\n"
" family: %s [%s], script: %d\n" " family: %s [%s], script: %d\n"
" weight: %d, style: %d\n" " weight: %d, style: %d\n"
@ -2683,7 +2671,7 @@ QFontEngine *QFontDatabase::findFont(const QFontDef &request, int script)
QFontCache::Key key(request, script, multi ? 1 : 0); QFontCache::Key key(request, script, multi ? 1 : 0);
engine = fontCache->findEngine(key); engine = fontCache->findEngine(key);
if (engine) { if (engine) {
FM_DEBUG("Cache hit level 1"); qCDebug(lcFontMatch, "Cache hit level 1");
return engine; return engine;
} }
@ -2712,7 +2700,7 @@ QFontEngine *QFontDatabase::findFont(const QFontDef &request, int script)
else else
blackListed.append(index); blackListed.append(index);
} else { } else {
FM_DEBUG(" NO MATCH FOUND\n"); qCDebug(lcFontMatch, " NO MATCH FOUND\n");
} }
if (!engine) { if (!engine) {
@ -2756,7 +2744,7 @@ QFontEngine *QFontDatabase::findFont(const QFontDef &request, int script)
if (!engine) if (!engine)
engine = new QFontEngineBox(request.pixelSize); engine = new QFontEngineBox(request.pixelSize);
FM_DEBUG("returning box engine"); qCDebug(lcFontMatch, "returning box engine");
} }
return engine; return engine;

View File

@ -1383,11 +1383,12 @@ void QTextEngine::shapeText(int item) const
if (QChar::isHighSurrogate(ucs4) && i + 1 < itemLength) { if (QChar::isHighSurrogate(ucs4) && i + 1 < itemLength) {
uint low = string[i + 1]; uint low = string[i + 1];
if (QChar::isLowSurrogate(low)) { if (QChar::isLowSurrogate(low)) {
// high part never changes in simple casing
uc[i] = ucs4;
++i; ++i;
ucs4 = QChar::surrogateToUcs4(ucs4, low); ucs4 = QChar::surrogateToUcs4(ucs4, low);
ucs4 = si.analysis.flags == QScriptAnalysis::Lowercase ? QChar::toLower(ucs4) ucs4 = si.analysis.flags == QScriptAnalysis::Lowercase ? QChar::toLower(ucs4)
: QChar::toUpper(ucs4); : QChar::toUpper(ucs4);
// high part never changes in simple casing
uc[i] = QChar::lowSurrogate(ucs4); uc[i] = QChar::lowSurrogate(ucs4);
} }
} else { } else {

View File

@ -1316,8 +1316,8 @@ QTextList *QTextBlock::textList() const
/*! /*!
\since 4.1 \since 4.1
Returns a pointer to a QTextBlockUserData object if previously set with Returns a pointer to a QTextBlockUserData object,
setUserData() or a null pointer. if one has been set with setUserData(), or \nullptr.
*/ */
QTextBlockUserData *QTextBlock::userData() const QTextBlockUserData *QTextBlock::userData() const
{ {

View File

@ -614,7 +614,7 @@ VkResult QVulkanInstance::errorCode() const
} }
/*! /*!
\return the VkInstance handle this QVulkanInstance wraps, or \c null if \return the VkInstance handle this QVulkanInstance wraps, or \nullptr if
create() has not yet been successfully called and no existing instance has create() has not yet been successfully called and no existing instance has
been provided via setVkInstance(). been provided via setVkInstance().
*/ */

View File

@ -408,7 +408,7 @@ int QLocalServer::maxPendingConnections() const
still a good idea to delete the object explicitly when you are done with still a good idea to delete the object explicitly when you are done with
it, to avoid wasting memory. it, to avoid wasting memory.
0 is returned if this function is called when there are no pending \nullptr is returned if this function is called when there are no pending
connections. connections.
\sa hasPendingConnections(), newConnection(), incomingConnection() \sa hasPendingConnections(), newConnection(), incomingConnection()

View File

@ -875,8 +875,14 @@ void QNativeSocketEngine::close()
if (d->closingDown) if (d->closingDown)
return; return;
if (d->pendingReadNotification) if (d->pendingReadNotification) {
// We use QPointer here to see if this QNativeSocketEngine was deleted as a result of
// finishing and cleaning up a network request when calling "processReadReady".
QPointer<QNativeSocketEngine> alive(this);
processReadReady(); processReadReady();
if (alive.isNull())
return;
}
d->closingDown = true; d->closingDown = true;

View File

@ -548,7 +548,7 @@ bool QTcpServer::hasPendingConnections() const
destroyed. It is still a good idea to delete the object destroyed. It is still a good idea to delete the object
explicitly when you are done with it, to avoid wasting memory. explicitly when you are done with it, to avoid wasting memory.
0 is returned if this function is called when there are no pending \nullptr is returned if this function is called when there are no pending
connections. connections.
\note The returned QTcpSocket object cannot be used from another \note The returned QTcpSocket object cannot be used from another

View File

@ -417,7 +417,7 @@ QByteArray QSslCertificate::digest(QCryptographicHash::Algorithm algorithm) cons
/*! /*!
\fn Qt::HANDLE QSslCertificate::handle() const \fn Qt::HANDLE QSslCertificate::handle() const
Returns a pointer to the native certificate handle, if there is Returns a pointer to the native certificate handle, if there is
one, or a null pointer otherwise. one, else \nullptr.
You can use this handle, together with the native API, to access You can use this handle, together with the native API, to access
extended information about the certificate. extended information about the certificate.

View File

@ -508,8 +508,8 @@ QByteArray QSslKey::toPem(const QByteArray &passPhrase) const
} }
/*! /*!
Returns a pointer to the native key handle, if it is available; Returns a pointer to the native key handle, if there is
otherwise a null pointer is returned. one, else \nullptr.
You can use this handle together with the native API to access You can use this handle together with the native API to access
extended information about the key. extended information about the key.

View File

@ -4023,7 +4023,7 @@ QGLWidget::~QGLWidget()
\fn QFunctionPointer QGLContext::getProcAddress(const QString &proc) const \fn QFunctionPointer QGLContext::getProcAddress(const QString &proc) const
Returns a function pointer to the GL extension function passed in Returns a function pointer to the GL extension function passed in
\a proc. 0 is returned if a pointer to the function could not be \a proc. \nullptr is returned if a pointer to the function could not be
obtained. obtained.
*/ */
QFunctionPointer QGLContext::getProcAddress(const QString &procName) const QFunctionPointer QGLContext::getProcAddress(const QString &procName) const

View File

@ -142,7 +142,6 @@ QStringList QFreeTypeFontDatabase::addTTFile(const QByteArray &fontData, const Q
weight = QFont::Bold; weight = QFont::Bold;
bool fixedPitch = (face->face_flags & FT_FACE_FLAG_FIXED_WIDTH); bool fixedPitch = (face->face_flags & FT_FACE_FLAG_FIXED_WIDTH);
QSupportedWritingSystems writingSystems; QSupportedWritingSystems writingSystems;
// detect symbol fonts // detect symbol fonts
for (int i = 0; i < face->num_charmaps; ++i) { for (int i = 0; i < face->num_charmaps; ++i) {

View File

@ -79,7 +79,7 @@ quint64 spiStatesFromQState(QAccessible::State state)
if (state.checkStateMixed) if (state.checkStateMixed)
setSpiStateBit(&spiState, ATSPI_STATE_INDETERMINATE); setSpiStateBit(&spiState, ATSPI_STATE_INDETERMINATE);
if (state.readOnly) if (state.readOnly)
unsetSpiStateBit(&spiState, ATSPI_STATE_EDITABLE); setSpiStateBit(&spiState, ATSPI_STATE_READ_ONLY);
// if (state.HotTracked) // if (state.HotTracked)
if (state.defaultButton) if (state.defaultButton)
setSpiStateBit(&spiState, ATSPI_STATE_IS_DEFAULT); setSpiStateBit(&spiState, ATSPI_STATE_IS_DEFAULT);

View File

@ -76,6 +76,7 @@
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
Q_DECLARE_LOGGING_CATEGORY(qLcTray) Q_DECLARE_LOGGING_CATEGORY(qLcTray)
Q_LOGGING_CATEGORY(lcQpaFonts, "qt.qpa.fonts")
ResourceHelper::ResourceHelper() ResourceHelper::ResourceHelper()
{ {
@ -96,6 +97,7 @@ const char *QGenericUnixTheme::name = "generic";
// Default system font, corresponding to the value returned by 4.8 for // Default system font, corresponding to the value returned by 4.8 for
// XRender/FontConfig which we can now assume as default. // XRender/FontConfig which we can now assume as default.
static const char defaultSystemFontNameC[] = "Sans Serif"; static const char defaultSystemFontNameC[] = "Sans Serif";
static const char defaultFixedFontNameC[] = "monospace";
enum { defaultSystemFontSize = 9 }; enum { defaultSystemFontSize = 9 };
#if !defined(QT_NO_DBUS) && !defined(QT_NO_SYSTEMTRAYICON) #if !defined(QT_NO_DBUS) && !defined(QT_NO_SYSTEMTRAYICON)
@ -136,9 +138,10 @@ public:
QGenericUnixThemePrivate() QGenericUnixThemePrivate()
: QPlatformThemePrivate() : QPlatformThemePrivate()
, systemFont(QLatin1String(defaultSystemFontNameC), defaultSystemFontSize) , systemFont(QLatin1String(defaultSystemFontNameC), defaultSystemFontSize)
, fixedFont(QStringLiteral("monospace"), systemFont.pointSize()) , fixedFont(QLatin1String(defaultFixedFontNameC), systemFont.pointSize())
{ {
fixedFont.setStyleHint(QFont::TypeWriter); fixedFont.setStyleHint(QFont::TypeWriter);
qCDebug(lcQpaFonts) << "default fonts: system" << systemFont << "fixed" << fixedFont;
} }
const QFont systemFont; const QFont systemFont;
@ -384,7 +387,7 @@ void QKdeThemePrivate::refresh()
if (QFont *fixedFont = kdeFont(readKdeSetting(QStringLiteral("fixed"), kdeDirs, kdeVersion, kdeSettings))) { if (QFont *fixedFont = kdeFont(readKdeSetting(QStringLiteral("fixed"), kdeDirs, kdeVersion, kdeSettings))) {
resources.fonts[QPlatformTheme::FixedFont] = fixedFont; resources.fonts[QPlatformTheme::FixedFont] = fixedFont;
} else { } else {
fixedFont = new QFont(QLatin1String(defaultSystemFontNameC), defaultSystemFontSize); fixedFont = new QFont(QLatin1String(defaultFixedFontNameC), defaultSystemFontSize);
fixedFont->setStyleHint(QFont::TypeWriter); fixedFont->setStyleHint(QFont::TypeWriter);
resources.fonts[QPlatformTheme::FixedFont] = fixedFont; resources.fonts[QPlatformTheme::FixedFont] = fixedFont;
} }
@ -397,6 +400,8 @@ void QKdeThemePrivate::refresh()
if (QFont *toolBarFont = kdeFont(readKdeSetting(QStringLiteral("toolBarFont"), kdeDirs, kdeVersion, kdeSettings))) if (QFont *toolBarFont = kdeFont(readKdeSetting(QStringLiteral("toolBarFont"), kdeDirs, kdeVersion, kdeSettings)))
resources.fonts[QPlatformTheme::ToolButtonFont] = toolBarFont; resources.fonts[QPlatformTheme::ToolButtonFont] = toolBarFont;
qCDebug(lcQpaFonts) << "default fonts: system" << resources.fonts[QPlatformTheme::SystemFont]
<< "fixed" << resources.fonts[QPlatformTheme::FixedFont];
qDeleteAll(kdeSettings); qDeleteAll(kdeSettings);
} }
@ -710,8 +715,9 @@ public:
QString fontName = gtkFontName.left(split); QString fontName = gtkFontName.left(split);
systemFont = new QFont(fontName, size); systemFont = new QFont(fontName, size);
fixedFont = new QFont(QLatin1String("monospace"), systemFont->pointSize()); fixedFont = new QFont(QLatin1String(defaultFixedFontNameC), systemFont->pointSize());
fixedFont->setStyleHint(QFont::TypeWriter); fixedFont->setStyleHint(QFont::TypeWriter);
qCDebug(lcQpaFonts) << "default fonts: system" << systemFont << "fixed" << fixedFont;
} }
mutable QFont *systemFont; mutable QFont *systemFont;

View File

@ -76,8 +76,10 @@ public:
void endPaint() override; void endPaint() override;
void flush(QWindow *, const QRegion &, const QPoint &) override; void flush(QWindow *, const QRegion &, const QPoint &) override;
#ifndef QT_NO_OPENGL
void composeAndFlush(QWindow *window, const QRegion &region, const QPoint &offset, void composeAndFlush(QWindow *window, const QRegion &region, const QPoint &offset,
QPlatformTextureList *textures, bool translucentBackground) override; QPlatformTextureList *textures, bool translucentBackground) override;
#endif
QPlatformGraphicsBuffer *graphicsBuffer() const override; QPlatformGraphicsBuffer *graphicsBuffer() const override;

View File

@ -523,6 +523,7 @@ void QCALayerBackingStore::flush(QWindow *flushedWindow, const QRegion &region,
// the window server. // the window server.
} }
#ifndef QT_NO_OPENGL
void QCALayerBackingStore::composeAndFlush(QWindow *window, const QRegion &region, const QPoint &offset, void QCALayerBackingStore::composeAndFlush(QWindow *window, const QRegion &region, const QPoint &offset,
QPlatformTextureList *textures, bool translucentBackground) QPlatformTextureList *textures, bool translucentBackground)
{ {
@ -531,6 +532,7 @@ void QCALayerBackingStore::composeAndFlush(QWindow *window, const QRegion &regio
QPlatformBackingStore::composeAndFlush(window, region, offset, textures, translucentBackground); QPlatformBackingStore::composeAndFlush(window, region, offset, textures, translucentBackground);
} }
#endif
QPlatformGraphicsBuffer *QCALayerBackingStore::graphicsBuffer() const QPlatformGraphicsBuffer *QCALayerBackingStore::graphicsBuffer() const
{ {

View File

@ -1208,23 +1208,34 @@ void QCocoaWindow::windowDidChangeScreen()
if (!window()) if (!window())
return; return;
const bool wasRunningDisplayLink = static_cast<QCocoaScreen *>(screen())->isRunningDisplayLink(); // Note: When a window is resized to 0x0 Cocoa will report the window's screen as nil
auto *currentScreen = QCocoaIntegration::instance()->screenForNSScreen(m_view.window.screen);
auto *previousScreen = static_cast<QCocoaScreen*>(screen());
if (QCocoaScreen *newScreen = QCocoaIntegration::instance()->screenForNSScreen(m_view.window.screen)) { Q_ASSERT_X(!m_view.window.screen || currentScreen,
if (newScreen == screen()) { "QCocoaWindow", "Failed to get QCocoaScreen for NSScreen");
// Screen properties have changed. Will be handled by
// NSApplicationDidChangeScreenParametersNotification
// in QCocoaIntegration::updateScreens().
return;
}
qCDebug(lcQpaWindow) << window() << "moved to" << newScreen; // Note: The previous screen may be the same as the current screen, either because
QWindowSystemInterface::handleWindowScreenChanged<QWindowSystemInterface::SynchronousDelivery>(window(), newScreen->screen()); // the screen was just reconfigured, which still results in AppKit sending an
// NSWindowDidChangeScreenNotification, because the previous screen was removed,
// and we ended up calling QWindow::setScreen to move the window, which doesn't
// actually move the window to the new screen, or because we've delivered the
// screen change to the top level window, which will make all the child windows
// of that window report the new screen when requested via QWindow::screen().
// We still need to deliver the screen change in all these cases, as the
// device-pixel ratio may have changed, and needs to be delivered to all
// windows, both top level and child windows.
if (hasPendingUpdateRequest() && wasRunningDisplayLink) qCDebug(lcQpaWindow) << "Screen changed for" << window() << "from" << previousScreen << "to" << currentScreen;
requestUpdate(); // Restart display-link on new screen QWindowSystemInterface::handleWindowScreenChanged<QWindowSystemInterface::SynchronousDelivery>(
} else { window(), currentScreen ? currentScreen->screen() : nullptr);
qCWarning(lcQpaWindow) << "Failed to get QCocoaScreen for" << m_view.window.screen;
if (currentScreen && hasPendingUpdateRequest()) {
// Restart display-link on new screen. We need to do this unconditionally,
// since we can't rely on the previousScreen reflecting whether or not the
// window actually moved from one screen to another, or just stayed on the
// same screen.
currentScreen->requestUpdate();
} }
} }

View File

@ -147,9 +147,34 @@
ulong timestamp = [theEvent timestamp] * 1000; ulong timestamp = [theEvent timestamp] * 1000;
auto eventType = cocoaEvent2QtMouseEvent(theEvent); const auto button = cocoaButton2QtButton(theEvent);
qCInfo(lcQpaMouse) << "Frame-strut" << eventType << "at" << qtWindowPoint << "with" << m_frameStrutButtons << "in" << self.window; auto eventType = [&]() {
QWindowSystemInterface::handleFrameStrutMouseEvent(m_platformWindow->window(), timestamp, qtWindowPoint, qtScreenPoint, m_frameStrutButtons); switch (theEvent.type) {
case NSEventTypeLeftMouseDown:
case NSEventTypeRightMouseDown:
case NSEventTypeOtherMouseDown:
return QEvent::NonClientAreaMouseButtonPress;
case NSEventTypeLeftMouseUp:
case NSEventTypeRightMouseUp:
case NSEventTypeOtherMouseUp:
return QEvent::NonClientAreaMouseButtonRelease;
case NSEventTypeLeftMouseDragged:
case NSEventTypeRightMouseDragged:
case NSEventTypeOtherMouseDragged:
return QEvent::NonClientAreaMouseMove;
default:
break;
}
return QEvent::None;
}();
qCInfo(lcQpaMouse) << eventType << "at" << qtWindowPoint << "with" << m_frameStrutButtons << "in" << self.window;
QWindowSystemInterface::handleFrameStrutMouseEvent(m_platformWindow->window(),
timestamp, qtWindowPoint, qtScreenPoint, m_frameStrutButtons, button, eventType);
} }
@end @end
@ -477,12 +502,15 @@
// uses the legacy cursorRect API, so the cursor is reset to the arrow // uses the legacy cursorRect API, so the cursor is reset to the arrow
// cursor. See rdar://34183708 // cursor. See rdar://34183708
if (self.cursor && self.cursor != NSCursor.currentCursor) { auto previousCursor = NSCursor.currentCursor;
qCInfo(lcQpaMouse) << "Updating cursor for" << self << "to" << self.cursor;
if (self.cursor)
[self.cursor set]; [self.cursor set];
} else { else
[super cursorUpdate:theEvent]; [super cursorUpdate:theEvent];
}
if (NSCursor.currentCursor != previousCursor)
qCInfo(lcQpaMouse) << "Cursor update for" << self << "resulted in new cursor" << NSCursor.currentCursor;
} }
- (void)mouseMovedImpl:(NSEvent *)theEvent - (void)mouseMovedImpl:(NSEvent *)theEvent

View File

@ -51,7 +51,9 @@ static QRegExp whitespaceRegex = QRegExp(QStringLiteral("\\s*"));
static QCocoaWindow *toPlatformWindow(NSWindow *window) static QCocoaWindow *toPlatformWindow(NSWindow *window)
{ {
return qnsview_cast(window.contentView).platformWindow; if ([window conformsToProtocol:@protocol(QNSWindowProtocol)])
return static_cast<QCocoaNSWindow *>(window).platformWindow;
return nullptr;
} }
@implementation QNSWindowDelegate @implementation QNSWindowDelegate

View File

@ -38,9 +38,9 @@ void QWasmFontDatabase::populateFontDatabase()
// Load font file from resources. Currently // Load font file from resources. Currently
// all fonts needs to be bundled with the nexe // all fonts needs to be bundled with the nexe
// as Qt resources. // as Qt resources.
QStringList fontFileNames = QStringList() << QStringLiteral(":/fonts/Vera.ttf") QStringList fontFileNames = QStringList() << QStringLiteral(":/fonts/DejaVuSansMono.ttf")
<< QStringLiteral(":/fonts/Vera.ttf")
<< QStringLiteral(":/fonts/DejaVuSans.ttf"); << QStringLiteral(":/fonts/DejaVuSans.ttf");
foreach (const QString &fontFileName, fontFileNames) { foreach (const QString &fontFileName, fontFileNames) {
QFile theFont(fontFileName); QFile theFont(fontFileName);
if (!theFont.open(QIODevice::ReadOnly)) if (!theFont.open(QIODevice::ReadOnly))
@ -82,5 +82,9 @@ void QWasmFontDatabase::releaseHandle(void *handle)
QFreeTypeFontDatabase::releaseHandle(handle); QFreeTypeFontDatabase::releaseHandle(handle);
} }
QFont QWasmFontDatabase::defaultFont() const
{
return QFont(QLatin1String("Bitstream Vera Sans"));
}
QT_END_NAMESPACE QT_END_NAMESPACE

View File

@ -44,6 +44,7 @@ public:
QChar::Script script) const override; QChar::Script script) const override;
QStringList addApplicationFont(const QByteArray &fontData, const QString &fileName) override; QStringList addApplicationFont(const QByteArray &fontData, const QString &fileName) override;
void releaseHandle(void *handle) override; void releaseHandle(void *handle) override;
QFont defaultFont() const override;
}; };
QT_END_NAMESPACE QT_END_NAMESPACE
#endif #endif

View File

@ -29,15 +29,22 @@
#include "qwasmtheme.h" #include "qwasmtheme.h"
#include <QtCore/qvariant.h> #include <QtCore/qvariant.h>
#include <QFontDatabase>
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
QWasmTheme::QWasmTheme() QWasmTheme::QWasmTheme()
{ {
QFontDatabase fdb;
for (auto family : fdb.families())
if (fdb.isFixedPitch(family))
fixedFont = new QFont(family);
} }
QWasmTheme::~QWasmTheme() QWasmTheme::~QWasmTheme()
{ {
if (fixedFont)
delete fixedFont;
} }
QVariant QWasmTheme::themeHint(ThemeHint hint) const QVariant QWasmTheme::themeHint(ThemeHint hint) const
@ -47,4 +54,12 @@ QVariant QWasmTheme::themeHint(ThemeHint hint) const
return QPlatformTheme::themeHint(hint); return QPlatformTheme::themeHint(hint);
} }
const QFont *QWasmTheme::font(Font type) const
{
if (type == QPlatformTheme::FixedFont) {
return fixedFont;
}
return nullptr;
}
QT_END_NAMESPACE QT_END_NAMESPACE

View File

@ -31,6 +31,7 @@
#define QWASMTHEME_H #define QWASMTHEME_H
#include <qpa/qplatformtheme.h> #include <qpa/qplatformtheme.h>
#include <QtGui/QFont>
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
@ -49,6 +50,8 @@ public:
~QWasmTheme(); ~QWasmTheme();
QVariant themeHint(ThemeHint hint) const override; QVariant themeHint(ThemeHint hint) const override;
const QFont *font(Font type) const override;
QFont *fixedFont = nullptr;
}; };
QT_END_NAMESPACE QT_END_NAMESPACE

View File

@ -39,7 +39,8 @@ HEADERS = \
wasmfonts.files = \ wasmfonts.files = \
../../../3rdparty/wasm/Vera.ttf \ ../../../3rdparty/wasm/Vera.ttf \
../../../3rdparty/wasm/DejaVuSans.ttf ../../../3rdparty/wasm/DejaVuSans.ttf \
../../../3rdparty/wasm/DejaVuSansMono.ttf
wasmfonts.prefix = /fonts wasmfonts.prefix = /fonts
wasmfonts.base = ../../../3rdparty/wasm wasmfonts.base = ../../../3rdparty/wasm
RESOURCES += wasmfonts RESOURCES += wasmfonts

View File

@ -614,6 +614,9 @@ bool QWindowsPointerHandler::translatePenEvent(QWindow *window, HWND hwnd, QtWin
if (m_needsEnterOnPointerUpdate) { if (m_needsEnterOnPointerUpdate) {
m_needsEnterOnPointerUpdate = false; m_needsEnterOnPointerUpdate = false;
if (window != m_currentWindow) { if (window != m_currentWindow) {
// make sure we subscribe to leave events for this window
trackLeave(hwnd);
QWindowSystemInterface::handleEnterEvent(window, localPos, globalPos); QWindowSystemInterface::handleEnterEvent(window, localPos, globalPos);
m_currentWindow = window; m_currentWindow = window;
if (QWindowsWindow *wumPlatformWindow = QWindowsWindow::windowsWindowOf(target)) if (QWindowsWindow *wumPlatformWindow = QWindowsWindow::windowsWindowOf(target))

View File

@ -435,6 +435,27 @@ bool QWindowsTabletSupport::translateTabletProximityEvent(WPARAM /* wParam */, L
m_currentDevice = m_devices.size(); m_currentDevice = m_devices.size();
m_devices.push_back(tabletInit(uniqueId, cursorType)); m_devices.push_back(tabletInit(uniqueId, cursorType));
} }
/**
* We should check button map for changes on every proximity event, not
* only during initialization phase.
*
* WARNING: in 2016 there were some Wacom table drivers, which could mess up
* button mapping if the remapped button was pressed, while the
* application **didn't have input focus**. This bug is somehow
* related to the fact that Wacom drivers allow user to configure
* per-application button-mappings. If the bug shows up again,
* just move this button-map fetching into initialization block.
*
* See https://bugs.kde.org/show_bug.cgi?id=359561
*/
BYTE logicalButtons[32];
memset(logicalButtons, 0, 32);
m_winTab32DLL.wTInfo(WTI_CURSORS + currentCursor, CSR_SYSBTNMAP, &logicalButtons);
m_devices[m_currentDevice].buttonsMap[0x1] = logicalButtons[0];
m_devices[m_currentDevice].buttonsMap[0x2] = logicalButtons[1];
m_devices[m_currentDevice].buttonsMap[0x4] = logicalButtons[2];
m_devices[m_currentDevice].currentPointerType = pointerType(currentCursor); m_devices[m_currentDevice].currentPointerType = pointerType(currentCursor);
m_state = PenProximity; m_state = PenProximity;
qCDebug(lcQpaTablet) << "enter proximity for device #" qCDebug(lcQpaTablet) << "enter proximity for device #"
@ -446,6 +467,52 @@ bool QWindowsTabletSupport::translateTabletProximityEvent(WPARAM /* wParam */, L
return true; return true;
} }
Qt::MouseButton buttonValueToEnum(DWORD button,
const QWindowsTabletDeviceData &tdd) {
enum : unsigned {
leftButtonValue = 0x1,
middleButtonValue = 0x2,
rightButtonValue = 0x4,
doubleClickButtonValue = 0x7
};
button = tdd.buttonsMap.value(button);
return button == leftButtonValue ? Qt::LeftButton :
button == rightButtonValue ? Qt::RightButton :
button == doubleClickButtonValue ? Qt::MiddleButton :
button == middleButtonValue ? Qt::MiddleButton :
button ? Qt::LeftButton /* fallback item */ :
Qt::NoButton;
}
Qt::MouseButtons convertTabletButtons(DWORD btnNew,
const QWindowsTabletDeviceData &tdd) {
Qt::MouseButtons buttons = Qt::NoButton;
for (unsigned int i = 0; i < 3; i++) {
unsigned int btn = 0x1 << i;
if (btn & btnNew) {
Qt::MouseButton convertedButton =
buttonValueToEnum(btn, tdd);
buttons |= convertedButton;
/**
* If a button that is present in hardware input is
* mapped to a Qt::NoButton, it means that it is going
* to be eaten by the driver, for example by its
* "Pan/Scroll" feature. Therefore we shouldn't handle
* any of the events associated to it. We'll just return
* Qt::NoButtons here.
*/
}
}
return buttons;
}
bool QWindowsTabletSupport::translateTabletPacketEvent() bool QWindowsTabletSupport::translateTabletPacketEvent()
{ {
static PACKET localPacketBuf[TabletPacketQSize]; // our own tablet packet queue. static PACKET localPacketBuf[TabletPacketQSize]; // our own tablet packet queue.
@ -552,9 +619,12 @@ bool QWindowsTabletSupport::translateTabletPacketEvent()
<< tiltY << "tanP:" << tangentialPressure << "rotation:" << rotation; << tiltY << "tanP:" << tangentialPressure << "rotation:" << rotation;
} }
Qt::MouseButtons buttons =
convertTabletButtons(packet.pkButtons, m_devices.at(m_currentDevice));
QWindowSystemInterface::handleTabletEvent(target, packet.pkTime, QPointF(localPos), globalPosF, QWindowSystemInterface::handleTabletEvent(target, packet.pkTime, QPointF(localPos), globalPosF,
currentDevice, currentPointer, currentDevice, currentPointer,
static_cast<Qt::MouseButtons>(packet.pkButtons), buttons,
pressureNew, tiltX, tiltY, pressureNew, tiltX, tiltY,
tangentialPressure, rotation, z, tangentialPressure, rotation, z,
uniqueId, uniqueId,

View File

@ -45,6 +45,7 @@
#include <QtCore/qvector.h> #include <QtCore/qvector.h>
#include <QtCore/qpoint.h> #include <QtCore/qpoint.h>
#include <QtCore/qhash.h>
#include <wintab.h> #include <wintab.h>
@ -100,6 +101,7 @@ struct QWindowsTabletDeviceData
qint64 uniqueId = 0; qint64 uniqueId = 0;
int currentDevice = 0; int currentDevice = 0;
int currentPointerType = 0; int currentPointerType = 0;
QHash<quint8, quint8> buttonsMap;
}; };
#ifndef QT_NO_DEBUG_STREAM #ifndef QT_NO_DEBUG_STREAM

View File

@ -1876,6 +1876,9 @@ bool QWindowsWindow::handleWmPaint(HWND hwnd, UINT message,
{ {
if (message == WM_ERASEBKGND) // Backing store - ignored. if (message == WM_ERASEBKGND) // Backing store - ignored.
return true; return true;
// QTBUG-75455: Suppress WM_PAINT sent to invisible windows when setting WS_EX_LAYERED
if (!window()->isVisible() && (GetWindowLong(hwnd, GWL_EXSTYLE) & WS_EX_LAYERED) != 0)
return false;
// Ignore invalid update bounding rectangles // Ignore invalid update bounding rectangles
RECT updateRect; RECT updateRect;
if (!GetUpdateRect(m_data.hwnd, &updateRect, FALSE)) if (!GetUpdateRect(m_data.hwnd, &updateRect, FALSE))

View File

@ -240,6 +240,10 @@ void QXcbConnection::xi2SetupDevice(void *info, bool removeExisting)
} else if (name.contains("uc-logic") && isTablet) { } else if (name.contains("uc-logic") && isTablet) {
tabletData.pointerType = QTabletEvent::Pen; tabletData.pointerType = QTabletEvent::Pen;
dbgType = QLatin1String("pen"); dbgType = QLatin1String("pen");
} else if (name.contains("ugee")) {
isTablet = true;
tabletData.pointerType = QTabletEvent::Pen;
dbgType = QLatin1String("pen");
} else { } else {
isTablet = false; isTablet = false;
} }

View File

@ -454,6 +454,13 @@ QAccessible::Role QAccessibleDisplay::role() const
return QAccessibleWidget::role(); return QAccessibleWidget::role();
} }
QAccessible::State QAccessibleDisplay::state() const
{
QAccessible::State s = QAccessibleWidget::state();
s.readOnly = true;
return s;
}
QString QAccessibleDisplay::text(QAccessible::Text t) const QString QAccessibleDisplay::text(QAccessible::Text t) const
{ {
QString str; QString str;
@ -732,10 +739,9 @@ QAccessible::State QAccessibleLineEdit::state() const
QAccessible::State state = QAccessibleWidget::state(); QAccessible::State state = QAccessibleWidget::state();
QLineEdit *l = lineEdit(); QLineEdit *l = lineEdit();
state.editable = true;
if (l->isReadOnly()) if (l->isReadOnly())
state.readOnly = true; state.readOnly = true;
else
state.editable = true;
if (l->echoMode() != QLineEdit::Normal) if (l->echoMode() != QLineEdit::Normal)
state.passwordEdit = true; state.passwordEdit = true;

View File

@ -116,6 +116,7 @@ public:
QString text(QAccessible::Text t) const override; QString text(QAccessible::Text t) const override;
QAccessible::Role role() const override; QAccessible::Role role() const override;
QAccessible::State state() const override;
QVector<QPair<QAccessibleInterface*, QAccessible::Relation> >relations(QAccessible::Relation match = QAccessible::AllRelations) const override; QVector<QPair<QAccessibleInterface*, QAccessible::Relation> >relations(QAccessible::Relation match = QAccessible::AllRelations) const override;
void *interface_cast(QAccessible::InterfaceType t) override; void *interface_cast(QAccessible::InterfaceType t) override;

View File

@ -1197,8 +1197,8 @@ QStringList QFileSystemModel::mimeTypes() const
\a indexes. The format used to describe the items corresponding to the \a indexes. The format used to describe the items corresponding to the
indexes is obtained from the mimeTypes() function. indexes is obtained from the mimeTypes() function.
If the list of indexes is empty, 0 is returned rather than a serialized If the list of indexes is empty, \nullptr is returned rather than a
empty list. serialized empty list.
*/ */
QMimeData *QFileSystemModel::mimeData(const QModelIndexList &indexes) const QMimeData *QFileSystemModel::mimeData(const QModelIndexList &indexes) const
{ {

View File

@ -1902,8 +1902,8 @@ QStringList QListWidget::mimeTypes() const
\a items. The format used to describe the items is obtained from the \a items. The format used to describe the items is obtained from the
mimeTypes() function. mimeTypes() function.
If the list of items is empty, 0 is returned instead of a serialized empty If the list of items is empty, \nullptr is returned instead of a
list. serialized empty list.
*/ */
#if QT_VERSION >= QT_VERSION_CHECK(6,0,0) #if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
QMimeData *QListWidget::mimeData(const QList<QListWidgetItem *> &items) const QMimeData *QListWidget::mimeData(const QList<QListWidgetItem *> &items) const

View File

@ -2633,8 +2633,8 @@ QStringList QTableWidget::mimeTypes() const
\a items. The format used to describe the items is obtained from the \a items. The format used to describe the items is obtained from the
mimeTypes() function. mimeTypes() function.
If the list of items is empty, 0 is returned rather than a serialized If the list of items is empty, \nullptr is returned rather than a
empty list. serialized empty list.
*/ */
#if QT_VERSION >= QT_VERSION_CHECK(6,0,0) #if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
QMimeData *QTableWidget::mimeData(const QList<QTableWidgetItem *> &items) const QMimeData *QTableWidget::mimeData(const QList<QTableWidgetItem *> &items) const

View File

@ -3395,8 +3395,8 @@ QStringList QTreeWidget::mimeTypes() const
\a items. The format used to describe the items is obtained from the \a items. The format used to describe the items is obtained from the
mimeTypes() function. mimeTypes() function.
If the list of items is empty, 0 is returned rather than a serialized If the list of items is empty, \nullptr is returned rather than a
empty list. serialized empty list.
*/ */
#if QT_VERSION >= QT_VERSION_CHECK(6,0,0) #if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
QMimeData *QTreeWidget::mimeData(const QList<QTreeWidgetItem *> &items) const QMimeData *QTreeWidget::mimeData(const QList<QTreeWidgetItem *> &items) const

View File

@ -170,7 +170,7 @@ QTreeWidgetItemIterator &QTreeWidgetItemIterator::operator=(const QTreeWidgetIte
/*! /*!
The prefix ++ operator (++it) advances the iterator to the next matching item The prefix ++ operator (++it) advances the iterator to the next matching item
and returns a reference to the resulting iterator. and returns a reference to the resulting iterator.
Sets the current pointer to 0 if the current item is the last matching item. Sets the current pointer to \nullptr if the current item is the last matching item.
*/ */
QTreeWidgetItemIterator &QTreeWidgetItemIterator::operator++() QTreeWidgetItemIterator &QTreeWidgetItemIterator::operator++()
@ -185,7 +185,7 @@ QTreeWidgetItemIterator &QTreeWidgetItemIterator::operator++()
/*! /*!
The prefix -- operator (--it) advances the iterator to the previous matching item The prefix -- operator (--it) advances the iterator to the previous matching item
and returns a reference to the resulting iterator. and returns a reference to the resulting iterator.
Sets the current pointer to 0 if the current item is the first matching item. Sets the current pointer to \nullptr if the current item is the first matching item.
*/ */
QTreeWidgetItemIterator &QTreeWidgetItemIterator::operator--() QTreeWidgetItemIterator &QTreeWidgetItemIterator::operator--()
@ -395,7 +395,7 @@ void QTreeWidgetItemIteratorPrivate::ensureValidIterator(const QTreeWidgetItem *
iterator goes backward.) iterator goes backward.)
If the current item is beyond the last item, the current item pointer is If the current item is beyond the last item, the current item pointer is
set to 0. Returns the resulting iterator. set to \nullptr. Returns the resulting iterator.
*/ */
/*! /*!
@ -411,7 +411,7 @@ void QTreeWidgetItemIteratorPrivate::ensureValidIterator(const QTreeWidgetItem *
iterator goes forward.) iterator goes forward.)
If the current item is ahead of the last item, the current item pointer is If the current item is ahead of the last item, the current item pointer is
set to 0. Returns the resulting iterator. set to \nullptr. Returns the resulting iterator.
*/ */
/*! /*!

View File

@ -1900,8 +1900,8 @@ void QApplication::aboutQt()
This signal is emitted when the widget that has keyboard focus changed from This signal is emitted when the widget that has keyboard focus changed from
\a old to \a now, i.e., because the user pressed the tab-key, clicked into \a old to \a now, i.e., because the user pressed the tab-key, clicked into
a widget or changed the active window. Both \a old and \a now can be the a widget or changed the active window. Both \a old and \a now can be \nullptr.
null-pointer.
The signal is emitted after both widget have been notified about the change The signal is emitted after both widget have been notified about the change
through QFocusEvent. through QFocusEvent.

View File

@ -109,7 +109,7 @@ static int menuBarHeightForWidth(QWidget *menubar, int w)
/*! /*!
Constructs a new top-level QLayout, with parent \a parent. Constructs a new top-level QLayout, with parent \a parent.
\a parent may not be a \nullptr. \a parent may not be \nullptr.
The layout is set directly as the top-level layout for The layout is set directly as the top-level layout for
\a parent. There can be only one top-level layout for a \a parent. There can be only one top-level layout for a
@ -419,9 +419,9 @@ void QLayout::setContentsMargins(const QMargins &margins)
/*! /*!
\since 4.3 \since 4.3
Extracts the left, top, right, and bottom margins used around the For each of \a left, \a top, \a right and \a bottom that is not
layout, and assigns them to *\a left, *\a top, *\a right, and *\a \nullptr, stores the size of the margin named in the location the
bottom (unless they are null pointers). pointer refers to.
By default, QLayout uses the values provided by the style. On By default, QLayout uses the values provided by the style. On
most platforms, the margin is 11 pixels in all directions. most platforms, the margin is 11 pixels in all directions.

View File

@ -4170,12 +4170,12 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q
if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(opt)) { if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(opt)) {
QRenderRule subRule = renderRule(w, opt, PseudoElement_TabBarTab); QRenderRule subRule = renderRule(w, opt, PseudoElement_TabBarTab);
QRect r = positionRect(w, subRule, PseudoElement_TabBarTab, opt->rect, opt->direction); QRect r = positionRect(w, subRule, PseudoElement_TabBarTab, opt->rect, opt->direction);
if (ce == CE_TabBarTabShape && subRule.hasDrawable()) { if (ce == CE_TabBarTabShape && subRule.hasDrawable() && tab->shape < QTabBar::TriangularNorth) {
subRule.drawRule(p, r); subRule.drawRule(p, r);
return; return;
} }
QStyleOptionTab tabCopy(*tab); QStyleOptionTab tabCopy(*tab);
subRule.configurePalette(&tabCopy.palette, QPalette::WindowText, QPalette::Window); subRule.configurePalette(&tabCopy.palette, QPalette::WindowText, QPalette::Base);
QFont oldFont = p->font(); QFont oldFont = p->font();
if (subRule.hasFont) if (subRule.hasFont)
p->setFont(subRule.font); p->setFont(subRule.font);

View File

@ -361,7 +361,7 @@ QUndoStack *QUndoView::stack() const
Sets the stack displayed by this view to \a stack. If \a stack is 0, the view Sets the stack displayed by this view to \a stack. If \a stack is 0, the view
will be empty. will be empty.
If the view was previously looking at a QUndoGroup, the group is set to 0. If the view was previously looking at a QUndoGroup, the group is set to \nullptr.
\sa stack(), setGroup() \sa stack(), setGroup()
*/ */

View File

@ -1369,6 +1369,12 @@ void QLineEdit::setReadOnly(bool enable)
QEvent event(QEvent::ReadOnlyChange); QEvent event(QEvent::ReadOnlyChange);
QCoreApplication::sendEvent(this, &event); QCoreApplication::sendEvent(this, &event);
update(); update();
#ifndef QT_NO_ACCESSIBILITY
QAccessible::State changedState;
changedState.readOnly = true;
QAccessibleStateChangeEvent ev(this, changedState);
QAccessible::updateAccessibility(&ev);
#endif
} }
} }

View File

@ -596,7 +596,7 @@ QStatusBar *QMainWindow::statusBar() const
/*! /*!
Sets the status bar for the main window to \a statusbar. Sets the status bar for the main window to \a statusbar.
Setting the status bar to 0 will remove it from the main window. Setting the status bar to \nullptr will remove it from the main window.
Note that QMainWindow takes ownership of the \a statusbar pointer Note that QMainWindow takes ownership of the \a statusbar pointer
and deletes it at the appropriate time. and deletes it at the appropriate time.
@ -1464,8 +1464,8 @@ void QMainWindow::contextMenuEvent(QContextMenuEvent *event)
#if QT_CONFIG(menu) #if QT_CONFIG(menu)
/*! /*!
Returns a popup menu containing checkable entries for the toolbars and Returns a popup menu containing checkable entries for the toolbars and
dock widgets present in the main window. If there are no toolbars and dock widgets present in the main window. If there are no toolbars and
dock widgets present, this function returns a null pointer. dock widgets present, this function returns \nullptr.
By default, this function is called by the main window when the user By default, this function is called by the main window when the user
activates a context menu, typically by right-clicking on a toolbar or a dock activates a context menu, typically by right-clicking on a toolbar or a dock

View File

@ -2000,9 +2000,9 @@ QMdiSubWindow *QMdiArea::addSubWindow(QWidget *widget, Qt::WindowFlags windowFla
Removes \a widget from the MDI area. The \a widget must be Removes \a widget from the MDI area. The \a widget must be
either a QMdiSubWindow or a widget that is the internal widget of either a QMdiSubWindow or a widget that is the internal widget of
a subwindow. Note \a widget is never actually deleted by QMdiArea. a subwindow. Note \a widget is never actually deleted by QMdiArea.
If a QMdiSubWindow is passed in its parent is set to 0 and it is If a QMdiSubWindow is passed in, its parent is set to \nullptr and it is
removed, but if an internal widget is passed in the child widget removed; but if an internal widget is passed in, the child widget
is set to 0 but the QMdiSubWindow is not removed. is set to \nullptr and the QMdiSubWindow is \e not removed.
\sa addSubWindow() \sa addSubWindow()
*/ */

View File

@ -897,8 +897,8 @@ QAction *QMenuBar::insertMenu(QAction *before, QMenu *menu)
} }
/*! /*!
Returns the QAction that is currently highlighted. A null pointer Returns the QAction that is currently highlighted, if any,
will be returned if no action is currently selected. else \nullptr.
*/ */
QAction *QMenuBar::activeAction() const QAction *QMenuBar::activeAction() const
{ {

View File

@ -1985,6 +1985,8 @@ void QWidgetTextControlPrivate::inputMethodEvent(QInputMethodEvent *e)
|| e->preeditString() != cursor.block().layout()->preeditAreaText() || e->preeditString() != cursor.block().layout()->preeditAreaText()
|| e->replacementLength() > 0; || e->replacementLength() > 0;
int oldCursorPos = cursor.position();
cursor.beginEditBlock(); cursor.beginEditBlock();
if (isGettingInput) { if (isGettingInput) {
cursor.removeSelectedText(); cursor.removeSelectedText();
@ -2089,6 +2091,8 @@ void QWidgetTextControlPrivate::inputMethodEvent(QInputMethodEvent *e)
if (cursor.d) if (cursor.d)
cursor.d->setX(); cursor.d->setX();
if (oldCursorPos != cursor.position())
emit q->cursorPositionChanged();
if (oldPreeditCursor != preeditCursor) if (oldPreeditCursor != preeditCursor)
emit q->microFocusChanged(); emit q->microFocusChanged();
} }

View File

@ -1951,7 +1951,7 @@ void QDomNodePrivate::setLocation(int lineNumber, int columnNumber)
which return a QDomNode, e.g. firstChild(). You can make an which return a QDomNode, e.g. firstChild(). You can make an
independent (deep) copy of the node with cloneNode(). independent (deep) copy of the node with cloneNode().
A QDomNode can be null, much like a null pointer. Creating a copy A QDomNode can be null, much like \nullptr. Creating a copy
of a null node results in another null node. It is not of a null node results in another null node. It is not
possible to modify a null node, but it is possible to assign another, possible to modify a null node, but it is possible to assign another,
possibly non-null node to it. In this case, the copy of the null node possibly non-null node to it. In this case, the copy of the null node

View File

@ -2371,7 +2371,7 @@ bool QXmlDefaultHandler::unparsedEntityDecl(const QString&, const QString&,
/*! /*!
\reimp \reimp
Sets \a ret to 0, so that the reader uses the system identifier Sets \a ret to \nullptr, so that the reader uses the system identifier
provided in the XML document. provided in the XML document.
*/ */
bool QXmlDefaultHandler::resolveEntity(const QString&, const QString&, bool QXmlDefaultHandler::resolveEntity(const QString&, const QString&,

View File

@ -29,6 +29,7 @@
#include <QtCore/QString> #include <QtCore/QString>
#include <QtCore/QTime> #include <QtCore/QTime>
#include <QtCore/QDeadlineTimer> #include <QtCore/QDeadlineTimer>
#include <QtCore/QElapsedTimer>
#include <QtTest/QtTest> #include <QtTest/QtTest>
#if QT_HAS_INCLUDE(<chrono>) #if QT_HAS_INCLUDE(<chrono>)
@ -50,6 +51,7 @@ private Q_SLOTS:
void current(); void current();
void deadlines(); void deadlines();
void setDeadline(); void setDeadline();
void overflow();
void expire(); void expire();
void stdchrono(); void stdchrono();
}; };
@ -417,6 +419,83 @@ void tst_QDeadlineTimer::setDeadline()
QCOMPARE(deadline.deadlineNSecs(), nsec); QCOMPARE(deadline.deadlineNSecs(), nsec);
} }
void tst_QDeadlineTimer::overflow()
{
QFETCH_GLOBAL(Qt::TimerType, timerType);
// Check the constructor for overflows (should also cover saturating the result of the deadline() method if overflowing)
QDeadlineTimer now = QDeadlineTimer::current(timerType), deadline(std::numeric_limits<qint64>::max() - 1, timerType);
QVERIFY(deadline.isForever() || deadline.deadline() >= now.deadline());
// Check the setDeadline with milliseconds (should also cover implicitly setting the nanoseconds as qint64 max)
deadline.setDeadline(std::numeric_limits<qint64>::max() - 1, timerType);
QVERIFY(deadline.isForever() || deadline.deadline() >= now.deadline());
// Check the setRemainingTime with milliseconds (should also cover implicitly setting the nanoseconds as qint64 max)
deadline.setRemainingTime(std::numeric_limits<qint64>::max() - 1, timerType);
QVERIFY(deadline.isForever() || deadline.deadline() >= now.deadline());
// Check that the deadline gets saturated when the arguments of setPreciseDeadline are large
deadline.setPreciseDeadline(std::numeric_limits<qint64>::max() - 1, std::numeric_limits<qint64>::max() - 1, timerType);
QCOMPARE(deadline.deadline(), std::numeric_limits<qint64>::max());
QVERIFY(deadline.isForever());
// Check that remainingTime gets saturated if we overflow
deadline.setPreciseRemainingTime(std::numeric_limits<qint64>::max() - 1, std::numeric_limits<qint64>::max() - 1, timerType);
QCOMPARE(deadline.remainingTime(), qint64(-1));
QVERIFY(deadline.isForever());
// Check that we saturate the getter for nanoseconds
deadline.setPreciseDeadline(std::numeric_limits<qint64>::max() - 1, 0, timerType);
QCOMPARE(deadline.deadlineNSecs(), std::numeric_limits<qint64>::max());
// Check that adding nanoseconds and overflowing is consistent and saturates the timer
deadline = QDeadlineTimer::addNSecs(deadline, std::numeric_limits<qint64>::max() - 1);
QVERIFY(deadline.isForever());
// Make sure forever is forever, regardless of us subtracting time from it
deadline = QDeadlineTimer(QDeadlineTimer::Forever, timerType);
deadline = QDeadlineTimer::addNSecs(deadline, -10000);
QVERIFY(deadline.isForever());
// Make sure we get the correct result when moving the deadline back and forth in time
QDeadlineTimer current = QDeadlineTimer::current(timerType);
QDeadlineTimer takenNSecs = QDeadlineTimer::addNSecs(current, -1000);
QVERIFY(takenNSecs.deadlineNSecs() - current.deadlineNSecs() == -1000);
QDeadlineTimer addedNSecs = QDeadlineTimer::addNSecs(current, 1000);
QVERIFY(addedNSecs.deadlineNSecs() - current.deadlineNSecs() == 1000);
// Make sure the calculation goes as expected when we need to subtract nanoseconds
// We make use of an additional timer to be certain that
// even when the environment is under load we can track the
// time needed to do the calls
static constexpr qint64 nsExpected = 1000 * 1000 * 1000 - 1000; // 1s - 1000ns, what we pass to setPreciseRemainingTime() later
QElapsedTimer callTimer;
callTimer.start();
deadline = QDeadlineTimer::current(timerType);
qint64 nsDeadline = deadline.deadlineNSecs();
// We adjust in relation to current() here, so we expect the difference to be a tad over the exact number.
// However we are tracking the elapsed time, so it shouldn't be a problem.
deadline.setPreciseRemainingTime(1, -1000, timerType);
qint64 difference = (deadline.deadlineNSecs() - nsDeadline) - nsExpected;
QVERIFY(difference >= 0); // Should always be true, but just in case
QVERIFY(difference <= callTimer.nsecsElapsed()); // Ideally difference should be 0 exactly
// Make sure setRemainingTime underflows gracefully
deadline.setPreciseRemainingTime(std::numeric_limits<qint64>::min() / 10, 0, timerType);
QVERIFY(!deadline.isForever()); // On Win/macOS the above underflows, make sure we don't saturate to Forever
QVERIFY(deadline.remainingTime() == 0);
// If the timer is saturated we don't want to get a valid number of milliseconds
QVERIFY(deadline.deadline() == std::numeric_limits<qint64>::min());
// Check that the conversion to milliseconds and nanoseconds underflows gracefully
deadline.setPreciseDeadline(std::numeric_limits<qint64>::min() / 10, 0, timerType);
QVERIFY(!deadline.isForever()); // On Win/macOS the above underflows, make sure we don't saturate to Forever
QVERIFY(deadline.deadline() == std::numeric_limits<qint64>::min());
QVERIFY(deadline.deadlineNSecs() == std::numeric_limits<qint64>::min());
}
void tst_QDeadlineTimer::expire() void tst_QDeadlineTimer::expire()
{ {
QFETCH_GLOBAL(Qt::TimerType, timerType); QFETCH_GLOBAL(Qt::TimerType, timerType);

View File

@ -2458,9 +2458,9 @@ void tst_QLocale::timeFormat()
QCOMPARE(c.timeFormat(QLocale::NarrowFormat), c.timeFormat(QLocale::ShortFormat)); QCOMPARE(c.timeFormat(QLocale::NarrowFormat), c.timeFormat(QLocale::ShortFormat));
const QLocale no("no_NO"); const QLocale no("no_NO");
QCOMPARE(no.timeFormat(QLocale::NarrowFormat), QLatin1String("HH:mm")); QCOMPARE(no.timeFormat(QLocale::NarrowFormat), QLatin1String("HH.mm"));
QCOMPARE(no.timeFormat(QLocale::ShortFormat), QLatin1String("HH:mm")); QCOMPARE(no.timeFormat(QLocale::ShortFormat), QLatin1String("HH.mm"));
QCOMPARE(no.timeFormat(QLocale::LongFormat), QLatin1String("HH:mm:ss t")); QCOMPARE(no.timeFormat(QLocale::LongFormat), QLatin1String("HH.mm.ss t"));
const QLocale id("id_ID"); const QLocale id("id_ID");
QCOMPARE(id.timeFormat(QLocale::ShortFormat), QLatin1String("HH.mm")); QCOMPARE(id.timeFormat(QLocale::ShortFormat), QLatin1String("HH.mm"));
@ -2482,9 +2482,9 @@ void tst_QLocale::dateTimeFormat()
QCOMPARE(c.dateTimeFormat(QLocale::NarrowFormat), c.dateTimeFormat(QLocale::ShortFormat)); QCOMPARE(c.dateTimeFormat(QLocale::NarrowFormat), c.dateTimeFormat(QLocale::ShortFormat));
const QLocale no("no_NO"); const QLocale no("no_NO");
QCOMPARE(no.dateTimeFormat(QLocale::NarrowFormat), QLatin1String("dd.MM.yyyy HH:mm")); QCOMPARE(no.dateTimeFormat(QLocale::NarrowFormat), QLatin1String("dd.MM.yyyy HH.mm"));
QCOMPARE(no.dateTimeFormat(QLocale::ShortFormat), QLatin1String("dd.MM.yyyy HH:mm")); QCOMPARE(no.dateTimeFormat(QLocale::ShortFormat), QLatin1String("dd.MM.yyyy HH.mm"));
QCOMPARE(no.dateTimeFormat(QLocale::LongFormat), QLatin1String("dddd d. MMMM yyyy HH:mm:ss t")); QCOMPARE(no.dateTimeFormat(QLocale::LongFormat), QLatin1String("dddd d. MMMM yyyy HH.mm.ss t"));
} }
void tst_QLocale::monthName() void tst_QLocale::monthName()

View File

@ -0,0 +1,3 @@
[systemFixedFont] # QTBUG-54623
winrt
b2qt

View File

@ -35,6 +35,8 @@
#include <private/qrawfont_p.h> #include <private/qrawfont_p.h>
#include <qpa/qplatformfontdatabase.h> #include <qpa/qplatformfontdatabase.h>
Q_LOGGING_CATEGORY(lcTests, "qt.text.tests")
class tst_QFontDatabase : public QObject class tst_QFontDatabase : public QObject
{ {
Q_OBJECT Q_OBJECT
@ -49,6 +51,7 @@ private slots:
void fixedPitch_data(); void fixedPitch_data();
void fixedPitch(); void fixedPitch();
void systemFixedFont();
#ifdef Q_OS_MAC #ifdef Q_OS_MAC
void trickyFonts_data(); void trickyFonts_data();
@ -156,6 +159,16 @@ void tst_QFontDatabase::fixedPitch()
QCOMPARE(fi.fixedPitch(), fixedPitch); QCOMPARE(fi.fixedPitch(), fixedPitch);
} }
void tst_QFontDatabase::systemFixedFont() // QTBUG-54623
{
QFont font = QFontDatabase::systemFont(QFontDatabase::FixedFont);
QFontInfo fontInfo(font);
bool fdbSaysFixed = QFontDatabase().isFixedPitch(fontInfo.family(), fontInfo.styleName());
qCDebug(lcTests) << "system fixed font is" << font << "really fixed?" << fdbSaysFixed << fontInfo.fixedPitch();
QVERIFY(fdbSaysFixed);
QVERIFY(fontInfo.fixedPitch());
}
#ifdef Q_OS_MAC #ifdef Q_OS_MAC
void tst_QFontDatabase::trickyFonts_data() void tst_QFontDatabase::trickyFonts_data()
{ {

View File

@ -2045,6 +2045,15 @@ void tst_QAccessibility::lineEditTest()
QVERIFY(!iface->state().selectable); QVERIFY(!iface->state().selectable);
QVERIFY(iface->state().selectableText); QVERIFY(iface->state().selectableText);
QVERIFY(!iface->state().hasPopup); QVERIFY(!iface->state().hasPopup);
QVERIFY(!iface->state().readOnly);
QVERIFY(iface->state().editable);
le->setReadOnly(true);
QVERIFY(iface->state().editable);
QVERIFY(iface->state().readOnly);
le->setReadOnly(false);
QVERIFY(!iface->state().readOnly);
QCOMPARE(bool(iface->state().focused), le->hasFocus()); QCOMPARE(bool(iface->state().focused), le->hasFocus());
QString secret(QLatin1String("secret")); QString secret(QLatin1String("secret"));
@ -3640,6 +3649,12 @@ void tst_QAccessibility::labelTest()
QVERIFY(acc_label); QVERIFY(acc_label);
QCOMPARE(acc_label->text(QAccessible::Name), text); QCOMPARE(acc_label->text(QAccessible::Name), text);
QCOMPARE(acc_label->state().editable, false);
QCOMPARE(acc_label->state().passwordEdit, false);
QCOMPARE(acc_label->state().disabled, false);
QCOMPARE(acc_label->state().focused, false);
QCOMPARE(acc_label->state().focusable, false);
QCOMPARE(acc_label->state().readOnly, true);
QVector<QPair<QAccessibleInterface *, QAccessible::Relation> > rels = acc_label->relations(); QVector<QPair<QAccessibleInterface *, QAccessible::Relation> > rels = acc_label->relations();
QCOMPARE(rels.count(), 1); QCOMPARE(rels.count(), 1);

View File

@ -5,3 +5,4 @@ SOURCES += tst_qaccessibilitylinux.cpp
QT += gui-private widgets dbus testlib accessibility_support-private linuxaccessibility_support-private QT += gui-private widgets dbus testlib accessibility_support-private linuxaccessibility_support-private
DBUS_INTERFACES = $$PWD/../../../../src/platformsupport/linuxaccessibility/dbusxml/Bus.xml

View File

@ -42,12 +42,11 @@
#include <QDBusInterface> #include <QDBusInterface>
#include <QDBusReply> #include <QDBusReply>
#include "atspi/atspi-constants.h" #include <atspi/atspi-constants.h>
#include <private/dbusconnection_p.h>
#include <private/struct_marshallers_p.h>
#include "bus_interface.h" #include "bus_interface.h"
#include "dbusconnection_p.h"
#include "struct_marshallers_p.h"
#define COMPARE3(v1, v2, v3) QCOMPARE(v1, v3); QCOMPARE(v2, v3); #define COMPARE3(v1, v2, v3) QCOMPARE(v1, v3); QCOMPARE(v2, v3);
class AccessibleTestWindow : public QWidget class AccessibleTestWindow : public QWidget
@ -251,6 +250,8 @@ void tst_QAccessibilityLinux::testLabel()
QCOMPARE(labelInterface->call(QDBus::Block, "GetRoleName").arguments().first().toString(), QLatin1String("label")); QCOMPARE(labelInterface->call(QDBus::Block, "GetRoleName").arguments().first().toString(), QLatin1String("label"));
QCOMPARE(labelInterface->call(QDBus::Block, "GetRole").arguments().first().toUInt(), 29u); QCOMPARE(labelInterface->call(QDBus::Block, "GetRole").arguments().first().toUInt(), 29u);
QCOMPARE(getParent(labelInterface), mainWindow->path()); QCOMPARE(getParent(labelInterface), mainWindow->path());
QVERIFY(!hasState(labelInterface, ATSPI_STATE_EDITABLE));
QVERIFY(hasState(labelInterface, ATSPI_STATE_READ_ONLY));
l->setText("New text"); l->setText("New text");
QCOMPARE(labelInterface->property("Name").toString(), l->text()); QCOMPARE(labelInterface->property("Name").toString(), l->text());
@ -303,6 +304,12 @@ void tst_QAccessibilityLinux::testLineEdit()
QCOMPARE(lineEdit->selectionStart(), -1); QCOMPARE(lineEdit->selectionStart(), -1);
QCOMPARE(textInterface->call(QDBus::Block, "GetNSelections").arguments().first().toInt(), 0); QCOMPARE(textInterface->call(QDBus::Block, "GetNSelections").arguments().first().toInt(), 0);
QVERIFY(hasState(accessibleInterface, ATSPI_STATE_EDITABLE));
QVERIFY(!hasState(accessibleInterface, ATSPI_STATE_READ_ONLY));
lineEdit->setReadOnly(true);
QVERIFY(hasState(accessibleInterface, ATSPI_STATE_EDITABLE));
QVERIFY(hasState(accessibleInterface, ATSPI_STATE_READ_ONLY));
m_window->clearChildren(); m_window->clearChildren();
delete accessibleInterface; delete accessibleInterface;
delete textInterface; delete textInterface;

View File

@ -11,6 +11,10 @@
<Incident type="pass" file="" line="0" /> <Incident type="pass" file="" line="0" />
<Duration msecs="0"/> <Duration msecs="0"/>
</TestFunction> </TestFunction>
<TestFunction name="wait">
<Incident type="pass" file="" line="0" />
<Duration msecs="0"/>
</TestFunction>
<TestFunction name="cleanupTestCase"> <TestFunction name="cleanupTestCase">
<Incident type="pass" file="" line="0" /> <Incident type="pass" file="" line="0" />
<Duration msecs="0"/> <Duration msecs="0"/>

Some files were not shown because too many files have changed in this diff Show More