summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/corelib/io/qdirentryinfo_p.h2
-rw-r--r--src/corelib/kernel/qproperty.h38
-rw-r--r--src/corelib/kernel/qvariant.cpp5
-rw-r--r--src/corelib/serialization/qxmlstream.cpp12
-rw-r--r--src/corelib/serialization/qxmlstream_p.h2
-rw-r--r--src/corelib/text/qbytearray.cpp9
-rw-r--r--src/corelib/text/qstringlist.cpp2
-rw-r--r--src/gui/itemmodels/qfileinfogatherer.cpp2
-rw-r--r--src/gui/math3d/qquaternion.cpp8
-rw-r--r--src/gui/math3d/qquaternion.h10
-rw-r--r--src/gui/painting/qdatabuffer_p.h10
-rw-r--r--src/gui/painting/qpaintengine_raster_p.h4
-rw-r--r--src/gui/text/qtextformat.cpp11
-rw-r--r--src/tools/moc/moc.cpp7
-rw-r--r--src/tools/moc/moc.h3
15 files changed, 78 insertions, 47 deletions
diff --git a/src/corelib/io/qdirentryinfo_p.h b/src/corelib/io/qdirentryinfo_p.h
index 7ed5391ff04..8864255c425 100644
--- a/src/corelib/io/qdirentryinfo_p.h
+++ b/src/corelib/io/qdirentryinfo_p.h
@@ -148,7 +148,7 @@ private:
QFileSystemEntry entry;
QFileSystemMetaData metaData;
- std::optional<QFileInfo> fileInfoOpt;
+ std::optional<QFileInfo> fileInfoOpt = std::nullopt;
};
QT_END_NAMESPACE
diff --git a/src/corelib/kernel/qproperty.h b/src/corelib/kernel/qproperty.h
index f4e7942e947..a3c4e109adf 100644
--- a/src/corelib/kernel/qproperty.h
+++ b/src/corelib/kernel/qproperty.h
@@ -299,7 +299,7 @@ public:
auto This = static_cast<QPropertyChangeHandler<Functor>*>(self);
This->m_handler();
})
- , m_handler(handler)
+ , m_handler(std::move(handler))
{
}
@@ -310,7 +310,7 @@ public:
auto This = static_cast<QPropertyChangeHandler<Functor>*>(self);
This->m_handler();
})
- , m_handler(handler)
+ , m_handler(std::move(handler))
{
setSource(property);
}
@@ -329,7 +329,7 @@ public:
auto This = static_cast<QPropertyNotifier *>(self);
This->m_handler();
})
- , m_handler(handler)
+ , m_handler(std::move(handler))
{
}
@@ -341,7 +341,7 @@ public:
auto This = static_cast<QPropertyNotifier *>(self);
This->m_handler();
})
- , m_handler(handler)
+ , m_handler(std::move(handler))
{
setSource(property);
}
@@ -516,7 +516,7 @@ public:
QPropertyChangeHandler<Functor> onValueChanged(Functor f)
{
static_assert(std::is_invocable_v<Functor>, "Functor callback must be callable without any parameters");
- return QPropertyChangeHandler<Functor>(*this, f);
+ return QPropertyChangeHandler<Functor>(*this, std::move(f));
}
template<typename Functor>
@@ -524,14 +524,14 @@ public:
{
static_assert(std::is_invocable_v<Functor>, "Functor callback must be callable without any parameters");
f();
- return onValueChanged(f);
+ return onValueChanged(std::move(f));
}
template<typename Functor>
QPropertyNotifier addNotifier(Functor f)
{
static_assert(std::is_invocable_v<Functor>, "Functor callback must be callable without any parameters");
- return QPropertyNotifier(*this, f);
+ return QPropertyNotifier(*this, std::move(f));
}
const QtPrivate::QPropertyBindingData &bindingData() const { return d; }
@@ -785,7 +785,7 @@ public:
template<typename Functor>
QPropertyChangeHandler<Functor> onValueChanged(Functor f) const
{
- QPropertyChangeHandler<Functor> handler(f);
+ QPropertyChangeHandler<Functor> handler(std::move(f));
observe(&handler);
return handler;
}
@@ -794,13 +794,13 @@ public:
QPropertyChangeHandler<Functor> subscribe(Functor f) const
{
f();
- return onValueChanged(f);
+ return onValueChanged(std::move(f));
}
template<typename Functor>
QPropertyNotifier addNotifier(Functor f)
{
- QPropertyNotifier handler(f);
+ QPropertyNotifier handler(std::move(f));
observe(&handler);
return handler;
}
@@ -1046,19 +1046,19 @@ public:
template<typename Functor>
QPropertyChangeHandler<Functor> onValueChanged(Functor f)
{
- return QBindable<T>(aliasedProperty(), iface).onValueChanged(f);
+ return QBindable<T>(aliasedProperty(), iface).onValueChanged(std::move(f));
}
template<typename Functor>
QPropertyChangeHandler<Functor> subscribe(Functor f)
{
- return QBindable<T>(aliasedProperty(), iface).subscribe(f);
+ return QBindable<T>(aliasedProperty(), iface).subscribe(std::move(f));
}
template<typename Functor>
QPropertyNotifier addNotifier(Functor f)
{
- return QBindable<T>(aliasedProperty(), iface).addNotifier(f);
+ return QBindable<T>(aliasedProperty(), iface).addNotifier(std::move(f));
}
bool isValid() const
@@ -1238,7 +1238,7 @@ public:
QPropertyChangeHandler<Functor> onValueChanged(Functor f)
{
static_assert(std::is_invocable_v<Functor>, "Functor callback must be callable without any parameters");
- return QPropertyChangeHandler<Functor>(*this, f);
+ return QPropertyChangeHandler<Functor>(*this, std::move(f));
}
template<typename Functor>
@@ -1246,14 +1246,14 @@ public:
{
static_assert(std::is_invocable_v<Functor>, "Functor callback must be callable without any parameters");
f();
- return onValueChanged(f);
+ return onValueChanged(std::move(f));
}
template<typename Functor>
QPropertyNotifier addNotifier(Functor f)
{
static_assert(std::is_invocable_v<Functor>, "Functor callback must be callable without any parameters");
- return QPropertyNotifier(*this, f);
+ return QPropertyNotifier(*this, std::move(f));
}
const QtPrivate::QPropertyBindingData &bindingData() const
@@ -1386,7 +1386,7 @@ public:
QPropertyChangeHandler<Functor> onValueChanged(Functor f)
{
static_assert(std::is_invocable_v<Functor>, "Functor callback must be callable without any parameters");
- return QPropertyChangeHandler<Functor>(*this, f);
+ return QPropertyChangeHandler<Functor>(*this, std::move(f));
}
template<typename Functor>
@@ -1394,14 +1394,14 @@ public:
{
static_assert(std::is_invocable_v<Functor>, "Functor callback must be callable without any parameters");
f();
- return onValueChanged(f);
+ return onValueChanged(std::move(f));
}
template<typename Functor>
QPropertyNotifier addNotifier(Functor f)
{
static_assert(std::is_invocable_v<Functor>, "Functor callback must be callable without any parameters");
- return QPropertyNotifier(*this, f);
+ return QPropertyNotifier(*this, std::move(f));
}
QtPrivate::QPropertyBindingData &bindingData() const
diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp
index 3a2dcb4a12d..e91797a3ffe 100644
--- a/src/corelib/kernel/qvariant.cpp
+++ b/src/corelib/kernel/qvariant.cpp
@@ -321,11 +321,6 @@ static QVariant::Private clonePrivate(const QVariant::Private &other)
\compares equality
- Because C++ forbids unions from including types that have
- non-default constructors or destructors, most interesting Qt
- classes cannot be used in unions. Without QVariant, this would be
- a problem for QObject::property() and for database work, etc.
-
A QVariant object holds a single value of a single typeId() at a
time. (Some types are multi-valued, for example a string list.)
You can find out what type, T, the variant holds, convert it to a
diff --git a/src/corelib/serialization/qxmlstream.cpp b/src/corelib/serialization/qxmlstream.cpp
index ad9e1089bfe..b4751d1324f 100644
--- a/src/corelib/serialization/qxmlstream.cpp
+++ b/src/corelib/serialization/qxmlstream.cpp
@@ -1081,10 +1081,12 @@ void QXmlStreamReaderPrivate::parseEntity(const QString &value)
inline void QXmlStreamReaderPrivate::reallocateStack()
{
stack_size <<= 1;
- sym_stack = reinterpret_cast<Value*> (realloc(sym_stack, stack_size * sizeof(Value)));
- Q_CHECK_PTR(sym_stack);
- state_stack = reinterpret_cast<int*> (realloc(state_stack, stack_size * sizeof(int)));
- Q_CHECK_PTR(state_stack);
+ void *p = realloc(sym_stack, stack_size * sizeof(Value));
+ Q_CHECK_PTR(p);
+ sym_stack = static_cast<Value*>(p);
+ p = realloc(state_stack, stack_size * sizeof(int));
+ Q_CHECK_PTR(p);
+ state_stack = static_cast<int*>(p);
}
@@ -2036,7 +2038,7 @@ void QXmlStreamReaderPrivate::startDocument()
// unspecified (i.e. System) encoding.
QString buf = decoder(QByteArrayView(rawReadBuffer).first(nbytesread));
if (!decoder.hasError())
- readBuffer = buf;
+ readBuffer = std::move(buf);
}
}
}
diff --git a/src/corelib/serialization/qxmlstream_p.h b/src/corelib/serialization/qxmlstream_p.h
index 4bba6bcc765..bd8770200db 100644
--- a/src/corelib/serialization/qxmlstream_p.h
+++ b/src/corelib/serialization/qxmlstream_p.h
@@ -140,8 +140,8 @@ public:
if (tos + extraCapacity + 1 > cap) {
cap = qMax(tos + extraCapacity + 1, cap << 1 );
void *ptr = realloc(static_cast<void *>(data), cap * sizeof(T));
+ Q_CHECK_PTR(ptr);
data = reinterpret_cast<T *>(ptr);
- Q_CHECK_PTR(data);
}
}
diff --git a/src/corelib/text/qbytearray.cpp b/src/corelib/text/qbytearray.cpp
index d518a2f28f2..3e27f0260d3 100644
--- a/src/corelib/text/qbytearray.cpp
+++ b/src/corelib/text/qbytearray.cpp
@@ -1889,6 +1889,15 @@ QByteArray::QByteArray(qsizetype size, Qt::Initialization)
}
/*!
+ \fn QByteArray::QByteArray(QByteArrayView v)
+ \since 6.8
+
+ Constructs a byte array initialized with the byte array view's data.
+
+ The QByteArray will be null if and only if \a v is null.
+*/
+
+/*!
Sets the size of the byte array to \a size bytes.
If \a size is greater than the current size, the byte array is
diff --git a/src/corelib/text/qstringlist.cpp b/src/corelib/text/qstringlist.cpp
index bb9cf2f0c9f..e6f85849f27 100644
--- a/src/corelib/text/qstringlist.cpp
+++ b/src/corelib/text/qstringlist.cpp
@@ -48,7 +48,7 @@ QT_BEGIN_NAMESPACE
\reentrant
- QStringList inherits from QList<QString>. Like QList, QStringList is
+ QStringList is actually just a QList<QString>. Like QList, QStringList is
\l{implicitly shared}. It provides fast index-based access as well as fast
insertions and removals. Passing string lists as value parameters is both
fast and safe.
diff --git a/src/gui/itemmodels/qfileinfogatherer.cpp b/src/gui/itemmodels/qfileinfogatherer.cpp
index a0192c99828..df43f53050a 100644
--- a/src/gui/itemmodels/qfileinfogatherer.cpp
+++ b/src/gui/itemmodels/qfileinfogatherer.cpp
@@ -149,6 +149,8 @@ void QFileInfoGatherer::fetchExtendedInformation(const QString &path, const QStr
while ((loc = this->path.lastIndexOf(path, loc - 1)) != -1) {
if (this->files.at(loc) == files)
return;
+ if (loc == 0)
+ break;
}
#if QT_CONFIG(thread)
diff --git a/src/gui/math3d/qquaternion.cpp b/src/gui/math3d/qquaternion.cpp
index edbe507e93d..72a01554750 100644
--- a/src/gui/math3d/qquaternion.cpp
+++ b/src/gui/math3d/qquaternion.cpp
@@ -427,13 +427,13 @@ QQuaternion QQuaternion::fromAxisAndAngle
*/
/*!
- \fn QQuaternion QQuaternion::fromEulerAngles(const QVector3D &eulerAngles)
+ \fn QQuaternion QQuaternion::fromEulerAngles(const QVector3D &angles)
\since 5.5
\overload
- Creates a quaternion that corresponds to a rotation of \a eulerAngles:
- eulerAngles.z() degrees around the z axis, eulerAngles.x() degrees around the x axis,
- and eulerAngles.y() degrees around the y axis (in that order).
+ Creates a quaternion that corresponds to a rotation of \a angles:
+ angles.z() degrees around the z axis, angles.x() degrees around the x axis,
+ and angles.y() degrees around the y axis (in that order).
\sa toEulerAngles()
*/
diff --git a/src/gui/math3d/qquaternion.h b/src/gui/math3d/qquaternion.h
index 7fb153063c5..0ea844ae41f 100644
--- a/src/gui/math3d/qquaternion.h
+++ b/src/gui/math3d/qquaternion.h
@@ -109,7 +109,7 @@ QT_WARNING_POP
#ifndef QT_NO_VECTOR3D
inline QVector3D toEulerAngles() const;
- static inline QQuaternion fromEulerAngles(const QVector3D &eulerAngles);
+ static inline QQuaternion fromEulerAngles(const QVector3D &angles);
#endif
QT7_ONLY(Q_GUI_EXPORT) void getEulerAngles(float *pitch, float *yaw, float *roll) const;
QT7_ONLY(Q_GUI_EXPORT) static QQuaternion fromEulerAngles(float pitch, float yaw, float roll);
@@ -311,23 +311,23 @@ inline QVector3D operator*(const QQuaternion &quaternion, const QVector3D &vec)
return quaternion.rotatedVector(vec);
}
-inline void QQuaternion::getAxisAndAngle(QVector3D *axis, float *angle) const
+void QQuaternion::getAxisAndAngle(QVector3D *axis, float *angle) const
{
float aX, aY, aZ;
getAxisAndAngle(&aX, &aY, &aZ, angle);
*axis = QVector3D(aX, aY, aZ);
}
-inline QVector3D QQuaternion::toEulerAngles() const
+QVector3D QQuaternion::toEulerAngles() const
{
float pitch, yaw, roll;
getEulerAngles(&pitch, &yaw, &roll);
return QVector3D(pitch, yaw, roll);
}
-inline QQuaternion QQuaternion::fromEulerAngles(const QVector3D &eulerAngles)
+QQuaternion QQuaternion::fromEulerAngles(const QVector3D &angles)
{
- return QQuaternion::fromEulerAngles(eulerAngles.x(), eulerAngles.y(), eulerAngles.z());
+ return QQuaternion::fromEulerAngles(angles.x(), angles.y(), angles.z());
}
#endif // QT_NO_VECTOR3D
diff --git a/src/gui/painting/qdatabuffer_p.h b/src/gui/painting/qdatabuffer_p.h
index c7474dc57a3..4872853514b 100644
--- a/src/gui/painting/qdatabuffer_p.h
+++ b/src/gui/painting/qdatabuffer_p.h
@@ -87,8 +87,9 @@ public:
capacity = 1;
while (capacity < size)
capacity *= 2;
- buffer = (Type*) QtPrivate::fittedRealloc(static_cast<void*>(buffer), 0, &capacity, sizeof(Type));
- Q_CHECK_PTR(buffer);
+ auto ptr = QtPrivate::fittedRealloc(static_cast<void*>(buffer), 0, &capacity, sizeof(Type));
+ Q_CHECK_PTR(ptr);
+ buffer = static_cast<Type*>(ptr);
}
}
@@ -96,8 +97,9 @@ public:
Q_ASSERT(capacity >= size);
if (size) {
capacity = size;
- buffer = (Type*) QtPrivate::fittedRealloc(static_cast<void*>(buffer), 0, &capacity, sizeof(Type));
- Q_CHECK_PTR(buffer);
+ const auto ptr = QtPrivate::fittedRealloc(static_cast<void*>(buffer), 0, &capacity, sizeof(Type));
+ Q_CHECK_PTR(ptr);
+ buffer = static_cast<Type*>(ptr);
siz = std::min(siz, size);
} else {
QtPrivate::sizedFree(buffer, capacity, sizeof(Type));
diff --git a/src/gui/painting/qpaintengine_raster_p.h b/src/gui/painting/qpaintengine_raster_p.h
index d436afc5c77..1a60afbdd8e 100644
--- a/src/gui/painting/qpaintengine_raster_p.h
+++ b/src/gui/painting/qpaintengine_raster_p.h
@@ -361,7 +361,7 @@ inline void QClipData::appendSpan(int x, int length, int y, int coverage)
if (count == allocated) {
allocated *= 2;
- m_spans = (QT_FT_Span *)realloc(m_spans, allocated*sizeof(QT_FT_Span));
+ m_spans = static_cast<QT_FT_Span*>(q_check_ptr(realloc(m_spans, allocated * sizeof(QT_FT_Span))));
}
m_spans[count].x = x;
m_spans[count].len = length;
@@ -378,7 +378,7 @@ inline void QClipData::appendSpans(const QT_FT_Span *s, int num)
do {
allocated *= 2;
} while (count + num > allocated);
- m_spans = (QT_FT_Span *)realloc(m_spans, allocated*sizeof(QT_FT_Span));
+ m_spans = static_cast<QT_FT_Span*>(q_check_ptr(realloc(m_spans, allocated * sizeof(QT_FT_Span))));
}
memcpy(m_spans+count, s, num*sizeof(QT_FT_Span));
count += num;
diff --git a/src/gui/text/qtextformat.cpp b/src/gui/text/qtextformat.cpp
index 06ae00123f0..379fb70a81a 100644
--- a/src/gui/text/qtextformat.cpp
+++ b/src/gui/text/qtextformat.cpp
@@ -2245,6 +2245,17 @@ void QTextCharFormat::setFont(const QFont &font, FontPropertiesInheritanceBehavi
/*!
Returns the font for this character format.
+
+ This function takes into account the format's font attributes (such as fontWeight()
+ and fontPointSize()) and resolves them on top of the default font, defined as follows.
+ If the format is part of a document, that is the document's default font.
+ Otherwise the properties are resolved on top of a default constructed QFont.
+
+ For example, if this format's font size hasn't been changed from the default font,
+ fontPointSize() returns 0, while \c {font().pointSize()} returns the actual
+ size used for drawing.
+
+ \sa QTextDocument::defaultFont()
*/
QFont QTextCharFormat::font() const
{
diff --git a/src/tools/moc/moc.cpp b/src/tools/moc/moc.cpp
index 14280712154..64fd334d467 100644
--- a/src/tools/moc/moc.cpp
+++ b/src/tools/moc/moc.cpp
@@ -259,6 +259,7 @@ bool Moc::parseEnum(EnumDef *def, ClassDef *containingClass)
return false; // anonymous enum
isTypdefEnum = true;
}
+ def->lineNumber = symbol().lineNum;
if (test(COLON)) { // C++11 strongly typed enum
// enum Foo : unsigned long { ... };
def->type = normalizeType(parseType().name);
@@ -464,6 +465,8 @@ bool Moc::parseFunction(FunctionDef *def, bool inMacro)
}
next(LPAREN, "Not a signal or slot declaration");
def->name = tempType.name;
+ def->lineNumber = symbol().lineNum;
+
scopedFunctionName = tempType.isScoped;
if (!test(RPAREN)) {
@@ -1366,6 +1369,7 @@ void Moc::createPropertyDef(PropertyDef &propDef, int propertyIndex, Moc::Proper
{
propDef.location = index;
propDef.relativeIndex = propertyIndex;
+ propDef.lineNumber = symbol().lineNum;
Type t = parseType();
QByteArray type = t.name;
@@ -2156,6 +2160,7 @@ QJsonObject FunctionDef::toJson(int index) const
if (revision > 0)
fdef["revision"_L1] = revision;
+ fdef["lineNumber"_L1] = lineNumber;
if (wasCloned)
fdef["isCloned"_L1] = true;
@@ -2220,6 +2225,7 @@ QJsonObject PropertyDef::toJson() const
prop["final"_L1] = final;
prop["required"_L1] = required;
prop["index"_L1] = relativeIndex;
+ prop["lineNumber"_L1] = lineNumber;
if (revision > 0)
prop["revision"_L1] = revision;
@@ -2231,6 +2237,7 @@ QJsonObject EnumDef::toJson(const ClassDef &cdef) const
QJsonObject def;
uint flags = this->flags | cdef.enumDeclarations.value(name);
def["name"_L1] = QString::fromUtf8(name);
+ def["lineNumber"_L1] = lineNumber;
if (!enumName.isEmpty())
def["alias"_L1] = QString::fromUtf8(enumName);
if (!type.isEmpty())
diff --git a/src/tools/moc/moc.h b/src/tools/moc/moc.h
index f08edb3f0d2..fcf000c655f 100644
--- a/src/tools/moc/moc.h
+++ b/src/tools/moc/moc.h
@@ -58,6 +58,7 @@ struct EnumDef
QFlags<QtMocConstants::EnumFlags> flags = {};
QJsonObject toJson(const ClassDef &cdef) const;
QByteArray qualifiedType(const ClassDef *cdef) const;
+ int lineNumber = 0;
};
Q_DECLARE_TYPEINFO(EnumDef, Q_RELOCATABLE_TYPE);
@@ -84,6 +85,7 @@ struct FunctionDef
enum Access { Private, Protected, Public };
Access access = Private;
int revision = 0;
+ int lineNumber = 0;
bool isConst = false;
bool isVirtual = false;
@@ -130,6 +132,7 @@ struct PropertyDef
bool final = false;
bool required = false;
int relativeIndex = -1; // property index in current metaobject
+ int lineNumber = 0;
qsizetype location = -1; // token index, used for error reporting