summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/global/qglobal.h3
-rw-r--r--src/corelib/io/qstorageinfo_unix.cpp66
-rw-r--r--src/corelib/thread/qbasicatomic.h4
-rw-r--r--src/corelib/tools/qarraydata.cpp6
-rw-r--r--src/corelib/tools/qarraydata.h4
-rw-r--r--src/corelib/tools/qarraydatapointer.h2
-rw-r--r--src/corelib/tools/qcontiguouscache.h2
-rw-r--r--src/corelib/tools/qhash.h2
-rw-r--r--src/corelib/tools/qlinkedlist.h2
-rw-r--r--src/corelib/tools/qlist.h2
-rw-r--r--src/corelib/tools/qmap.h2
-rw-r--r--src/corelib/tools/qrefcount.h6
-rw-r--r--src/corelib/tools/qset.h2
-rw-r--r--src/corelib/tools/qvector.h8
14 files changed, 64 insertions, 47 deletions
diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h
index 5bb1ce77bd..a7183cb983 100644
--- a/src/corelib/global/qglobal.h
+++ b/src/corelib/global/qglobal.h
@@ -55,6 +55,9 @@
#include <QtCore/qfeatures.h>
#endif
+// The QT_SUPPORTS macro is deprecated. Don't use it in new code.
+// Instead, use #ifdef/ndef QT_NO_feature.
+// ### Qt6: remove macro
#ifdef _MSC_VER
# define QT_SUPPORTS(FEATURE) (!defined QT_NO_##FEATURE)
#else
diff --git a/src/corelib/io/qstorageinfo_unix.cpp b/src/corelib/io/qstorageinfo_unix.cpp
index e365d8d7e6..1d1b2907b7 100644
--- a/src/corelib/io/qstorageinfo_unix.cpp
+++ b/src/corelib/io/qstorageinfo_unix.cpp
@@ -102,25 +102,6 @@
QT_BEGIN_NAMESPACE
-static bool isPseudoFs(const QString &mountDir, const QByteArray &type)
-{
- if (mountDir.startsWith(QLatin1String("/dev"))
- || mountDir.startsWith(QLatin1String("/proc"))
- || mountDir.startsWith(QLatin1String("/sys"))
- || mountDir.startsWith(QLatin1String("/var/run"))
- || mountDir.startsWith(QLatin1String("/var/lock"))) {
- return true;
- }
- if (type == "tmpfs")
- return true;
-#if defined(Q_OS_LINUX)
- if (type == "rootfs" || type == "rpc_pipefs")
- return true;
-#endif
-
- return false;
-}
-
class QStorageIterator
{
public:
@@ -158,6 +139,39 @@ private:
#endif
};
+template <typename String>
+static bool isParentOf(const String &parent, const QString &dirName)
+{
+ return dirName.startsWith(parent) &&
+ (dirName.size() == parent.size() || dirName.at(parent.size()) == QLatin1Char('/') ||
+ parent.size() == 1);
+}
+
+static bool isPseudoFs(const QStorageIterator &it)
+{
+ QString mountDir = it.rootPath();
+ if (isParentOf(QLatin1String("/dev"), mountDir)
+ || isParentOf(QLatin1String("/proc"), mountDir)
+ || isParentOf(QLatin1String("/sys"), mountDir)
+ || isParentOf(QLatin1String("/var/run"), mountDir)
+ || isParentOf(QLatin1String("/var/lock"), mountDir)) {
+ return true;
+ }
+
+ QByteArray type = it.fileSystemType();
+ if (type == "tmpfs")
+ return false;
+#if defined(Q_OS_LINUX)
+ if (type == "rootfs" || type == "rpc_pipefs")
+ return true;
+#endif
+
+ if (!it.device().startsWith('/'))
+ return true;
+
+ return false;
+}
+
#if defined(Q_OS_BSD4)
inline QStorageIterator::QStorageIterator()
@@ -444,10 +458,8 @@ void QStorageInfoPrivate::initRootPath()
while (it.next()) {
const QString mountDir = it.rootPath();
const QByteArray fsName = it.fileSystemType();
- if (isPseudoFs(mountDir, fsName))
- continue;
// we try to find most suitable entry
- if (oldRootPath.startsWith(mountDir) && maxLength < mountDir.length()) {
+ if (isParentOf(mountDir, oldRootPath) && maxLength < mountDir.length()) {
maxLength = mountDir.length();
rootPath = mountDir;
device = it.device();
@@ -461,11 +473,14 @@ static inline QString retrieveLabel(const QByteArray &device)
#ifdef Q_OS_LINUX
static const char pathDiskByLabel[] = "/dev/disk/by-label";
+ QFileInfo devinfo(QFile::decodeName(device));
+ QString devicePath = devinfo.canonicalFilePath();
+
QDirIterator it(QLatin1String(pathDiskByLabel), QDir::NoDotAndDotDot);
while (it.hasNext()) {
it.next();
QFileInfo fileInfo(it.fileInfo());
- if (fileInfo.isSymLink() && fileInfo.symLinkTarget().toLocal8Bit() == device)
+ if (fileInfo.isSymLink() && fileInfo.symLinkTarget() == devicePath)
return fileInfo.fileName();
}
#elif defined Q_OS_HAIKU
@@ -536,11 +551,10 @@ QList<QStorageInfo> QStorageInfoPrivate::mountedVolumes()
QList<QStorageInfo> volumes;
while (it.next()) {
- const QString mountDir = it.rootPath();
- const QByteArray fsName = it.fileSystemType();
- if (isPseudoFs(mountDir, fsName))
+ if (isPseudoFs(it))
continue;
+ const QString mountDir = it.rootPath();
volumes.append(QStorageInfo(mountDir));
}
diff --git a/src/corelib/thread/qbasicatomic.h b/src/corelib/thread/qbasicatomic.h
index c29b80d3d0..7960174277 100644
--- a/src/corelib/thread/qbasicatomic.h
+++ b/src/corelib/thread/qbasicatomic.h
@@ -249,8 +249,8 @@ public:
AtomicType _q_value;
- Type load() const Q_DECL_NOTHROW { return _q_value; }
- void store(Type newValue) Q_DECL_NOTHROW { _q_value = newValue; }
+ Type load() const Q_DECL_NOTHROW { return Ops::load(_q_value); }
+ void store(Type newValue) Q_DECL_NOTHROW { Ops::store(_q_value, newValue); }
operator Type() const Q_DECL_NOTHROW { return loadAcquire(); }
Type operator=(Type newValue) Q_DECL_NOTHROW { storeRelease(newValue); return newValue; }
diff --git a/src/corelib/tools/qarraydata.cpp b/src/corelib/tools/qarraydata.cpp
index fa6556f7d9..eb6ce21282 100644
--- a/src/corelib/tools/qarraydata.cpp
+++ b/src/corelib/tools/qarraydata.cpp
@@ -65,7 +65,7 @@ QArrayData *QArrayData::allocate(size_t objectSize, size_t alignment,
// Don't allocate empty headers
if (!(options & RawData) && !capacity) {
-#if QT_SUPPORTS(UNSHARABLE_CONTAINERS)
+#if !defined(QT_NO_UNSHARABLE_CONTAINERS)
if (options & Unsharable)
return const_cast<QArrayData *>(&qt_array_unsharable_empty);
#endif
@@ -110,7 +110,7 @@ QArrayData *QArrayData::allocate(size_t objectSize, size_t alignment,
quintptr data = (quintptr(header) + sizeof(QArrayData) + alignment - 1)
& ~(alignment - 1);
-#if QT_SUPPORTS(UNSHARABLE_CONTAINERS)
+#if !defined(QT_NO_UNSHARABLE_CONTAINERS)
header->ref.atomic.store(bool(!(options & Unsharable)));
#else
header->ref.atomic.store(1);
@@ -132,7 +132,7 @@ void QArrayData::deallocate(QArrayData *data, size_t objectSize,
&& !(alignment & (alignment - 1)));
Q_UNUSED(objectSize) Q_UNUSED(alignment)
-#if QT_SUPPORTS(UNSHARABLE_CONTAINERS)
+#if !defined(QT_NO_UNSHARABLE_CONTAINERS)
if (data == &qt_array_unsharable_empty)
return;
#endif
diff --git a/src/corelib/tools/qarraydata.h b/src/corelib/tools/qarraydata.h
index 865bd4325d..cbbfe1bea2 100644
--- a/src/corelib/tools/qarraydata.h
+++ b/src/corelib/tools/qarraydata.h
@@ -72,7 +72,7 @@ struct Q_CORE_EXPORT QArrayData
enum AllocationOption {
CapacityReserved = 0x1,
-#if QT_SUPPORTS(UNSHARABLE_CONTAINERS)
+#if !defined(QT_NO_UNSHARABLE_CONTAINERS)
Unsharable = 0x2,
#endif
RawData = 0x4,
@@ -249,7 +249,7 @@ struct QTypedArrayData
return allocate(/* capacity */ 0);
}
-#if QT_SUPPORTS(UNSHARABLE_CONTAINERS)
+#if !defined(QT_NO_UNSHARABLE_CONTAINERS)
static QTypedArrayData *unsharableEmpty()
{
Q_STATIC_ASSERT(sizeof(QTypedArrayData) == sizeof(QArrayData));
diff --git a/src/corelib/tools/qarraydatapointer.h b/src/corelib/tools/qarraydatapointer.h
index 9804d2c2d5..615d7c5f80 100644
--- a/src/corelib/tools/qarraydatapointer.h
+++ b/src/corelib/tools/qarraydatapointer.h
@@ -127,7 +127,7 @@ public:
return (!d->isMutable() || d->ref.isShared());
}
-#if QT_SUPPORTS(UNSHARABLE_CONTAINERS)
+#if !defined(QT_NO_UNSHARABLE_CONTAINERS)
void setSharable(bool sharable)
{
if (needsDetach()) {
diff --git a/src/corelib/tools/qcontiguouscache.h b/src/corelib/tools/qcontiguouscache.h
index 41d198f9bc..d546e949c2 100644
--- a/src/corelib/tools/qcontiguouscache.h
+++ b/src/corelib/tools/qcontiguouscache.h
@@ -96,7 +96,7 @@ public:
inline void detach() { if (d->ref.load() != 1) detach_helper(); }
inline bool isDetached() const { return d->ref.load() == 1; }
-#if QT_SUPPORTS(UNSHARABLE_CONTAINERS)
+#if !defined(QT_NO_UNSHARABLE_CONTAINERS)
inline void setSharable(bool sharable) { if (!sharable) detach(); d->sharable = sharable; }
#endif
diff --git a/src/corelib/tools/qhash.h b/src/corelib/tools/qhash.h
index a18dd74706..a5bde40fb8 100644
--- a/src/corelib/tools/qhash.h
+++ b/src/corelib/tools/qhash.h
@@ -266,7 +266,7 @@ public:
inline void detach() { if (d->ref.isShared()) detach_helper(); }
inline bool isDetached() const { return !d->ref.isShared(); }
-#if QT_SUPPORTS(UNSHARABLE_CONTAINERS)
+#if !defined(QT_NO_UNSHARABLE_CONTAINERS)
inline void setSharable(bool sharable) { if (!sharable) detach(); if (d != &QHashData::shared_null) d->sharable = sharable; }
#endif
bool isSharedWith(const QHash &other) const { return d == other.d; }
diff --git a/src/corelib/tools/qlinkedlist.h b/src/corelib/tools/qlinkedlist.h
index 110529d843..710bf5a9f2 100644
--- a/src/corelib/tools/qlinkedlist.h
+++ b/src/corelib/tools/qlinkedlist.h
@@ -99,7 +99,7 @@ public:
inline void detach()
{ if (d->ref.isShared()) detach_helper2(this->e); }
inline bool isDetached() const { return !d->ref.isShared(); }
-#if QT_SUPPORTS(UNSHARABLE_CONTAINERS)
+#if !defined(QT_NO_UNSHARABLE_CONTAINERS)
inline void setSharable(bool sharable) { if (!sharable) detach(); if (d != &QLinkedListData::shared_null) d->sharable = sharable; }
#endif
inline bool isSharedWith(const QLinkedList<T> &other) const { return d == other.d; }
diff --git a/src/corelib/tools/qlist.h b/src/corelib/tools/qlist.h
index e04a6be1ab..381875e96f 100644
--- a/src/corelib/tools/qlist.h
+++ b/src/corelib/tools/qlist.h
@@ -169,7 +169,7 @@ public:
}
inline bool isDetached() const { return !d->ref.isShared(); }
-#if QT_SUPPORTS(UNSHARABLE_CONTAINERS)
+#if !defined(QT_NO_UNSHARABLE_CONTAINERS)
inline void setSharable(bool sharable)
{
if (sharable == d->ref.isSharable())
diff --git a/src/corelib/tools/qmap.h b/src/corelib/tools/qmap.h
index ed49e70f4e..7b5a643a1e 100644
--- a/src/corelib/tools/qmap.h
+++ b/src/corelib/tools/qmap.h
@@ -359,7 +359,7 @@ public:
inline void detach() { if (d->ref.isShared()) detach_helper(); }
inline bool isDetached() const { return !d->ref.isShared(); }
-#if QT_SUPPORTS(UNSHARABLE_CONTAINERS)
+#if !defined(QT_NO_UNSHARABLE_CONTAINERS)
inline void setSharable(bool sharable)
{
if (sharable == d->ref.isSharable())
diff --git a/src/corelib/tools/qrefcount.h b/src/corelib/tools/qrefcount.h
index a390989e76..bff6885d65 100644
--- a/src/corelib/tools/qrefcount.h
+++ b/src/corelib/tools/qrefcount.h
@@ -47,7 +47,7 @@ class RefCount
public:
inline bool ref() Q_DECL_NOTHROW {
int count = atomic.load();
-#if QT_SUPPORTS(UNSHARABLE_CONTAINERS)
+#if !defined(QT_NO_UNSHARABLE_CONTAINERS)
if (count == 0) // !isSharable
return false;
#endif
@@ -58,7 +58,7 @@ public:
inline bool deref() Q_DECL_NOTHROW {
int count = atomic.load();
-#if QT_SUPPORTS(UNSHARABLE_CONTAINERS)
+#if !defined(QT_NO_UNSHARABLE_CONTAINERS)
if (count == 0) // !isSharable
return false;
#endif
@@ -67,7 +67,7 @@ public:
return atomic.deref();
}
-#if QT_SUPPORTS(UNSHARABLE_CONTAINERS)
+#if !defined(QT_NO_UNSHARABLE_CONTAINERS)
bool setSharable(bool sharable) Q_DECL_NOTHROW
{
Q_ASSERT(!isShared());
diff --git a/src/corelib/tools/qset.h b/src/corelib/tools/qset.h
index 3f4208e8b3..7e7eb5210c 100644
--- a/src/corelib/tools/qset.h
+++ b/src/corelib/tools/qset.h
@@ -79,7 +79,7 @@ public:
inline void detach() { q_hash.detach(); }
inline bool isDetached() const { return q_hash.isDetached(); }
-#if QT_SUPPORTS(UNSHARABLE_CONTAINERS)
+#if !defined(QT_NO_UNSHARABLE_CONTAINERS)
inline void setSharable(bool sharable) { q_hash.setSharable(sharable); }
#endif
diff --git a/src/corelib/tools/qvector.h b/src/corelib/tools/qvector.h
index 691872cb36..3154220634 100644
--- a/src/corelib/tools/qvector.h
+++ b/src/corelib/tools/qvector.h
@@ -100,7 +100,7 @@ public:
inline void detach();
inline bool isDetached() const { return !d->ref.isShared(); }
-#if QT_SUPPORTS(UNSHARABLE_CONTAINERS)
+#if !defined(QT_NO_UNSHARABLE_CONTAINERS)
inline void setSharable(bool sharable)
{
if (sharable == d->ref.isSharable())
@@ -376,7 +376,7 @@ template <typename T>
void QVector<T>::detach()
{
if (!isDetached()) {
-#if QT_SUPPORTS(UNSHARABLE_CONTAINERS)
+#if !defined(QT_NO_UNSHARABLE_CONTAINERS)
if (!d->alloc)
d = Data::unsharableEmpty();
else
@@ -533,7 +533,7 @@ void QVector<T>::reallocData(const int asize, const int aalloc, QArrayData::Allo
x = Data::allocate(aalloc, options);
Q_CHECK_PTR(x);
// aalloc is bigger then 0 so it is not [un]sharedEmpty
-#if QT_SUPPORTS(UNSHARABLE_CONTAINERS)
+#if !defined(QT_NO_UNSHARABLE_CONTAINERS)
Q_ASSERT(x->ref.isSharable() || options.testFlag(QArrayData::Unsharable));
#endif
Q_ASSERT(!x->ref.isStatic());
@@ -601,7 +601,7 @@ void QVector<T>::reallocData(const int asize, const int aalloc, QArrayData::Allo
Q_ASSERT(d->data());
Q_ASSERT(uint(d->size) <= d->alloc);
-#if QT_SUPPORTS(UNSHARABLE_CONTAINERS)
+#if !defined(QT_NO_UNSHARABLE_CONTAINERS)
Q_ASSERT(d != Data::unsharableEmpty());
#endif
Q_ASSERT(aalloc ? d != Data::sharedNull() : d == Data::sharedNull());