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

Change-Id: I309691a541ff0b296fb6bbfbc0761cc1c627573a
This commit is contained in:
Liang Qi 2016-08-25 11:41:18 +02:00
commit 6f58358791
179 changed files with 841 additions and 634 deletions

View File

@ -1,3 +1,4 @@
CONFIG += precompile_header CONFIG += precompile_header
PRECOMPILED_DIR = .pch
PRECOMPILED_HEADER = header.h PRECOMPILED_HEADER = header.h
SOURCES = source.cpp SOURCES = source.cpp

View File

@ -612,7 +612,7 @@ MakefileGenerator::init()
int x; int x;
//build up a list of compilers //build up a list of compilers
QList<Compiler> compilers; QVector<Compiler> compilers;
{ {
const char *builtins[] = { "OBJECTS", "SOURCES", "PRECOMPILED_HEADER", 0 }; const char *builtins[] = { "OBJECTS", "SOURCES", "PRECOMPILED_HEADER", 0 };
for(x = 0; builtins[x]; ++x) { for(x = 0; builtins[x]; ++x) {

View File

@ -155,6 +155,8 @@ protected:
}; };
uint flags, type; uint flags, type;
}; };
friend class QTypeInfo<Compiler>;
void initCompiler(const Compiler &comp); void initCompiler(const Compiler &comp);
enum VPATHFlag { enum VPATHFlag {
VPATH_NoFlag = 0x00, VPATH_NoFlag = 0x00,
@ -264,6 +266,7 @@ public:
bool isWindowsShell() const { return Option::dir_sep == QLatin1String("\\"); } bool isWindowsShell() const { return Option::dir_sep == QLatin1String("\\"); }
QString shellQuote(const QString &str); QString shellQuote(const QString &str);
}; };
Q_DECLARE_TYPEINFO(MakefileGenerator::Compiler, Q_MOVABLE_TYPE);
Q_DECLARE_OPERATORS_FOR_FLAGS(MakefileGenerator::FileFixifyTypes) Q_DECLARE_OPERATORS_FOR_FLAGS(MakefileGenerator::FileFixifyTypes)
inline void MakefileGenerator::setNoIO(bool o) inline void MakefileGenerator::setNoIO(bool o)

View File

@ -41,10 +41,10 @@ struct SourceDependChildren;
class SourceFiles; class SourceFiles;
class QMakeLocalFileName { class QMakeLocalFileName {
uint is_null : 1; bool is_null;
mutable QString real_name, local_name; mutable QString real_name, local_name;
public: public:
QMakeLocalFileName() : is_null(1) { } QMakeLocalFileName() : is_null(true) {}
QMakeLocalFileName(const QString &); QMakeLocalFileName(const QString &);
bool isNull() const { return is_null; } bool isNull() const { return is_null; }
inline const QString &real() const { return real_name; } inline const QString &real() const { return real_name; }

View File

@ -860,7 +860,6 @@ class VCConfiguration
public: public:
// Functions // Functions
VCConfiguration(); VCConfiguration();
~VCConfiguration(){}
bool suppressUnknownOptionWarnings; bool suppressUnknownOptionWarnings;
DotNET CompilerVersion; DotNET CompilerVersion;
@ -936,7 +935,6 @@ class VCFilter
public: public:
// Functions // Functions
VCFilter(); VCFilter();
~VCFilter(){}
void addFile(const QString& filename); void addFile(const QString& filename);
void addFile(const VCFilterFile& fileInfo); void addFile(const VCFilterFile& fileInfo);
@ -962,7 +960,7 @@ public:
VCCLCompilerTool CompilerTool; VCCLCompilerTool CompilerTool;
}; };
typedef QList<VCFilter> VCFilterList; typedef QVector<VCFilter> VCFilterList;
class VCProjectSingleConfig class VCProjectSingleConfig
{ {
public: public:
@ -976,9 +974,6 @@ public:
Resources, Resources,
Extras Extras
}; };
// Functions
VCProjectSingleConfig(){}
~VCProjectSingleConfig(){}
// Variables // Variables
QString Name; QString Name;
@ -1009,6 +1004,7 @@ public:
const VCFilter &filterByName(const QString &name) const; const VCFilter &filterByName(const QString &name) const;
const VCFilter &filterForExtraCompiler(const QString &compilerName) const; const VCFilter &filterForExtraCompiler(const QString &compilerName) const;
}; };
Q_DECLARE_TYPEINFO(VCProjectSingleConfig, Q_MOVABLE_TYPE);
// Tree & Flat view of files -------------------------------------------------- // Tree & Flat view of files --------------------------------------------------
class VCFilter; class VCFilter;

View File

@ -321,7 +321,7 @@ QMakeEvaluator::quoteValue(const ProString &val)
break; break;
case 32: case 32:
quote = true; quote = true;
// fallthrough Q_FALLTHROUGH();
default: default:
ret += c; ret += c;
break; break;

View File

@ -318,7 +318,7 @@ ProStringList QMakeEvaluator::split_value_list(const QStringRef &vals, const Pro
--x; --x;
} }
} }
// fallthrough Q_FALLTHROUGH();
default: default:
hadWord = true; hadWord = true;
break; break;
@ -1643,7 +1643,7 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::expandVariableReferences(
tokPtr++; tokPtr++;
continue; continue;
} }
// fallthrough Q_FALLTHROUGH();
default: default:
Q_ASSERT_X(false, "expandVariableReferences", "Unrecognized token"); Q_ASSERT_X(false, "expandVariableReferences", "Unrecognized token");
break; break;
@ -2109,7 +2109,7 @@ QString QMakeEvaluator::formatValue(const ProString &val, bool forceQuote)
break; break;
case 32: case 32:
quote = true; quote = true;
// fallthrough Q_FALLTHROUGH();
default: default:
ret += c; ret += c;
break; break;

View File

@ -44,8 +44,8 @@
// W A R N I N G // W A R N I N G
// ------------- // -------------
// //
// This file is not part of the Qt API. It exists for the convenience // This file is not part of the Qt API. It exists purely as an
// of QIODevice. This header file may change from version to // implementation detail. This header file may change from version to
// version without notice, or even be removed. // version without notice, or even be removed.
// //
// We mean it. // We mean it.

View File

@ -44,8 +44,8 @@
// W A R N I N G // W A R N I N G
// ------------- // -------------
// //
// This file is not part of the Qt API. It exists for the convenience // This file is not part of the Qt API. It exists purely as an
// of QIODevice. This header file may change from version to // implementation detail. This header file may change from version to
// version without notice, or even be removed. // version without notice, or even be removed.
// //
// We mean it. // We mean it.

View File

@ -44,8 +44,8 @@
// W A R N I N G // W A R N I N G
// ------------- // -------------
// //
// This file is not part of the Qt API. It exists for the convenience // This file is not part of the Qt API. It exists purely as an
// of QIODevice. This header file may change from version to // implementation detail. This header file may change from version to
// version without notice, or even be removed. // version without notice, or even be removed.
// //
// We mean it. // We mean it.

View File

@ -44,8 +44,8 @@
// W A R N I N G // W A R N I N G
// ------------- // -------------
// //
// This file is not part of the Qt API. It exists for the convenience // This file is not part of the Qt API. It exists purely as an
// of QIODevice. This header file may change from version to // implementation detail. This header file may change from version to
// version without notice, or even be removed. // version without notice, or even be removed.
// //
// We mean it. // We mean it.

View File

@ -44,8 +44,8 @@
// W A R N I N G // W A R N I N G
// ------------- // -------------
// //
// This file is not part of the Qt API. It exists for the convenience // This file is not part of the Qt API. It exists purely as an
// of QIODevice. This header file may change from version to // implementation detail. This header file may change from version to
// version without notice, or even be removed. // version without notice, or even be removed.
// //
// We mean it. // We mean it.

View File

@ -411,7 +411,7 @@ QByteArray QIconvCodec::convertFromUnicode(const QChar *uc, int len, ConverterSt
switch (errno) { switch (errno) {
case EILSEQ: case EILSEQ:
++invalidCount; ++invalidCount;
// fall through Q_FALLTHROUGH();
case EINVAL: case EINVAL:
{ {
inBytes += sizeof(QChar); inBytes += sizeof(QChar);

View File

@ -44,9 +44,9 @@
// W A R N I N G // W A R N I N G
// ------------- // -------------
// //
// This file is not part of the Qt API. It exists for the convenience // This file is not part of the Qt API. It exists purely as an
// of the QLibrary class. This header file may change from // implementation detail. This header file may change from version to
// version to version without notice, or even be removed. // version without notice, or even be removed.
// //
// We mean it. // We mean it.
// //

View File

@ -288,7 +288,7 @@ QString QJisCodec::convertToUnicode(const char* chars, int len, ConverterState *
result += QLatin1Char(ch); result += QLatin1Char(ch);
break; break;
} }
/* fall through */ Q_FALLTHROUGH();
case JISX0201_Latin: case JISX0201_Latin:
u = conv->jisx0201ToUnicode(ch); u = conv->jisx0201ToUnicode(ch);
result += QValidChar(u); result += QValidChar(u);

View File

@ -1341,6 +1341,18 @@
Q_ASSUME_IMPL(valueOfExpression);\ Q_ASSUME_IMPL(valueOfExpression);\
} while (0) } while (0)
#if QT_HAS_CPP_ATTRIBUTE(fallthrough)
# define Q_FALLTHROUGH() [[fallthrough]]
#elif defined(__cplusplus)
/* Clang can not parse namespaced attributes in C mode, but defines __has_cpp_attribute */
# if QT_HAS_CPP_ATTRIBUTE(clang::fallthrough)
# define Q_FALLTHROUGH() [[clang::fallthrough]]
# endif
#endif
#ifndef Q_FALLTHROUGH
# define Q_FALLTHROUGH() (void)0
#endif
/* /*
Sanitize compiler feature availability Sanitize compiler feature availability

View File

@ -2956,6 +2956,20 @@ QString QSysInfo::machineHostName()
\sa Q_ASSERT(), Q_ASSUME(), qFatal() \sa Q_ASSERT(), Q_ASSUME(), qFatal()
*/ */
/*!
\macro void Q_FALLTHROUGH()
\relates <QtGlobal>
\since 5.8
Can be used in switch statements at the end of case block to tell the compiler
and other developers that that the lack of a break statement is intentional.
This is useful since a missing break statement is often a bug, and some
compilers can be configured to emit warnings when one is not found.
\sa Q_UNREACHABLE()
*/
/*! /*!
\macro void Q_CHECK_PTR(void *pointer) \macro void Q_CHECK_PTR(void *pointer)
\relates <QtGlobal> \relates <QtGlobal>

View File

@ -349,7 +349,7 @@ static QString readSymLink(const QFileSystemEntry &link)
if (matchVolName.indexIn(result) == 0) { if (matchVolName.indexIn(result) == 0) {
DWORD len; DWORD len;
wchar_t buffer[MAX_PATH]; wchar_t buffer[MAX_PATH];
QString volumeName = result.mid(0, matchVolName.matchedLength()).prepend(QLatin1String("\\\\?\\")); const QString volumeName = QLatin1String("\\\\?\\") + result.leftRef(matchVolName.matchedLength());
if (GetVolumePathNamesForVolumeName(reinterpret_cast<LPCWSTR>(volumeName.utf16()), buffer, MAX_PATH, &len) != 0) if (GetVolumePathNamesForVolumeName(reinterpret_cast<LPCWSTR>(volumeName.utf16()), buffer, MAX_PATH, &len) != 0)
result.replace(0,matchVolName.matchedLength(), QString::fromWCharArray(buffer)); result.replace(0,matchVolName.matchedLength(), QString::fromWCharArray(buffer));
} }

View File

@ -44,9 +44,9 @@
// W A R N I N G // W A R N I N G
// ------------- // -------------
// //
// This file is not part of the Qt API. It exists for the convenience // This file is not part of the Qt API. It exists purely as an
// of the QLibrary class. This header file may change from // implementation detail. This header file may change from version to
// version to version without notice, or even be removed. // version without notice, or even be removed.
// //
// We mean it. // We mean it.
// //

View File

@ -44,9 +44,9 @@
// W A R N I N G // W A R N I N G
// ------------- // -------------
// //
// This file is not part of the Qt API. It exists for the convenience // This file is not part of the Qt API. It exists purely as an
// of the QLibrary class. This header file may change from // implementation detail. This header file may change from version to
// version to version without notice, or even be removed. // version without notice, or even be removed.
// //
// We mean it. // We mean it.
// //

View File

@ -44,9 +44,9 @@
// W A R N I N G // W A R N I N G
// ------------- // -------------
// //
// This file is not part of the Qt API. It exists for the convenience // This file is not part of the Qt API. It exists purely as an
// of the QLibrary class. This header file may change from // implementation detail. This header file may change from version to
// version to version without notice, or even be removed. // version without notice, or even be removed.
// //
// We mean it. // We mean it.
// //

View File

@ -44,9 +44,9 @@
// W A R N I N G // W A R N I N G
// ------------- // -------------
// //
// This file is not part of the Qt API. It exists for the convenience // This file is not part of the Qt API. It exists purely as an
// of the QLibrary class. This header file may change from // implementation detail. This header file may change from version to
// version to version without notice, or even be removed. // version without notice, or even be removed.
// //
// We mean it. // We mean it.
// //

View File

@ -44,9 +44,9 @@
// W A R N I N G // W A R N I N G
// ------------- // -------------
// //
// This file is not part of the Qt API. It exists for the convenience // This file is not part of the Qt API. It exists purely as an
// of the QLibrary class. This header file may change from // implementation detail. This header file may change from version to
// version to version without notice, or even be removed. // version without notice, or even be removed.
// //
// We mean it. // We mean it.
// //

View File

@ -44,9 +44,9 @@
// W A R N I N G // W A R N I N G
// ------------- // -------------
// //
// This file is not part of the Qt API. It exists for the convenience // This file is not part of the Qt API. It exists purely as an
// of the QLibrary class. This header file may change from // implementation detail. This header file may change from version to
// version to version without notice, or even be removed. // version without notice, or even be removed.
// //
// We mean it. // We mean it.
// //

View File

@ -44,9 +44,9 @@
// W A R N I N G // W A R N I N G
// ------------- // -------------
// //
// This file is not part of the Qt API. It exists for the convenience of // This file is not part of the Qt API. It exists purely as an
// qurl*.cpp This header file may change from version to version without // implementation detail. This header file may change from version to
// notice, or even be removed. // version without notice, or even be removed.
// //
// We mean it. // We mean it.
// //

View File

@ -813,7 +813,7 @@ StNormal:
++i; ++i;
goto StSkipSpaces; goto StSkipSpaces;
} }
// fallthrough Q_FALLTHROUGH();
default: { default: {
int j = i + 1; int j = i + 1;
while (j < to) { while (j < to) {

View File

@ -742,7 +742,7 @@ void QWinSettingsPrivate::set(const QString &uKey, const QVariant &value)
} }
case QVariant::ByteArray: case QVariant::ByteArray:
// fallthrough intended Q_FALLTHROUGH();
default: { default: {
// If the string does not contain '\0', we can use REG_SZ, the native registry // If the string does not contain '\0', we can use REG_SZ, the native registry

View File

@ -339,7 +339,7 @@ bool Value::isValid(const Base *b) const
case QJsonValue::Double: case QJsonValue::Double:
if (latinOrIntValue) if (latinOrIntValue)
break; break;
// fall through Q_FALLTHROUGH();
case QJsonValue::String: case QJsonValue::String:
case QJsonValue::Array: case QJsonValue::Array:
case QJsonValue::Object: case QJsonValue::Object:
@ -418,7 +418,7 @@ uint Value::valueToStore(const QJsonValue &v, uint offset)
if (c != INT_MAX) if (c != INT_MAX)
return c; return c;
} }
// fall through Q_FALLTHROUGH();
case QJsonValue::String: case QJsonValue::String:
case QJsonValue::Array: case QJsonValue::Array:
case QJsonValue::Object: case QJsonValue::Object:

View File

@ -44,9 +44,9 @@
// W A R N I N G // W A R N I N G
// ------------- // -------------
// //
// This file is not part of the Qt API. It exists for the convenience // This file is not part of the Qt API. It exists purely as an
// of the QLibrary class. This header file may change from // implementation detail. This header file may change from version to
// version to version without notice, or even be removed. // version without notice, or even be removed.
// //
// We mean it. // We mean it.
// //

View File

@ -1622,16 +1622,9 @@ namespace QtPrivate {
{ return -1; } { return -1; }
}; };
#ifndef Q_COMPILER_VARIADIC_TEMPLATES
// Function pointers don't derive from QObject // Function pointers don't derive from QObject
template <class Result> struct IsPointerToTypeDerivedFromQObject<Result(*)()> { enum { Value = false }; };
template <class Result, class Arg0> struct IsPointerToTypeDerivedFromQObject<Result(*)(Arg0)> { enum { Value = false }; };
template <class Result, class Arg0, class Arg1> struct IsPointerToTypeDerivedFromQObject<Result(*)(Arg0, Arg1)> { enum { Value = false }; };
template <class Result, class Arg0, class Arg1, class Arg2> struct IsPointerToTypeDerivedFromQObject<Result(*)(Arg0, Arg1, Arg2)> { enum { Value = false }; };
#else
template <typename Result, typename... Args> template <typename Result, typename... Args>
struct IsPointerToTypeDerivedFromQObject<Result(*)(Args...)> { enum { Value = false }; }; struct IsPointerToTypeDerivedFromQObject<Result(*)(Args...)> { enum { Value = false }; };
#endif
template<typename T> template<typename T>
struct QMetaTypeTypeFlags struct QMetaTypeTypeFlags

View File

@ -122,7 +122,7 @@ QVariant QMimeDataPrivate::retrieveTypedData(const QString &format, QVariant::Ty
const QList<QVariant> list = data.toList(); const QList<QVariant> list = data.toList();
for (int i = 0; i < list.size(); ++i) { for (int i = 0; i < list.size(); ++i) {
if (list.at(i).type() == QVariant::Url) { if (list.at(i).type() == QVariant::Url) {
text.append(list.at(i).toUrl().toDisplayString() + QLatin1Char('\n')); text += list.at(i).toUrl().toDisplayString() + QLatin1Char('\n');
++numUrls; ++numUrls;
} }
} }
@ -167,7 +167,7 @@ QVariant QMimeDataPrivate::retrieveTypedData(const QString &format, QVariant::Ty
case QVariant::List: { case QVariant::List: {
if (format != QLatin1String("text/uri-list")) if (format != QLatin1String("text/uri-list"))
break; break;
// fall through Q_FALLTHROUGH();
} }
case QVariant::Url: { case QVariant::Url: {
QByteArray ba = data.toByteArray(); QByteArray ba = data.toByteArray();

View File

@ -149,12 +149,13 @@ QString QSystemError::toString() const
return windowsErrorString(errorCode); return windowsErrorString(errorCode);
#else #else
//unix: fall through as native and standard library are the same //unix: fall through as native and standard library are the same
Q_FALLTHROUGH();
#endif #endif
case StandardLibraryError: case StandardLibraryError:
return standardLibraryErrorString(errorCode); return standardLibraryErrorString(errorCode);
default: default:
qWarning("invalid error scope"); qWarning("invalid error scope");
//fall through Q_FALLTHROUGH();
case NoError: case NoError:
return QLatin1String("No error"); return QLatin1String("No error");
} }

View File

@ -468,7 +468,6 @@ void QTimerInfoList::registerTimer(int timerId, int interval, Qt::TimerType time
// above 20 s, 5% inaccuracy is above 1 s, so we convert to VeryCoarseTimer // above 20 s, 5% inaccuracy is above 1 s, so we convert to VeryCoarseTimer
if (interval >= 20000) { if (interval >= 20000) {
t->timerType = Qt::VeryCoarseTimer; t->timerType = Qt::VeryCoarseTimer;
// fall through
} else { } else {
t->timeout = expected; t->timeout = expected;
if (interval <= 20) { if (interval <= 20) {
@ -479,7 +478,7 @@ void QTimerInfoList::registerTimer(int timerId, int interval, Qt::TimerType time
} }
break; break;
} }
// fall through Q_FALLTHROUGH();
case Qt::VeryCoarseTimer: case Qt::VeryCoarseTimer:
// the very coarse timer is based on full second precision, // the very coarse timer is based on full second precision,
// so we keep the interval in seconds (round to closest second) // so we keep the interval in seconds (round to closest second)

View File

@ -489,8 +489,7 @@ bool QTranslator::load(const QString & filename, const QString & directory,
const QString suffixOrDotQM = suffix.isNull() ? dotQmLiteral() : suffix; const QString suffixOrDotQM = suffix.isNull() ? dotQmLiteral() : suffix;
QStringRef fname(&filename); QStringRef fname(&filename);
QString realname; QString realname;
QString delims; const QString delims = search_delimiters.isNull() ? QStringLiteral("_.") : search_delimiters;
delims = search_delimiters.isNull() ? QStringLiteral("_.") : search_delimiters;
for (;;) { for (;;) {
QFileInfo fi; QFileInfo fi;

View File

@ -203,7 +203,7 @@ static qlonglong qConvertToNumber(const QVariant::Private *d, bool *ok)
case QMetaType::QJsonValue: case QMetaType::QJsonValue:
if (!v_cast<QJsonValue>(d)->isDouble()) if (!v_cast<QJsonValue>(d)->isDouble())
break; break;
// no break Q_FALLTHROUGH();
#endif #endif
case QVariant::Double: case QVariant::Double:
case QVariant::Int: case QVariant::Int:
@ -278,7 +278,7 @@ static qulonglong qConvertToUnsignedNumber(const QVariant::Private *d, bool *ok)
case QMetaType::QJsonValue: case QMetaType::QJsonValue:
if (!v_cast<QJsonValue>(d)->isDouble()) if (!v_cast<QJsonValue>(d)->isDouble())
break; break;
// no break Q_FALLTHROUGH();
#endif #endif
case QVariant::Double: case QVariant::Double:
case QVariant::Int: case QVariant::Int:
@ -3119,7 +3119,7 @@ bool QVariant::canConvert(int targetTypeId) const
case QVariant::Int: case QVariant::Int:
if (currentType == QVariant::KeySequence) if (currentType == QVariant::KeySequence)
return true; return true;
// fall through Q_FALLTHROUGH();
case QVariant::UInt: case QVariant::UInt:
case QVariant::LongLong: case QVariant::LongLong:
case QVariant::ULongLong: case QVariant::ULongLong:

View File

@ -217,22 +217,24 @@ bool QMimeBinaryProvider::isValid()
bool QMimeBinaryProvider::CacheFileList::checkCacheChanged() bool QMimeBinaryProvider::CacheFileList::checkCacheChanged()
{ {
bool somethingChanged = false; bool somethingChanged = false;
QMutableListIterator<CacheFile *> it(*this); for (CacheFile *cacheFile : qAsConst(*this)) {
while (it.hasNext()) {
CacheFile *cacheFile = it.next();
QFileInfo fileInfo(cacheFile->file); QFileInfo fileInfo(cacheFile->file);
if (!fileInfo.exists()) { // This can't happen by just running update-mime-database. But the user could use rm -rf :-) if (!fileInfo.exists() || fileInfo.lastModified() > cacheFile->m_mtime) {
delete cacheFile; // Deletion can't happen by just running update-mime-database.
it.remove(); // But the user could use rm -rf :-)
somethingChanged = true; cacheFile->reload(); // will mark itself as invalid on failure
} else if (fileInfo.lastModified() > cacheFile->m_mtime) {
if (!cacheFile->reload()) {
delete cacheFile;
it.remove();
}
somethingChanged = true; somethingChanged = true;
} }
} }
if (somethingChanged) {
auto deleteIfNoLongerValid = [](CacheFile *cacheFile) -> bool {
const bool invalid = !cacheFile->isValid();
if (invalid)
delete cacheFile;
return invalid;
};
erase(std::remove_if(begin(), end(), deleteIfNoLongerValid), end());
}
return somethingChanged; return somethingChanged;
} }

View File

@ -91,8 +91,6 @@ public:
QObject *instance(int index) const; QObject *instance(int index) const;
}; };
#ifdef Q_COMPILER_VARIADIC_TEMPLATES
template <class PluginInterface, class FactoryInterface, typename ...Args> template <class PluginInterface, class FactoryInterface, typename ...Args>
PluginInterface *qLoadPlugin(const QFactoryLoader *loader, const QString &key, Args &&...args) PluginInterface *qLoadPlugin(const QFactoryLoader *loader, const QString &key, Args &&...args)
{ {
@ -106,68 +104,6 @@ PluginInterface *qLoadPlugin(const QFactoryLoader *loader, const QString &key, A
return nullptr; return nullptr;
} }
#else
template <class PluginInterface, class FactoryInterface>
PluginInterface *qLoadPlugin(const QFactoryLoader *loader, const QString &key)
{
const int index = loader->indexOf(key);
if (index != -1) {
QObject *factoryObject = loader->instance(index);
if (FactoryInterface *factory = qobject_cast<FactoryInterface *>(factoryObject))
if (PluginInterface *result = factory->create(key))
return result;
}
return 0;
}
template <class PluginInterface, class FactoryInterface, class P1>
PluginInterface *qLoadPlugin(const QFactoryLoader *loader,
const QString &key,
P1 &&p1)
{
const int index = loader->indexOf(key);
if (index != -1) {
QObject *factoryObject = loader->instance(index);
if (FactoryInterface *factory = qobject_cast<FactoryInterface *>(factoryObject))
if (PluginInterface *result = factory->create(key, std::forward<P1>(p1)))
return result;
}
return 0;
}
template <class PluginInterface, class FactoryInterface, class P1, class P2>
PluginInterface *qLoadPlugin(const QFactoryLoader *loader,
const QString &key,
P1 &&p1, P2 &&p2)
{
const int index = loader->indexOf(key);
if (index != -1) {
QObject *factoryObject = loader->instance(index);
if (FactoryInterface *factory = qobject_cast<FactoryInterface *>(factoryObject))
if (PluginInterface *result = factory->create(key, std::forward<P1>(p1), std::forward<P2>(p2)))
return result;
}
return 0;
}
template <class PluginInterface, class FactoryInterface, class P1, class P2, class P3>
PluginInterface *qLoadPlugin(const QFactoryLoader *loader,
const QString &key,
P1 &&p1, P2 &&p2, P3 &&p3)
{
const int index = loader->indexOf(key);
if (index != -1) {
QObject *factoryObject = loader->instance(index);
if (FactoryInterface *factory = qobject_cast<FactoryInterface *>(factoryObject))
if (PluginInterface *result = factory->create(key, std::forward<P1>(p1), std::forward<P2>(p2), std::forward<P3>(p3)))
return result;
}
return 0;
}
#endif
template <class PluginInterface, class FactoryInterface, typename Arg> template <class PluginInterface, class FactoryInterface, typename Arg>
Q_DECL_DEPRECATED PluginInterface *qLoadPlugin1(const QFactoryLoader *loader, const QString &key, Arg &&arg) Q_DECL_DEPRECATED PluginInterface *qLoadPlugin1(const QFactoryLoader *loader, const QString &key, Arg &&arg)
{ return qLoadPlugin<PluginInterface, FactoryInterface>(loader, key, std::forward<Arg>(arg)); } { return qLoadPlugin<PluginInterface, FactoryInterface>(loader, key, std::forward<Arg>(arg)); }

View File

@ -44,8 +44,8 @@
// W A R N I N G // W A R N I N G
// ------------- // -------------
// //
// This file is not part of the Qt API. It exists for the convenience // This file is not part of the Qt API. It exists purely as an
// of QSettings. This header file may change from version to // implementation detail. This header file may change from version to
// version without notice, or even be removed. // version without notice, or even be removed.
// //
// We mean it. // We mean it.

View File

@ -2656,7 +2656,7 @@ static void setTimeSpec(QDateTimeData &d, Qt::TimeSpec spec, int offsetSeconds)
case Qt::TimeZone: case Qt::TimeZone:
// Use system time zone instead // Use system time zone instead
spec = Qt::LocalTime; spec = Qt::LocalTime;
// fallthrough Q_FALLTHROUGH();
case Qt::UTC: case Qt::UTC:
case Qt::LocalTime: case Qt::LocalTime:
offsetSeconds = 0; offsetSeconds = 0;

View File

@ -602,7 +602,7 @@ int QDateTimeParser::sectionMaxSize(Section s, int count) const
return 2; return 2;
#else #else
mcount = 7; mcount = 7;
// fall through Q_FALLTHROUGH();
#endif #endif
case MonthSection: case MonthSection:
#ifdef QT_NO_TEXTDATE #ifdef QT_NO_TEXTDATE
@ -770,7 +770,8 @@ int QDateTimeParser::parseSection(const QDateTime &currentValue, int sectionInde
state = Intermediate; state = Intermediate;
} }
break; break;
} // else: fall through }
Q_FALLTHROUGH();
case DaySection: case DaySection:
case YearSection: case YearSection:
case YearSection2Digits: case YearSection2Digits:
@ -1155,7 +1156,7 @@ end:
done = true; done = true;
break; break;
} }
// fallthrough Q_FALLTHROUGH();
default: { default: {
int toMin; int toMin;
int toMax; int toMax;
@ -1489,7 +1490,7 @@ QDateTimeParser::FieldInfo QDateTimeParser::fieldInfo(int index) const
switch (sn.type) { switch (sn.type) {
case MSecSection: case MSecSection:
ret |= Fraction; ret |= Fraction;
// fallthrough Q_FALLTHROUGH();
case SecondSection: case SecondSection:
case MinuteSection: case MinuteSection:
case Hour24Section: case Hour24Section:
@ -1509,7 +1510,7 @@ QDateTimeParser::FieldInfo QDateTimeParser::fieldInfo(int index) const
switch (sn.count) { switch (sn.count) {
case 2: case 2:
ret |= FixedWidth; ret |= FixedWidth;
// fallthrough Q_FALLTHROUGH();
case 1: case 1:
ret |= (Numeric|AllowPartial); ret |= (Numeric|AllowPartial);
break; break;

View File

@ -136,8 +136,12 @@ public:
Node *i; Node *i;
inline iterator() : i(0) {} inline iterator() : i(0) {}
inline iterator(Node *n) : i(n) {} inline iterator(Node *n) : i(n) {}
inline iterator(const iterator &o) : i(o.i) {} #if QT_VERSION < QT_VERSION_CHECK(6,0,0)
inline iterator &operator=(const iterator &o) { i = o.i; return *this; } iterator(const iterator &other) Q_DECL_NOTHROW : i(other.i) {}
iterator &operator=(const iterator &other) Q_DECL_NOTHROW { i = other.i; return *this; }
iterator(iterator &&other) Q_DECL_NOTHROW : i(other.i) {}
iterator &operator=(iterator &&other) Q_DECL_NOTHROW { return *this = other; }
#endif
inline T &operator*() const { return i->t; } inline T &operator*() const { return i->t; }
inline T *operator->() const { return &i->t; } inline T *operator->() const { return &i->t; }
inline bool operator==(const iterator &o) const { return i == o.i; } inline bool operator==(const iterator &o) const { return i == o.i; }
@ -169,9 +173,13 @@ public:
Node *i; Node *i;
inline const_iterator() : i(0) {} inline const_iterator() : i(0) {}
inline const_iterator(Node *n) : i(n) {} inline const_iterator(Node *n) : i(n) {}
inline const_iterator(const const_iterator &o) : i(o.i){}
inline const_iterator(iterator ci) : i(ci.i){} inline const_iterator(iterator ci) : i(ci.i){}
inline const_iterator &operator=(const const_iterator &o) { i = o.i; return *this; } #if QT_VERSION < QT_VERSION_CHECK(6,0,0)
const_iterator(const const_iterator &other) Q_DECL_NOTHROW : i(other.i) {}
const_iterator &operator=(const const_iterator &other) Q_DECL_NOTHROW { i = other.i; return *this; }
const_iterator(const_iterator &&other) Q_DECL_NOTHROW : i(other.i) {}
const_iterator &operator=(const_iterator &&other) Q_DECL_NOTHROW { return *this = other; }
#endif
inline const T &operator*() const { return i->t; } inline const T &operator*() const { return i->t; }
inline const T *operator->() const { return &i->t; } inline const T *operator->() const { return &i->t; }
inline bool operator==(const const_iterator &o) const { return i == o.i; } inline bool operator==(const const_iterator &o) const { return i == o.i; }

View File

@ -3011,7 +3011,7 @@ int QRegExpEngine::getEscape()
case 'I': case 'I':
if (xmlSchemaExtensions) { if (xmlSchemaExtensions) {
yyCharClass->setNegative(!yyCharClass->negative()); yyCharClass->setNegative(!yyCharClass->negative());
// fall through Q_FALLTHROUGH();
} else { } else {
break; break;
} }
@ -3051,7 +3051,7 @@ int QRegExpEngine::getEscape()
case 'C': case 'C':
if (xmlSchemaExtensions) { if (xmlSchemaExtensions) {
yyCharClass->setNegative(!yyCharClass->negative()); yyCharClass->setNegative(!yyCharClass->negative());
// fall through Q_FALLTHROUGH();
} else { } else {
break; break;
} }
@ -3097,7 +3097,7 @@ int QRegExpEngine::getEscape()
case 'P': case 'P':
if (xmlSchemaExtensions) { if (xmlSchemaExtensions) {
yyCharClass->setNegative(!yyCharClass->negative()); yyCharClass->setNegative(!yyCharClass->negative());
// fall through Q_FALLTHROUGH();
} else { } else {
break; break;
} }

View File

@ -67,10 +67,6 @@ QT_END_NAMESPACE
#endif #endif
#include <QtCore/qhashfunctions.h> #include <QtCore/qhashfunctions.h>
#if defined(Q_COMPILER_RVALUE_REFS) && defined(Q_COMPILER_VARIADIC_TEMPLATES)
# include <utility> // for std::forward
#endif
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
@ -428,7 +424,6 @@ public:
QWeakPointer<T> toWeakRef() const; QWeakPointer<T> toWeakRef() const;
#if defined(Q_COMPILER_RVALUE_REFS) && defined(Q_COMPILER_VARIADIC_TEMPLATES)
template <typename... Args> template <typename... Args>
static QSharedPointer create(Args && ...arguments) static QSharedPointer create(Args && ...arguments)
{ {
@ -450,49 +445,6 @@ public:
result.enableSharedFromThis(result.data()); result.enableSharedFromThis(result.data());
return result; return result;
} }
#else
static inline QSharedPointer create()
{
typedef QtSharedPointer::ExternalRefCountWithContiguousData<T> Private;
# ifdef QT_SHAREDPOINTER_TRACK_POINTERS
typename Private::DestroyerFn destroy = &Private::safetyCheckDeleter;
# else
typename Private::DestroyerFn destroy = &Private::deleter;
# endif
QSharedPointer result(Qt::Uninitialized);
result.d = Private::create(&result.value, destroy);
// now initialize the data
new (result.data()) T();
# ifdef QT_SHAREDPOINTER_TRACK_POINTERS
internalSafetyCheckAdd(result.d, result.value);
# endif
result.d->setQObjectShared(result.value, true);
result.enableSharedFromThis(result.data());
return result;
}
template <typename Arg>
static inline QSharedPointer create(const Arg &arg)
{
typedef QtSharedPointer::ExternalRefCountWithContiguousData<T> Private;
# ifdef QT_SHAREDPOINTER_TRACK_POINTERS
typename Private::DestroyerFn destroy = &Private::safetyCheckDeleter;
# else
typename Private::DestroyerFn destroy = &Private::deleter;
# endif
QSharedPointer result(Qt::Uninitialized);
result.d = Private::create(&result.value, destroy);
// now initialize the data
new (result.data()) T(arg);
# ifdef QT_SHAREDPOINTER_TRACK_POINTERS
internalSafetyCheckAdd(result.d, result.value);
# endif
result.d->setQObjectShared(result.value, true);
return result;
}
#endif
private: private:
explicit QSharedPointer(Qt::Initialization) {} explicit QSharedPointer(Qt::Initialization) {}

View File

@ -522,13 +522,13 @@ static void getLineBreaks(const ushort *string, quint32 len, QCharAttributes *at
// do not change breaks before and after the expression // do not change breaks before and after the expression
for (quint32 j = nestart + 1; j < pos; ++j) for (quint32 j = nestart + 1; j < pos; ++j)
attributes[j].lineBreak = false; attributes[j].lineBreak = false;
// fall through Q_FALLTHROUGH();
case LB::NS::None: case LB::NS::None:
nelast = LB::NS::XX; // reset state nelast = LB::NS::XX; // reset state
break; break;
case LB::NS::Start: case LB::NS::Start:
nestart = i; nestart = i;
// fall through Q_FALLTHROUGH();
default: default:
nelast = necur; nelast = necur;
break; break;

View File

@ -976,11 +976,11 @@ bool QXmlStreamReaderPrivate::scanUntil(const char *str, short tokenToInject)
case '\r': case '\r':
if ((c = filterCarriageReturn()) == 0) if ((c = filterCarriageReturn()) == 0)
break; break;
// fall through Q_FALLTHROUGH();
case '\n': case '\n':
++lineNumber; ++lineNumber;
lastLineStart = characterOffset + readBufferPos; lastLineStart = characterOffset + readBufferPos;
// fall through Q_FALLTHROUGH();
case '\t': case '\t':
textBuffer += QChar(c); textBuffer += QChar(c);
continue; continue;
@ -1158,11 +1158,11 @@ inline int QXmlStreamReaderPrivate::fastScanLiteralContent()
case '\r': case '\r':
if (filterCarriageReturn() == 0) if (filterCarriageReturn() == 0)
return n; return n;
// fall through Q_FALLTHROUGH();
case '\n': case '\n':
++lineNumber; ++lineNumber;
lastLineStart = characterOffset + readBufferPos; lastLineStart = characterOffset + readBufferPos;
// fall through Q_FALLTHROUGH();
case ' ': case ' ':
case '\t': case '\t':
if (normalizeLiterals) if (normalizeLiterals)
@ -1179,7 +1179,7 @@ inline int QXmlStreamReaderPrivate::fastScanLiteralContent()
putChar(c); putChar(c);
return n; return n;
} }
// fall through Q_FALLTHROUGH();
default: default:
if (c < 0x20) { if (c < 0x20) {
putChar(c); putChar(c);
@ -1201,11 +1201,11 @@ inline int QXmlStreamReaderPrivate::fastScanSpace()
case '\r': case '\r':
if ((c = filterCarriageReturn()) == 0) if ((c = filterCarriageReturn()) == 0)
return n; return n;
// fall through Q_FALLTHROUGH();
case '\n': case '\n':
++lineNumber; ++lineNumber;
lastLineStart = characterOffset + readBufferPos; lastLineStart = characterOffset + readBufferPos;
// fall through Q_FALLTHROUGH();
case ' ': case ' ':
case '\t': case '\t':
textBuffer += QChar(c); textBuffer += QChar(c);
@ -1259,11 +1259,11 @@ inline int QXmlStreamReaderPrivate::fastScanContentCharList()
case '\r': case '\r':
if ((c = filterCarriageReturn()) == 0) if ((c = filterCarriageReturn()) == 0)
return n; return n;
// fall through Q_FALLTHROUGH();
case '\n': case '\n':
++lineNumber; ++lineNumber;
lastLineStart = characterOffset + readBufferPos; lastLineStart = characterOffset + readBufferPos;
// fall through Q_FALLTHROUGH();
case ' ': case ' ':
case '\t': case '\t':
textBuffer += QChar(ushort(c)); textBuffer += QChar(ushort(c));
@ -1275,7 +1275,7 @@ inline int QXmlStreamReaderPrivate::fastScanContentCharList()
putChar(c); putChar(c);
return n; return n;
} }
// fall through Q_FALLTHROUGH();
default: default:
if (c < 0x20) { if (c < 0x20) {
putChar(c); putChar(c);
@ -1339,7 +1339,7 @@ inline int QXmlStreamReaderPrivate::fastScanName(int *prefix)
putChar(c); putChar(c);
return n; return n;
} }
// fall through Q_FALLTHROUGH();
default: default:
textBuffer += QChar(c); textBuffer += QChar(c);
++n; ++n;
@ -2123,7 +2123,7 @@ QString QXmlStreamReader::readElementText(ReadElementTextBehaviour behaviour)
result += readElementText(behaviour); result += readElementText(behaviour);
break; break;
} }
// Fall through (for ErrorOnUnexpectedElement) Q_FALLTHROUGH();
default: default:
if (d->error || behaviour == ErrorOnUnexpectedElement) { if (d->error || behaviour == ErrorOnUnexpectedElement) {
if (!d->error) if (!d->error)

View File

@ -1048,7 +1048,7 @@ bool QXmlStreamReaderPrivate::parse()
dtdName.clear(); dtdName.clear();
dtdPublicId.clear(); dtdPublicId.clear();
dtdSystemId.clear(); dtdSystemId.clear();
// fall through Q_FALLTHROUGH();
case QXmlStreamReader::Comment: case QXmlStreamReader::Comment:
case QXmlStreamReader::Characters: case QXmlStreamReader::Characters:
isCDATA = false; isCDATA = false;
@ -1080,7 +1080,7 @@ bool QXmlStreamReaderPrivate::parse()
return false; return false;
} }
#endif #endif
// fall through Q_FALLTHROUGH();
default: default:
clearTextBuffer(); clearTextBuffer();
; ;
@ -1124,7 +1124,7 @@ bool QXmlStreamReaderPrivate::parse()
} else { } else {
break; break;
} }
// fall through Q_FALLTHROUGH();
case ~0U: { case ~0U: {
token = EOF_SYMBOL; token = EOF_SYMBOL;
if (!tagsDone && !inParseEntity) { if (!tagsDone && !inParseEntity) {
@ -1338,7 +1338,7 @@ bool QXmlStreamReaderPrivate::parse()
case 17: case 17:
case 18: case 18:
dtdName = symString(3); dtdName = symString(3);
// fall through Q_FALLTHROUGH();
case 19: case 19:
case 20: case 20:
@ -1480,7 +1480,7 @@ bool QXmlStreamReaderPrivate::parse()
if (entityDeclaration.parameter) if (entityDeclaration.parameter)
raiseWellFormedError(QXmlStream::tr("NDATA in parameter entity declaration.")); raiseWellFormedError(QXmlStream::tr("NDATA in parameter entity declaration."));
} }
//fall through Q_FALLTHROUGH();
case 94: case 94:
case 95: { case 95: {
@ -1588,7 +1588,7 @@ bool QXmlStreamReaderPrivate::parse()
case 129: case 129:
isWhitespace = false; isWhitespace = false;
// fall through Q_FALLTHROUGH();
case 130: case 130:
sym(1).len += fastScanContentCharList(); sym(1).len += fastScanContentCharList();
@ -1760,7 +1760,7 @@ bool QXmlStreamReaderPrivate::parse()
case 236: case 236:
isEmptyElement = true; isEmptyElement = true;
// fall through Q_FALLTHROUGH();
case 237: case 237:
setType(QXmlStreamReader::StartElement); setType(QXmlStreamReader::StartElement);

View File

@ -318,7 +318,7 @@ void QDBusMarshaller::open(QDBusMarshaller &sub, int code, const char *signature
case DBUS_TYPE_ARRAY: case DBUS_TYPE_ARRAY:
*ba += char(code); *ba += char(code);
*ba += signature; *ba += signature;
// fall through Q_FALLTHROUGH();
case DBUS_TYPE_DICT_ENTRY: case DBUS_TYPE_DICT_ENTRY:
sub.closeCode = 0; sub.closeCode = 0;
@ -495,9 +495,9 @@ bool QDBusMarshaller::appendVariantInternal(const QVariant &arg)
return true; return true;
default: default:
; // fall through ;
} }
// fall through Q_FALLTHROUGH();
case DBUS_TYPE_STRUCT: case DBUS_TYPE_STRUCT:
case DBUS_STRUCT_BEGIN_CHAR: case DBUS_STRUCT_BEGIN_CHAR:
@ -513,7 +513,7 @@ bool QDBusMarshaller::appendVariantInternal(const QVariant &arg)
append(qvariant_cast<QDBusUnixFileDescriptor>(arg)); append(qvariant_cast<QDBusUnixFileDescriptor>(arg));
return true; return true;
} }
// fall through Q_FALLTHROUGH();
default: default:
qWarning("QDBusMarshaller::appendVariantInternal: Found unknown D-BUS type '%s'", qWarning("QDBusMarshaller::appendVariantInternal: Found unknown D-BUS type '%s'",

View File

@ -373,7 +373,7 @@ int QDBusMetaType::signatureToType(const char *signature)
return qMetaTypeId<QList<QDBusSignature> >(); return qMetaTypeId<QList<QDBusSignature> >();
} }
// fall through Q_FALLTHROUGH();
default: default:
return QMetaType::UnknownType; return QMetaType::UnknownType;
} }

View File

@ -59,10 +59,10 @@ static inline QString typeNameToXml(const char *typeName)
{ {
// ### copied from qtextdocument.cpp // ### copied from qtextdocument.cpp
// ### move this into Qt Core at some point // ### move this into Qt Core at some point
QString plain = QLatin1String(typeName); const QLatin1String plain(typeName);
QString rich; QString rich;
rich.reserve(int(plain.length() * 1.1)); rich.reserve(int(plain.size() * 1.1));
for (int i = 0; i < plain.length(); ++i) { for (int i = 0; i < plain.size(); ++i) {
if (plain.at(i) == QLatin1Char('<')) if (plain.at(i) == QLatin1Char('<'))
rich += QLatin1String("&lt;"); rich += QLatin1String("&lt;");
else if (plain.at(i) == QLatin1Char('>')) else if (plain.at(i) == QLatin1Char('>'))

View File

@ -1888,7 +1888,7 @@ void QImage::invertPixels(InvertMode mode)
case QImage::Format_RGBA8888: case QImage::Format_RGBA8888:
if (mode == InvertRgba) if (mode == InvertRgba)
break; break;
// no break Q_FALLTHROUGH();
case QImage::Format_RGBX8888: case QImage::Format_RGBX8888:
#if Q_BYTE_ORDER == Q_BIG_ENDIAN #if Q_BYTE_ORDER == Q_BIG_ENDIAN
xorbits = 0xffffff00; xorbits = 0xffffff00;
@ -1900,7 +1900,7 @@ void QImage::invertPixels(InvertMode mode)
case QImage::Format_ARGB32: case QImage::Format_ARGB32:
if (mode == InvertRgba) if (mode == InvertRgba)
break; break;
// no break Q_FALLTHROUGH();
case QImage::Format_RGB32: case QImage::Format_RGB32:
xorbits = 0x00ffffff; xorbits = 0x00ffffff;
break; break;

View File

@ -1151,7 +1151,7 @@ bool QImageReader::autoTransform() const
case QImageReaderPrivate::UsePluginDefault: case QImageReaderPrivate::UsePluginDefault:
if (d->initHandler()) if (d->initHandler())
return d->handler->supportsOption(QImageIOHandler::TransformedByDefault); return d->handler->supportsOption(QImageIOHandler::TransformedByDefault);
// no break Q_FALLTHROUGH();
default: default:
break; break;
} }

View File

@ -44,13 +44,12 @@
// W A R N I N G // W A R N I N G
// ------------- // -------------
// //
// This file is not part of the Qt API. It exists for the convenience // This file is not part of the Qt API. It exists purely as an
// of QAbstractItemModel*. This header file may change from version // implementation detail. This header file may change from version to
// to version without notice, or even be removed. // version without notice, or even be removed.
// //
// We mean it. // We mean it.
// //
//
#include <QtGui/private/qtguiglobal_p.h> #include <QtGui/private/qtguiglobal_p.h>
#include <QtGui/qpaintengine.h> #include <QtGui/qpaintengine.h>

View File

@ -113,10 +113,10 @@ int QBlittablePlatformPixmap::metric(QPaintDevice::PaintDeviceMetric metric) con
return qRound(h * 25.4 / qt_defaultDpiY()); return qRound(h * 25.4 / qt_defaultDpiY());
case QPaintDevice::PdmDepth: case QPaintDevice::PdmDepth:
return 32; return 32;
case QPaintDevice::PdmDpiX: // fall-through case QPaintDevice::PdmDpiX:
case QPaintDevice::PdmPhysicalDpiX: case QPaintDevice::PdmPhysicalDpiX:
return qt_defaultDpiX(); return qt_defaultDpiX();
case QPaintDevice::PdmDpiY: // fall-through case QPaintDevice::PdmDpiY:
case QPaintDevice::PdmPhysicalDpiY: case QPaintDevice::PdmPhysicalDpiY:
return qt_defaultDpiY(); return qt_defaultDpiY();
case QPaintDevice::PdmDevicePixelRatio: case QPaintDevice::PdmDevicePixelRatio:

View File

@ -44,9 +44,9 @@
// W A R N I N G // W A R N I N G
// ------------- // -------------
// //
// This file is not part of the Qt API. It exists for the convenience // This file is not part of the Qt API. It exists purely as an
// of the QLibrary class. This header file may change from // implementation detail. This header file may change from version to
// version to version without notice, or even be removed. // version without notice, or even be removed.
// //
// We mean it. // We mean it.
// //

View File

@ -44,9 +44,9 @@
// W A R N I N G // W A R N I N G
// ------------- // -------------
// //
// This file is not part of the Qt API. It exists for the convenience // This file is not part of the Qt API. It exists purely as an
// of the QLibrary class. This header file may change from // implementation detail. This header file may change from version to
// version to version without notice, or even be removed. // version without notice, or even be removed.
// //
// We mean it. // We mean it.
// //

View File

@ -44,9 +44,9 @@
// W A R N I N G // W A R N I N G
// ------------- // -------------
// //
// This file is not part of the Qt API. It exists for the convenience // This file is not part of the Qt API. It exists purely as an
// of the QLibrary class. This header file may change from // implementation detail. This header file may change from version to
// version to version without notice, or even be removed. // version without notice, or even be removed.
// //
// We mean it. // We mean it.
// //

View File

@ -44,9 +44,9 @@
// W A R N I N G // W A R N I N G
// ------------- // -------------
// //
// This file is not part of the Qt API. It exists for the convenience // This file is not part of the Qt API. It exists purely as an
// of the QLibrary class. This header file may change from // implementation detail. This header file may change from version to
// version to version without notice, or even be removed. // version without notice, or even be removed.
// //
// We mean it. // We mean it.
// //

View File

@ -149,17 +149,12 @@ Qt::DropAction QDragManager::drag(QDrag *o)
#if !(defined(QT_NO_DRAGANDDROP) && defined(QT_NO_CLIPBOARD)) #if !(defined(QT_NO_DRAGANDDROP) && defined(QT_NO_CLIPBOARD))
static QStringList imageReadMimeFormats() static QStringList imageMimeFormats(const QList<QByteArray> &imageFormats)
{ {
QStringList formats; QStringList formats;
QList<QByteArray> imageFormats = QImageReader::supportedImageFormats(); formats.reserve(imageFormats.size());
const int numImageFormats = imageFormats.size(); for (const auto &format : imageFormats)
formats.reserve(numImageFormats); formats.append(QLatin1String("image/") + QLatin1String(format.toLower()));
for (int i = 0; i < numImageFormats; ++i) {
QString format = QLatin1String("image/");
format += QString::fromLatin1(imageFormats.at(i).toLower());
formats.append(format);
}
//put png at the front because it is best //put png at the front because it is best
int pngIndex = formats.indexOf(QLatin1String("image/png")); int pngIndex = formats.indexOf(QLatin1String("image/png"));
@ -169,25 +164,15 @@ static QStringList imageReadMimeFormats()
return formats; return formats;
} }
static inline QStringList imageReadMimeFormats()
static QStringList imageWriteMimeFormats()
{ {
QStringList formats; return imageMimeFormats(QImageReader::supportedImageFormats());
QList<QByteArray> imageFormats = QImageWriter::supportedImageFormats(); }
const int numImageFormats = imageFormats.size();
formats.reserve(numImageFormats);
for (int i = 0; i < numImageFormats; ++i) {
QString format = QLatin1String("image/");
format += QString::fromLatin1(imageFormats.at(i).toLower());
formats.append(format);
}
//put png at the front because it is best
int pngIndex = formats.indexOf(QLatin1String("image/png"));
if (pngIndex != -1 && pngIndex != 0)
formats.move(pngIndex, 0);
return formats; static inline QStringList imageWriteMimeFormats()
{
return imageMimeFormats(QImageWriter::supportedImageFormats());
} }
QInternalMimeData::QInternalMimeData() QInternalMimeData::QInternalMimeData()

View File

@ -154,14 +154,14 @@ bool QPlatformGraphicsBufferHelper::bindSWToTexture(const QPlatformGraphicsBuffe
switch (imageformat) { switch (imageformat) {
case QImage::Format_ARGB32_Premultiplied: case QImage::Format_ARGB32_Premultiplied:
premultiplied = true; premultiplied = true;
// no break Q_FALLTHROUGH();
case QImage::Format_RGB32: case QImage::Format_RGB32:
case QImage::Format_ARGB32: case QImage::Format_ARGB32:
swizzle = true; swizzle = true;
break; break;
case QImage::Format_RGBA8888_Premultiplied: case QImage::Format_RGBA8888_Premultiplied:
premultiplied = true; premultiplied = true;
// no break Q_FALLTHROUGH();
case QImage::Format_RGBX8888: case QImage::Format_RGBX8888:
case QImage::Format_RGBA8888: case QImage::Format_RGBA8888:
break; break;

View File

@ -22,12 +22,9 @@ qtConfig(opengl(es2)?) {
opengl/qopenglpaintengine_p.h \ opengl/qopenglpaintengine_p.h \
opengl/qopenglengineshadersource_p.h \ opengl/qopenglengineshadersource_p.h \
opengl/qopenglcustomshaderstage_p.h \ opengl/qopenglcustomshaderstage_p.h \
opengl/qtriangulatingstroker_p.h \
opengl/qopengltextureglyphcache_p.h \ opengl/qopengltextureglyphcache_p.h \
opengl/qopenglshadercache_p.h \ opengl/qopenglshadercache_p.h \
opengl/qopenglshadercache_meego_p.h \ opengl/qopenglshadercache_meego_p.h \
opengl/qtriangulator_p.h \
opengl/qrbtree_p.h \
opengl/qopenglversionfunctions.h \ opengl/qopenglversionfunctions.h \
opengl/qopenglversionfunctionsfactory_p.h \ opengl/qopenglversionfunctionsfactory_p.h \
opengl/qopenglvertexarrayobject.h \ opengl/qopenglvertexarrayobject.h \
@ -51,9 +48,7 @@ qtConfig(opengl(es2)?) {
opengl/qopengl2pexvertexarray.cpp \ opengl/qopengl2pexvertexarray.cpp \
opengl/qopenglpaintengine.cpp \ opengl/qopenglpaintengine.cpp \
opengl/qopenglcustomshaderstage.cpp \ opengl/qopenglcustomshaderstage.cpp \
opengl/qtriangulatingstroker.cpp \
opengl/qopengltextureglyphcache.cpp \ opengl/qopengltextureglyphcache.cpp \
opengl/qtriangulator.cpp \
opengl/qopenglversionfunctions.cpp \ opengl/qopenglversionfunctions.cpp \
opengl/qopenglversionfunctionsfactory.cpp \ opengl/qopenglversionfunctionsfactory.cpp \
opengl/qopenglvertexarrayobject.cpp \ opengl/qopenglvertexarrayobject.cpp \

View File

@ -44,9 +44,9 @@
// W A R N I N G // W A R N I N G
// ------------- // -------------
// //
// This file is not part of the Qt API. It exists for the convenience // This file is not part of the Qt API. It exists purely as an
// of the QLibrary class. This header file may change from // implementation detail. This header file may change from version to
// version to version without notice, or even be removed. // version without notice, or even be removed.
// //
// We mean it. // We mean it.
// //

View File

@ -520,8 +520,8 @@ void QOpenGLTextureBlitter::release()
} }
/*! /*!
Enables or disables swizzling for the red and blue color Sets whether swizzling is enabled for the red and blue color channels to
channels. An BGRA to RGBA conversion (occurring in the shader on \a swizzle. An BGRA to RGBA conversion (occurring in the shader on
the GPU, instead of a slow CPU-side transformation) can be useful the GPU, instead of a slow CPU-side transformation) can be useful
when the source texture contains data from a QImage with a format when the source texture contains data from a QImage with a format
like QImage::Format_ARGB32 which maps to BGRA on little endian like QImage::Format_ARGB32 which maps to BGRA on little endian
@ -538,10 +538,11 @@ void QOpenGLTextureBlitter::setRedBlueSwizzle(bool swizzle)
} }
/*! /*!
Changes the opacity. The default opacity is 1.0. Changes the opacity to \a opacity. The default opacity is 1.0.
\note the blitter does not alter the blend state. It is up to the \note the blitter does not alter the blend state. It is up to the
caller of blit() to ensure the correct blend settings are active. caller of blit() to ensure the correct blend settings are active.
*/ */
void QOpenGLTextureBlitter::setOpacity(float opacity) void QOpenGLTextureBlitter::setOpacity(float opacity)
{ {
@ -613,7 +614,7 @@ void QOpenGLTextureBlitter::blit(GLuint texture,
the source dimensions and will in most cases be set to (0, 0, the source dimensions and will in most cases be set to (0, 0,
image width, image height). image width, image height).
For unscaled output the size of \a target and \viewport should For unscaled output the size of \a target and \a viewport should
match. match.
\sa blit() \sa blit()

View File

@ -44,9 +44,9 @@
// W A R N I N G // W A R N I N G
// ------------- // -------------
// //
// This file is not part of the Qt API. It exists for the convenience // This file is not part of the Qt API. It exists purely as an
// of the QLibrary class. This header file may change from // implementation detail. This header file may change from version to
// version to version without notice, or even be removed. // version without notice, or even be removed.
// //
// We mean it. // We mean it.
// //

View File

@ -42,6 +42,7 @@ HEADERS += \
painting/qpolygonclipper_p.h \ painting/qpolygonclipper_p.h \
painting/qrasterdefs_p.h \ painting/qrasterdefs_p.h \
painting/qrasterizer_p.h \ painting/qrasterizer_p.h \
painting/qrbtree_p.h \
painting/qregion.h \ painting/qregion.h \
painting/qrgb.h \ painting/qrgb.h \
painting/qrgba64.h \ painting/qrgba64.h \
@ -49,6 +50,8 @@ HEADERS += \
painting/qstroker_p.h \ painting/qstroker_p.h \
painting/qtextureglyphcache_p.h \ painting/qtextureglyphcache_p.h \
painting/qtransform.h \ painting/qtransform.h \
painting/qtriangulatingstroker_p.h \
painting/qtriangulator_p.h \
painting/qplatformbackingstore.h \ painting/qplatformbackingstore.h \
painting/qpathsimplifier_p.h painting/qpathsimplifier_p.h
@ -92,6 +95,8 @@ SOURCES += \
painting/qstroker.cpp \ painting/qstroker.cpp \
painting/qtextureglyphcache.cpp \ painting/qtextureglyphcache.cpp \
painting/qtransform.cpp \ painting/qtransform.cpp \
painting/qtriangulatingstroker.cpp \
painting/qtriangulator.cpp \
painting/qplatformbackingstore.cpp \ painting/qplatformbackingstore.cpp \
painting/qpathsimplifier.cpp painting/qpathsimplifier.cpp

View File

@ -343,14 +343,6 @@ bool qt_get_named_rgb(const QChar *name, int len, QRgb *rgb)
return get_named_rgb(name_no_space, rgb); return get_named_rgb(name_no_space, rgb);
} }
uint qt_get_rgb_val(const char *name)
{
QRgb r = 0;
qt_get_named_rgb(name,&r);
return r;
}
QStringList qt_get_colornames() QStringList qt_get_colornames()
{ {
int i = 0; int i = 0;
@ -368,10 +360,6 @@ bool qt_get_named_rgb(const char *, QRgb*)
return false; return false;
} }
uint qt_get_rgb_val(const char *)
{
return 0;
}
QStringList qt_get_colornames() QStringList qt_get_colornames()
{ {
return QStringList(); return QStringList();

View File

@ -57,7 +57,6 @@
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
uint qt_get_rgb_val(const char *name);
bool qt_get_named_rgb(const char *, QRgb*); bool qt_get_named_rgb(const char *, QRgb*);
bool qt_get_named_rgb(const QChar *, int len, QRgb*); bool qt_get_named_rgb(const QChar *, int len, QRgb*);
bool qt_get_hex_rgb(const char *, QRgb *); bool qt_get_hex_rgb(const char *, QRgb *);

View File

@ -197,7 +197,7 @@ void qDrawEdge(QPainter *p, qreal x1, qreal y1, qreal x2, qreal y2, qreal dw1, q
if ((style == BorderStyle_Outset && (edge == TopEdge || edge == LeftEdge)) if ((style == BorderStyle_Outset && (edge == TopEdge || edge == LeftEdge))
|| (style == BorderStyle_Inset && (edge == BottomEdge || edge == RightEdge))) || (style == BorderStyle_Inset && (edge == BottomEdge || edge == RightEdge)))
c = c.color().lighter(); c = c.color().lighter();
// fall through! Q_FALLTHROUGH();
case BorderStyle_Solid: { case BorderStyle_Solid: {
p->setPen(Qt::NoPen); p->setPen(Qt::NoPen);
p->setBrush(c); p->setBrush(c);

View File

@ -2245,45 +2245,48 @@ static const uint * QT_FASTCALL fetchTransformedBilinearARGB32PM(uint *buffer, c
const int16x8_t v_disty_ = vshlq_n_s16(v_disty, 4); const int16x8_t v_disty_ = vshlq_n_s16(v_disty, 4);
int32x4_t v_fdx = vdupq_n_s32(fdx*4); int32x4_t v_fdx = vdupq_n_s32(fdx*4);
ptrdiff_t secondLine = reinterpret_cast<const uint *>(s2) - reinterpret_cast<const uint *>(s1); int32x4_t v_fx = vmovq_n_s32(fx);
fx += fdx;
union Vect_buffer { int32x4_t vect; quint32 i[4]; }; v_fx = vsetq_lane_s32(fx, v_fx, 1);
Vect_buffer v_fx; fx += fdx;
v_fx = vsetq_lane_s32(fx, v_fx, 2);
for (int i = 0; i < 4; i++) { fx += fdx;
v_fx.i[i] = fx; v_fx = vsetq_lane_s32(fx, v_fx, 3);
fx += fdx; fx += fdx;
}
const int32x4_t v_ffff_mask = vdupq_n_s32(0x0000ffff); const int32x4_t v_ffff_mask = vdupq_n_s32(0x0000ffff);
const int32x4_t v_fx_r = vdupq_n_s32(0x0800); const int32x4_t v_fx_r = vdupq_n_s32(0x0800);
while (b < boundedEnd) { while (b < boundedEnd) {
uint32x4x2_t v_top, v_bot;
Vect_buffer tl, tr, bl, br; int32x4_t v_fx_shifted = vshrq_n_s32(v_fx, 16);
Vect_buffer v_fx_shifted; int x1 = vgetq_lane_s32(v_fx_shifted, 0);
v_fx_shifted.vect = vshrq_n_s32(v_fx.vect, 16); v_top = vld2q_lane_u32(s1 + x1, v_top, 0);
v_bot = vld2q_lane_u32(s2 + x1, v_bot, 0);
int32x4_t v_distx = vshrq_n_s32(vaddq_s32(vandq_s32(v_fx.vect, v_ffff_mask), v_fx_r), 12); x1 = vgetq_lane_s32(v_fx_shifted, 1);
v_top = vld2q_lane_u32(s1 + x1, v_top, 1);
for (int i = 0; i < 4; i++) { v_bot = vld2q_lane_u32(s2 + x1, v_bot, 1);
int x1 = v_fx_shifted.i[i]; x1 = vgetq_lane_s32(v_fx_shifted, 2);
const uint *addr_tl = reinterpret_cast<const uint *>(s1) + x1; v_top = vld2q_lane_u32(s1 + x1, v_top, 2);
const uint *addr_tr = addr_tl + 1; v_bot = vld2q_lane_u32(s2 + x1, v_bot, 2);
tl.i[i] = *addr_tl; x1 = vgetq_lane_s32(v_fx_shifted, 3);
tr.i[i] = *addr_tr; v_top = vld2q_lane_u32(s1 + x1, v_top, 3);
bl.i[i] = *(addr_tl+secondLine); v_bot = vld2q_lane_u32(s2 + x1, v_bot, 3);
br.i[i] = *(addr_tr+secondLine);
}
int32x4_t v_distx = vshrq_n_s32(vaddq_s32(vandq_s32(v_fx, v_ffff_mask), v_fx_r), 12);
v_distx = vorrq_s32(v_distx, vshlq_n_s32(v_distx, 16)); v_distx = vorrq_s32(v_distx, vshlq_n_s32(v_distx, 16));
interpolate_4_pixels_16_neon(vreinterpretq_s16_s32(tl.vect), vreinterpretq_s16_s32(tr.vect), vreinterpretq_s16_s32(bl.vect), vreinterpretq_s16_s32(br.vect), vreinterpretq_s16_s32(v_distx), v_disty, v_disty_, colorMask, invColorMask, v_256, b); interpolate_4_pixels_16_neon(
vreinterpretq_s16_u32(v_top.val[0]), vreinterpretq_s16_u32(v_top.val[1]),
vreinterpretq_s16_u32(v_bot.val[0]), vreinterpretq_s16_u32(v_bot.val[1]),
vreinterpretq_s16_s32(v_distx), v_disty, v_disty_,
colorMask, invColorMask, v_256, b);
b+=4; b+=4;
v_fx.vect = vaddq_s32(v_fx.vect, v_fdx); v_fx = vaddq_s32(v_fx, v_fdx);
} }
fx = v_fx.i[0]; fx = vgetq_lane_s32(v_fx, 0);
#endif #endif
} }
@ -2419,6 +2422,87 @@ static const uint * QT_FASTCALL fetchTransformedBilinearARGB32PM(uint *buffer, c
} }
fx = _mm_cvtsi128_si32(v_fx); fx = _mm_cvtsi128_si32(v_fx);
fy = _mm_cvtsi128_si32(v_fy); fy = _mm_cvtsi128_si32(v_fy);
#elif defined(__ARM_NEON__)
BILINEAR_ROTATE_BOUNDS_PROLOG
const int16x8_t colorMask = vdupq_n_s16(0x00ff);
const int16x8_t invColorMask = vmvnq_s16(colorMask);
const int16x8_t v_256 = vdupq_n_s16(256);
int32x4_t v_fdx = vdupq_n_s32(fdx * 4);
int32x4_t v_fdy = vdupq_n_s32(fdy * 4);
const uchar *textureData = data->texture.imageData;
const int bytesPerLine = data->texture.bytesPerLine;
int32x4_t v_fx = vmovq_n_s32(fx);
int32x4_t v_fy = vmovq_n_s32(fy);
fx += fdx; fy += fdy;
v_fx = vsetq_lane_s32(fx, v_fx, 1);
v_fy = vsetq_lane_s32(fy, v_fy, 1);
fx += fdx; fy += fdy;
v_fx = vsetq_lane_s32(fx, v_fx, 2);
v_fy = vsetq_lane_s32(fy, v_fy, 2);
fx += fdx; fy += fdy;
v_fx = vsetq_lane_s32(fx, v_fx, 3);
v_fy = vsetq_lane_s32(fy, v_fy, 3);
fx += fdx; fy += fdy;
const int32x4_t v_ffff_mask = vdupq_n_s32(0x0000ffff);
const int32x4_t v_round = vdupq_n_s32(0x0800);
while (b < boundedEnd) {
uint32x4x2_t v_top, v_bot;
int32x4_t v_fx_shifted, v_fy_shifted;
v_fx_shifted = vshrq_n_s32(v_fx, 16);
v_fy_shifted = vshrq_n_s32(v_fy, 16);
int x1 = vgetq_lane_s32(v_fx_shifted, 0);
int y1 = vgetq_lane_s32(v_fy_shifted, 0);
const uchar *sl = textureData + bytesPerLine * y1;
const uint *s1 = reinterpret_cast<const uint *>(sl);
const uint *s2 = reinterpret_cast<const uint *>(sl + bytesPerLine);
v_top = vld2q_lane_u32(s1 + x1, v_top, 0);
v_bot = vld2q_lane_u32(s2 + x1, v_bot, 0);
x1 = vgetq_lane_s32(v_fx_shifted, 1);
y1 = vgetq_lane_s32(v_fy_shifted, 1);
sl = textureData + bytesPerLine * y1;
s1 = reinterpret_cast<const uint *>(sl);
s2 = reinterpret_cast<const uint *>(sl + bytesPerLine);
v_top = vld2q_lane_u32(s1 + x1, v_top, 1);
v_bot = vld2q_lane_u32(s2 + x1, v_bot, 1);
x1 = vgetq_lane_s32(v_fx_shifted, 2);
y1 = vgetq_lane_s32(v_fy_shifted, 2);
sl = textureData + bytesPerLine * y1;
s1 = reinterpret_cast<const uint *>(sl);
s2 = reinterpret_cast<const uint *>(sl + bytesPerLine);
v_top = vld2q_lane_u32(s1 + x1, v_top, 2);
v_bot = vld2q_lane_u32(s2 + x1, v_bot, 2);
x1 = vgetq_lane_s32(v_fx_shifted, 3);
y1 = vgetq_lane_s32(v_fy_shifted, 3);
sl = textureData + bytesPerLine * y1;
s1 = reinterpret_cast<const uint *>(sl);
s2 = reinterpret_cast<const uint *>(sl + bytesPerLine);
v_top = vld2q_lane_u32(s1 + x1, v_top, 3);
v_bot = vld2q_lane_u32(s2 + x1, v_bot, 3);
int32x4_t v_distx = vshrq_n_s32(vaddq_s32(vandq_s32(v_fx, v_ffff_mask), v_round), 12);
int32x4_t v_disty = vshrq_n_s32(vaddq_s32(vandq_s32(v_fy, v_ffff_mask), v_round), 12);
v_distx = vorrq_s32(v_distx, vshlq_n_s32(v_distx, 16));
v_disty = vorrq_s32(v_disty, vshlq_n_s32(v_disty, 16));
int16x8_t v_disty_ = vshlq_n_s16(vreinterpretq_s16_s32(v_disty), 4);
interpolate_4_pixels_16_neon(
vreinterpretq_s16_u32(v_top.val[0]), vreinterpretq_s16_u32(v_top.val[1]),
vreinterpretq_s16_u32(v_bot.val[0]), vreinterpretq_s16_u32(v_bot.val[1]),
vreinterpretq_s16_s32(v_distx), vreinterpretq_s16_s32(v_disty),
v_disty_, colorMask, invColorMask, v_256, b);
b += 4;
v_fx = vaddq_s32(v_fx, v_fdx);
v_fy = vaddq_s32(v_fy, v_fdy);
}
fx = vgetq_lane_s32(v_fx, 0);
fy = vgetq_lane_s32(v_fy, 0);
#endif #endif
} }

View File

@ -1760,7 +1760,7 @@ static bool bool_op(bool a, bool b, QPathClipper::Operation op)
switch (op) { switch (op) {
case QPathClipper::BoolAnd: case QPathClipper::BoolAnd:
return a && b; return a && b;
case QPathClipper::BoolOr: // fall-through case QPathClipper::BoolOr:
case QPathClipper::Simplify: case QPathClipper::Simplify:
return a || b; return a || b;
case QPathClipper::BoolSub: case QPathClipper::BoolSub:
@ -1956,7 +1956,7 @@ QPointF intersectLine(const QPointF &a, const QPointF &b, qreal t)
{ {
QLineF line(a, b); QLineF line(a, b);
switch (edge) { switch (edge) {
case Left: // fall-through case Left:
case Right: case Right:
return line.pointAt((t - a.x()) / (b.x() - a.x())); return line.pointAt((t - a.x()) / (b.x() - a.x()));
default: default:

View File

@ -2091,7 +2091,7 @@ int QPdfEnginePrivate::generateLinearGradientShader(const QLinearGradient *gradi
break; break;
case QGradient::ReflectSpread: case QGradient::ReflectSpread:
reflect = true; reflect = true;
// fall through Q_FALLTHROUGH();
case QGradient::RepeatSpread: { case QGradient::RepeatSpread: {
// calculate required bounds // calculate required bounds
QRectF pageRect = m_pageLayout.fullRectPixels(resolution); QRectF pageRect = m_pageLayout.fullRectPixels(resolution);
@ -2154,7 +2154,7 @@ int QPdfEnginePrivate::generateRadialGradientShader(const QRadialGradient *gradi
break; break;
case QGradient::ReflectSpread: case QGradient::ReflectSpread:
reflect = true; reflect = true;
// fall through Q_FALLTHROUGH();
case QGradient::RepeatSpread: { case QGradient::RepeatSpread: {
Q_ASSERT(qFuzzyIsNull(r0)); // QPainter emulates if this is not 0 Q_ASSERT(qFuzzyIsNull(r0)); // QPainter emulates if this is not 0

View File

@ -471,14 +471,14 @@ GLuint QPlatformBackingStore::toTexture(const QRegion &dirtyRegion, QSize *textu
switch (image.format()) { switch (image.format()) {
case QImage::Format_ARGB32_Premultiplied: case QImage::Format_ARGB32_Premultiplied:
*flags |= TexturePremultiplied; *flags |= TexturePremultiplied;
// no break Q_FALLTHROUGH();
case QImage::Format_RGB32: case QImage::Format_RGB32:
case QImage::Format_ARGB32: case QImage::Format_ARGB32:
*flags |= TextureSwizzle; *flags |= TextureSwizzle;
break; break;
case QImage::Format_RGBA8888_Premultiplied: case QImage::Format_RGBA8888_Premultiplied:
*flags |= TexturePremultiplied; *flags |= TexturePremultiplied;
// no break Q_FALLTHROUGH();
case QImage::Format_RGBX8888: case QImage::Format_RGBX8888:
case QImage::Format_RGBA8888: case QImage::Format_RGBA8888:
break; break;

View File

@ -446,7 +446,7 @@ QTransform &QTransform::translate(qreal dx, qreal dy)
break; break;
case TxProject: case TxProject:
m_33 += dx*m_13 + dy*m_23; m_33 += dx*m_13 + dy*m_23;
// Fall through Q_FALLTHROUGH();
case TxShear: case TxShear:
case TxRotate: case TxRotate:
affine._dx += dx*affine._m11 + dy*affine._m21; affine._dx += dx*affine._m11 + dy*affine._m21;
@ -508,12 +508,12 @@ QTransform & QTransform::scale(qreal sx, qreal sy)
case TxProject: case TxProject:
m_13 *= sx; m_13 *= sx;
m_23 *= sy; m_23 *= sy;
// fall through Q_FALLTHROUGH();
case TxRotate: case TxRotate:
case TxShear: case TxShear:
affine._m12 *= sx; affine._m12 *= sx;
affine._m21 *= sy; affine._m21 *= sy;
// fall through Q_FALLTHROUGH();
case TxScale: case TxScale:
affine._m11 *= sx; affine._m11 *= sx;
affine._m22 *= sy; affine._m22 *= sy;
@ -581,7 +581,7 @@ QTransform & QTransform::shear(qreal sh, qreal sv)
m_13 += tm13; m_13 += tm13;
m_23 += tm23; m_23 += tm23;
} }
// fall through Q_FALLTHROUGH();
case TxRotate: case TxRotate:
case TxShear: { case TxShear: {
qreal tm11 = sv*affine._m21; qreal tm11 = sv*affine._m21;
@ -663,7 +663,7 @@ QTransform & QTransform::rotate(qreal a, Qt::Axis axis)
qreal tm23 = -sina*m_13 + cosa*m_23; qreal tm23 = -sina*m_13 + cosa*m_23;
m_13 = tm13; m_13 = tm13;
m_23 = tm23; m_23 = tm23;
// fall through Q_FALLTHROUGH();
} }
case TxRotate: case TxRotate:
case TxShear: { case TxShear: {
@ -742,7 +742,7 @@ QTransform & QTransform::rotateRadians(qreal a, Qt::Axis axis)
qreal tm23 = -sina*m_13 + cosa*m_23; qreal tm23 = -sina*m_13 + cosa*m_23;
m_13 = tm13; m_13 = tm13;
m_23 = tm23; m_23 = tm23;
// fall through Q_FALLTHROUGH();
} }
case TxRotate: case TxRotate:
case TxShear: { case TxShear: {

View File

@ -50,9 +50,10 @@
#include <QtCore/qglobal.h> #include <QtCore/qglobal.h>
#include <QtCore/qpoint.h> #include <QtCore/qpoint.h>
#include <QtCore/qalgorithms.h> #include <QtCore/qalgorithms.h>
#ifndef QT_NO_OPENGL
#include <private/qopenglcontext_p.h> # include <private/qopenglcontext_p.h>
#include <private/qopenglextensions_p.h> # include <private/qopenglextensions_p.h>
#endif
#include <private/qrbtree_p.h> #include <private/qrbtree_p.h>
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
@ -873,7 +874,7 @@ void QTriangulator<T>::initialize(const QVectorPath &path, const QTransform &mat
case QPainterPath::MoveToElement: case QPainterPath::MoveToElement:
if (!m_indices.isEmpty()) if (!m_indices.isEmpty())
m_indices.push_back(T(-1)); // Q_TRIANGULATE_END_OF_POLYGON m_indices.push_back(T(-1)); // Q_TRIANGULATE_END_OF_POLYGON
// Fall through. Q_FALLTHROUGH();
case QPainterPath::LineToElement: case QPainterPath::LineToElement:
m_indices.push_back(T(m_vertices.size())); m_indices.push_back(T(m_vertices.size()));
m_vertices.resize(m_vertices.size() + 1); m_vertices.resize(m_vertices.size() + 1);
@ -2099,7 +2100,7 @@ void QTriangulator<T>::SimpleToMonotone::monotoneDecomposition()
} else { } else {
qWarning("Inconsistent polygon. (#3)"); qWarning("Inconsistent polygon. (#3)");
} }
// Fall through. Q_FALLTHROUGH();
case StartVertex: case StartVertex:
if (m_clockwiseOrder) { if (m_clockwiseOrder) {
leftEdgeNode = searchEdgeLeftOfEdge(j); leftEdgeNode = searchEdgeLeftOfEdge(j);
@ -2128,7 +2129,7 @@ void QTriangulator<T>::SimpleToMonotone::monotoneDecomposition()
} else { } else {
qWarning("Inconsistent polygon. (#4)"); qWarning("Inconsistent polygon. (#4)");
} }
// Fall through. Q_FALLTHROUGH();
case EndVertex: case EndVertex:
if (m_clockwiseOrder) { if (m_clockwiseOrder) {
if (m_edges.at(m_edges.at(i).helper).type == MergeVertex) if (m_edges.at(m_edges.at(i).helper).type == MergeVertex)
@ -2267,10 +2268,14 @@ void QTriangulator<T>::MonotoneToTriangles::decompose()
static bool hasElementIndexUint() static bool hasElementIndexUint()
{ {
#ifndef QT_NO_OPENGL
QOpenGLContext *context = QOpenGLContext::currentContext(); QOpenGLContext *context = QOpenGLContext::currentContext();
if (!context) if (!context)
return false; return false;
return static_cast<QOpenGLExtensions *>(context->functions())->hasOpenGLExtension(QOpenGLExtensions::ElementIndexUint); return static_cast<QOpenGLExtensions *>(context->functions())->hasOpenGLExtension(QOpenGLExtensions::ElementIndexUint);
#else
return false;
#endif
} }
Q_GUI_EXPORT QTriangleSet qTriangulate(const qreal *polygon, Q_GUI_EXPORT QTriangleSet qTriangulate(const qreal *polygon,

View File

@ -2111,7 +2111,7 @@ QString Scanner::preprocess(const QString &input, bool *hasEscapeSequences)
hexCount = qMin(hexCount, 6); hexCount = qMin(hexCount, 6);
bool ok = false; bool ok = false;
ushort code = output.mid(hexStart, hexCount).toUShort(&ok, 16); ushort code = output.midRef(hexStart, hexCount).toUShort(&ok, 16);
if (ok) { if (ok) {
output.replace(hexStart - 1, hexCount + 1, QChar(code)); output.replace(hexStart - 1, hexCount + 1, QChar(code));
i = hexStart; i = hexStart;

View File

@ -44,9 +44,9 @@
// W A R N I N G // W A R N I N G
// ------------- // -------------
// //
// This file is not part of the Qt API. It exists for the convenience // This file is not part of the Qt API. It exists purely as an
// of the QLibrary class. This header file may change from // implementation detail. This header file may change from version to
// version to version without notice, or even be removed. // version without notice, or even be removed.
// //
// We mean it. // We mean it.
// //

View File

@ -1376,6 +1376,7 @@ void QFont::setStyleStrategy(StyleStrategy s)
Predefined stretch values that follow the CSS naming convention. The higher Predefined stretch values that follow the CSS naming convention. The higher
the value, the more stretched the text is. the value, the more stretched the text is.
\value AnyStretch 0 Accept any stretch matched using the other QFont properties (added in Qt 5.8)
\value UltraCondensed 50 \value UltraCondensed 50
\value ExtraCondensed 62 \value ExtraCondensed 62
\value Condensed 75 \value Condensed 75
@ -1402,20 +1403,25 @@ int QFont::stretch() const
/*! /*!
Sets the stretch factor for the font. Sets the stretch factor for the font.
The stretch factor changes the width of all characters in the font The stretch factor matches a condensed or expanded version of the font or
by \a factor percent. For example, setting \a factor to 150 applies a stretch transform that changes the width of all characters
in the font by \a factor percent. For example, setting \a factor to 150
results in all characters in the font being 1.5 times (ie. 150%) results in all characters in the font being 1.5 times (ie. 150%)
wider. The default stretch factor is 100. The minimum stretch wider. The minimum stretch factor is 1, and the maximum stretch factor
factor is 1, and the maximum stretch factor is 4000. is 4000. The default stretch factor is \c AnyStretch, which will accept
any stretch factor and not apply any transform on the font.
The stretch factor is only applied to outline fonts. The stretch The stretch factor is only applied to outline fonts. The stretch
factor is ignored for bitmap fonts. factor is ignored for bitmap fonts.
\note When matching a font with a native non-default stretch factor,
requesting a stretch of 100 will stretch it back to a medium width font.
\sa stretch(), QFont::Stretch \sa stretch(), QFont::Stretch
*/ */
void QFont::setStretch(int factor) void QFont::setStretch(int factor)
{ {
if (factor < 1 || factor > 4000) { if (factor < 0 || factor > 4000) {
qWarning("QFont::setStretch: Parameter '%d' out of range", factor); qWarning("QFont::setStretch: Parameter '%d' out of range", factor);
return; return;
} }

View File

@ -113,6 +113,7 @@ public:
}; };
enum Stretch { enum Stretch {
AnyStretch = 0,
UltraCondensed = 50, UltraCondensed = 50,
ExtraCondensed = 62, ExtraCondensed = 62,
Condensed = 75, Condensed = 75,

View File

@ -71,7 +71,7 @@ struct QFontDef
inline QFontDef() inline QFontDef()
: pointSize(-1.0), pixelSize(-1), : pointSize(-1.0), pixelSize(-1),
styleStrategy(QFont::PreferDefault), styleHint(QFont::AnyStyle), styleStrategy(QFont::PreferDefault), styleHint(QFont::AnyStyle),
weight(50), fixedPitch(false), style(QFont::StyleNormal), stretch(100), weight(50), fixedPitch(false), style(QFont::StyleNormal), stretch(QFont::AnyStretch),
hintingPreference(QFont::PreferDefaultHinting), ignorePitch(true), hintingPreference(QFont::PreferDefaultHinting), ignorePitch(true),
fixedPitchComputed(0), reserved(0) fixedPitchComputed(0), reserved(0)
{ {

View File

@ -951,12 +951,14 @@ QFontEngine *loadSingleEngine(int script,
} }
} }
// If the font data's native stretch matches the requested stretch we need to set stretch to 100 // To avoid synthesized stretch we need a matching stretch to be 100 after this point.
// to avoid the fontengine synthesizing stretch. If they didn't match exactly we need to calculate // If stretch didn't match exactly we need to calculate the new stretch factor.
// the new stretch factor. This only done if not matched by styleName. // This only done if not matched by styleName.
if (style->key.stretch != 0 && request.stretch != 0 if (style->key.stretch != 0 && request.stretch != 0
&& (request.styleName.isEmpty() || request.styleName != style->styleName)) { && (request.styleName.isEmpty() || request.styleName != style->styleName)) {
def.stretch = (request.stretch * 100 + 50) / style->key.stretch; def.stretch = (request.stretch * 100 + style->key.stretch / 2) / style->key.stretch;
} else {
def.stretch = 100;
} }
engine = pfdb->fontEngine(def, size->handle); engine = pfdb->fontEngine(def, size->handle);
@ -1219,7 +1221,8 @@ static int match(int script, const QFontDef &request,
QtFontStyle::Key styleKey; QtFontStyle::Key styleKey;
styleKey.style = request.style; styleKey.style = request.style;
styleKey.weight = request.weight; styleKey.weight = request.weight;
styleKey.stretch = request.stretch; // Prefer a stretch closest to 100.
styleKey.stretch = request.stretch ? request.stretch : 100;
char pitch = request.ignorePitch ? '*' : request.fixedPitch ? 'm' : 'p'; char pitch = request.ignorePitch ? '*' : request.fixedPitch ? 'm' : 'p';
@ -2740,8 +2743,6 @@ void QFontDatabase::load(const QFontPrivate *d, int script)
} }
if (req.pointSize < 0) if (req.pointSize < 0)
req.pointSize = req.pixelSize*72.0/d->dpi; req.pointSize = req.pixelSize*72.0/d->dpi;
if (req.stretch == 0)
req.stretch = 100;
// respect the fallback families that might be passed through the request // respect the fallback families that might be passed through the request
const QStringList fallBackFamilies = familyList(req); const QStringList fallBackFamilies = familyList(req);

View File

@ -418,6 +418,13 @@ glyph_metrics_t QFontEngine::boundingBox(glyph_t glyph, const QTransform &matrix
return metrics; return metrics;
} }
QFixed QFontEngine::calculatedCapHeight() const
{
const glyph_t glyph = glyphIndex('H');
glyph_metrics_t bb = const_cast<QFontEngine *>(this)->boundingBox(glyph);
return bb.height;
}
QFixed QFontEngine::xHeight() const QFixed QFontEngine::xHeight() const
{ {
const glyph_t glyph = glyphIndex('x'); const glyph_t glyph = glyphIndex('x');
@ -1703,6 +1710,11 @@ QFixed QFontEngineBox::ascent() const
return _size; return _size;
} }
QFixed QFontEngineBox::capHeight() const
{
return _size;
}
QFixed QFontEngineBox::descent() const QFixed QFontEngineBox::descent() const
{ {
return 0; return 0;
@ -2163,6 +2175,9 @@ glyph_metrics_t QFontEngineMulti::boundingBox(glyph_t glyph)
QFixed QFontEngineMulti::ascent() const QFixed QFontEngineMulti::ascent() const
{ return engine(0)->ascent(); } { return engine(0)->ascent(); }
QFixed QFontEngineMulti::capHeight() const
{ return engine(0)->capHeight(); }
QFixed QFontEngineMulti::descent() const QFixed QFontEngineMulti::descent() const
{ return engine(0)->descent(); } { return engine(0)->descent(); }

View File

@ -414,6 +414,7 @@ QFontEngine::Properties QFreetypeFace::properties() const
p.italicAngle = 0; p.italicAngle = 0;
p.capHeight = p.ascent; p.capHeight = p.ascent;
p.lineWidth = face->underline_thickness; p.lineWidth = face->underline_thickness;
return p; return p;
} }
@ -585,8 +586,7 @@ static void convertRGBToARGB_helper(const uchar *src, uint *dst, int width, int
uchar green = src[x + 1]; uchar green = src[x + 1];
uchar blue = src[x + 1 + offs]; uchar blue = src[x + 1 + offs];
LcdFilter::filterPixel(red, green, blue); LcdFilter::filterPixel(red, green, blue);
// alpha = green *dd++ = (0xFF << 24) | (red << 16) | (green << 8) | blue;
*dd++ = (green << 24) | (red << 16) | (green << 8) | blue;
} }
dst += width; dst += width;
src += src_pitch; src += src_pitch;
@ -611,8 +611,7 @@ static void convertRGBToARGB_V_helper(const uchar *src, uint *dst, int width, in
uchar green = src[x + src_pitch]; uchar green = src[x + src_pitch];
uchar blue = src[x + src_pitch + offs]; uchar blue = src[x + src_pitch + offs];
LcdFilter::filterPixel(red, green, blue); LcdFilter::filterPixel(red, green, blue);
// alpha = green *dst++ = (0XFF << 24) | (red << 16) | (green << 8) | blue;
*dst++ = (green << 24) | (red << 16) | (green << 8) | blue;
} }
src += 3*src_pitch; src += 3*src_pitch;
} }
@ -1299,6 +1298,18 @@ QFixed QFontEngineFT::ascent() const
return v; return v;
} }
QFixed QFontEngineFT::capHeight() const
{
TT_OS2 *os2 = (TT_OS2 *)FT_Get_Sfnt_Table(freetype->face, ft_sfnt_os2);
if (os2 && os2->version >= 2) {
lockFace();
QFixed answer = QFixed::fromFixed(FT_MulFix(os2->sCapHeight, freetype->face->size->metrics.y_scale));
unlockFace();
return answer;
}
return calculatedCapHeight();
}
QFixed QFontEngineFT::descent() const QFixed QFontEngineFT::descent() const
{ {
QFixed v = QFixed::fromFixed(-metrics.descender); QFixed v = QFixed::fromFixed(-metrics.descender);
@ -1317,33 +1328,25 @@ QFixed QFontEngineFT::leading() const
QFixed QFontEngineFT::xHeight() const QFixed QFontEngineFT::xHeight() const
{ {
if (!isScalableBitmap()) { TT_OS2 *os2 = (TT_OS2 *)FT_Get_Sfnt_Table(freetype->face, ft_sfnt_os2);
TT_OS2 *os2 = (TT_OS2 *)FT_Get_Sfnt_Table(freetype->face, ft_sfnt_os2); if (os2 && os2->sxHeight) {
if (os2 && os2->sxHeight) { lockFace();
lockFace(); QFixed answer = QFixed(os2->sxHeight * freetype->face->size->metrics.y_ppem) / emSquareSize();
QFixed answer = QFixed(os2->sxHeight * freetype->face->size->metrics.y_ppem) / emSquareSize(); unlockFace();
unlockFace(); return answer;
return answer;
}
} else {
return QFixed(freetype->face->size->metrics.y_ppem) * scalableBitmapScaleFactor;
} }
return QFontEngine::xHeight(); return QFontEngine::xHeight();
} }
QFixed QFontEngineFT::averageCharWidth() const QFixed QFontEngineFT::averageCharWidth() const
{ {
if (!isScalableBitmap()) { TT_OS2 *os2 = (TT_OS2 *)FT_Get_Sfnt_Table(freetype->face, ft_sfnt_os2);
TT_OS2 *os2 = (TT_OS2 *)FT_Get_Sfnt_Table(freetype->face, ft_sfnt_os2); if (os2 && os2->xAvgCharWidth) {
if (os2 && os2->xAvgCharWidth) { lockFace();
lockFace(); QFixed answer = QFixed(os2->xAvgCharWidth * freetype->face->size->metrics.x_ppem) / emSquareSize();
QFixed answer = QFixed(os2->xAvgCharWidth * freetype->face->size->metrics.x_ppem) / emSquareSize(); unlockFace();
unlockFace(); return answer;
return answer;
}
} else {
const qreal aspectRatio = (qreal)xsize / ysize;
return QFixed::fromReal(fontDef.pixelSize * aspectRatio);
} }
return QFontEngine::averageCharWidth(); return QFontEngine::averageCharWidth();
@ -1842,7 +1845,7 @@ static inline QImage alphaMapFromGlyphData(QFontEngineFT::Glyph *glyph, QFontEng
bytesPerLine = (glyph->width + 3) & ~3; bytesPerLine = (glyph->width + 3) & ~3;
break; break;
case QFontEngine::Format_A32: case QFontEngine::Format_A32:
format = QImage::Format_ARGB32; format = QImage::Format_RGB32;
bytesPerLine = glyph->width * 4; bytesPerLine = glyph->width * 4;
break; break;
default: default:

View File

@ -209,6 +209,7 @@ private:
int synthesized() const Q_DECL_OVERRIDE; int synthesized() const Q_DECL_OVERRIDE;
QFixed ascent() const Q_DECL_OVERRIDE; QFixed ascent() const Q_DECL_OVERRIDE;
QFixed capHeight() const Q_DECL_OVERRIDE;
QFixed descent() const Q_DECL_OVERRIDE; QFixed descent() const Q_DECL_OVERRIDE;
QFixed leading() const Q_DECL_OVERRIDE; QFixed leading() const Q_DECL_OVERRIDE;
QFixed xHeight() const Q_DECL_OVERRIDE; QFixed xHeight() const Q_DECL_OVERRIDE;

View File

@ -211,6 +211,7 @@ public:
glyph_metrics_t tightBoundingBox(const QGlyphLayout &glyphs); glyph_metrics_t tightBoundingBox(const QGlyphLayout &glyphs);
virtual QFixed ascent() const = 0; virtual QFixed ascent() const = 0;
virtual QFixed capHeight() const = 0;
virtual QFixed descent() const = 0; virtual QFixed descent() const = 0;
virtual QFixed leading() const = 0; virtual QFixed leading() const = 0;
virtual QFixed xHeight() const; virtual QFixed xHeight() const;
@ -348,6 +349,7 @@ protected:
QFixed lastRightBearing(const QGlyphLayout &glyphs, bool round = false); QFixed lastRightBearing(const QGlyphLayout &glyphs, bool round = false);
inline void setUserData(const QVariant &userData) { m_userData = userData; } inline void setUserData(const QVariant &userData) { m_userData = userData; }
QFixed calculatedCapHeight() const;
private: private:
struct GlyphCacheEntry { struct GlyphCacheEntry {
@ -414,6 +416,7 @@ public:
virtual QFontEngine *cloneWithSize(qreal pixelSize) const Q_DECL_OVERRIDE; virtual QFontEngine *cloneWithSize(qreal pixelSize) const Q_DECL_OVERRIDE;
virtual QFixed ascent() const Q_DECL_OVERRIDE; virtual QFixed ascent() const Q_DECL_OVERRIDE;
virtual QFixed capHeight() const Q_DECL_OVERRIDE;
virtual QFixed descent() const Q_DECL_OVERRIDE; virtual QFixed descent() const Q_DECL_OVERRIDE;
virtual QFixed leading() const Q_DECL_OVERRIDE; virtual QFixed leading() const Q_DECL_OVERRIDE;
virtual qreal maxCharWidth() const Q_DECL_OVERRIDE; virtual qreal maxCharWidth() const Q_DECL_OVERRIDE;
@ -451,6 +454,7 @@ public:
virtual void getGlyphBearings(glyph_t glyph, qreal *leftBearing = 0, qreal *rightBearing = 0) Q_DECL_OVERRIDE; virtual void getGlyphBearings(glyph_t glyph, qreal *leftBearing = 0, qreal *rightBearing = 0) Q_DECL_OVERRIDE;
virtual QFixed ascent() const Q_DECL_OVERRIDE; virtual QFixed ascent() const Q_DECL_OVERRIDE;
virtual QFixed capHeight() const Q_DECL_OVERRIDE;
virtual QFixed descent() const Q_DECL_OVERRIDE; virtual QFixed descent() const Q_DECL_OVERRIDE;
virtual QFixed leading() const Q_DECL_OVERRIDE; virtual QFixed leading() const Q_DECL_OVERRIDE;
virtual QFixed xHeight() const Q_DECL_OVERRIDE; virtual QFixed xHeight() const Q_DECL_OVERRIDE;

View File

@ -459,6 +459,11 @@ QFixed QFontEngineQPF2::ascent() const
return QFixed::fromReal(extractHeaderField(fontData, Tag_Ascent).value<qreal>()); return QFixed::fromReal(extractHeaderField(fontData, Tag_Ascent).value<qreal>());
} }
QFixed QFontEngineQPF2::capHeight() const
{
return calculatedCapHeight();
}
QFixed QFontEngineQPF2::descent() const QFixed QFontEngineQPF2::descent() const
{ {
return QFixed::fromReal(extractHeaderField(fontData, Tag_Descent).value<qreal>()); return QFixed::fromReal(extractHeaderField(fontData, Tag_Descent).value<qreal>());

View File

@ -172,6 +172,7 @@ public:
glyph_metrics_t boundingBox(glyph_t glyph) Q_DECL_OVERRIDE; glyph_metrics_t boundingBox(glyph_t glyph) Q_DECL_OVERRIDE;
QFixed ascent() const Q_DECL_OVERRIDE; QFixed ascent() const Q_DECL_OVERRIDE;
QFixed capHeight() const Q_DECL_OVERRIDE;
QFixed descent() const Q_DECL_OVERRIDE; QFixed descent() const Q_DECL_OVERRIDE;
QFixed leading() const Q_DECL_OVERRIDE; QFixed leading() const Q_DECL_OVERRIDE;
qreal maxCharWidth() const Q_DECL_OVERRIDE; qreal maxCharWidth() const Q_DECL_OVERRIDE;

View File

@ -274,6 +274,24 @@ int QFontMetrics::ascent() const
return qRound(engine->ascent()); return qRound(engine->ascent());
} }
/*!
Returns the cap height of the font.
\since 5.8
The cap height of a font is the height of a capital letter above
the baseline. It specifically is the height of capital letters
that are flat - such as H or I - as opposed to round letters such
as O, or pointed letters like A, both of which may display overshoot.
\sa ascent()
*/
int QFontMetrics::capHeight() const
{
QFontEngine *engine = d->engineForScript(QChar::Script_Common);
Q_ASSERT(engine != 0);
return qRound(engine->capHeight());
}
/*! /*!
Returns the descent of the font. Returns the descent of the font.
@ -1138,6 +1156,24 @@ qreal QFontMetricsF::ascent() const
return engine->ascent().toReal(); return engine->ascent().toReal();
} }
/*!
Returns the cap height of the font.
\since 5.8
The cap height of a font is the height of a capital letter above
the baseline. It specifically is the height of capital letters
that are flat - such as H or I - as opposed to round letters such
as O, or pointed letters like A, both of which may display overshoot.
\sa ascent()
*/
qreal QFontMetricsF::capHeight() const
{
QFontEngine *engine = d->engineForScript(QChar::Script_Common);
Q_ASSERT(engine != 0);
return engine->capHeight().toReal();
}
/*! /*!
Returns the descent of the font. Returns the descent of the font.

View File

@ -73,6 +73,7 @@ public:
{ qSwap(d, other.d); } { qSwap(d, other.d); }
int ascent() const; int ascent() const;
int capHeight() const;
int descent() const; int descent() const;
int height() const; int height() const;
int leading() const; int leading() const;
@ -146,6 +147,7 @@ public:
void swap(QFontMetricsF &other) { qSwap(d, other.d); } void swap(QFontMetricsF &other) { qSwap(d, other.d); }
qreal ascent() const; qreal ascent() const;
qreal capHeight() const;
qreal descent() const; qreal descent() const;
qreal height() const; qreal height() const;
qreal leading() const; qreal leading() const;

View File

@ -740,7 +740,7 @@ static void convertPath(const QPainterPath &path, QVector<TTF_POINT> *points, QV
points->takeLast(); points->takeLast();
endPoints->append(points->size() - 1); endPoints->append(points->size() - 1);
} }
// fall through Q_FALLTHROUGH();
case QPainterPath::LineToElement: case QPainterPath::LineToElement:
p.flags = OnCurve; p.flags = OnCurve;
break; break;
@ -966,7 +966,7 @@ static QTtfGlyph generateGlyph(int index, const QPainterPath &path, qreal advanc
glyph.advanceWidth = qRound(advance * 2048. / ppem); glyph.advanceWidth = qRound(advance * 2048. / ppem);
glyph.lsb = qRound(lsb * 2048. / ppem); glyph.lsb = qRound(lsb * 2048. / ppem);
if (!path.elementCount()) { if (path.isEmpty()) {
//qDebug("glyph %d is empty", index); //qDebug("glyph %d is empty", index);
lsb = 0; lsb = 0;
glyph.xMin = glyph.xMax = glyph.yMin = glyph.yMax = 0; glyph.xMin = glyph.xMax = glyph.yMin = glyph.yMax = 0;

View File

@ -324,6 +324,23 @@ qreal QRawFont::ascent() const
return d->isValid() ? d->fontEngine->ascent().toReal() : 0.0; return d->isValid() ? d->fontEngine->ascent().toReal() : 0.0;
} }
/*!
Returns the cap height of this QRawFont in pixel units.
\since 5.8
The cap height of a font is the height of a capital letter above
the baseline. It specifically is the height of capital letters
that are flat - such as H or I - as opposed to round letters such
as O, or pointed letters like A, both of which may display overshoot.
\sa QFontMetricsF::capHeight()
*/
qreal QRawFont::capHeight() const
{
return d->isValid() ? d->fontEngine->capHeight().toReal() : 0.0;
}
/*! /*!
Returns the descent of this QRawFont in pixel units. Returns the descent of this QRawFont in pixel units.

View File

@ -118,6 +118,7 @@ public:
QFont::HintingPreference hintingPreference() const; QFont::HintingPreference hintingPreference() const;
qreal ascent() const; qreal ascent() const;
qreal capHeight() const;
qreal descent() const; qreal descent() const;
qreal leading() const; qreal leading() const;
qreal xHeight() const; qreal xHeight() const;

View File

@ -438,7 +438,7 @@ bool QTextCursorPrivate::movePosition(QTextCursor::MoveOperation op, QTextCursor
if (relativePos < blockIt.length()-1) if (relativePos < blockIt.length()-1)
++position; ++position;
// FALL THROUGH! Q_FALLTHROUGH();
} }
case QTextCursor::PreviousWord: case QTextCursor::PreviousWord:
case QTextCursor::WordLeft: case QTextCursor::WordLeft:
@ -590,9 +590,9 @@ bool QTextCursorPrivate::movePosition(QTextCursor::MoveOperation op, QTextCursor
adjustX = false; adjustX = false;
break; break;
} }
case QTextCursor::NextCell: // fall through case QTextCursor::NextCell:
case QTextCursor::PreviousCell: // fall through case QTextCursor::PreviousCell:
case QTextCursor::NextRow: // fall through case QTextCursor::NextRow:
case QTextCursor::PreviousRow: { case QTextCursor::PreviousRow: {
QTextTable *table = qobject_cast<QTextTable *>(priv->frameAt(position)); QTextTable *table = qobject_cast<QTextTable *>(priv->frameAt(position));
if (!table) if (!table)

View File

@ -131,7 +131,7 @@ static bool isValidBlockSeparator(QChar ch)
|| ch == QTextEndOfFrame; || ch == QTextEndOfFrame;
} }
static bool noBlockInString(const QString &str) static bool noBlockInString(const QStringRef &str)
{ {
return !str.contains(QChar::ParagraphSeparator) return !str.contains(QChar::ParagraphSeparator)
&& !str.contains(QTextBeginningOfFrame) && !str.contains(QTextBeginningOfFrame)
@ -320,7 +320,7 @@ void QTextDocumentPrivate::setLayout(QAbstractTextDocumentLayout *layout)
void QTextDocumentPrivate::insert_string(int pos, uint strPos, uint length, int format, QTextUndoCommand::Operation op) void QTextDocumentPrivate::insert_string(int pos, uint strPos, uint length, int format, QTextUndoCommand::Operation op)
{ {
// ##### optimize when only appending to the fragment! // ##### optimize when only appending to the fragment!
Q_ASSERT(noBlockInString(text.mid(strPos, length))); Q_ASSERT(noBlockInString(text.midRef(strPos, length)));
split(pos); split(pos);
uint x = fragments.insert_single(pos, length); uint x = fragments.insert_single(pos, length);
@ -476,7 +476,7 @@ void QTextDocumentPrivate::insert(int pos, const QString &str, int format)
if (str.size() == 0) if (str.size() == 0)
return; return;
Q_ASSERT(noBlockInString(str)); Q_ASSERT(noBlockInString(QStringRef(&str)));
int strPos = text.length(); int strPos = text.length();
text.append(str); text.append(str);
@ -494,7 +494,7 @@ int QTextDocumentPrivate::remove_string(int pos, uint length, QTextUndoCommand::
Q_ASSERT(blocks.size(b) > length); Q_ASSERT(blocks.size(b) > length);
Q_ASSERT(x && fragments.position(x) == (uint)pos && fragments.size(x) == length); Q_ASSERT(x && fragments.position(x) == (uint)pos && fragments.size(x) == length);
Q_ASSERT(noBlockInString(text.mid(fragments.fragment(x)->stringPosition, length))); Q_ASSERT(noBlockInString(text.midRef(fragments.fragment(x)->stringPosition, length)));
blocks.setSize(b, blocks.size(b)-length); blocks.setSize(b, blocks.size(b)-length);
@ -629,7 +629,7 @@ void QTextDocumentPrivate::move(int pos, int to, int length, QTextUndoCommand::O
if (key+1 != blocks.position(b)) { if (key+1 != blocks.position(b)) {
// qDebug("remove_string from %d length %d", key, X->size_array[0]); // qDebug("remove_string from %d length %d", key, X->size_array[0]);
Q_ASSERT(noBlockInString(text.mid(X->stringPosition, X->size_array[0]))); Q_ASSERT(noBlockInString(text.midRef(X->stringPosition, X->size_array[0])));
w = remove_string(key, X->size_array[0], op); w = remove_string(key, X->size_array[0], op);
if (needsInsert) { if (needsInsert) {

View File

@ -827,7 +827,7 @@ bool QTextHtmlImporter::closeTag()
case Html_div: case Html_div:
if (closedNode->children.isEmpty()) if (closedNode->children.isEmpty())
break; break;
// fall through Q_FALLTHROUGH();
default: default:
if (closedNode->isBlock()) if (closedNode->isBlock())
blockTagClosed = true; blockTagClosed = true;

View File

@ -508,7 +508,7 @@ static bool bidiItemize(QTextEngine *engine, QScriptAnalysis *analysis, QBidiCon
case QChar::DirAN: case QChar::DirAN:
if (eor >= 0) if (eor >= 0)
appendItems(analysis, sor, eor, control, dir); appendItems(analysis, sor, eor, control, dir);
// fall through Q_FALLTHROUGH();
case QChar::DirR: case QChar::DirR:
case QChar::DirAL: case QChar::DirAL:
dir = QChar::DirR; eor = current; status.eor = QChar::DirR; break; dir = QChar::DirR; eor = current; status.eor = QChar::DirR; break;
@ -564,7 +564,7 @@ static bool bidiItemize(QTextEngine *engine, QScriptAnalysis *analysis, QBidiCon
status.eor = QChar::DirON; status.eor = QChar::DirON;
dir = QChar::DirAN; dir = QChar::DirAN;
} }
// fall through Q_FALLTHROUGH();
case QChar::DirEN: case QChar::DirEN:
case QChar::DirL: case QChar::DirL:
eor = current; eor = current;
@ -744,7 +744,7 @@ static bool bidiItemize(QTextEngine *engine, QScriptAnalysis *analysis, QBidiCon
status.last = QChar::DirL; status.last = QChar::DirL;
break; break;
} }
// fall through Q_FALLTHROUGH();
default: default:
status.last = dirCurrent; status.last = dirCurrent;
} }
@ -1664,7 +1664,7 @@ void QTextEngine::itemize() const
analysis->bidiLevel = control.baseLevel(); analysis->bidiLevel = control.baseLevel();
break; break;
} }
// fall through Q_FALLTHROUGH();
default: default:
analysis->flags = QScriptAnalysis::None; analysis->flags = QScriptAnalysis::None;
break; break;
@ -2251,7 +2251,6 @@ void QTextEngine::justify(const QScriptLine &line)
case Justification_Prohibited: case Justification_Prohibited:
break; break;
case Justification_Space: case Justification_Space:
// fall through
case Justification_Arabic_Space: case Justification_Arabic_Space:
if (kashida_pos >= 0) { if (kashida_pos >= 0) {
// qDebug("kashida position at %d in word", kashida_pos); // qDebug("kashida position at %d in word", kashida_pos);
@ -2264,7 +2263,7 @@ void QTextEngine::justify(const QScriptLine &line)
} }
kashida_pos = -1; kashida_pos = -1;
kashida_type = Justification_Arabic_Normal; kashida_type = Justification_Arabic_Normal;
// fall through Q_FALLTHROUGH();
case Justification_Character: case Justification_Character:
set(&justificationPoints[nPoints++], justification, g.mid(i), fontEngine(si)); set(&justificationPoints[nPoints++], justification, g.mid(i), fontEngine(si));
maxJustify = qMax(maxJustify, justification); maxJustify = qMax(maxJustify, justification);
@ -2712,7 +2711,7 @@ static QString stringMidRetainingBidiCC(const QString &string,
suffix += c; suffix += c;
} }
return prefix + ellidePrefix + string.mid(midStart, midLength) + ellideSuffix + suffix; return prefix + ellidePrefix + string.midRef(midStart, midLength) + ellideSuffix + suffix;
} }
QString QTextEngine::elidedText(Qt::TextElideMode mode, const QFixed &width, int flags, int from, int count) const QString QTextEngine::elidedText(Qt::TextElideMode mode, const QFixed &width, int flags, int from, int count) const
@ -2875,7 +2874,7 @@ QString QTextEngine::elidedText(Qt::TextElideMode mode, const QFixed &width, int
if (prevCharJoins(layoutData->string, rightPos)) if (prevCharJoins(layoutData->string, rightPos))
ellipsisText.append(QChar(0x200d) /* ZWJ */); ellipsisText.append(QChar(0x200d) /* ZWJ */);
return layoutData->string.mid(from, leftPos - from) + ellipsisText + layoutData->string.mid(rightPos, to - rightPos); return layoutData->string.midRef(from, leftPos - from) + ellipsisText + layoutData->string.midRef(rightPos, to - rightPos);
} }
return layoutData->string.mid(from, to - from); return layoutData->string.mid(from, to - from);
@ -2967,9 +2966,8 @@ QFixed QTextEngine::calculateTabWidth(int item, QFixed x) const
switch (tabSpec.type) { switch (tabSpec.type) {
case QTextOption::CenterTab: case QTextOption::CenterTab:
length /= 2; length /= 2;
// fall through Q_FALLTHROUGH();
case QTextOption::DelimiterTab: case QTextOption::DelimiterTab:
// fall through
case QTextOption::RightTab: case QTextOption::RightTab:
tab = QFixed::fromReal(tabSpec.position) * dpiScale - length; tab = QFixed::fromReal(tabSpec.position) * dpiScale - length;
if (tab < x) // default to tab taking no space if (tab < x) // default to tab taking no space

View File

@ -1871,7 +1871,7 @@ QVector<QCss::Declaration> standardDeclarationForNode(const QTextHtmlParserNode
decls << decl; decls << decl;
if (node.id == Html_b || node.id == Html_strong) if (node.id == Html_b || node.id == Html_strong)
break; break;
// Delibrate fall through Q_FALLTHROUGH();
case Html_big: case Html_big:
case Html_small: case Html_small:
if (node.id != Html_th) { if (node.id != Html_th) {
@ -1892,7 +1892,7 @@ QVector<QCss::Declaration> standardDeclarationForNode(const QTextHtmlParserNode
decls << decl; decls << decl;
break; break;
} }
// Delibrate fall through Q_FALLTHROUGH();
case Html_center: case Html_center:
case Html_td: case Html_td:
decl = QCss::Declaration(); decl = QCss::Declaration();
@ -1969,7 +1969,7 @@ QVector<QCss::Declaration> standardDeclarationForNode(const QTextHtmlParserNode
} }
if (node.id != Html_pre) if (node.id != Html_pre)
break; break;
// Delibrate fall through Q_FALLTHROUGH();
case Html_br: case Html_br:
case Html_nobr: case Html_nobr:
decl = QCss::Declaration(); decl = QCss::Declaration();

View File

@ -48,9 +48,9 @@
// W A R N I N G // W A R N I N G
// ------------- // -------------
// //
// This file is not part of the Qt API. It exists for the convenience // This file is not part of the Qt API. It exists purely as an
// of the QLibrary class. This header file may change from // implementation detail. This header file may change from version to
// version to version without notice, or even be removed. // version without notice, or even be removed.
// //
// We mean it. // We mean it.
// //

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