Source

Target

Showing with 157 additions and 50 deletions
...@@ -618,7 +618,6 @@ ...@@ -618,7 +618,6 @@
# endif # endif
# if (__GNUC__ * 100 + __GNUC_MINOR__) >= 404 # if (__GNUC__ * 100 + __GNUC_MINOR__) >= 404
/* C++11 features supported in GCC 4.4: */ /* C++11 features supported in GCC 4.4: */
# define Q_COMPILER_ATOMICS
# define Q_COMPILER_AUTO_FUNCTION # define Q_COMPILER_AUTO_FUNCTION
# define Q_COMPILER_AUTO_TYPE # define Q_COMPILER_AUTO_TYPE
# define Q_COMPILER_CLASS_ENUM # define Q_COMPILER_CLASS_ENUM
...@@ -642,6 +641,11 @@ ...@@ -642,6 +641,11 @@
# define Q_COMPILER_RANGE_FOR # define Q_COMPILER_RANGE_FOR
# endif # endif
# if (__GNUC__ * 100 + __GNUC_MINOR__) >= 407 # if (__GNUC__ * 100 + __GNUC_MINOR__) >= 407
/* GCC 4.4 implemented <atomic> and std::atomic using its old intrinsics.
* However, the implementation is incomplete for most platforms until GCC 4.7:
* instead, std::atomic would use an external lock. Since we need an std::atomic
* that is behavior-compatible with QBasicAtomic, we only enable it here */
# define Q_COMPILER_ATOMICS
/* GCC 4.6.x has problems dealing with noexcept expressions, /* GCC 4.6.x has problems dealing with noexcept expressions,
* so turn the feature on for 4.7 and above, only */ * so turn the feature on for 4.7 and above, only */
# define Q_COMPILER_NOEXCEPT # define Q_COMPILER_NOEXCEPT
......
...@@ -97,31 +97,32 @@ public: ...@@ -97,31 +97,32 @@ public:
inline QFlags(const QFlags &other); inline QFlags(const QFlags &other);
inline QFlags &operator=(const QFlags &other); inline QFlags &operator=(const QFlags &other);
#endif #endif
Q_DECL_CONSTEXPR inline QFlags(Enum f) : i(f) {} Q_DECL_CONSTEXPR inline QFlags(Enum f) : i(Int(f)) {}
Q_DECL_CONSTEXPR inline QFlags(Zero = 0) : i(0) {} Q_DECL_CONSTEXPR inline QFlags(Zero = 0) : i(0) {}
Q_DECL_CONSTEXPR inline QFlags(QFlag f) : i(f) {} Q_DECL_CONSTEXPR inline QFlags(QFlag f) : i(f) {}
inline QFlags &operator&=(int mask) { i &= mask; return *this; } inline QFlags &operator&=(int mask) { i &= mask; return *this; }
inline QFlags &operator&=(uint mask) { i &= mask; return *this; } inline QFlags &operator&=(uint mask) { i &= mask; return *this; }
inline QFlags &operator&=(Enum mask) { i &= Int(mask); return *this; }
inline QFlags &operator|=(QFlags f) { i |= f.i; return *this; } inline QFlags &operator|=(QFlags f) { i |= f.i; return *this; }
inline QFlags &operator|=(Enum f) { i |= f; return *this; } inline QFlags &operator|=(Enum f) { i |= Int(f); return *this; }
inline QFlags &operator^=(QFlags f) { i ^= f.i; return *this; } inline QFlags &operator^=(QFlags f) { i ^= f.i; return *this; }
inline QFlags &operator^=(Enum f) { i ^= f; return *this; } inline QFlags &operator^=(Enum f) { i ^= Int(f); return *this; }
Q_DECL_CONSTEXPR inline operator Int() const { return i; } Q_DECL_CONSTEXPR inline operator Int() const { return i; }
Q_DECL_CONSTEXPR inline QFlags operator|(QFlags f) const { return QFlags(Enum(i | f.i)); } Q_DECL_CONSTEXPR inline QFlags operator|(QFlags f) const { return QFlags(Enum(i | f.i)); }
Q_DECL_CONSTEXPR inline QFlags operator|(Enum f) const { return QFlags(Enum(i | f)); } Q_DECL_CONSTEXPR inline QFlags operator|(Enum f) const { return QFlags(Enum(i | Int(f))); }
Q_DECL_CONSTEXPR inline QFlags operator^(QFlags f) const { return QFlags(Enum(i ^ f.i)); } Q_DECL_CONSTEXPR inline QFlags operator^(QFlags f) const { return QFlags(Enum(i ^ f.i)); }
Q_DECL_CONSTEXPR inline QFlags operator^(Enum f) const { return QFlags(Enum(i ^ f)); } Q_DECL_CONSTEXPR inline QFlags operator^(Enum f) const { return QFlags(Enum(i ^ Int(f))); }
Q_DECL_CONSTEXPR inline QFlags operator&(int mask) const { return QFlags(Enum(i & mask)); } Q_DECL_CONSTEXPR inline QFlags operator&(int mask) const { return QFlags(Enum(i & mask)); }
Q_DECL_CONSTEXPR inline QFlags operator&(uint mask) const { return QFlags(Enum(i & mask)); } Q_DECL_CONSTEXPR inline QFlags operator&(uint mask) const { return QFlags(Enum(i & mask)); }
Q_DECL_CONSTEXPR inline QFlags operator&(Enum f) const { return QFlags(Enum(i & f)); } Q_DECL_CONSTEXPR inline QFlags operator&(Enum f) const { return QFlags(Enum(i & Int(f))); }
Q_DECL_CONSTEXPR inline QFlags operator~() const { return QFlags(Enum(~i)); } Q_DECL_CONSTEXPR inline QFlags operator~() const { return QFlags(Enum(~i)); }
Q_DECL_CONSTEXPR inline bool operator!() const { return !i; } Q_DECL_CONSTEXPR inline bool operator!() const { return !i; }
Q_DECL_CONSTEXPR inline bool testFlag(Enum f) const { return (i & f) == f && (f != 0 || i == Int(f) ); } Q_DECL_CONSTEXPR inline bool testFlag(Enum f) const { return (i & Int(f)) == Int(f) && (Int(f) != 0 || i == Int(f) ); }
private: private:
Int i; Int i;
}; };
......
...@@ -72,7 +72,7 @@ ...@@ -72,7 +72,7 @@
# include <envLib.h> # include <envLib.h>
#endif #endif
#if defined(Q_OS_MAC) && !defined(Q_OS_IOS) #if defined(Q_OS_MACX)
#include <CoreServices/CoreServices.h> #include <CoreServices/CoreServices.h>
#endif #endif
...@@ -239,6 +239,12 @@ Q_CORE_EXPORT void *qMemSet(void *dest, int c, size_t n); ...@@ -239,6 +239,12 @@ Q_CORE_EXPORT void *qMemSet(void *dest, int c, size_t n);
\overload \overload
*/ */
/*!
\fn QFlags &QFlags::operator&=(Enum mask)
\overload
*/
/*! /*!
\fn QFlags &QFlags::operator|=(QFlags other) \fn QFlags &QFlags::operator|=(QFlags other)
...@@ -928,8 +934,8 @@ bool qSharedBuild() Q_DECL_NOTHROW ...@@ -928,8 +934,8 @@ bool qSharedBuild() Q_DECL_NOTHROW
\endlist \endlist
Some constants are defined only on certain platforms. You can use Some constants are defined only on certain platforms. You can use
the preprocessor symbols Q_OS_WIN and Q_OS_MAC to test that the preprocessor symbols Q_OS_WIN and Q_OS_MACX to test that
the application is compiled under Windows or Mac. the application is compiled under Windows or OS X.
\sa QLibraryInfo \sa QLibraryInfo
*/ */
...@@ -1072,6 +1078,27 @@ bool qSharedBuild() Q_DECL_NOTHROW ...@@ -1072,6 +1078,27 @@ bool qSharedBuild() Q_DECL_NOTHROW
Defined on Darwin OS (synonym for Q_OS_MAC). Defined on Darwin OS (synonym for Q_OS_MAC).
*/ */
/*!
\macro Q_OS_MAC
\relates <QtGlobal>
Defined on OS X and iOS (synonym for Q_OS_DARWIN).
*/
/*!
\macro Q_OS_MACX
\relates <QtGlobal>
Defined on OS X.
*/
/*!
\macro Q_OS_IOS
\relates <QtGlobal>
Defined on iOS.
*/
/*! /*!
\macro Q_OS_WIN \macro Q_OS_WIN
\relates <QtGlobal> \relates <QtGlobal>
...@@ -1394,13 +1421,6 @@ bool qSharedBuild() Q_DECL_NOTHROW ...@@ -1394,13 +1421,6 @@ bool qSharedBuild() Q_DECL_NOTHROW
Optimizing C++ Compilers. Optimizing C++ Compilers.
*/ */
/*!
\macro Q_OS_MAC
\relates <QtGlobal>
Defined on MAC OS (synonym for Darwin).
*/
/*! /*!
\macro Q_PROCESSOR_ALPHA \macro Q_PROCESSOR_ALPHA
\relates <QtGlobal> \relates <QtGlobal>
...@@ -1646,7 +1666,7 @@ static const unsigned int qt_one = 1; ...@@ -1646,7 +1666,7 @@ static const unsigned int qt_one = 1;
const int QSysInfo::ByteOrder = ((*((unsigned char *) &qt_one) == 0) ? BigEndian : LittleEndian); const int QSysInfo::ByteOrder = ((*((unsigned char *) &qt_one) == 0) ? BigEndian : LittleEndian);
#endif #endif
#if defined(Q_OS_MAC) && !defined(Q_OS_IOS) #if defined(Q_OS_MACX)
QT_BEGIN_INCLUDE_NAMESPACE QT_BEGIN_INCLUDE_NAMESPACE
#include "private/qcore_mac_p.h" #include "private/qcore_mac_p.h"
...@@ -1668,7 +1688,7 @@ Q_CORE_EXPORT void qt_mac_to_pascal_string(QString s, Str255 str, TextEncoding e ...@@ -1668,7 +1688,7 @@ Q_CORE_EXPORT void qt_mac_to_pascal_string(QString s, Str255 str, TextEncoding e
Q_CORE_EXPORT QString qt_mac_from_pascal_string(const Str255 pstr) { Q_CORE_EXPORT QString qt_mac_from_pascal_string(const Str255 pstr) {
return QCFString(CFStringCreateWithPascalString(0, pstr, CFStringGetSystemEncoding())); return QCFString(CFStringCreateWithPascalString(0, pstr, CFStringGetSystemEncoding()));
} }
#endif // defined(Q_OS_MAC) && !defined(Q_OS_IOS) #endif // defined(Q_OS_MACX)
#if defined(Q_OS_MAC) #if defined(Q_OS_MAC)
......
...@@ -291,6 +291,7 @@ static const struct { ...@@ -291,6 +291,7 @@ static const struct {
{ "Sysroot", "" }, { "Sysroot", "" },
{ "HostPrefix", "" }, { "HostPrefix", "" },
{ "HostBinaries", "bin" }, { "HostBinaries", "bin" },
{ "HostLibraries", "lib" },
{ "HostData", "." }, { "HostData", "." },
{ "TargetSpec", "" }, { "TargetSpec", "" },
{ "HostSpec", "" }, { "HostSpec", "" },
......
...@@ -82,6 +82,7 @@ public: ...@@ -82,6 +82,7 @@ public:
SysrootPath, SysrootPath,
HostPrefixPath, HostPrefixPath,
HostBinariesPath, HostBinariesPath,
HostLibrariesPath,
HostDataPath, HostDataPath,
TargetSpecPath, TargetSpecPath,
HostSpecPath, HostSpecPath,
......
...@@ -293,7 +293,8 @@ public: ...@@ -293,7 +293,8 @@ public:
WindowType_Mask = 0x000000ff, WindowType_Mask = 0x000000ff,
MSWindowsFixedSizeDialogHint = 0x00000100, MSWindowsFixedSizeDialogHint = 0x00000100,
MSWindowsOwnDC = 0x00000200, MSWindowsOwnDC = 0x00000200,
X11BypassWindowManagerHint = 0x00000400, BypassWindowManagerHint = 0x00000400,
X11BypassWindowManagerHint = BypassWindowManagerHint,
FramelessWindowHint = 0x00000800, FramelessWindowHint = 0x00000800,
WindowTitleHint = 0x00001000, WindowTitleHint = 0x00001000,
WindowSystemMenuHint = 0x00002000, WindowSystemMenuHint = 0x00002000,
......
...@@ -1999,6 +1999,12 @@ ...@@ -1999,6 +1999,12 @@
\value MSWindowsOwnDC Gives the window its own display \value MSWindowsOwnDC Gives the window its own display
context on Windows. context on Windows.
\value BypassWindowManagerHint This flag can be used to indicate to the platform plugin
that "all" window manager protocols should be disabled. This flag will behave
different depending on what operating system the application is running on and
what window manager is running. The flag can be used to get a native window
with no configuration set.
\value X11BypassWindowManagerHint Bypass the window \value X11BypassWindowManagerHint Bypass the window
manager completely. This results in a borderless window manager completely. This results in a borderless window
that is not managed at all (i.e., no keyboard input unless that is not managed at all (i.e., no keyboard input unless
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal ** Contact: http://www.qt-project.org/legal
** **
** This file is part of the FOO module of the Qt Toolkit. ** This file is part of the QtCore module of the Qt Toolkit.
** **
** $QT_BEGIN_LICENSE:LGPL$ ** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage ** Commercial License Usage
......
...@@ -50,8 +50,9 @@ ...@@ -50,8 +50,9 @@
The operating system, must be one of: (Q_OS_x) The operating system, must be one of: (Q_OS_x)
DARWIN - Darwin OS (synonym for Q_OS_MAC) DARWIN - Darwin OS (synonym for Q_OS_MAC)
MAC - Mac OS X or iOS (iPhoneOS) MAC - OS X or iOS (synonym for Q_OS_DARWIN)
IOS - iOS (treated as a variant of Mac OS) MACX - OS X
IOS - iOS
MSDOS - MS-DOS and Windows MSDOS - MS-DOS and Windows
OS2 - OS/2 OS2 - OS/2
OS2EMX - XFree86 on OS/2 (not PM) OS2EMX - XFree86 on OS/2 (not PM)
...@@ -166,7 +167,6 @@ ...@@ -166,7 +167,6 @@
#if defined(Q_OS_DARWIN) #if defined(Q_OS_DARWIN)
# define Q_OS_MAC # define Q_OS_MAC
# define Q_OS_MACX /* Q_OS_MACX is only for compatibility.*/
# if defined(Q_OS_DARWIN64) # if defined(Q_OS_DARWIN64)
# define Q_OS_MAC64 # define Q_OS_MAC64
# elif defined(Q_OS_DARWIN32) # elif defined(Q_OS_DARWIN32)
...@@ -175,6 +175,8 @@ ...@@ -175,6 +175,8 @@
# include <TargetConditionals.h> # include <TargetConditionals.h>
# if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE # if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE
# define Q_OS_IOS # define Q_OS_IOS
# else
# define Q_OS_MACX
# endif # endif
#endif #endif
......
...@@ -280,7 +280,7 @@ inline QDebug operator<<(QDebug debug, const QFlags<T> &flags) ...@@ -280,7 +280,7 @@ inline QDebug operator<<(QDebug debug, const QFlags<T> &flags)
debug.nospace() << '|'; debug.nospace() << '|';
else else
needSeparator = true; needSeparator = true;
debug.nospace() << "0x" << QByteArray::number(T(1 << i), 16).constData(); debug.nospace() << "0x" << QByteArray::number(typename QFlags<T>::Int(1) << i, 16).constData();
} }
} }
debug << ')'; debug << ')';
......
...@@ -272,7 +272,7 @@ void QFileSystemMetaData::fillFromStatBuf(const QT_STATBUF &statBuffer) ...@@ -272,7 +272,7 @@ void QFileSystemMetaData::fillFromStatBuf(const QT_STATBUF &statBuffer)
// Attributes // Attributes
entryFlags |= QFileSystemMetaData::ExistsAttribute; entryFlags |= QFileSystemMetaData::ExistsAttribute;
size_ = statBuffer.st_size; size_ = statBuffer.st_size;
#if defined (Q_OS_MAC) && !defined(Q_OS_IOS) #if defined(Q_OS_MACX)
if (statBuffer.st_flags & UF_HIDDEN) { if (statBuffer.st_flags & UF_HIDDEN) {
entryFlags |= QFileSystemMetaData::HiddenAttribute; entryFlags |= QFileSystemMetaData::HiddenAttribute;
knownFlagsMask |= QFileSystemMetaData::HiddenAttribute; knownFlagsMask |= QFileSystemMetaData::HiddenAttribute;
......
...@@ -84,7 +84,7 @@ public: ...@@ -84,7 +84,7 @@ public:
static QString resolveGroupName(uint groupId); static QString resolveGroupName(uint groupId);
#endif #endif
#if defined(Q_OS_MAC) && !defined(Q_OS_IOS) #if defined(Q_OS_MACX)
static QString bundleName(const QFileSystemEntry &entry); static QString bundleName(const QFileSystemEntry &entry);
#else #else
static QString bundleName(const QFileSystemEntry &entry) { Q_UNUSED(entry) return QString(); } static QString bundleName(const QFileSystemEntry &entry) { Q_UNUSED(entry) return QString(); }
......
...@@ -59,7 +59,7 @@ ...@@ -59,7 +59,7 @@
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
#if defined(Q_OS_MAC) && !defined(Q_OS_IOS) #if defined(Q_OS_MACX)
static inline bool _q_isMacHidden(const char *nativePath) static inline bool _q_isMacHidden(const char *nativePath)
{ {
OSErr err; OSErr err;
...@@ -143,7 +143,7 @@ QFileSystemEntry QFileSystemEngine::getLinkTarget(const QFileSystemEntry &link, ...@@ -143,7 +143,7 @@ QFileSystemEntry QFileSystemEngine::getLinkTarget(const QFileSystemEntry &link,
ret.chop(1); ret.chop(1);
return QFileSystemEntry(ret); return QFileSystemEntry(ret);
} }
#if defined(Q_OS_MAC) && !defined(Q_OS_IOS) #if defined(Q_OS_MACX)
{ {
FSRef fref; FSRef fref;
if (FSPathMakeRef((const UInt8 *)QFile::encodeName(QDir::cleanPath(link.filePath())).data(), &fref, 0) == noErr) { if (FSPathMakeRef((const UInt8 *)QFile::encodeName(QDir::cleanPath(link.filePath())).data(), &fref, 0) == noErr) {
...@@ -175,7 +175,7 @@ QFileSystemEntry QFileSystemEngine::canonicalName(const QFileSystemEntry &entry, ...@@ -175,7 +175,7 @@ QFileSystemEntry QFileSystemEngine::canonicalName(const QFileSystemEntry &entry,
return QFileSystemEntry(slowCanonicalized(absoluteName(entry).filePath())); return QFileSystemEntry(slowCanonicalized(absoluteName(entry).filePath()));
#else #else
char *ret = 0; char *ret = 0;
# if defined(Q_OS_MAC) && !defined(Q_OS_IOS) # if defined(Q_OS_MACX)
// When using -mmacosx-version-min=10.4, we get the legacy realpath implementation, // When using -mmacosx-version-min=10.4, we get the legacy realpath implementation,
// which does not work properly with the realpath(X,0) form. See QTBUG-28282. // which does not work properly with the realpath(X,0) form. See QTBUG-28282.
if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_6) { if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_6) {
...@@ -335,7 +335,7 @@ QString QFileSystemEngine::resolveGroupName(uint groupId) ...@@ -335,7 +335,7 @@ QString QFileSystemEngine::resolveGroupName(uint groupId)
return QString(); return QString();
} }
#if defined(Q_OS_MAC) && !defined(Q_OS_IOS) #if defined(Q_OS_MACX)
//static //static
QString QFileSystemEngine::bundleName(const QFileSystemEntry &entry) QString QFileSystemEngine::bundleName(const QFileSystemEntry &entry)
{ {
...@@ -355,7 +355,7 @@ QString QFileSystemEngine::bundleName(const QFileSystemEntry &entry) ...@@ -355,7 +355,7 @@ QString QFileSystemEngine::bundleName(const QFileSystemEntry &entry)
bool QFileSystemEngine::fillMetaData(const QFileSystemEntry &entry, QFileSystemMetaData &data, bool QFileSystemEngine::fillMetaData(const QFileSystemEntry &entry, QFileSystemMetaData &data,
QFileSystemMetaData::MetaDataFlags what) QFileSystemMetaData::MetaDataFlags what)
{ {
#if defined(Q_OS_MAC) && !defined(Q_OS_IOS) #if defined(Q_OS_MACX)
if (what & QFileSystemMetaData::BundleType) { if (what & QFileSystemMetaData::BundleType) {
if (!data.hasFlags(QFileSystemMetaData::DirectoryType)) if (!data.hasFlags(QFileSystemMetaData::DirectoryType))
what |= QFileSystemMetaData::DirectoryType; what |= QFileSystemMetaData::DirectoryType;
...@@ -364,7 +364,7 @@ bool QFileSystemEngine::fillMetaData(const QFileSystemEntry &entry, QFileSystemM ...@@ -364,7 +364,7 @@ bool QFileSystemEngine::fillMetaData(const QFileSystemEntry &entry, QFileSystemM
// Mac OS >= 10.5: st_flags & UF_HIDDEN // Mac OS >= 10.5: st_flags & UF_HIDDEN
what |= QFileSystemMetaData::PosixStatFlags; what |= QFileSystemMetaData::PosixStatFlags;
} }
#endif // defined(Q_OS_MAC) && !defined(Q_OS_IOS) #endif // defined(Q_OS_MACX)
if (what & QFileSystemMetaData::PosixStatFlags) if (what & QFileSystemMetaData::PosixStatFlags)
what |= QFileSystemMetaData::PosixStatFlags; what |= QFileSystemMetaData::PosixStatFlags;
...@@ -425,7 +425,7 @@ bool QFileSystemEngine::fillMetaData(const QFileSystemEntry &entry, QFileSystemM ...@@ -425,7 +425,7 @@ bool QFileSystemEngine::fillMetaData(const QFileSystemEntry &entry, QFileSystemM
| QFileSystemMetaData::ExistsAttribute; | QFileSystemMetaData::ExistsAttribute;
} }
#if defined(Q_OS_MAC) && !defined(Q_OS_IOS) #if defined(Q_OS_MACX)
if (what & QFileSystemMetaData::AliasType) if (what & QFileSystemMetaData::AliasType)
{ {
if (entryExists) { if (entryExists) {
...@@ -471,7 +471,7 @@ bool QFileSystemEngine::fillMetaData(const QFileSystemEntry &entry, QFileSystemM ...@@ -471,7 +471,7 @@ bool QFileSystemEngine::fillMetaData(const QFileSystemEntry &entry, QFileSystemM
data.knownFlagsMask |= QFileSystemMetaData::HiddenAttribute; data.knownFlagsMask |= QFileSystemMetaData::HiddenAttribute;
} }
#if defined(Q_OS_MAC) && !defined(Q_OS_IOS) #if defined(Q_OS_MACX)
if (what & QFileSystemMetaData::BundleType) { if (what & QFileSystemMetaData::BundleType) {
if (entryExists && data.isDirectory()) { if (entryExists && data.isDirectory()) {
QCFType<CFStringRef> path = CFStringCreateWithBytes(0, QCFType<CFStringRef> path = CFStringCreateWithBytes(0,
......
...@@ -100,7 +100,7 @@ public: ...@@ -100,7 +100,7 @@ public:
LinkType = 0x00010000, LinkType = 0x00010000,
FileType = 0x00020000, FileType = 0x00020000,
DirectoryType = 0x00040000, DirectoryType = 0x00040000,
#if defined(Q_OS_MAC) && !defined(Q_OS_IOS) #if defined(Q_OS_MACX)
BundleType = 0x00080000, BundleType = 0x00080000,
AliasType = 0x08000000, AliasType = 0x08000000,
#else #else
...@@ -248,7 +248,7 @@ private: ...@@ -248,7 +248,7 @@ private:
Q_DECLARE_OPERATORS_FOR_FLAGS(QFileSystemMetaData::MetaDataFlags) Q_DECLARE_OPERATORS_FOR_FLAGS(QFileSystemMetaData::MetaDataFlags)
#if defined(Q_OS_MAC) && !defined(Q_OS_IOS) #if defined(Q_OS_MACX)
inline bool QFileSystemMetaData::isBundle() const { return (entryFlags & BundleType); } inline bool QFileSystemMetaData::isBundle() const { return (entryFlags & BundleType); }
inline bool QFileSystemMetaData::isAlias() const { return (entryFlags & AliasType); } inline bool QFileSystemMetaData::isAlias() const { return (entryFlags & AliasType); }
#else #else
......
...@@ -265,7 +265,13 @@ QProcessEnvironment &QProcessEnvironment::operator=(const QProcessEnvironment &o ...@@ -265,7 +265,13 @@ QProcessEnvironment &QProcessEnvironment::operator=(const QProcessEnvironment &o
*/ */
bool QProcessEnvironment::operator==(const QProcessEnvironment &other) const bool QProcessEnvironment::operator==(const QProcessEnvironment &other) const
{ {
return d == other.d || (d && other.d && d->hash == other.d->hash); if (d == other.d)
return true;
if (d && other.d) {
QProcessEnvironmentPrivate::OrderedMutexLocker locker(d, other.d);
return d->hash == other.d->hash;
}
return false;
} }
/*! /*!
...@@ -276,6 +282,7 @@ bool QProcessEnvironment::operator==(const QProcessEnvironment &other) const ...@@ -276,6 +282,7 @@ bool QProcessEnvironment::operator==(const QProcessEnvironment &other) const
*/ */
bool QProcessEnvironment::isEmpty() const bool QProcessEnvironment::isEmpty() const
{ {
// Needs no locking, as no hash nodes are accessed
return d ? d->hash.isEmpty() : true; return d ? d->hash.isEmpty() : true;
} }
...@@ -302,7 +309,10 @@ void QProcessEnvironment::clear() ...@@ -302,7 +309,10 @@ void QProcessEnvironment::clear()
*/ */
bool QProcessEnvironment::contains(const QString &name) const bool QProcessEnvironment::contains(const QString &name) const
{ {
return d ? d->hash.contains(d->prepareName(name)) : false; if (!d)
return false;
QProcessEnvironmentPrivate::MutexLocker locker(d);
return d->hash.contains(d->prepareName(name));
} }
/*! /*!
...@@ -319,7 +329,8 @@ bool QProcessEnvironment::contains(const QString &name) const ...@@ -319,7 +329,8 @@ bool QProcessEnvironment::contains(const QString &name) const
*/ */
void QProcessEnvironment::insert(const QString &name, const QString &value) void QProcessEnvironment::insert(const QString &name, const QString &value)
{ {
// d detaches from null // our re-impl of detach() detaches from null
d.detach(); // detach before prepareName()
d->hash.insert(d->prepareName(name), d->prepareValue(value)); d->hash.insert(d->prepareName(name), d->prepareValue(value));
} }
...@@ -333,8 +344,10 @@ void QProcessEnvironment::insert(const QString &name, const QString &value) ...@@ -333,8 +344,10 @@ void QProcessEnvironment::insert(const QString &name, const QString &value)
*/ */
void QProcessEnvironment::remove(const QString &name) void QProcessEnvironment::remove(const QString &name)
{ {
if (d) if (d) {
d.detach(); // detach before prepareName()
d->hash.remove(d->prepareName(name)); d->hash.remove(d->prepareName(name));
}
} }
/*! /*!
...@@ -349,6 +362,7 @@ QString QProcessEnvironment::value(const QString &name, const QString &defaultVa ...@@ -349,6 +362,7 @@ QString QProcessEnvironment::value(const QString &name, const QString &defaultVa
if (!d) if (!d)
return defaultValue; return defaultValue;
QProcessEnvironmentPrivate::MutexLocker locker(d);
QProcessEnvironmentPrivate::Hash::ConstIterator it = d->hash.constFind(d->prepareName(name)); QProcessEnvironmentPrivate::Hash::ConstIterator it = d->hash.constFind(d->prepareName(name));
if (it == d->hash.constEnd()) if (it == d->hash.constEnd())
return defaultValue; return defaultValue;
...@@ -371,7 +385,10 @@ QString QProcessEnvironment::value(const QString &name, const QString &defaultVa ...@@ -371,7 +385,10 @@ QString QProcessEnvironment::value(const QString &name, const QString &defaultVa
*/ */
QStringList QProcessEnvironment::toStringList() const QStringList QProcessEnvironment::toStringList() const
{ {
return d ? d->toList() : QStringList(); if (!d)
return QStringList();
QProcessEnvironmentPrivate::MutexLocker locker(d);
return d->toList();
} }
/*! /*!
...@@ -382,7 +399,10 @@ QStringList QProcessEnvironment::toStringList() const ...@@ -382,7 +399,10 @@ QStringList QProcessEnvironment::toStringList() const
*/ */
QStringList QProcessEnvironment::keys() const QStringList QProcessEnvironment::keys() const
{ {
return d ? d->keys() : QStringList(); if (!d)
return QStringList();
QProcessEnvironmentPrivate::MutexLocker locker(d);
return d->keys();
} }
/*! /*!
...@@ -397,7 +417,8 @@ void QProcessEnvironment::insert(const QProcessEnvironment &e) ...@@ -397,7 +417,8 @@ void QProcessEnvironment::insert(const QProcessEnvironment &e)
if (!e.d) if (!e.d)
return; return;
// d detaches from null // our re-impl of detach() detaches from null
QProcessEnvironmentPrivate::MutexLocker locker(e.d);
d->insert(*e.d); d->insert(*e.d);
} }
...@@ -2340,7 +2361,7 @@ bool QProcess::startDetached(const QString &program) ...@@ -2340,7 +2361,7 @@ bool QProcess::startDetached(const QString &program)
} }
QT_BEGIN_INCLUDE_NAMESPACE QT_BEGIN_INCLUDE_NAMESPACE
#if defined(Q_OS_MAC) && !defined(Q_OS_IOS) #if defined(Q_OS_MACX)
# include <crt_externs.h> # include <crt_externs.h>
# define environ (*_NSGetEnviron()) # define environ (*_NSGetEnviron())
#elif defined(Q_OS_WINCE) || defined(Q_OS_IOS) #elif defined(Q_OS_WINCE) || defined(Q_OS_IOS)
......
...@@ -219,7 +219,7 @@ Q_SIGNALS: ...@@ -219,7 +219,7 @@ Q_SIGNALS:
QPrivateSignal QPrivateSignal
#endif #endif
); );
void finished(int exitCode); void finished(int exitCode); // ### Qt 6: merge the two signals with a default value
void finished(int exitCode, QProcess::ExitStatus exitStatus); void finished(int exitCode, QProcess::ExitStatus exitStatus);
void error(QProcess::ProcessError error); void error(QProcess::ProcessError error);
void stateChanged(QProcess::ProcessState state void stateChanged(QProcess::ProcessState state
......
...@@ -59,6 +59,9 @@ ...@@ -59,6 +59,9 @@
#include "QtCore/qshareddata.h" #include "QtCore/qshareddata.h"
#include "private/qringbuffer_p.h" #include "private/qringbuffer_p.h"
#include "private/qiodevice_p.h" #include "private/qiodevice_p.h"
#ifdef Q_OS_UNIX
#include <QtCore/private/qorderedmutexlocker_p.h>
#endif
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
#include "QtCore/qt_windows.h" #include "QtCore/qt_windows.h"
...@@ -148,6 +151,13 @@ public: ...@@ -148,6 +151,13 @@ public:
inline QString nameToString(const Key &name) const { return name; } inline QString nameToString(const Key &name) const { return name; }
inline Value prepareValue(const QString &value) const { return value; } inline Value prepareValue(const QString &value) const { return value; }
inline QString valueToString(const Value &value) const { return value; } inline QString valueToString(const Value &value) const { return value; }
struct MutexLocker {
MutexLocker(const QProcessEnvironmentPrivate *) {}
};
struct OrderedMutexLocker {
OrderedMutexLocker(const QProcessEnvironmentPrivate *,
const QProcessEnvironmentPrivate *) {}
};
#else #else
inline Key prepareName(const QString &name) const inline Key prepareName(const QString &name) const
{ {
...@@ -164,6 +174,37 @@ public: ...@@ -164,6 +174,37 @@ public:
} }
inline Value prepareValue(const QString &value) const { return Value(value); } inline Value prepareValue(const QString &value) const { return Value(value); }
inline QString valueToString(const Value &value) const { return value.string(); } inline QString valueToString(const Value &value) const { return value.string(); }
struct MutexLocker : public QMutexLocker
{
MutexLocker(const QProcessEnvironmentPrivate *d) : QMutexLocker(&d->mutex) {}
};
struct OrderedMutexLocker : public QOrderedMutexLocker
{
OrderedMutexLocker(const QProcessEnvironmentPrivate *d1,
const QProcessEnvironmentPrivate *d2) :
QOrderedMutexLocker(&d1->mutex, &d2->mutex)
{}
};
QProcessEnvironmentPrivate() : QSharedData() {}
QProcessEnvironmentPrivate(const QProcessEnvironmentPrivate &other) :
QSharedData()
{
// This being locked ensures that the functions that only assign
// d pointers don't need explicit locking.
// We don't need to lock our own mutex, as this object is new and
// consequently not shared. For the same reason, non-const methods
// do not need a lock, as they detach objects (however, we need to
// ensure that they really detach before using prepareName()).
MutexLocker locker(&other);
hash = other.hash;
nameMap = other.nameMap;
// We need to detach our members, so that our mutex can protect them.
// As we are being detached, they likely would be detached a moment later anyway.
hash.detach();
nameMap.detach();
}
#endif #endif
typedef QHash<Key, Value> Hash; typedef QHash<Key, Value> Hash;
...@@ -172,6 +213,8 @@ public: ...@@ -172,6 +213,8 @@ public:
#ifdef Q_OS_UNIX #ifdef Q_OS_UNIX
typedef QHash<QString, Key> NameHash; typedef QHash<QString, Key> NameHash;
mutable NameHash nameMap; mutable NameHash nameMap;
mutable QMutex mutex;
#endif #endif
static QProcessEnvironment fromList(const QStringList &list); static QProcessEnvironment fromList(const QStringList &list);
......
...@@ -472,7 +472,7 @@ bool QProcessPrivate::createChannel(Channel &channel) ...@@ -472,7 +472,7 @@ bool QProcessPrivate::createChannel(Channel &channel)
} }
QT_BEGIN_INCLUDE_NAMESPACE QT_BEGIN_INCLUDE_NAMESPACE
#if defined(Q_OS_MAC) && !defined(Q_OS_IOS) #if defined(Q_OS_MACX)
# include <crt_externs.h> # include <crt_externs.h>
# define environ (*_NSGetEnviron()) # define environ (*_NSGetEnviron())
#else #else
...@@ -617,8 +617,10 @@ void QProcessPrivate::startProcess() ...@@ -617,8 +617,10 @@ void QProcessPrivate::startProcess()
// Duplicate the environment. // Duplicate the environment.
int envc = 0; int envc = 0;
char **envp = 0; char **envp = 0;
if (environment.d.constData()) if (environment.d.constData()) {
QProcessEnvironmentPrivate::MutexLocker locker(environment.d);
envp = _q_dupEnvironment(environment.d.constData()->hash, &envc); envp = _q_dupEnvironment(environment.d.constData()->hash, &envc);
}
// Encode the working directory if it's non-empty, otherwise just pass 0. // Encode the working directory if it's non-empty, otherwise just pass 0.
const char *workingDirPtr = 0; const char *workingDirPtr = 0;
......
...@@ -233,6 +233,11 @@ bool QProcessPrivate::waitForStarted(int) ...@@ -233,6 +233,11 @@ bool QProcessPrivate::waitForStarted(int)
return false; return false;
} }
bool QProcessPrivate::drainOutputPipes()
{
return true;
}
bool QProcessPrivate::waitForReadyRead(int msecs) bool QProcessPrivate::waitForReadyRead(int msecs)
{ {
return false; return false;
......
...@@ -665,7 +665,7 @@ int QResourceRoot::findNode(const QString &_path, const QLocale &locale) const ...@@ -665,7 +665,7 @@ int QResourceRoot::findNode(const QString &_path, const QLocale &locale) const
qDebug() << " " << child+j << " :: " << name(child+j); qDebug() << " " << child+j << " :: " << name(child+j);
} }
#endif #endif
const uint h = qt_hash(segment.toString()); const uint h = qt_hash(segment);
//do the binary search for the hash //do the binary search for the hash
int l = 0, r = child_count-1; int l = 0, r = child_count-1;
......