Whitespace cleanup in corelib/ mimetypes, plugin and thread
Done with selective application of clang-format Change-Id: Iee6bf2426de81356b6d480629ba972f980b6d93d Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
3e09ac369d
commit
1be271713e
@ -131,7 +131,7 @@ QMimeTypeParserBase::ParseState QMimeTypeParserBase::nextState(ParseState curren
|
|||||||
case ParseMagicMatchRule:
|
case ParseMagicMatchRule:
|
||||||
if (startElement == QLatin1String(mimeTypeTagC)) // Sequence of <mime-type>
|
if (startElement == QLatin1String(mimeTypeTagC)) // Sequence of <mime-type>
|
||||||
return ParseMimeType;
|
return ParseMimeType;
|
||||||
if (startElement == QLatin1String(commentTagC ))
|
if (startElement == QLatin1String(commentTagC))
|
||||||
return ParseComment;
|
return ParseComment;
|
||||||
if (startElement == QLatin1String(genericIconTagC))
|
if (startElement == QLatin1String(genericIconTagC))
|
||||||
return ParseGenericIcon;
|
return ParseGenericIcon;
|
||||||
@ -174,7 +174,8 @@ bool QMimeTypeParserBase::parseNumber(QStringView n, int *target, QString *error
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifndef QT_NO_XMLSTREAMREADER
|
#ifndef QT_NO_XMLSTREAMREADER
|
||||||
struct CreateMagicMatchRuleResult {
|
struct CreateMagicMatchRuleResult
|
||||||
|
{
|
||||||
QString errorMessage; // must be first
|
QString errorMessage; // must be first
|
||||||
QMimeMagicRule rule;
|
QMimeMagicRule rule;
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ int QElfParser::parse(const char *dataStart, ulong fdlen, const QString &library
|
|||||||
qDebug() << "QElfParser::parse " << library;
|
qDebug() << "QElfParser::parse " << library;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (fdlen < 64){
|
if (fdlen < 64) {
|
||||||
if (lib)
|
if (lib)
|
||||||
lib->errorString = QLibrary::tr("'%1' is not an ELF object (%2)").arg(library, QLibrary::tr("file too small"));
|
lib->errorString = QLibrary::tr("'%1' is not an ELF object (%2)").arg(library, QLibrary::tr("file too small"));
|
||||||
return NotElf;
|
return NotElf;
|
||||||
@ -129,7 +129,7 @@ int QElfParser::parse(const char *dataStart, ulong fdlen, const QString &library
|
|||||||
|
|
||||||
qelfhalf_t e_shentsize = read<qelfhalf_t> (data);
|
qelfhalf_t e_shentsize = read<qelfhalf_t> (data);
|
||||||
|
|
||||||
if (e_shentsize % 4){
|
if (e_shentsize % 4) {
|
||||||
if (lib)
|
if (lib)
|
||||||
lib->errorString = QLibrary::tr("'%1' is an invalid ELF object (%2)").arg(library, QLibrary::tr("unexpected e_shentsize"));
|
lib->errorString = QLibrary::tr("'%1' is an invalid ELF object (%2)").arg(library, QLibrary::tr("unexpected e_shentsize"));
|
||||||
return Corrupt;
|
return Corrupt;
|
||||||
|
@ -56,7 +56,7 @@
|
|||||||
|
|
||||||
QT_REQUIRE_CONFIG(library);
|
QT_REQUIRE_CONFIG(library);
|
||||||
|
|
||||||
#if defined (Q_OF_ELF) && defined(Q_CC_GNU)
|
#if defined(Q_OF_ELF) && defined(Q_CC_GNU)
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
@ -72,7 +72,7 @@ class QElfParser
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum { QtMetaDataSection, NoQtSection, NotElf, Corrupt };
|
enum { QtMetaDataSection, NoQtSection, NotElf, Corrupt };
|
||||||
enum {ElfLittleEndian = 0, ElfBigEndian = 1};
|
enum { ElfLittleEndian = 0, ElfBigEndian = 1 };
|
||||||
|
|
||||||
struct ElfSectionHeader
|
struct ElfSectionHeader
|
||||||
{
|
{
|
||||||
|
@ -45,7 +45,6 @@
|
|||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
|
||||||
struct Q_CORE_EXPORT QFactoryInterface
|
struct Q_CORE_EXPORT QFactoryInterface
|
||||||
{
|
{
|
||||||
virtual ~QFactoryInterface();
|
virtual ~QFactoryInterface();
|
||||||
|
@ -141,7 +141,7 @@ class QFactoryLoaderPrivate : public QObjectPrivate
|
|||||||
{
|
{
|
||||||
Q_DECLARE_PUBLIC(QFactoryLoader)
|
Q_DECLARE_PUBLIC(QFactoryLoader)
|
||||||
public:
|
public:
|
||||||
QFactoryLoaderPrivate(){}
|
QFactoryLoaderPrivate() { }
|
||||||
QByteArray iid;
|
QByteArray iid;
|
||||||
#if QT_CONFIG(library)
|
#if QT_CONFIG(library)
|
||||||
~QFactoryLoaderPrivate();
|
~QFactoryLoaderPrivate();
|
||||||
|
@ -286,7 +286,7 @@ static bool findPatternUnloaded(const QString &library, QLibraryPrivate *lib)
|
|||||||
pos += rel;
|
pos += rel;
|
||||||
hasMetaData = true;
|
hasMetaData = true;
|
||||||
}
|
}
|
||||||
#elif defined (Q_OF_MACH_O)
|
#elif defined(Q_OF_MACH_O)
|
||||||
{
|
{
|
||||||
QString errorString;
|
QString errorString;
|
||||||
int r = QMachOParser::parse(filedata, fdlen, library, &errorString, &pos, &fdlen);
|
int r = QMachOParser::parse(filedata, fdlen, library, &errorString, &pos, &fdlen);
|
||||||
@ -382,7 +382,7 @@ private:
|
|||||||
static inline QLibraryStore *instance();
|
static inline QLibraryStore *instance();
|
||||||
|
|
||||||
// all members and instance() are protected by qt_library_mutex
|
// all members and instance() are protected by qt_library_mutex
|
||||||
typedef QMap<QString, QLibraryPrivate*> LibraryMap;
|
typedef QMap<QString, QLibraryPrivate *> LibraryMap;
|
||||||
LibraryMap libraryMap;
|
LibraryMap libraryMap;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -608,8 +608,8 @@ bool QLibraryPrivate::unload(UnloadFlag flag)
|
|||||||
if (qt_debug_component())
|
if (qt_debug_component())
|
||||||
qWarning() << "QLibraryPrivate::unload succeeded on" << fileName
|
qWarning() << "QLibraryPrivate::unload succeeded on" << fileName
|
||||||
<< (flag == NoUnloadSys ? "(faked)" : "");
|
<< (flag == NoUnloadSys ? "(faked)" : "");
|
||||||
//when the library is unloaded, we release the reference on it so that 'this'
|
// when the library is unloaded, we release the reference on it so that 'this'
|
||||||
//can get deleted
|
// can get deleted
|
||||||
libraryRefCount.deref();
|
libraryRefCount.deref();
|
||||||
pHnd.storeRelaxed(nullptr);
|
pHnd.storeRelaxed(nullptr);
|
||||||
instanceFactory.storeRelaxed(nullptr);
|
instanceFactory.storeRelaxed(nullptr);
|
||||||
@ -772,7 +772,7 @@ void QLibraryPrivate::updatePluginState()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!success) {
|
if (!success) {
|
||||||
if (errorString.isEmpty()){
|
if (errorString.isEmpty()) {
|
||||||
if (fileName.isEmpty())
|
if (fileName.isEmpty())
|
||||||
errorString = QLibrary::tr("The shared library was not found.");
|
errorString = QLibrary::tr("The shared library was not found.");
|
||||||
else
|
else
|
||||||
@ -884,12 +884,11 @@ QLibrary::QLibrary(QObject *parent) : QObject(parent)
|
|||||||
suffix in accordance with the platform, e.g. ".so" on Unix,
|
suffix in accordance with the platform, e.g. ".so" on Unix,
|
||||||
".dylib" on \macos and iOS, and ".dll" on Windows. (See \l{fileName}.)
|
".dylib" on \macos and iOS, and ".dll" on Windows. (See \l{fileName}.)
|
||||||
*/
|
*/
|
||||||
QLibrary::QLibrary(const QString& fileName, QObject *parent) : QObject(parent)
|
QLibrary::QLibrary(const QString &fileName, QObject *parent) : QObject(parent)
|
||||||
{
|
{
|
||||||
setFileName(fileName);
|
setFileName(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Constructs a library object with the given \a parent that will
|
Constructs a library object with the given \a parent that will
|
||||||
load the library specified by \a fileName and major version number \a verNum.
|
load the library specified by \a fileName and major version number \a verNum.
|
||||||
@ -900,7 +899,7 @@ QLibrary::QLibrary(const QString& fileName, QObject *parent) : QObject(parent)
|
|||||||
suffix in accordance with the platform, e.g. ".so" on Unix,
|
suffix in accordance with the platform, e.g. ".so" on Unix,
|
||||||
".dylib" on \macos and iOS, and ".dll" on Windows. (See \l{fileName}.)
|
".dylib" on \macos and iOS, and ".dll" on Windows. (See \l{fileName}.)
|
||||||
*/
|
*/
|
||||||
QLibrary::QLibrary(const QString& fileName, int verNum, QObject *parent) : QObject(parent)
|
QLibrary::QLibrary(const QString &fileName, int verNum, QObject *parent) : QObject(parent)
|
||||||
{
|
{
|
||||||
setFileNameAndVersion(fileName, verNum);
|
setFileNameAndVersion(fileName, verNum);
|
||||||
}
|
}
|
||||||
@ -915,7 +914,7 @@ QLibrary::QLibrary(const QString& fileName, int verNum, QObject *parent) : QObje
|
|||||||
suffix in accordance with the platform, e.g. ".so" on Unix,
|
suffix in accordance with the platform, e.g. ".so" on Unix,
|
||||||
".dylib" on \macos and iOS, and ".dll" on Windows. (See \l{fileName}.)
|
".dylib" on \macos and iOS, and ".dll" on Windows. (See \l{fileName}.)
|
||||||
*/
|
*/
|
||||||
QLibrary::QLibrary(const QString& fileName, const QString &version, QObject *parent)
|
QLibrary::QLibrary(const QString &fileName, const QString &version, QObject *parent)
|
||||||
: QObject(parent)
|
: QObject(parent)
|
||||||
{
|
{
|
||||||
setFileNameAndVersion(fileName, version);
|
setFileNameAndVersion(fileName, version);
|
||||||
@ -935,7 +934,6 @@ QLibrary::~QLibrary()
|
|||||||
d->release();
|
d->release();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\property QLibrary::fileName
|
\property QLibrary::fileName
|
||||||
\brief the file name of the library
|
\brief the file name of the library
|
||||||
|
@ -67,9 +67,9 @@ public:
|
|||||||
Q_FLAG(LoadHints)
|
Q_FLAG(LoadHints)
|
||||||
|
|
||||||
explicit QLibrary(QObject *parent = nullptr);
|
explicit QLibrary(QObject *parent = nullptr);
|
||||||
explicit QLibrary(const QString& fileName, QObject *parent = nullptr);
|
explicit QLibrary(const QString &fileName, QObject *parent = nullptr);
|
||||||
explicit QLibrary(const QString& fileName, int verNum, QObject *parent = nullptr);
|
explicit QLibrary(const QString &fileName, int verNum, QObject *parent = nullptr);
|
||||||
explicit QLibrary(const QString& fileName, const QString &version, QObject *parent = nullptr);
|
explicit QLibrary(const QString &fileName, const QString &version, QObject *parent = nullptr);
|
||||||
~QLibrary();
|
~QLibrary();
|
||||||
|
|
||||||
QFunctionPointer resolve(const char *symbol);
|
QFunctionPointer resolve(const char *symbol);
|
||||||
@ -92,6 +92,7 @@ public:
|
|||||||
|
|
||||||
void setLoadHints(LoadHints hints);
|
void setLoadHints(LoadHints hints);
|
||||||
LoadHints loadHints() const;
|
LoadHints loadHints() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
enum LoadStatusTag {
|
enum LoadStatusTag {
|
||||||
NotLoaded,
|
NotLoaded,
|
||||||
|
@ -61,10 +61,10 @@ QT_BEGIN_NAMESPACE
|
|||||||
static QString qdlerror()
|
static QString qdlerror()
|
||||||
{
|
{
|
||||||
const char *err = dlerror();
|
const char *err = dlerror();
|
||||||
return err ? QLatin1Char('(') + QString::fromLocal8Bit(err) + QLatin1Char(')'): QString();
|
return err ? QLatin1Char('(') + QString::fromLocal8Bit(err) + QLatin1Char(')') : QString();
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList QLibraryPrivate::suffixes_sys(const QString& fullVersion)
|
QStringList QLibraryPrivate::suffixes_sys(const QString &fullVersion)
|
||||||
{
|
{
|
||||||
QStringList suffixes;
|
QStringList suffixes;
|
||||||
#if defined(Q_OS_HPUX)
|
#if defined(Q_OS_HPUX)
|
||||||
@ -266,7 +266,7 @@ bool QLibraryPrivate::load_sys()
|
|||||||
QByteArray utf8Bundle = fileName.toUtf8();
|
QByteArray utf8Bundle = fileName.toUtf8();
|
||||||
QCFType<CFURLRef> bundleUrl = CFURLCreateFromFileSystemRepresentation(NULL, reinterpret_cast<const UInt8*>(utf8Bundle.data()), utf8Bundle.length(), true);
|
QCFType<CFURLRef> bundleUrl = CFURLCreateFromFileSystemRepresentation(NULL, reinterpret_cast<const UInt8*>(utf8Bundle.data()), utf8Bundle.length(), true);
|
||||||
QCFType<CFBundleRef> bundle = CFBundleCreate(NULL, bundleUrl);
|
QCFType<CFBundleRef> bundle = CFBundleCreate(NULL, bundleUrl);
|
||||||
if(bundle) {
|
if (bundle) {
|
||||||
QCFType<CFURLRef> url = CFBundleCopyExecutableURL(bundle);
|
QCFType<CFURLRef> url = CFBundleCopyExecutableURL(bundle);
|
||||||
char executableFile[FILENAME_MAX];
|
char executableFile[FILENAME_MAX];
|
||||||
CFURLGetFileSystemRepresentation(url, true, reinterpret_cast<UInt8*>(executableFile), FILENAME_MAX);
|
CFURLGetFileSystemRepresentation(url, true, reinterpret_cast<UInt8*>(executableFile), FILENAME_MAX);
|
||||||
@ -320,7 +320,7 @@ Q_CORE_EXPORT QFunctionPointer qt_mac_resolve_sys(void *handle, const char *symb
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
QFunctionPointer QLibraryPrivate::resolve_sys(const char* symbol)
|
QFunctionPointer QLibraryPrivate::resolve_sys(const char *symbol)
|
||||||
{
|
{
|
||||||
QFunctionPointer address = QFunctionPointer(dlsym(pHnd.loadAcquire(), symbol));
|
QFunctionPointer address = QFunctionPointer(dlsym(pHnd.loadAcquire(), symbol));
|
||||||
return address;
|
return address;
|
||||||
|
@ -147,7 +147,7 @@ bool QLibraryPrivate::unload_sys()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
QFunctionPointer QLibraryPrivate::resolve_sys(const char* symbol)
|
QFunctionPointer QLibraryPrivate::resolve_sys(const char *symbol)
|
||||||
{
|
{
|
||||||
FARPROC address = GetProcAddress(pHnd.loadAcquire(), symbol);
|
FARPROC address = GetProcAddress(pHnd.loadAcquire(), symbol);
|
||||||
return QFunctionPointer(address);
|
return QFunctionPointer(address);
|
||||||
|
@ -211,7 +211,6 @@ bool QPluginLoader::load()
|
|||||||
return d->loadPlugin();
|
return d->loadPlugin();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Unloads the plugin and returns \c true if the plugin could be
|
Unloads the plugin and returns \c true if the plugin could be
|
||||||
unloaded; otherwise returns \c false.
|
unloaded; otherwise returns \c false.
|
||||||
@ -234,7 +233,7 @@ bool QPluginLoader::unload()
|
|||||||
did_load = false;
|
did_load = false;
|
||||||
return d->unload();
|
return d->unload();
|
||||||
}
|
}
|
||||||
if (d) // Ouch
|
if (d) // Ouch
|
||||||
d->errorString = tr("The plugin was not loaded.");
|
d->errorString = tr("The plugin was not loaded.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -347,7 +346,7 @@ void QPluginLoader::setFileName(const QString &fileName)
|
|||||||
#else
|
#else
|
||||||
if (qt_debug_component()) {
|
if (qt_debug_component()) {
|
||||||
qWarning("Cannot load %s into a statically linked Qt library.",
|
qWarning("Cannot load %s into a statically linked Qt library.",
|
||||||
(const char*)QFile::encodeName(fileName));
|
(const char *)QFile::encodeName(fileName));
|
||||||
}
|
}
|
||||||
Q_UNUSED(fileName);
|
Q_UNUSED(fileName);
|
||||||
#endif
|
#endif
|
||||||
|
@ -100,4 +100,4 @@ public:
|
|||||||
|
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
#endif //QPLUGINLOADER_H
|
#endif // QPLUGINLOADER_H
|
||||||
|
@ -118,7 +118,6 @@ HINSTANCE QSystemLibrary::load(const wchar_t *libraryName, bool onlySystemDirect
|
|||||||
return inst;
|
return inst;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
@ -110,6 +110,6 @@ private:
|
|||||||
|
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
#endif //Q_OS_WIN
|
#endif // Q_OS_WIN
|
||||||
|
|
||||||
#endif //QSYSTEMLIBRARY_P_H
|
#endif // QSYSTEMLIBRARY_P_H
|
||||||
|
@ -58,7 +58,7 @@ void _q_toHex(char *&dst, Integral value)
|
|||||||
{
|
{
|
||||||
value = qToBigEndian(value);
|
value = qToBigEndian(value);
|
||||||
|
|
||||||
const char* p = reinterpret_cast<const char*>(&value);
|
const char *p = reinterpret_cast<const char *>(&value);
|
||||||
|
|
||||||
for (uint i = 0; i < sizeof(Integral); ++i, dst += 2) {
|
for (uint i = 0; i < sizeof(Integral); ++i, dst += 2) {
|
||||||
dst[0] = QtMiscUtils::toHexLower((p[i] >> 4) & 0xf);
|
dst[0] = QtMiscUtils::toHexLower((p[i] >> 4) & 0xf);
|
||||||
@ -646,7 +646,7 @@ QString QUuid::toString(QUuid::StringFormat mode) const
|
|||||||
QByteArray QUuid::toByteArray(QUuid::StringFormat mode) const
|
QByteArray QUuid::toByteArray(QUuid::StringFormat mode) const
|
||||||
{
|
{
|
||||||
QByteArray result(MaxStringUuidLength, Qt::Uninitialized);
|
QByteArray result(MaxStringUuidLength, Qt::Uninitialized);
|
||||||
const auto end = _q_uuidToHex(*this, const_cast<char*>(result.constData()), mode);
|
const auto end = _q_uuidToHex(*this, const_cast<char *>(result.constData()), mode);
|
||||||
result.resize(end - result.constData());
|
result.resize(end - result.constData());
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -687,7 +687,7 @@ QByteArray QUuid::toRfc4122() const
|
|||||||
{
|
{
|
||||||
// we know how many bytes a UUID has, I hope :)
|
// we know how many bytes a UUID has, I hope :)
|
||||||
QByteArray bytes(16, Qt::Uninitialized);
|
QByteArray bytes(16, Qt::Uninitialized);
|
||||||
uchar *data = reinterpret_cast<uchar*>(bytes.data());
|
uchar *data = reinterpret_cast<uchar *>(bytes.data());
|
||||||
|
|
||||||
qToBigEndian(data1, data);
|
qToBigEndian(data1, data);
|
||||||
data += sizeof(quint32);
|
data += sizeof(quint32);
|
||||||
@ -717,7 +717,7 @@ QDataStream &operator<<(QDataStream &s, const QUuid &id)
|
|||||||
} else {
|
} else {
|
||||||
// we know how many bytes a UUID has, I hope :)
|
// we know how many bytes a UUID has, I hope :)
|
||||||
bytes = QByteArray(16, Qt::Uninitialized);
|
bytes = QByteArray(16, Qt::Uninitialized);
|
||||||
uchar *data = reinterpret_cast<uchar*>(bytes.data());
|
uchar *data = reinterpret_cast<uchar *>(bytes.data());
|
||||||
|
|
||||||
qToLittleEndian(id.data1, data);
|
qToLittleEndian(id.data1, data);
|
||||||
data += sizeof(quint32);
|
data += sizeof(quint32);
|
||||||
|
@ -104,7 +104,7 @@ public:
|
|||||||
data1 = 0;
|
data1 = 0;
|
||||||
data2 = 0;
|
data2 = 0;
|
||||||
data3 = 0;
|
data3 = 0;
|
||||||
for(int i = 0; i < 8; i++)
|
for (int i = 0; i < 8; i++)
|
||||||
data4[i] = 0;
|
data4[i] = 0;
|
||||||
}
|
}
|
||||||
QUuid(uint l, ushort w1, ushort w2, uchar b1, uchar b2, uchar b3, uchar b4, uchar b5, uchar b6, uchar b7, uchar b8) noexcept
|
QUuid(uint l, ushort w1, ushort w2, uchar b1, uchar b2, uchar b3, uchar b4, uchar b5, uchar b6, uchar b7, uchar b8) noexcept
|
||||||
@ -169,7 +169,7 @@ public:
|
|||||||
data1 = guid.Data1;
|
data1 = guid.Data1;
|
||||||
data2 = guid.Data2;
|
data2 = guid.Data2;
|
||||||
data3 = guid.Data3;
|
data3 = guid.Data3;
|
||||||
for(int i = 0; i < 8; i++)
|
for (int i = 0; i < 8; i++)
|
||||||
data4[i] = guid.Data4[i];
|
data4[i] = guid.Data4[i];
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -213,7 +213,6 @@ public:
|
|||||||
return QUuid::createUuidV5(ns, baseData.toUtf8());
|
return QUuid::createUuidV5(ns, baseData.toUtf8());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QUuid::Variant variant() const noexcept;
|
QUuid::Variant variant() const noexcept;
|
||||||
QUuid::Version version() const noexcept;
|
QUuid::Version version() const noexcept;
|
||||||
|
|
||||||
|
@ -105,7 +105,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QList<QFuture<T> > m_futures;
|
QList<QFuture<T>> m_futures;
|
||||||
bool m_cancelOnWait;
|
bool m_cancelOnWait;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -90,7 +90,8 @@ public:
|
|||||||
QAtomicInt refCount;
|
QAtomicInt refCount;
|
||||||
int id;
|
int id;
|
||||||
|
|
||||||
bool ref() {
|
bool ref()
|
||||||
|
{
|
||||||
Q_ASSERT(refCount.loadRelaxed() >= 0);
|
Q_ASSERT(refCount.loadRelaxed() >= 0);
|
||||||
int c;
|
int c;
|
||||||
do {
|
do {
|
||||||
@ -101,7 +102,8 @@ public:
|
|||||||
Q_ASSERT(refCount.loadRelaxed() >= 0);
|
Q_ASSERT(refCount.loadRelaxed() >= 0);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
void deref() {
|
void deref()
|
||||||
|
{
|
||||||
Q_ASSERT(refCount.loadRelaxed() >= 0);
|
Q_ASSERT(refCount.loadRelaxed() >= 0);
|
||||||
if (!refCount.deref())
|
if (!refCount.deref())
|
||||||
release();
|
release();
|
||||||
|
@ -858,7 +858,7 @@ bool QThread::wait(QDeadlineTimer deadline)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QThread::event(QEvent* event)
|
bool QThread::event(QEvent *event)
|
||||||
{
|
{
|
||||||
return QObject::event(event);
|
return QObject::event(event);
|
||||||
}
|
}
|
||||||
|
@ -109,7 +109,8 @@ public:
|
|||||||
|
|
||||||
inline QPostEventList() : QList<QPostEvent>(), recursion(0), startOffset(0), insertionOffset(0) { }
|
inline QPostEventList() : QList<QPostEvent>(), recursion(0), startOffset(0), insertionOffset(0) { }
|
||||||
|
|
||||||
void addEvent(const QPostEvent &ev) {
|
void addEvent(const QPostEvent &ev)
|
||||||
|
{
|
||||||
int priority = ev.priority;
|
int priority = ev.priority;
|
||||||
if (isEmpty() ||
|
if (isEmpty() ||
|
||||||
constLast().priority >= priority ||
|
constLast().priority >= priority ||
|
||||||
@ -125,6 +126,7 @@ public:
|
|||||||
insert(at, ev);
|
insert(at, ev);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
//hides because they do not keep that list sorted. addEvent must be used
|
//hides because they do not keep that list sorted. addEvent must be used
|
||||||
using QList<QPostEvent>::append;
|
using QList<QPostEvent>::append;
|
||||||
@ -176,7 +178,7 @@ public:
|
|||||||
|
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
static unsigned int __stdcall start(void *) noexcept;
|
static unsigned int __stdcall start(void *) noexcept;
|
||||||
static void finish(void *, bool lockAnyway=true) noexcept;
|
static void finish(void *, bool lockAnyway = true) noexcept;
|
||||||
|
|
||||||
Qt::HANDLE handle;
|
Qt::HANDLE handle;
|
||||||
unsigned int id;
|
unsigned int id;
|
||||||
@ -215,7 +217,7 @@ public:
|
|||||||
QThreadData *data;
|
QThreadData *data;
|
||||||
bool running = false;
|
bool running = false;
|
||||||
|
|
||||||
static void setCurrentThread(QThread*) {}
|
static void setCurrentThread(QThread *) { }
|
||||||
static QThread *threadForId(int) { return QThread::currentThread(); }
|
static QThread *threadForId(int) { return QThread::currentThread(); }
|
||||||
static QAbstractEventDispatcher *createEventDispatcher(QThreadData *data);
|
static QAbstractEventDispatcher *createEventDispatcher(QThreadData *data);
|
||||||
|
|
||||||
@ -265,7 +267,7 @@ public:
|
|||||||
static const uint Count = 2;
|
static const uint Count = 2;
|
||||||
|
|
||||||
uint idx;
|
uint idx;
|
||||||
const char* locations[Count];
|
const char *locations[Count];
|
||||||
|
|
||||||
public:
|
public:
|
||||||
FlaggedDebugSignatures() : idx(0)
|
FlaggedDebugSignatures() : idx(0)
|
||||||
|
@ -235,7 +235,7 @@ void QAdoptedThread::init()
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
typedef void*(*QtThreadCallback)(void*);
|
typedef void *(*QtThreadCallback)(void *);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // QT_CONFIG(thread)
|
#endif // QT_CONFIG(thread)
|
||||||
|
@ -258,7 +258,7 @@ bool QThreadPoolPrivate::tooManyThreadsActive() const
|
|||||||
void QThreadPoolPrivate::startThread(QRunnable *runnable)
|
void QThreadPoolPrivate::startThread(QRunnable *runnable)
|
||||||
{
|
{
|
||||||
Q_ASSERT(runnable != nullptr);
|
Q_ASSERT(runnable != nullptr);
|
||||||
QScopedPointer <QThreadPoolThread> thread(new QThreadPoolThread(this));
|
QScopedPointer<QThreadPoolThread> thread(new QThreadPoolThread(this));
|
||||||
thread->setObjectName(QLatin1String("Thread (pooled)"));
|
thread->setObjectName(QLatin1String("Thread (pooled)"));
|
||||||
Q_ASSERT(!allThreads.contains(thread.data())); // if this assert hits, we have an ABA problem (deleted threads don't get removed here)
|
Q_ASSERT(!allThreads.contains(thread.data())); // if this assert hits, we have an ABA problem (deleted threads don't get removed here)
|
||||||
allThreads.insert(thread.data());
|
allThreads.insert(thread.data());
|
||||||
@ -282,7 +282,7 @@ void QThreadPoolPrivate::reset()
|
|||||||
waitingThreads.clear();
|
waitingThreads.clear();
|
||||||
mutex.unlock();
|
mutex.unlock();
|
||||||
|
|
||||||
for (QThreadPoolThread *thread: qAsConst(allThreadsCopy)) {
|
for (QThreadPoolThread *thread : qAsConst(allThreadsCopy)) {
|
||||||
if (!thread->isFinished()) {
|
if (!thread->isFinished()) {
|
||||||
thread->runnableReady.wakeAll();
|
thread->runnableReady.wakeAll();
|
||||||
thread->wait();
|
thread->wait();
|
||||||
|
@ -51,7 +51,6 @@ QT_REQUIRE_CONFIG(thread);
|
|||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
|
||||||
class QThreadPoolPrivate;
|
class QThreadPoolPrivate;
|
||||||
class Q_CORE_EXPORT QThreadPool : public QObject
|
class Q_CORE_EXPORT QThreadPool : public QObject
|
||||||
{
|
{
|
||||||
|
@ -65,47 +65,44 @@ QT_BEGIN_NAMESPACE
|
|||||||
|
|
||||||
class QDeadlineTimer;
|
class QDeadlineTimer;
|
||||||
|
|
||||||
class QueuePage {
|
class QueuePage
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
enum {
|
enum {
|
||||||
MaxPageSize = 256
|
MaxPageSize = 256
|
||||||
};
|
};
|
||||||
|
|
||||||
QueuePage(QRunnable *runnable, int pri)
|
QueuePage(QRunnable *runnable, int pri) : m_priority(pri) { push(runnable); }
|
||||||
: m_priority(pri)
|
|
||||||
|
bool isFull() { return m_lastIndex >= MaxPageSize - 1; }
|
||||||
|
|
||||||
|
bool isFinished() { return m_firstIndex > m_lastIndex; }
|
||||||
|
|
||||||
|
void push(QRunnable *runnable)
|
||||||
{
|
{
|
||||||
push(runnable);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isFull() {
|
|
||||||
return m_lastIndex >= MaxPageSize - 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isFinished() {
|
|
||||||
return m_firstIndex > m_lastIndex;
|
|
||||||
}
|
|
||||||
|
|
||||||
void push(QRunnable *runnable) {
|
|
||||||
Q_ASSERT(runnable != nullptr);
|
Q_ASSERT(runnable != nullptr);
|
||||||
Q_ASSERT(!isFull());
|
Q_ASSERT(!isFull());
|
||||||
m_lastIndex += 1;
|
m_lastIndex += 1;
|
||||||
m_entries[m_lastIndex] = runnable;
|
m_entries[m_lastIndex] = runnable;
|
||||||
}
|
}
|
||||||
|
|
||||||
void skipToNextOrEnd() {
|
void skipToNextOrEnd()
|
||||||
|
{
|
||||||
while (!isFinished() && m_entries[m_firstIndex] == nullptr) {
|
while (!isFinished() && m_entries[m_firstIndex] == nullptr) {
|
||||||
m_firstIndex += 1;
|
m_firstIndex += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QRunnable *first() {
|
QRunnable *first()
|
||||||
|
{
|
||||||
Q_ASSERT(!isFinished());
|
Q_ASSERT(!isFinished());
|
||||||
QRunnable *runnable = m_entries[m_firstIndex];
|
QRunnable *runnable = m_entries[m_firstIndex];
|
||||||
Q_ASSERT(runnable);
|
Q_ASSERT(runnable);
|
||||||
return runnable;
|
return runnable;
|
||||||
}
|
}
|
||||||
|
|
||||||
QRunnable *pop() {
|
QRunnable *pop()
|
||||||
|
{
|
||||||
Q_ASSERT(!isFinished());
|
Q_ASSERT(!isFinished());
|
||||||
QRunnable *runnable = first();
|
QRunnable *runnable = first();
|
||||||
Q_ASSERT(runnable);
|
Q_ASSERT(runnable);
|
||||||
@ -120,7 +117,8 @@ public:
|
|||||||
return runnable;
|
return runnable;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool tryTake(QRunnable *runnable) {
|
bool tryTake(QRunnable *runnable)
|
||||||
|
{
|
||||||
Q_ASSERT(!isFinished());
|
Q_ASSERT(!isFinished());
|
||||||
for (int i = m_firstIndex; i <= m_lastIndex; i++) {
|
for (int i = m_firstIndex; i <= m_lastIndex; i++) {
|
||||||
if (m_entries[i] == runnable) {
|
if (m_entries[i] == runnable) {
|
||||||
@ -135,9 +133,7 @@ public:
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int priority() const {
|
int priority() const { return m_priority; }
|
||||||
return m_priority;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int m_priority = 0;
|
int m_priority = 0;
|
||||||
|
@ -209,7 +209,7 @@ public:
|
|||||||
return qThreadStorage_hasLocalData(data);
|
return qThreadStorage_hasLocalData(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline T& localData()
|
inline T &localData()
|
||||||
{
|
{
|
||||||
if (!data)
|
if (!data)
|
||||||
data.reset(new T());
|
data.reset(new T());
|
||||||
|
@ -73,7 +73,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(QWaitCondition)
|
Q_DISABLE_COPY(QWaitCondition)
|
||||||
|
|
||||||
QWaitConditionPrivate * d;
|
QWaitConditionPrivate *d;
|
||||||
};
|
};
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
@ -60,8 +60,7 @@
|
|||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
namespace QtPrivate
|
namespace QtPrivate {
|
||||||
{
|
|
||||||
|
|
||||||
#if defined(Q_OS_INTEGRITY)
|
#if defined(Q_OS_INTEGRITY)
|
||||||
|
|
||||||
@ -70,6 +69,7 @@ class condition_variable;
|
|||||||
class mutex : private QMutex
|
class mutex : private QMutex
|
||||||
{
|
{
|
||||||
friend class QtPrivate::condition_variable;
|
friend class QtPrivate::condition_variable;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// all special member functions are ok!
|
// all special member functions are ok!
|
||||||
// do not expose the (QMutex::Recursive) ctor
|
// do not expose the (QMutex::Recursive) ctor
|
||||||
|
@ -114,7 +114,8 @@ void qt_abstime_for_timeout(timespec *ts, QDeadlineTimer deadline)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
class QWaitConditionPrivate {
|
class QWaitConditionPrivate
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
pthread_mutex_t mutex;
|
pthread_mutex_t mutex;
|
||||||
pthread_cond_t cond;
|
pthread_cond_t cond;
|
||||||
@ -169,7 +170,6 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
QWaitCondition::QWaitCondition()
|
QWaitCondition::QWaitCondition()
|
||||||
{
|
{
|
||||||
d = new QWaitConditionPrivate;
|
d = new QWaitConditionPrivate;
|
||||||
@ -178,7 +178,6 @@ QWaitCondition::QWaitCondition()
|
|||||||
d->waiters = d->wakeups = 0;
|
d->waiters = d->wakeups = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QWaitCondition::~QWaitCondition()
|
QWaitCondition::~QWaitCondition()
|
||||||
{
|
{
|
||||||
report_error(pthread_cond_destroy(&d->cond), "QWaitCondition", "cv destroy");
|
report_error(pthread_cond_destroy(&d->cond), "QWaitCondition", "cv destroy");
|
||||||
@ -211,7 +210,7 @@ bool QWaitCondition::wait(QMutex *mutex, unsigned long time)
|
|||||||
|
|
||||||
bool QWaitCondition::wait(QMutex *mutex, QDeadlineTimer deadline)
|
bool QWaitCondition::wait(QMutex *mutex, QDeadlineTimer deadline)
|
||||||
{
|
{
|
||||||
if (! mutex)
|
if (!mutex)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
report_error(pthread_mutex_lock(&d->mutex), "QWaitCondition::wait()", "mutex lock");
|
report_error(pthread_mutex_lock(&d->mutex), "QWaitCondition::wait()", "mutex lock");
|
||||||
|
@ -45,7 +45,7 @@
|
|||||||
#include "qlist.h"
|
#include "qlist.h"
|
||||||
#include "qalgorithms.h"
|
#include "qalgorithms.h"
|
||||||
|
|
||||||
#define Q_MUTEX_T void*
|
#define Q_MUTEX_T void *
|
||||||
#include <private/qmutex_p.h>
|
#include <private/qmutex_p.h>
|
||||||
#include <private/qreadwritelock_p.h>
|
#include <private/qreadwritelock_p.h>
|
||||||
#include <qt_windows.h>
|
#include <qt_windows.h>
|
||||||
@ -87,7 +87,7 @@ QWaitConditionEvent *QWaitConditionPrivate::pre()
|
|||||||
{
|
{
|
||||||
mtx.lock();
|
mtx.lock();
|
||||||
QWaitConditionEvent *wce =
|
QWaitConditionEvent *wce =
|
||||||
freeQueue.isEmpty() ? new QWaitConditionEvent : freeQueue.takeFirst();
|
freeQueue.isEmpty() ? new QWaitConditionEvent : freeQueue.takeFirst();
|
||||||
wce->priority = GetThreadPriority(GetCurrentThread());
|
wce->priority = GetThreadPriority(GetCurrentThread());
|
||||||
wce->wokenUp = false;
|
wce->wokenUp = false;
|
||||||
|
|
||||||
@ -109,7 +109,8 @@ bool QWaitConditionPrivate::wait(QWaitConditionEvent *wce, unsigned long time)
|
|||||||
// wait for the event
|
// wait for the event
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
switch (WaitForSingleObjectEx(wce->event, time, FALSE)) {
|
switch (WaitForSingleObjectEx(wce->event, time, FALSE)) {
|
||||||
default: break;
|
default:
|
||||||
|
break;
|
||||||
|
|
||||||
case WAIT_OBJECT_0:
|
case WAIT_OBJECT_0:
|
||||||
ret = true;
|
ret = true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user