From 48d7db6b3119ee27d9ae6b1bd0fdb24333f44756 Mon Sep 17 00:00:00 2001 From: Alexander Volkov Date: Wed, 16 Nov 2016 13:51:08 +0300 Subject: QtCore: Add missing override Change-Id: Ifdec31aabdd0371f36abbb382e49f52f5b58ee94 Reviewed-by: hjk --- src/corelib/codecs/qsimplecodec_p.h | 10 +++++----- src/corelib/io/qfile_p.h | 2 +- src/corelib/io/qtemporaryfile_p.h | 14 +++++++------- src/corelib/mimetypes/qmimetypeparser_p.h | 10 +++++----- src/corelib/statemachine/qhistorystate_p.h | 4 ++-- 5 files changed, 20 insertions(+), 20 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/codecs/qsimplecodec_p.h b/src/corelib/codecs/qsimplecodec_p.h index d45cf2377f..a84f9af1e9 100644 --- a/src/corelib/codecs/qsimplecodec_p.h +++ b/src/corelib/codecs/qsimplecodec_p.h @@ -66,12 +66,12 @@ public: explicit QSimpleTextCodec(int); ~QSimpleTextCodec(); - QString convertToUnicode(const char *, int, ConverterState *) const; - QByteArray convertFromUnicode(const QChar *, int, ConverterState *) const; + QString convertToUnicode(const char *, int, ConverterState *) const override; + QByteArray convertFromUnicode(const QChar *, int, ConverterState *) const override; - QByteArray name() const; - QList aliases() const; - int mibEnum() const; + QByteArray name() const override; + QList aliases() const override; + int mibEnum() const override; private: int forwardIndex; diff --git a/src/corelib/io/qfile_p.h b/src/corelib/io/qfile_p.h index fd7db3c120..545890c6b3 100644 --- a/src/corelib/io/qfile_p.h +++ b/src/corelib/io/qfile_p.h @@ -70,7 +70,7 @@ protected: bool openExternalFile(int flags, int fd, QFile::FileHandleFlags handleFlags); bool openExternalFile(int flags, FILE *fh, QFile::FileHandleFlags handleFlags); - virtual QAbstractFileEngine *engine() const; + QAbstractFileEngine *engine() const override; QString fileName; }; diff --git a/src/corelib/io/qtemporaryfile_p.h b/src/corelib/io/qtemporaryfile_p.h index 58cc318ffd..40974bd6cd 100644 --- a/src/corelib/io/qtemporaryfile_p.h +++ b/src/corelib/io/qtemporaryfile_p.h @@ -69,7 +69,7 @@ protected: QTemporaryFilePrivate(); ~QTemporaryFilePrivate(); - QAbstractFileEngine *engine() const; + QAbstractFileEngine *engine() const override; void resetFileEngine() const; bool autoRemove; @@ -98,14 +98,14 @@ public: ~QTemporaryFileEngine(); bool isReallyOpen() const; - void setFileName(const QString &file); + void setFileName(const QString &file) override; void setFileTemplate(const QString &fileTemplate); - bool open(QIODevice::OpenMode flags); - bool remove(); - bool rename(const QString &newName); - bool renameOverwrite(const QString &newName); - bool close(); + bool open(QIODevice::OpenMode flags) override; + bool remove() override; + bool rename(const QString &newName) override; + bool renameOverwrite(const QString &newName) override; + bool close() override; quint32 fileMode; bool filePathIsTemplate; diff --git a/src/corelib/mimetypes/qmimetypeparser_p.h b/src/corelib/mimetypes/qmimetypeparser_p.h index a502439419..0ce39e701c 100644 --- a/src/corelib/mimetypes/qmimetypeparser_p.h +++ b/src/corelib/mimetypes/qmimetypeparser_p.h @@ -108,19 +108,19 @@ public: explicit QMimeTypeParser(QMimeXMLProvider &provider) : m_provider(provider) {} protected: - inline bool process(const QMimeType &t, QString *) + inline bool process(const QMimeType &t, QString *) override { m_provider.addMimeType(t); return true; } - inline bool process(const QMimeGlobPattern &glob, QString *) + inline bool process(const QMimeGlobPattern &glob, QString *) override { m_provider.addGlobPattern(glob); return true; } - inline void processParent(const QString &child, const QString &parent) + inline void processParent(const QString &child, const QString &parent) override { m_provider.addParent(child, parent); } - inline void processAlias(const QString &alias, const QString &name) + inline void processAlias(const QString &alias, const QString &name) override { m_provider.addAlias(alias, name); } - inline void processMagicMatcher(const QMimeMagicRuleMatcher &matcher) + inline void processMagicMatcher(const QMimeMagicRuleMatcher &matcher) override { m_provider.addMagicMatcher(matcher); } private: diff --git a/src/corelib/statemachine/qhistorystate_p.h b/src/corelib/statemachine/qhistorystate_p.h index 2e93c31982..f3eb20f194 100644 --- a/src/corelib/statemachine/qhistorystate_p.h +++ b/src/corelib/statemachine/qhistorystate_p.h @@ -87,8 +87,8 @@ protected: // state, it will handle this transition as a special case. The history state itself is never // entered either: either the stored configuration will be used, or the target(s) of this // transition are used. - virtual bool eventTest(QEvent *event) { Q_UNUSED(event); return false; } - virtual void onTransition(QEvent *event) { Q_UNUSED(event); } + bool eventTest(QEvent *event) override { Q_UNUSED(event); return false; } + void onTransition(QEvent *event) override { Q_UNUSED(event); } }; QT_END_NAMESPACE -- cgit v1.2.3 From 658c8370e4dd74ee82046799b56947bb3c738b92 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Fri, 22 Jan 2016 17:03:48 +0100 Subject: QDateTimeParser: localize variable to avoid shadowing The outer scope it was in had a later clause with its own pos variable. Change-Id: I8d083d3d5935416ef82a78890ed145f02d6d6ded Reviewed-by: Timur Pocheptsov --- src/corelib/tools/qdatetimeparser.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/corelib') diff --git a/src/corelib/tools/qdatetimeparser.cpp b/src/corelib/tools/qdatetimeparser.cpp index 5b7bf0d3d4..bda786aa24 100644 --- a/src/corelib/tools/qdatetimeparser.cpp +++ b/src/corelib/tools/qdatetimeparser.cpp @@ -879,12 +879,12 @@ QDateTimeParser::StateNode QDateTimeParser::parse(QString &input, int &cursorPos State state = Acceptable; QDateTime newCurrentValue; - int pos = 0; bool conflicts = false; const int sectionNodesCount = sectionNodes.size(); QDTPDEBUG << "parse" << input; { + int pos = 0; int year, month, day; currentValue.date().getDate(&year, &month, &day); int year2digits = year % 100; -- cgit v1.2.3 From 4b1c343e5e8f75b567e88541c1b8ea89a3a5b666 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Tue, 15 Nov 2016 15:11:00 +0100 Subject: Doc: Add missing reference to qInfo() Change-Id: I7438aa8ff9fddf2e0155ffe0d442f96d4d9265d4 Reviewed-by: Leena Miettinen --- src/corelib/global/qlogging.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/corelib') diff --git a/src/corelib/global/qlogging.cpp b/src/corelib/global/qlogging.cpp index eb26b6198d..6b95449b3d 100644 --- a/src/corelib/global/qlogging.cpp +++ b/src/corelib/global/qlogging.cpp @@ -1748,7 +1748,7 @@ void qErrnoWarning(int code, const char *msg, ...) \snippet code/src_corelib_global_qglobal.cpp 23 - \sa QtMessageHandler, QtMsgType, qDebug(), qWarning(), qCritical(), qFatal(), + \sa QtMessageHandler, QtMsgType, qDebug(), qInfo(), qWarning(), qCritical(), qFatal(), {Debugging Techniques} */ -- cgit v1.2.3 From 3691f7ca0c7117f18ea38ca3950ee9a8a91a53c8 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Fri, 20 Sep 2013 02:38:22 +0200 Subject: QFutureInterface: make accesses to 'state' thread-safe Introduce helper functions switch_{on,off,from_to} to make the code more readable, and prepare everything for later optimizations reducing the sizes of critical sections (by locking the mutex later, or even never). This commit, however, is only concerned with shutting up tsan. In waitForResult(), simplified the code by removing an unneeded if guard: the condition is checked in the while loop immediately following in the then-block, and the local variable declaration that precedes the loop is not worth guarding. Change-Id: I24bfd864ca96f862302536ad8662065e6f366fa8 Reviewed-by: David Faure --- src/corelib/thread/qfutureinterface.cpp | 109 ++++++++++++++++++-------------- src/corelib/thread/qfutureinterface_p.h | 2 +- 2 files changed, 64 insertions(+), 47 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/thread/qfutureinterface.cpp b/src/corelib/thread/qfutureinterface.cpp index 2fe038165b..a29f8ebba7 100644 --- a/src/corelib/thread/qfutureinterface.cpp +++ b/src/corelib/thread/qfutureinterface.cpp @@ -77,13 +77,33 @@ QFutureInterfaceBase::~QFutureInterfaceBase() delete d; } +static inline int switch_on(QAtomicInt &a, int which) +{ + return a.fetchAndOrRelaxed(which) | which; +} + +static inline int switch_off(QAtomicInt &a, int which) +{ + return a.fetchAndAndRelaxed(~which) & ~which; +} + +static inline int switch_from_to(QAtomicInt &a, int from, int to) +{ + int newValue; + int expected = a.load(); + do { + newValue = (expected & ~from) | to; + } while (!a.testAndSetRelaxed(expected, newValue, expected)); + return newValue; +} + void QFutureInterfaceBase::cancel() { QMutexLocker locker(&d->m_mutex); - if (d->state & Canceled) + if (d->state.load() & Canceled) return; - d->state = State((d->state & ~Paused) | Canceled); + switch_from_to(d->state, Paused, Canceled); d->waitCondition.wakeAll(); d->pausedWaitCondition.wakeAll(); d->sendCallOut(QFutureCallOutEvent(QFutureCallOutEvent::Canceled)); @@ -93,10 +113,10 @@ void QFutureInterfaceBase::setPaused(bool paused) { QMutexLocker locker(&d->m_mutex); if (paused) { - d->state = State(d->state | Paused); + switch_on(d->state, Paused); d->sendCallOut(QFutureCallOutEvent(QFutureCallOutEvent::Paused)); } else { - d->state = State(d->state & ~Paused); + switch_off(d->state, Paused); d->pausedWaitCondition.wakeAll(); d->sendCallOut(QFutureCallOutEvent(QFutureCallOutEvent::Resumed)); } @@ -105,29 +125,24 @@ void QFutureInterfaceBase::setPaused(bool paused) void QFutureInterfaceBase::togglePaused() { QMutexLocker locker(&d->m_mutex); - if (d->state & Paused) { - d->state = State(d->state & ~Paused); + if (d->state.load() & Paused) { + switch_off(d->state, Paused); d->pausedWaitCondition.wakeAll(); d->sendCallOut(QFutureCallOutEvent(QFutureCallOutEvent::Resumed)); } else { - d->state = State(d->state | Paused); + switch_on(d->state, Paused); d->sendCallOut(QFutureCallOutEvent(QFutureCallOutEvent::Paused)); } } void QFutureInterfaceBase::setThrottled(bool enable) { - // bail out if we are not changing the state - if ((enable && (d->state & Throttled)) || (!enable && !(d->state & Throttled))) - return; - - // lock and change the state QMutexLocker lock(&d->m_mutex); if (enable) { - d->state = State(d->state | Throttled); + switch_on(d->state, Throttled); } else { - d->state = State(d->state & ~Throttled); - if (!(d->state & Paused)) + switch_off(d->state, Throttled); + if (!(d->state.load() & Paused)) d->pausedWaitCondition.wakeAll(); } } @@ -178,11 +193,15 @@ bool QFutureInterfaceBase::waitForNextResult() void QFutureInterfaceBase::waitForResume() { // return early if possible to avoid taking the mutex lock. - if ((d->state & Paused) == false || (d->state & Canceled)) - return; + { + const int state = d->state.load(); + if (!(state & Paused) || (state & Canceled)) + return; + } QMutexLocker lock(&d->m_mutex); - if ((d->state & Paused) == false || (d->state & Canceled)) + const int state = d->state.load(); + if (!(state & Paused) || (state & Canceled)) return; // decrease active thread count since this thread will wait. @@ -230,7 +249,7 @@ bool QFutureInterfaceBase::isProgressUpdateNeeded() const void QFutureInterfaceBase::reportStarted() { QMutexLocker locker(&d->m_mutex); - if ((d->state & Started) || (d->state & Canceled) || (d->state & Finished)) + if (d->state.load() & (Started|Canceled|Finished)) return; d->setState(State(Started | Running)); @@ -246,11 +265,11 @@ void QFutureInterfaceBase::reportCanceled() void QFutureInterfaceBase::reportException(const QException &exception) { QMutexLocker locker(&d->m_mutex); - if ((d->state & Canceled) || (d->state & Finished)) + if (d->state.load() & (Canceled|Finished)) return; d->m_exceptionStore.setException(exception); - d->state = State(d->state | Canceled); + switch_on(d->state, Canceled); d->waitCondition.wakeAll(); d->pausedWaitCondition.wakeAll(); d->sendCallOut(QFutureCallOutEvent(QFutureCallOutEvent::Canceled)); @@ -260,8 +279,8 @@ void QFutureInterfaceBase::reportException(const QException &exception) void QFutureInterfaceBase::reportFinished() { QMutexLocker locker(&d->m_mutex); - if (!(d->state & Finished)) { - d->state = State((d->state & ~Running) | Finished); + if (!isFinished()) { + switch_from_to(d->state, Running, Finished); d->waitCondition.wakeAll(); d->sendCallOut(QFutureCallOutEvent(QFutureCallOutEvent::Finished)); } @@ -281,7 +300,7 @@ int QFutureInterfaceBase::expectedResultCount() bool QFutureInterfaceBase::queryState(State state) const { - return (d->state & state); + return d->state.load() & state; } void QFutureInterfaceBase::waitForResult(int resultIndex) @@ -289,7 +308,7 @@ void QFutureInterfaceBase::waitForResult(int resultIndex) d->m_exceptionStore.throwPossibleException(); QMutexLocker lock(&d->m_mutex); - if (!(d->state & Running)) + if (!isRunning()) return; lock.unlock(); @@ -299,11 +318,9 @@ void QFutureInterfaceBase::waitForResult(int resultIndex) lock.relock(); - if (d->state & Running) { - const int waitIndex = (resultIndex == -1) ? INT_MAX : resultIndex; - while ((d->state & Running) && d->internal_isResultReadyAt(waitIndex) == false) - d->waitCondition.wait(&d->m_mutex); - } + const int waitIndex = (resultIndex == -1) ? INT_MAX : resultIndex; + while (isRunning() && !d->internal_isResultReadyAt(waitIndex)) + d->waitCondition.wait(&d->m_mutex); d->m_exceptionStore.throwPossibleException(); } @@ -311,7 +328,7 @@ void QFutureInterfaceBase::waitForResult(int resultIndex) void QFutureInterfaceBase::waitForFinished() { QMutexLocker lock(&d->m_mutex); - const bool alreadyFinished = !(d->state & Running); + const bool alreadyFinished = !isRunning(); lock.unlock(); if (!alreadyFinished) { @@ -319,7 +336,7 @@ void QFutureInterfaceBase::waitForFinished() lock.relock(); - while (d->state & Running) + while (isRunning()) d->waitCondition.wait(&d->m_mutex); } @@ -328,7 +345,7 @@ void QFutureInterfaceBase::waitForFinished() void QFutureInterfaceBase::reportResultsReady(int beginIndex, int endIndex) { - if ((d->state & Canceled) || (d->state & Finished) || beginIndex == endIndex) + if (beginIndex == endIndex || (d->state.load() & (Canceled|Finished))) return; d->waitCondition.wakeAll(); @@ -390,7 +407,7 @@ void QFutureInterfaceBase::setProgressValueAndText(int progressValue, if (d->m_progressValue >= progressValue) return; - if ((d->state & Canceled) || (d->state & Finished)) + if (d->state.load() & (Canceled|Finished)) return; if (d->internal_updateProgress(progressValue, progressText)) { @@ -462,10 +479,10 @@ bool QFutureInterfaceBasePrivate::internal_waitForNextResult() if (m_results.hasNextResult()) return true; - while ((state & QFutureInterfaceBase::Running) && m_results.hasNextResult() == false) + while ((state.load() & QFutureInterfaceBase::Running) && m_results.hasNextResult() == false) waitCondition.wait(&m_mutex); - return (!(state & QFutureInterfaceBase::Canceled) && m_results.hasNextResult()); + return !(state.load() & QFutureInterfaceBase::Canceled) && m_results.hasNextResult(); } bool QFutureInterfaceBasePrivate::internal_updateProgress(int progress, @@ -488,16 +505,16 @@ bool QFutureInterfaceBasePrivate::internal_updateProgress(int progress, void QFutureInterfaceBasePrivate::internal_setThrottled(bool enable) { // bail out if we are not changing the state - if ((enable && (state & QFutureInterfaceBase::Throttled)) - || (!enable && !(state & QFutureInterfaceBase::Throttled))) + if ((enable && (state.load() & QFutureInterfaceBase::Throttled)) + || (!enable && !(state.load() & QFutureInterfaceBase::Throttled))) return; // change the state if (enable) { - state = QFutureInterfaceBase::State(state | QFutureInterfaceBase::Throttled); + switch_on(state, QFutureInterfaceBase::Throttled); } else { - state = QFutureInterfaceBase::State(state & ~QFutureInterfaceBase::Throttled); - if (!(state & QFutureInterfaceBase::Paused)) + switch_off(state, QFutureInterfaceBase::Throttled); + if (!(state.load() & QFutureInterfaceBase::Paused)) pausedWaitCondition.wakeAll(); } } @@ -532,7 +549,7 @@ void QFutureInterfaceBasePrivate::connectOutputInterface(QFutureCallOutInterface { QMutexLocker locker(&m_mutex); - if (state & QFutureInterfaceBase::Started) { + if (state.load() & QFutureInterfaceBase::Started) { interface->postCallOutEvent(QFutureCallOutEvent(QFutureCallOutEvent::Started)); interface->postCallOutEvent(QFutureCallOutEvent(QFutureCallOutEvent::ProgressRange, m_progressMinimum, @@ -552,13 +569,13 @@ void QFutureInterfaceBasePrivate::connectOutputInterface(QFutureCallOutInterface it.batchedAdvance(); } - if (state & QFutureInterfaceBase::Paused) + if (state.load() & QFutureInterfaceBase::Paused) interface->postCallOutEvent(QFutureCallOutEvent(QFutureCallOutEvent::Paused)); - if (state & QFutureInterfaceBase::Canceled) + if (state.load() & QFutureInterfaceBase::Canceled) interface->postCallOutEvent(QFutureCallOutEvent(QFutureCallOutEvent::Canceled)); - if (state & QFutureInterfaceBase::Finished) + if (state.load() & QFutureInterfaceBase::Finished) interface->postCallOutEvent(QFutureCallOutEvent(QFutureCallOutEvent::Finished)); outputConnections.append(interface); @@ -577,7 +594,7 @@ void QFutureInterfaceBasePrivate::disconnectOutputInterface(QFutureCallOutInterf void QFutureInterfaceBasePrivate::setState(QFutureInterfaceBase::State newState) { - state = newState; + state.store(newState); } QT_END_NAMESPACE diff --git a/src/corelib/thread/qfutureinterface_p.h b/src/corelib/thread/qfutureinterface_p.h index e2d588cd07..eb0c38421b 100644 --- a/src/corelib/thread/qfutureinterface_p.h +++ b/src/corelib/thread/qfutureinterface_p.h @@ -155,7 +155,7 @@ public: int m_progressValue; // TQ int m_progressMinimum; // TQ int m_progressMaximum; // TQ - QFutureInterfaceBase::State state; + QAtomicInt state; // reads and writes can happen unprotected, both must be atomic QElapsedTimer progressTime; QWaitCondition pausedWaitCondition; QtPrivate::ResultStoreBase m_results; -- cgit v1.2.3 From 38675e18fcc841228141568a2ecfafdeb99eba2a Mon Sep 17 00:00:00 2001 From: Oliver Wolff Date: Thu, 17 Nov 2016 10:40:44 +0100 Subject: Add support for Visual Studio 2017 Tested with RC Task-number: QTBUG-57086 Change-Id: I21f56edca3852b52edd2c5fdcce76817141e8d4a Reviewed-by: Friedemann Kleint --- src/corelib/global/qlibraryinfo.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/corelib') diff --git a/src/corelib/global/qlibraryinfo.cpp b/src/corelib/global/qlibraryinfo.cpp index 8bcacca13f..14be4c3475 100644 --- a/src/corelib/global/qlibraryinfo.cpp +++ b/src/corelib/global/qlibraryinfo.cpp @@ -310,8 +310,10 @@ QLibraryInfo::buildDate() # define COMPILER_STRING "MSVC 2012" # elif _MSC_VER < 1900 # define COMPILER_STRING "MSVC 2013" -# elif _MSC_VER < 2000 +# elif _MSC_VER < 1910 # define COMPILER_STRING "MSVC 2015" +# elif _MSC_VER < 2000 +# define COMPILER_STRING "MSVC 2017" # else # define COMPILER_STRING "MSVC _MSC_VER " QT_STRINGIFY(_MSC_VER) # endif -- cgit v1.2.3 From 9f17c245893e296d5c92ed1ef1e5d08896b469b1 Mon Sep 17 00:00:00 2001 From: Oliver Wolff Date: Thu, 17 Nov 2016 10:40:44 +0100 Subject: Enable constexpr support for Visual Studio 2017 Change-Id: I894789c41cc2c1a327c14d0526e658520d096085 Reviewed-by: Friedemann Kleint Reviewed-by: Thiago Macieira --- src/corelib/global/qcompilerdetection.h | 3 +++ src/corelib/thread/qbasicatomic.h | 5 +++++ 2 files changed, 8 insertions(+) (limited to 'src/corelib') diff --git a/src/corelib/global/qcompilerdetection.h b/src/corelib/global/qcompilerdetection.h index e324c043af..25e6e4c6bf 100644 --- a/src/corelib/global/qcompilerdetection.h +++ b/src/corelib/global/qcompilerdetection.h @@ -931,6 +931,9 @@ # define Q_COMPILER_THREADSAFE_STATICS # define Q_COMPILER_UNIFORM_INIT # endif +# if _MSC_VER >= 1910 +# define Q_COMPILER_CONSTEXPR +# endif # endif /* __cplusplus */ #endif /* Q_CC_MSVC */ diff --git a/src/corelib/thread/qbasicatomic.h b/src/corelib/thread/qbasicatomic.h index 7960174277..c1e01a3212 100644 --- a/src/corelib/thread/qbasicatomic.h +++ b/src/corelib/thread/qbasicatomic.h @@ -78,6 +78,9 @@ # error "Qt has not been ported to this platform" #endif +QT_WARNING_PUSH +QT_WARNING_DISABLE_MSVC(4522) + QT_BEGIN_NAMESPACE #if 0 @@ -340,4 +343,6 @@ public: QT_END_NAMESPACE +QT_WARNING_POP + #endif // QBASICATOMIC_H -- cgit v1.2.3 From 3cd457bdad6eee4a703ef9773b80165a272fbdc7 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Mon, 21 Nov 2016 11:38:43 +0100 Subject: Handle RemovePath correctly when calling matches() Change-Id: Ied324a537df127e676fad26b42e658a9d5aeec9b Reviewed-by: David Faure --- src/corelib/io/qurl.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/corelib') diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp index 7512bcd83f..de78d09dd9 100644 --- a/src/corelib/io/qurl.cpp +++ b/src/corelib/io/qurl.cpp @@ -3703,6 +3703,9 @@ bool QUrl::matches(const QUrl &url, FormattingOptions options) const if ((d->sectionIsPresent & mask) != (url.d->sectionIsPresent & mask)) return false; + if (options & QUrl::RemovePath) + return true; + // Compare paths, after applying path-related options QString path1; d->appendPath(path1, options, QUrlPrivate::Path); -- cgit v1.2.3 From e2b856d56290e9b3eaaf889b3e0a08badbaa6046 Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov Date: Thu, 17 Nov 2016 16:10:11 +0100 Subject: QDir::tempPath - use NSTemporaryDirectory on Darwin MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Instead of hardcoded "/tmp". Task-number: QTBUG-57165 Change-Id: I9d3ae157c22ce131281b8279149eea87a26244e8 Reviewed-by: Morten Johan Sørvig --- src/corelib/io/qfilesystemengine_unix.cpp | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp index 3cc27bf847..a3b28a8d95 100644 --- a/src/corelib/io/qfilesystemengine_unix.cpp +++ b/src/corelib/io/qfilesystemengine_unix.cpp @@ -59,6 +59,13 @@ #include #endif +#if defined(Q_OS_DARWIN) +// We cannot include (it's an Objective-C header), but +// we need these declarations: +Q_FORWARD_DECLARE_OBJC_CLASS(NSString); +extern "C" NSString *NSTemporaryDirectory(); +#endif + QT_BEGIN_NAMESPACE #if defined(Q_OS_DARWIN) @@ -706,8 +713,17 @@ QString QFileSystemEngine::tempPath() return QDir::cleanPath(temp); #else QString temp = QFile::decodeName(qgetenv("TMPDIR")); - if (temp.isEmpty()) - temp = QLatin1String("/tmp"); + if (temp.isEmpty()) { +#if defined(Q_OS_DARWIN) && !defined(QT_BOOTSTRAPPED) + if (NSString *nsPath = NSTemporaryDirectory()) { + temp = QString::fromCFString((CFStringRef)nsPath); + } else { +#else + { +#endif + temp = QLatin1String("/tmp"); + } + } return QDir::cleanPath(temp); #endif } -- cgit v1.2.3