From 02e448784543df2d81135ac583c39df6237dac69 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 10 Apr 2015 23:18:23 -0700 Subject: Correct calculation of filesystem data on unusual filesystems POSIX.1 says f_blocks, f_bfree, f_bavail are calculated in terms of f_frsize, not of the regular block size f_bsize. On most systems, it's the same, which is why we didn't catch it. I don't have any filesystem to test this on to confirm. Reference: http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_statvfs.h.html Task-number: QTBUG-45137 Change-Id: I27eaacb532114dd188c4ffff13d3e13016bed4e6 Reviewed-by: Dmitry Shachnev Reviewed-by: Allan Sandfeld Jensen Reviewed-by: Ivan Komissarov --- src/corelib/io/qstorageinfo_unix.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/corelib/io') diff --git a/src/corelib/io/qstorageinfo_unix.cpp b/src/corelib/io/qstorageinfo_unix.cpp index 2a83e87b0c..cd3c60650e 100644 --- a/src/corelib/io/qstorageinfo_unix.cpp +++ b/src/corelib/io/qstorageinfo_unix.cpp @@ -416,9 +416,9 @@ void QStorageInfoPrivate::retreiveVolumeInfo() valid = true; ready = true; - bytesTotal = statfs_buf.f_blocks * statfs_buf.f_bsize; - bytesFree = statfs_buf.f_bfree * statfs_buf.f_bsize; - bytesAvailable = statfs_buf.f_bavail * statfs_buf.f_bsize; + bytesTotal = statfs_buf.f_blocks * statfs_buf.f_frsize; + bytesFree = statfs_buf.f_bfree * statfs_buf.f_frsize; + bytesAvailable = statfs_buf.f_bavail * statfs_buf.f_frsize; #if defined(Q_OS_ANDROID) #if defined(_STATFS_F_FLAGS) readOnly = (statfs_buf.f_flags & ST_RDONLY) != 0; -- cgit v1.2.3 From 18a3b431678e3b456c33a9f7ae21d8653dd2ef85 Mon Sep 17 00:00:00 2001 From: Samuel Gaist Date: Mon, 27 Apr 2015 01:22:36 +0200 Subject: Update QProcess doc to use non-deprecated setProcessEnvironment Currently the documentation still mentions the use of the deprected setEnvironment function. This patch aims to correct that Task-number: QTBUG-45235 Change-Id: Iab35754b39f025c7493a6f061eb72e23bc4cf308 Reviewed-by: Oswald Buddenhagen --- src/corelib/io/qprocess.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/corelib/io') diff --git a/src/corelib/io/qprocess.cpp b/src/corelib/io/qprocess.cpp index baba9a0f9e..4d2a75c0fa 100644 --- a/src/corelib/io/qprocess.cpp +++ b/src/corelib/io/qprocess.cpp @@ -373,8 +373,8 @@ QString QProcessEnvironment::value(const QString &name, const QString &defaultVa Use with the QProcess::setEnvironment function is not recommended due to potential encoding problems under Unix, and worse performance. - \sa systemEnvironment(), QProcess::systemEnvironment(), QProcess::environment(), - QProcess::setEnvironment() + \sa systemEnvironment(), QProcess::systemEnvironment(), + QProcess::setProcessEnvironment() */ QStringList QProcessEnvironment::toStringList() const { @@ -534,7 +534,7 @@ void QProcessPrivate::Channel::clear() Certain processes need special environment settings in order to operate. You can set environment variables for your process by - calling setEnvironment(). To set a working directory, call + calling setProcessEnvironment(). To set a working directory, call setWorkingDirectory(). By default, processes are run in the current working directory of the calling process. @@ -2471,7 +2471,7 @@ QT_END_INCLUDE_NAMESPACE \note For new code, it is recommended to use QProcessEnvironment::systemEnvironment() - \sa QProcessEnvironment::systemEnvironment(), environment(), setEnvironment() + \sa QProcessEnvironment::systemEnvironment(), setProcessEnvironment() */ QStringList QProcess::systemEnvironment() { -- cgit v1.2.3 From 925822eca54d98ea4da73ea75387393e76dbcdda Mon Sep 17 00:00:00 2001 From: Samuel Gaist Date: Sun, 2 Aug 2015 01:50:33 +0200 Subject: QProcessEnvironment documentation typo fix Task-number: QTBUG-45985 Change-Id: I42de961ca6d57847c135abd8395494d0e416ab05 Reviewed-by: Sze Howe Koh --- src/corelib/io/qprocess.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/corelib/io') diff --git a/src/corelib/io/qprocess.cpp b/src/corelib/io/qprocess.cpp index 914774b433..af80f4f281 100644 --- a/src/corelib/io/qprocess.cpp +++ b/src/corelib/io/qprocess.cpp @@ -127,7 +127,7 @@ QT_BEGIN_NAMESPACE Unix environment allows both variable names and contents to contain arbitrary binary data (except for the NUL character). QProcessEnvironment will preserve such variables, but does not support manipulating variables whose names or - values are not encodable by the current locale settings (see + values cannot be encoded by the current locale settings (see QTextCodec::codecForLocale). On Windows, the variable names are case-insensitive, but case-preserving. @@ -528,7 +528,7 @@ void QProcessPrivate::Channel::clear() QProcess can merge the two output channels, so that standard output and standard error data from the running process both use the standard output channel. Call setProcessChannelMode() with - MergedChannels before starting the process to activative + MergedChannels before starting the process to activate this feature. You also have the option of forwarding the output of the running process to the calling, main process, by passing ForwardedChannels as the argument. It is also possible to forward @@ -1266,7 +1266,7 @@ QProcess::InputChannelMode QProcess::inputChannelMode() const /*! \since 5.2 - Sets the channel mode of the QProcess standard intput + Sets the channel mode of the QProcess standard input channel to the \a mode specified. This mode will be used the next time start() is called. @@ -2311,7 +2311,7 @@ void QProcess::setArguments(const QStringList &arguments) The process may not exit as a result of calling this function (it is given the chance to prompt the user for any unsaved files, etc). - On Windows, terminate() posts a WM_CLOSE message to all toplevel windows + On Windows, terminate() posts a WM_CLOSE message to all top-level windows of the process and then to the main thread of the process itself. On Unix and OS X the \c SIGTERM signal is sent. @@ -2507,7 +2507,7 @@ QT_END_INCLUDE_NAMESPACE This function does not cache the system environment. Therefore, it's possible to obtain an updated version of the environment if low-level C - library functions like \tt setenv ot \tt putenv have been called. + library functions like \tt setenv or \tt putenv have been called. However, note that repeated calls to this function will recreate the list of environment variables, which is a non-trivial operation. @@ -2537,7 +2537,7 @@ QStringList QProcess::systemEnvironment() It is returned as a QProcessEnvironment. This function does not cache the system environment. Therefore, it's possible to obtain an updated version of the environment if low-level C library - functions like \tt setenv ot \tt putenv have been called. + functions like \tt setenv or \tt putenv have been called. However, note that repeated calls to this function will recreate the QProcessEnvironment object, which is a non-trivial operation. -- cgit v1.2.3 From 1ff66a79626d40a8379a639a0fae3696fc7a06c0 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 18 Feb 2015 12:36:47 -0800 Subject: QProcess: Ensure that the stdin buffer is cleared on start() The buffer may have been left dirty if we were unable to write all the data to the child process in the previous run. So ensure we clear it before starting a new one. We already did that for stdout and stderr, for some reason. Task-number: QTBUG-44517 Change-Id: I1a800c709d3543699131ffff13c419da3bbffacf Reviewed-by: Kai Koehne Reviewed-by: Joerg Bornemann Reviewed-by: Thiago Macieira Reviewed-by: Oswald Buddenhagen --- src/corelib/io/qprocess.cpp | 3 ++- src/corelib/io/qwindowspipewriter.cpp | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'src/corelib/io') diff --git a/src/corelib/io/qprocess.cpp b/src/corelib/io/qprocess.cpp index 176386d6df..c29b97b535 100644 --- a/src/corelib/io/qprocess.cpp +++ b/src/corelib/io/qprocess.cpp @@ -1,7 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2015 The Qt Company Ltd. -** Copyright (C) 2014 Intel Corporation +** Copyright (C) 2015 Intel Corporation ** Contact: http://www.qt.io/licensing/ ** ** This file is part of the QtCore module of the Qt Toolkit. @@ -2135,6 +2135,7 @@ void QProcessPrivate::start(QIODevice::OpenMode mode) qDebug() << "QProcess::start(" << program << ',' << arguments << ',' << mode << ')'; #endif + stdinChannel.buffer.clear(); stdoutChannel.buffer.clear(); stderrChannel.buffer.clear(); diff --git a/src/corelib/io/qwindowspipewriter.cpp b/src/corelib/io/qwindowspipewriter.cpp index add2ac94da..57053f129a 100644 --- a/src/corelib/io/qwindowspipewriter.cpp +++ b/src/corelib/io/qwindowspipewriter.cpp @@ -85,7 +85,7 @@ qint64 QWindowsPipeWriter::write(const char *ptr, qint64 maxlen) return -1; QMutexLocker locker(&lock); - data.append(QByteArray(ptr, maxlen)); + data.append(ptr, maxlen); waitCondition.wakeOne(); return maxlen; } -- cgit v1.2.3 From 507625d984f9467b056e603560d62a2e4a56074d Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Tue, 28 Jul 2015 13:43:54 +0200 Subject: fix assertion in QProcess/Win Do not call bytesAvailableInChannel if the source pipe end is invalid. This is the case when redirecting channels on Windows. The assertions in bytesAvailableInChannel were triggered whenever an output process or output file was set and waitForBytesWritten was called. Task-number: QTBUG-45548 Change-Id: I225dfea2c5e27e122f75008a3a06d425554e00fe Reviewed-by: Alex Trotsenko Reviewed-by: Oswald Buddenhagen --- src/corelib/io/qprocess_win.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/corelib/io') diff --git a/src/corelib/io/qprocess_win.cpp b/src/corelib/io/qprocess_win.cpp index cef961ecbd..eb88ded2c9 100644 --- a/src/corelib/io/qprocess_win.cpp +++ b/src/corelib/io/qprocess_win.cpp @@ -704,13 +704,15 @@ bool QProcessPrivate::waitForBytesWritten(int msecs) return true; // If we wouldn't write anything, check if we can read stdout. - if (bytesAvailableInChannel(&stdoutChannel) != 0) { + if (stdoutChannel.pipe[0] != INVALID_Q_PIPE + && bytesAvailableInChannel(&stdoutChannel) != 0) { tryReadFromChannel(&stdoutChannel); timer.resetIncrements(); } // Check if we can read stderr. - if (bytesAvailableInChannel(&stderrChannel) != 0) { + if (stderrChannel.pipe[0] != INVALID_Q_PIPE + && bytesAvailableInChannel(&stderrChannel) != 0) { tryReadFromChannel(&stderrChannel); timer.resetIncrements(); } -- cgit v1.2.3 From e525d1f44d2678f0360a0ee6c9ce2c9cb44f52a2 Mon Sep 17 00:00:00 2001 From: Topi Reinio Date: Wed, 19 Aug 2015 13:24:59 +0200 Subject: Doc: Remove invalid uses of \relates command A function cannot be both a member and a non-member of the same class. Change-Id: I07d1e04c09fea2ba1171b3692e716660044cd37a Reviewed-by: Martin Smith --- src/corelib/io/qabstractfileengine.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'src/corelib/io') diff --git a/src/corelib/io/qabstractfileengine.cpp b/src/corelib/io/qabstractfileengine.cpp index 07270eb790..2ab789e0af 100644 --- a/src/corelib/io/qabstractfileengine.cpp +++ b/src/corelib/io/qabstractfileengine.cpp @@ -891,7 +891,6 @@ bool QAbstractFileEngine::unmap(uchar *address) /*! \typedef QAbstractFileEngine::Iterator \since 4.3 - \relates QAbstractFileEngine Synonym for QAbstractFileEngineIterator. */ -- cgit v1.2.3 From cb6ab056480e39ed347d5a75e4b1b1f34443148c Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Fri, 19 Jun 2015 13:38:58 +0200 Subject: QLoggingRegistry: Look up logging configuration in Qt data path Distributions like Fedora would like to disable logging globally, without having to patch Qt. Fedora right now therefore adds a /etc/xdg/qtlogging.ini file, which unfortunately though also messes with Qt versions compiled by the user. This patch lets QLoggingRegistry look up logging configurations also in QLibraryInfo::DataPath, which would allow to tweak the values per Qt installation. See also https://bugzilla.redhat.com/show_bug.cgi?id=1227295 Change-Id: I0fca304a47f45739d0c08a9e4e715673bf10aa80 Reviewed-by: Alex Blasche --- src/corelib/io/qloggingcategory.cpp | 1 + src/corelib/io/qloggingregistry.cpp | 64 ++++++++++++++++++++----------------- src/corelib/io/qloggingregistry_p.h | 1 + 3 files changed, 37 insertions(+), 29 deletions(-) (limited to 'src/corelib/io') diff --git a/src/corelib/io/qloggingcategory.cpp b/src/corelib/io/qloggingcategory.cpp index 1d06e2a912..b51085ef42 100644 --- a/src/corelib/io/qloggingcategory.cpp +++ b/src/corelib/io/qloggingcategory.cpp @@ -157,6 +157,7 @@ static void setBoolLane(QBasicAtomicInt *atomic, bool enable, int shift) Order of evaluation: \list + \li [QLibraryInfo::DataPath]/qtlogging.ini \li QtProject/qtlogging.ini \li \l setFilterRules() \li \c QT_LOGGING_CONF diff --git a/src/corelib/io/qloggingregistry.cpp b/src/corelib/io/qloggingregistry.cpp index f0b72cd9be..b53e251102 100644 --- a/src/corelib/io/qloggingregistry.cpp +++ b/src/corelib/io/qloggingregistry.cpp @@ -34,6 +34,7 @@ #include "qloggingregistry_p.h" #include +#include #include #include #include @@ -247,6 +248,21 @@ static bool qtLoggingDebug() return debugEnv; } +static QVector loadRulesFromFile(const QString &filePath) +{ + QFile file(filePath); + if (file.open(QIODevice::ReadOnly | QIODevice::Text)) { + if (qtLoggingDebug()) + debugMsg("Loading \"%s\" ...", + QDir::toNativeSeparators(file.fileName()).toUtf8().constData()); + QTextStream stream(&file); + QLoggingSettingsParser parser; + parser.setContent(stream); + return parser.rules(); + } + return QVector(); +} + /*! \internal Initializes the rules database by loading @@ -256,18 +272,9 @@ void QLoggingRegistry::init() { // get rules from environment const QByteArray rulesFilePath = qgetenv("QT_LOGGING_CONF"); - if (!rulesFilePath.isEmpty()) { - QFile file(QFile::decodeName(rulesFilePath)); - if (file.open(QIODevice::ReadOnly | QIODevice::Text)) { - if (qtLoggingDebug()) - debugMsg("Loading \"%s\" ...", - QDir::toNativeSeparators(file.fileName()).toUtf8().constData()); - QTextStream stream(&file); - QLoggingSettingsParser parser; - parser.setContent(stream); - envRules = parser.rules(); - } - } + if (!rulesFilePath.isEmpty()) + envRules = loadRulesFromFile(QFile::decodeName(rulesFilePath)); + const QByteArray rulesSrc = qgetenv("QT_LOGGING_RULES").replace(';', '\n'); if (!rulesSrc.isEmpty()) { QTextStream stream(rulesSrc); @@ -277,23 +284,22 @@ void QLoggingRegistry::init() envRules += parser.rules(); } - // get rules from qt configuration - QString envPath = QStandardPaths::locate(QStandardPaths::GenericConfigLocation, - QStringLiteral("QtProject/qtlogging.ini")); - if (!envPath.isEmpty()) { - QFile file(envPath); - if (file.open(QIODevice::ReadOnly | QIODevice::Text)) { - if (qtLoggingDebug()) - debugMsg("Loading \"%s\" ...", - QDir::toNativeSeparators(envPath).toUtf8().constData()); - QTextStream stream(&file); - QLoggingSettingsParser parser; - parser.setContent(stream); - configRules = parser.rules(); - } - } + const QString configFileName = QStringLiteral("qtlogging.ini"); + +#if !defined(QT_BOOTSTRAPPED) + // get rules from Qt data configuration path + const QString qtConfigPath + = QDir(QLibraryInfo::location(QLibraryInfo::DataPath)).absoluteFilePath(configFileName); + qtConfigRules = loadRulesFromFile(qtConfigPath); +#endif + + // get rules from user's/system configuration + const QString envPath = QStandardPaths::locate(QStandardPaths::GenericConfigLocation, + QString::fromLatin1("QtProject/") + configFileName); + if (!envPath.isEmpty()) + configRules = loadRulesFromFile(envPath); - if (!envRules.isEmpty() || !configRules.isEmpty()) { + if (!envRules.isEmpty() || !qtConfigRules.isEmpty() || !configRules.isEmpty()) { QMutexLocker locker(®istryMutex); updateRules(); } @@ -356,7 +362,7 @@ void QLoggingRegistry::updateRules() if (categoryFilter != defaultCategoryFilter) return; - rules = configRules + apiRules + envRules; + rules = qtConfigRules + configRules + apiRules + envRules; foreach (QLoggingCategory *cat, categories.keys()) (*categoryFilter)(cat); diff --git a/src/corelib/io/qloggingregistry_p.h b/src/corelib/io/qloggingregistry_p.h index 718e09d9bb..bb32a4996d 100644 --- a/src/corelib/io/qloggingregistry_p.h +++ b/src/corelib/io/qloggingregistry_p.h @@ -122,6 +122,7 @@ private: QMutex registryMutex; + QVector qtConfigRules; QVector configRules; QVector envRules; QVector apiRules; -- cgit v1.2.3 From ffbc2d3dc06017959167feecd60b66891c3b2c7b Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Wed, 19 Aug 2015 14:56:08 +0200 Subject: Doc: Mention Windows limitations in QFileInfo permission methods MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The limitation is already mentioned in the class documentation, but IMO is severe enough to be highlighted in the documentation of the respective methods, too. Change-Id: I16c68eb41ab9d3a7698d7ef06f747cfd98a8aaff Reviewed-by: Oswald Buddenhagen Reviewed-by: Topi Reiniƶ --- src/corelib/io/qfileinfo.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'src/corelib/io') diff --git a/src/corelib/io/qfileinfo.cpp b/src/corelib/io/qfileinfo.cpp index 8a86ec5858..51b39b1114 100644 --- a/src/corelib/io/qfileinfo.cpp +++ b/src/corelib/io/qfileinfo.cpp @@ -263,6 +263,7 @@ QDateTime &QFileInfoPrivate::getFileTime(QAbstractFileEngine::FileTime request) groupId(). You can examine a file's permissions and ownership in a single statement using the permission() function. + \target NTFS permissions \note On NTFS file systems, ownership and permissions checking is disabled by default for performance reasons. To enable it, include the following line: @@ -893,6 +894,9 @@ QDir QFileInfo::absoluteDir() const /*! Returns \c true if the user can read the file; otherwise returns \c false. + \note If the \l{NTFS permissions} check has not been enabled, the result + on Windows will merely reflect whether the file exists. + \sa isWritable(), isExecutable(), permission() */ bool QFileInfo::isReadable() const @@ -911,6 +915,9 @@ bool QFileInfo::isReadable() const /*! Returns \c true if the user can write to the file; otherwise returns \c false. + \note If the \l{NTFS permissions} check has not been enabled, the result on + Windows will merely reflect whether the file is marked as Read Only. + \sa isReadable(), isExecutable(), permission() */ bool QFileInfo::isWritable() const @@ -1137,7 +1144,8 @@ QString QFileInfo::readLink() const returned. This function can be time consuming under Unix (in the order of - milliseconds). + milliseconds). On Windows, it will return an empty string unless + the \l{NTFS permissions} check has been enabled. \sa ownerId(), group(), groupId() */ @@ -1217,6 +1225,9 @@ uint QFileInfo::groupId() const On systems where files do not have permissions this function always returns \c true. + \note The result might be inaccurate on Windows if the + \l{NTFS permissions} check has not been enabled. + Example: \snippet code/src_corelib_io_qfileinfo.cpp 10 @@ -1240,6 +1251,9 @@ bool QFileInfo::permission(QFile::Permissions permissions) const /*! Returns the complete OR-ed together combination of QFile::Permissions for the file. + + \note The result might be inaccurate on Windows if the + \l{NTFS permissions} check has not been enabled. */ QFile::Permissions QFileInfo::permissions() const { -- cgit v1.2.3 From a5cc210decde2a1becaf5f0da41a8e6ae1a7f7ad Mon Sep 17 00:00:00 2001 From: Topi Reinio Date: Mon, 7 Sep 2015 10:25:46 +0200 Subject: Doc: Move selected \keywords to be \targets instead QDoc now handles \keyword slightly differently - it no longer generates a unique html anchor at the location it appears in. Instead, it'll inherit the anchor of the documentation item it appears in. Therefore, switch the \keyword commands that are used for linking to a subsection within a page to be \targets instead, so they'll get an anchor and not link to the top of the page. Change-Id: Iec6d3f0edbcfb0aec95e222615eca9de2b0e153e Reviewed-by: Martin Smith --- src/corelib/io/qtextstream.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/corelib/io') diff --git a/src/corelib/io/qtextstream.cpp b/src/corelib/io/qtextstream.cpp index 8ad1c2852c..64038695e3 100644 --- a/src/corelib/io/qtextstream.cpp +++ b/src/corelib/io/qtextstream.cpp @@ -121,7 +121,7 @@ static const int QTEXTSTREAM_BUFFERSIZE = 16384; digits of the generated number. Some extra number formatting options are also available through setNumberFlags(). - \keyword QTextStream manipulators + \target QTextStream manipulators Like \c in the standard C++ library, QTextStream also defines several global manipulator functions: -- cgit v1.2.3 From 4bbdfaa8ff5b6087b3edf4676ea87a4c0af3f700 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 4 Sep 2015 16:20:54 +0200 Subject: Fix some qdoc warnings. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit qtbase/src/corelib/io/qdebug.cpp:698: warning: Class QDebugStateSaver has no \inmodule command; using project name by default: QtCore qtbase/src/gui/opengl/qopenglframebufferobject.cpp:1138: warning: Can't link to 'takeTextures()' qtbase/src/gui/opengl/qopenglframebufferobject.cpp:1159: warning: Can't link to 'takeTextures()' qtbase/src/gui/opengl/qopenglframebufferobject.cpp:953: warning: No such parameter 'height' in QOpenGLFramebufferObject::addColorAttachment() qtbase/src/gui/opengl/qopenglframebufferobject.cpp:953: warning: No such parameter 'width' in QOpenGLFramebufferObject::addColorAttachment() qtbase/src/gui/opengl/qopenglframebufferobject.cpp:953: warning: Undocumented parameter 'size' in QOpenGLFramebufferObject::addColorAttachment() qtbase/src/gui/painting/qpaintdevice.qdoc:80: warning: Undocumented enum item 'PdmDevicePixelRatioScaled' in QPaintDevice::PaintDeviceMetric qtbase/src/testlib/qbenchmarkmetric.cpp:154: warning: Invalid use of '\relates' (already a member of 'QTest') qtbase/src/testlib/qbenchmarkmetric.cpp:81: warning: Invalid use of '\relates' (already a member of 'QTest') qtbase/src/widgets/dialogs/qdialog.cpp:152: warning: Can't link to 'QCloseEvent::ignore()' qtbase/src/widgets/dialogs/qdialog.cpp:557: warning: Can't link to 'QApplication::quit()' qtbase/src/widgets/kernel/qwidget.cpp:8326: warning: Can't link to 'QCloseEvent::accept()' qtbase/src/widgets/kernel/qwidget.cpp:8326: warning: Can't link to 'QCloseEvent::ignore()' qtbase/src/widgets/kernel/qwidget.cpp:9300: warning: Can't link to 'QWheelEvent::accept()' qtbase/src/widgets/kernel/qwidget.cpp:9300: warning: Can't link to 'QWheelEvent::ignore()' qtbase/src/widgets/kernel/qwidget.cpp:9321: warning: Can't link to 'QTabletEvent::accept()' qtbase/src/widgets/kernel/qwidget.cpp:9321: warning: Can't link to 'QTabletEvent::ignore()' qtbase/src/widgets/kernel/qwidget.cpp:9373: warning: Can't link to 'QKeyEvent::ignore()' Change-Id: I97ae85398181645c1054c303e5c8a87deb619409 Reviewed-by: Martin Smith Reviewed-by: Topi Reiniƶ --- src/corelib/io/qdebug.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/corelib/io') diff --git a/src/corelib/io/qdebug.cpp b/src/corelib/io/qdebug.cpp index 54a705b72b..13eccce9da 100644 --- a/src/corelib/io/qdebug.cpp +++ b/src/corelib/io/qdebug.cpp @@ -697,7 +697,7 @@ QDebug &QDebug::resetFormat() /*! \class QDebugStateSaver - + \inmodule QtCore \brief Convenience class for custom QDebug operators Saves the settings used by QDebug, and restores them upon destruction, -- cgit v1.2.3 From d36a1dfb51af3f981262bc8e8fcd22b91aa890a6 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Tue, 1 Sep 2015 03:03:28 +0200 Subject: Serialize the capitalization value of QFont By serializing the capitalization value of QFont, it ensures that it is correctly preserved when QPicture streams it and later plays it back. Subsequently the QDataStream version has been bumped up to account for the change of the data format for serializing QFont. [ChangeLog][QtGui][QFont] QFont now serializes the capitalization setting. [ChangeLog][Important Behavior Changes] QDataStream version bumped up to 17 to account for changes in the serialization of QFont. Task-number: QTBUG-15214 Change-Id: I042680760e5a69d18d41e786b7500a3eebbe562f Reviewed-by: Mitch Curtis --- src/corelib/io/qdatastream.cpp | 2 +- src/corelib/io/qdatastream.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src/corelib/io') diff --git a/src/corelib/io/qdatastream.cpp b/src/corelib/io/qdatastream.cpp index 713b5a2f55..675178ea80 100644 --- a/src/corelib/io/qdatastream.cpp +++ b/src/corelib/io/qdatastream.cpp @@ -526,7 +526,7 @@ void QDataStream::setByteOrder(ByteOrder bo) \value Qt_5_3 Same as Qt_5_2 \value Qt_5_4 Version 16 (Qt 5.4) \value Qt_5_5 Same as Qt_5_4 - \value Qt_5_6 Same as Qt_5_4 + \value Qt_5_6 Version 17 (Qt 5.6) \omitvalue Qt_DefaultCompiledVersion \sa setVersion(), version() diff --git a/src/corelib/io/qdatastream.h b/src/corelib/io/qdatastream.h index b87dbe4784..5730c12907 100644 --- a/src/corelib/io/qdatastream.h +++ b/src/corelib/io/qdatastream.h @@ -83,7 +83,7 @@ public: Qt_5_3 = Qt_5_2, Qt_5_4 = 16, Qt_5_5 = Qt_5_4, - Qt_5_6 = Qt_5_5, + Qt_5_6 = 17, #if QT_VERSION >= 0x050700 #error Add the datastream version for this Qt version and update Qt_DefaultCompiledVersion #endif -- cgit v1.2.3 From 46a372e1a115fb05b746339c790a7f3e5d6d01fc Mon Sep 17 00:00:00 2001 From: Jake Petroules Date: Mon, 13 Jul 2015 20:16:44 -0700 Subject: Modernize and unify filesystem code on Apple platforms. Replace deprecated File Manager APIs with modern equivalents. Change some Q_OS_MACX to Q_OS_DARWIN in file system related code. All of these apply to iOS as well as OS X, and were ifdef'ed for OS X only primarily due to legacy reasons - carryovers from Qt 4 or Carbon APIs which have since been refactored into using CoreFoundation. This also makes the code consistent with the documentation. Change-Id: I414e9bdfffff731413ddf16171b1317027d87caf Reviewed-by: Richard Moe Gustavsen --- src/corelib/io/io.pri | 1 + src/corelib/io/qfilesystemengine.cpp | 2 +- src/corelib/io/qfilesystemengine_p.h | 2 +- src/corelib/io/qfilesystemengine_unix.cpp | 161 ++++++++++++++---------------- src/corelib/io/qfilesystemmetadata_p.h | 4 +- src/corelib/io/qstorageinfo_mac.cpp | 40 +++----- 6 files changed, 94 insertions(+), 116 deletions(-) (limited to 'src/corelib/io') diff --git a/src/corelib/io/io.pri b/src/corelib/io/io.pri index f496d037d8..b2bcbdf727 100644 --- a/src/corelib/io/io.pri +++ b/src/corelib/io/io.pri @@ -160,6 +160,7 @@ win32 { } else:ios { OBJECTIVE_SOURCES += io/qstandardpaths_ios.mm SOURCES += io/qstorageinfo_mac.cpp + LIBS += -framework MobileCoreServices } else { SOURCES += io/qstandardpaths_unix.cpp } diff --git a/src/corelib/io/qfilesystemengine.cpp b/src/corelib/io/qfilesystemengine.cpp index df41457a18..e4dec2b7fb 100644 --- a/src/corelib/io/qfilesystemengine.cpp +++ b/src/corelib/io/qfilesystemengine.cpp @@ -264,7 +264,7 @@ void QFileSystemMetaData::fillFromStatBuf(const QT_STATBUF &statBuffer) // Attributes entryFlags |= QFileSystemMetaData::ExistsAttribute; size_ = statBuffer.st_size; -#if defined(Q_OS_MACX) +#if defined(Q_OS_DARWIN) if (statBuffer.st_flags & UF_HIDDEN) { entryFlags |= QFileSystemMetaData::HiddenAttribute; knownFlagsMask |= QFileSystemMetaData::HiddenAttribute; diff --git a/src/corelib/io/qfilesystemengine_p.h b/src/corelib/io/qfilesystemengine_p.h index 06d5db637a..6db9319836 100644 --- a/src/corelib/io/qfilesystemengine_p.h +++ b/src/corelib/io/qfilesystemengine_p.h @@ -76,7 +76,7 @@ public: static QString resolveGroupName(uint groupId); #endif -#if defined(Q_OS_MACX) +#if defined(Q_OS_DARWIN) static QString bundleName(const QFileSystemEntry &entry); #else static QString bundleName(const QFileSystemEntry &entry) { Q_UNUSED(entry) return QString(); } diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp index 2c9fed530b..7bc2293b0d 100644 --- a/src/corelib/io/qfilesystemengine_unix.cpp +++ b/src/corelib/io/qfilesystemengine_unix.cpp @@ -51,26 +51,38 @@ # include #endif +#ifdef Q_OS_OSX +#include +#endif + +#ifdef Q_OS_IOS +#include +#endif + QT_BEGIN_NAMESPACE -#if defined(Q_OS_MACX) -static inline bool _q_isMacHidden(const char *nativePath) +#if defined(Q_OS_DARWIN) +static inline bool hasResourcePropertyFlag(const QFileSystemMetaData &data, + const QFileSystemEntry &entry, + CFStringRef key) { - OSErr err; - - FSRef fsRef; - err = FSPathMakeRefWithOptions(reinterpret_cast(nativePath), - kFSPathMakeRefDoNotFollowLeafSymlink, &fsRef, 0); - if (err != noErr) + QCFString path = CFStringCreateWithFileSystemRepresentation(0, + entry.nativeFilePath().constData()); + if (!path) return false; - FSCatalogInfo catInfo; - err = FSGetCatalogInfo(&fsRef, kFSCatInfoFinderInfo, &catInfo, NULL, NULL, NULL); - if (err != noErr) + QCFType url = CFURLCreateWithFileSystemPath(0, path, kCFURLPOSIXPathStyle, + data.hasFlags(QFileSystemMetaData::DirectoryType)); + if (!url) return false; - FileInfo * const fileInfo = reinterpret_cast(&catInfo.finderInfo); - return (fileInfo->finderFlags & kIsInvisible); + CFBooleanRef value; + if (CFURLCopyResourcePropertyForKey(url, key, &value, NULL)) { + if (value == kCFBooleanTrue) + return true; + } + + return false; } static bool isPackage(const QFileSystemMetaData &data, const QFileSystemEntry &entry) @@ -97,6 +109,7 @@ static bool isPackage(const QFileSystemMetaData &data, const QFileSystemEntry &e if (CFBundleGetPackageInfoInDirectory(url, &type, &creator)) return true; +#ifdef Q_OS_OSX // Find if an application other than Finder claims to know how to handle the package QCFType application; LSGetApplicationForURL(url, @@ -111,30 +124,11 @@ static bool isPackage(const QFileSystemMetaData &data, const QFileSystemEntry &e if (applicationId != QLatin1String("com.apple.finder")) return true; } +#endif } // Third step: check if the directory has the package bit set - FSRef packageRef; - FSPathMakeRef((UInt8 *)entry.nativeFilePath().constData(), &packageRef, NULL); - - FSCatalogInfo catalogInfo; - FSGetCatalogInfo(&packageRef, - kFSCatInfoFinderInfo, - &catalogInfo, - NULL, - NULL, - NULL); - - FolderInfo *folderInfo = reinterpret_cast(catalogInfo.finderInfo); - return folderInfo->finderFlags & kHasBundle; -} - -#else -static inline bool _q_isMacHidden(const char *nativePath) -{ - Q_UNUSED(nativePath); - // no-op - return false; + return hasResourcePropertyFlag(data, entry, kCFURLIsPackageKey); } #endif @@ -194,21 +188,34 @@ QFileSystemEntry QFileSystemEngine::getLinkTarget(const QFileSystemEntry &link, ret.chop(1); return QFileSystemEntry(ret); } -#if defined(Q_OS_MACX) +#if defined(Q_OS_DARWIN) { - FSRef fref; - if (FSPathMakeRef((const UInt8 *)QFile::encodeName(QDir::cleanPath(link.filePath())).data(), &fref, 0) == noErr) { - // TODO get the meta data info from the QFileSystemMetaData object - Boolean isAlias, isFolder; - if (FSResolveAliasFile(&fref, true, &isFolder, &isAlias) == noErr && isAlias) { - AliasHandle alias; - if (FSNewAlias(0, &fref, &alias) == noErr && alias) { - QCFString cfstr; - if (FSCopyAliasInfo(alias, 0, 0, &cfstr, 0, 0) == noErr) - return QFileSystemEntry(QCFString::toQString(cfstr)); - } - } - } + QCFString path = CFStringCreateWithFileSystemRepresentation(0, + QFile::encodeName(QDir::cleanPath(link.filePath())).data()); + if (!path) + return QFileSystemEntry(); + + QCFType url = CFURLCreateWithFileSystemPath(0, path, kCFURLPOSIXPathStyle, + data.hasFlags(QFileSystemMetaData::DirectoryType)); + if (!url) + return QFileSystemEntry(); + + QCFType bookmarkData = CFURLCreateBookmarkDataFromFile(0, url, NULL); + if (!bookmarkData) + return QFileSystemEntry(); + + QCFType resolvedUrl = CFURLCreateByResolvingBookmarkData(0, + bookmarkData, + (CFURLBookmarkResolutionOptions)(kCFBookmarkResolutionWithoutUIMask + | kCFBookmarkResolutionWithoutMountingMask), NULL, NULL, NULL, NULL); + if (!resolvedUrl) + return QFileSystemEntry(); + + QCFString cfstr(CFURLCopyFileSystemPath(resolvedUrl, kCFURLPOSIXPathStyle)); + if (!cfstr) + return QFileSystemEntry(); + + return QFileSystemEntry(QCFString::toQString(cfstr)); } #endif return QFileSystemEntry(); @@ -226,31 +233,14 @@ QFileSystemEntry QFileSystemEngine::canonicalName(const QFileSystemEntry &entry, return QFileSystemEntry(slowCanonicalized(absoluteName(entry).filePath())); #else char *ret = 0; -# if defined(Q_OS_MACX) - // 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. - if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_6) { - ret = (char*)malloc(PATH_MAX + 1); - if (ret && realpath(entry.nativeFilePath().constData(), (char*)ret) == 0) { - const int savedErrno = errno; // errno is checked below, and free() might change it - free(ret); - errno = savedErrno; - ret = 0; - } - } else { - // on 10.5 we can use FSRef to resolve the file path. - QString path = QDir::cleanPath(entry.filePath()); - FSRef fsref; - if (FSPathMakeRef((const UInt8 *)path.toUtf8().data(), &fsref, 0) == noErr) { - CFURLRef urlref = CFURLCreateFromFSRef(NULL, &fsref); - CFStringRef canonicalPath = CFURLCopyFileSystemPath(urlref, kCFURLPOSIXPathStyle); - QString ret = QCFString::toQString(canonicalPath); - CFRelease(canonicalPath); - CFRelease(urlref); - return QFileSystemEntry(ret); - } +# if defined(Q_OS_DARWIN) + ret = (char*)malloc(PATH_MAX + 1); + if (ret && realpath(entry.nativeFilePath().constData(), (char*)ret) == 0) { + const int savedErrno = errno; // errno is checked below, and free() might change it + free(ret); + errno = savedErrno; + ret = 0; } - # elif defined(Q_OS_ANDROID) // On some Android versions, realpath() will return a path even if it does not exist // To work around this, we check existence in advance. @@ -406,7 +396,7 @@ QString QFileSystemEngine::resolveGroupName(uint groupId) return QString(); } -#if defined(Q_OS_MACX) +#if defined(Q_OS_DARWIN) //static QString QFileSystemEngine::bundleName(const QFileSystemEntry &entry) { @@ -426,7 +416,7 @@ QString QFileSystemEngine::bundleName(const QFileSystemEntry &entry) bool QFileSystemEngine::fillMetaData(const QFileSystemEntry &entry, QFileSystemMetaData &data, QFileSystemMetaData::MetaDataFlags what) { -#if defined(Q_OS_MACX) +#if defined(Q_OS_DARWIN) if (what & QFileSystemMetaData::BundleType) { if (!data.hasFlags(QFileSystemMetaData::DirectoryType)) what |= QFileSystemMetaData::DirectoryType; @@ -435,7 +425,7 @@ bool QFileSystemEngine::fillMetaData(const QFileSystemEntry &entry, QFileSystemM // OS X >= 10.5: st_flags & UF_HIDDEN what |= QFileSystemMetaData::PosixStatFlags; } -#endif // defined(Q_OS_MACX) +#endif // defined(Q_OS_DARWIN) if (what & QFileSystemMetaData::PosixStatFlags) what |= QFileSystemMetaData::PosixStatFlags; @@ -496,19 +486,11 @@ bool QFileSystemEngine::fillMetaData(const QFileSystemEntry &entry, QFileSystemM | QFileSystemMetaData::ExistsAttribute; } -#if defined(Q_OS_MACX) +#if defined(Q_OS_DARWIN) if (what & QFileSystemMetaData::AliasType) { - if (entryExists) { - FSRef fref; - if (FSPathMakeRef((const UInt8 *)nativeFilePath, &fref, NULL) == noErr) { - Boolean isAlias, isFolder; - if (FSIsAliasFile(&fref, &isAlias, &isFolder) == noErr) { - if (isAlias) - data.entryFlags |= QFileSystemMetaData::AliasType; - } - } - } + if (entryExists && hasResourcePropertyFlag(data, entry, kCFURLIsAliasFileKey)) + data.entryFlags |= QFileSystemMetaData::AliasType; data.knownFlagsMask |= QFileSystemMetaData::AliasType; } #endif @@ -537,12 +519,15 @@ bool QFileSystemEngine::fillMetaData(const QFileSystemEntry &entry, QFileSystemM && !data.isHidden()) { QString fileName = entry.fileName(); if ((fileName.size() > 0 && fileName.at(0) == QLatin1Char('.')) - || (entryExists && _q_isMacHidden(nativeFilePath))) +#if defined(Q_OS_DARWIN) + || (entryExists && hasResourcePropertyFlag(data, entry, kCFURLIsHiddenKey)) +#endif + ) data.entryFlags |= QFileSystemMetaData::HiddenAttribute; data.knownFlagsMask |= QFileSystemMetaData::HiddenAttribute; } -#if defined(Q_OS_MACX) +#if defined(Q_OS_DARWIN) if (what & QFileSystemMetaData::BundleType) { if (entryExists && isPackage(data, entry)) data.entryFlags |= QFileSystemMetaData::BundleType; diff --git a/src/corelib/io/qfilesystemmetadata_p.h b/src/corelib/io/qfilesystemmetadata_p.h index da9576b5f8..828b5b329c 100644 --- a/src/corelib/io/qfilesystemmetadata_p.h +++ b/src/corelib/io/qfilesystemmetadata_p.h @@ -93,7 +93,7 @@ public: LinkType = 0x00010000, FileType = 0x00020000, DirectoryType = 0x00040000, -#if defined(Q_OS_MACX) +#if defined(Q_OS_DARWIN) BundleType = 0x00080000, AliasType = 0x08000000, #else @@ -243,7 +243,7 @@ private: Q_DECLARE_OPERATORS_FOR_FLAGS(QFileSystemMetaData::MetaDataFlags) -#if defined(Q_OS_MACX) +#if defined(Q_OS_DARWIN) inline bool QFileSystemMetaData::isBundle() const { return (entryFlags & BundleType); } inline bool QFileSystemMetaData::isAlias() const { return (entryFlags & AliasType); } #else diff --git a/src/corelib/io/qstorageinfo_mac.cpp b/src/corelib/io/qstorageinfo_mac.cpp index 1ef9983918..64ca6d7175 100644 --- a/src/corelib/io/qstorageinfo_mac.cpp +++ b/src/corelib/io/qstorageinfo_mac.cpp @@ -147,32 +147,24 @@ void QStorageInfoPrivate::retrieveUrlProperties(bool initRootPath) void QStorageInfoPrivate::retrieveLabel() { -#if !defined(Q_OS_IOS) - // deprecated since 10.8 - FSRef ref; - FSPathMakeRef(reinterpret_cast(QFile::encodeName(rootPath).constData()), - &ref, - Q_NULLPTR); - - // deprecated since 10.8 - FSCatalogInfo catalogInfo; - OSErr error; - error = FSGetCatalogInfo(&ref, kFSCatInfoVolume, &catalogInfo, Q_NULLPTR, Q_NULLPTR, Q_NULLPTR); - if (error != noErr) + QCFString path = CFStringCreateWithFileSystemRepresentation(0, + QFile::encodeName(rootPath).constData()); + if (!path) return; - // deprecated (use CFURLCopyResourcePropertiesForKeys for 10.7 and higher) - HFSUniStr255 volumeName; - error = FSGetVolumeInfo(catalogInfo.volume, - 0, - Q_NULLPTR, - kFSVolInfoFSInfo, - Q_NULLPTR, - &volumeName, - Q_NULLPTR); - if (error == noErr) - name = QCFString(FSCreateStringFromHFSUniStr(Q_NULLPTR, &volumeName)); -#endif + QCFType url = CFURLCreateWithFileSystemPath(0, path, kCFURLPOSIXPathStyle, true); + if (!url) + return; + + QCFType volumeUrl; + if (!CFURLCopyResourcePropertyForKey(url, kCFURLVolumeURLKey, &volumeUrl, NULL)) + return; + + QCFString volumeName; + if (!CFURLCopyResourcePropertyForKey(url, kCFURLNameKey, &volumeName, NULL)) + return; + + name = volumeName; } QList QStorageInfoPrivate::mountedVolumes() -- cgit v1.2.3 From af6467c5328492e34f7f346d6a5a32badd963431 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 8 Sep 2015 12:14:45 -0300 Subject: Fix some -Wcast-qual warnings This is happening in code I don't usually test (32-bit, non-ICU, etc.) KeccakF-1600-opt32.c:481:22: error: cast from type 'const unsigned char*' to type 'UINT32* {aka unsigned int*}' casts away qualifiers [-Werror=cast-qual] KeccakF-1600-opt32.c:217:62: note: in definition of macro 'extractLanes' Change-Id: I42e7ef1a481840699a8dffff140209823301a07a Reviewed-by: Lars Knoll Reviewed-by: Richard J. Moore --- src/corelib/io/qurlidna.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/corelib/io') diff --git a/src/corelib/io/qurlidna.cpp b/src/corelib/io/qurlidna.cpp index f9a0acf41a..46553d38a5 100644 --- a/src/corelib/io/qurlidna.cpp +++ b/src/corelib/io/qurlidna.cpp @@ -1503,7 +1503,7 @@ static bool isMappedToNothing(uint uc) static bool containsProhibitedOuptut(const QString *str, int from) { const ushort *in = reinterpret_cast(str->begin() + from); - const ushort *end = (ushort *)str->data() + str->size(); + const ushort *end = (const ushort *)str->data() + str->size(); for ( ; in < end; ++in) { uint uc = *in; if (QChar(uc).isHighSurrogate() && in < end - 1) { -- cgit v1.2.3 From 1ddd33ae662d3fe14e4bd581815a7c3aa42d832e Mon Sep 17 00:00:00 2001 From: Topi Reinio Date: Fri, 11 Sep 2015 10:35:09 +0200 Subject: Doc: Fix QDoc warnings for QTextStream qtextstream.cpp:2825: warning: Can't link to 'left()' qtextstream.cpp:2825: warning: Can't link to 'right()' qtextstream.cpp:2797: warning: Can't link to 'right()' qtextstream.cpp:2797: warning: Can't link to 'center()' qtextstream.cpp:2811: warning: Can't link to 'left()' qtextstream.cpp:2811: warning: Can't link to 'center()' Change-Id: I613354ca8137030c9f121cb976fe3bc35e1a415b Reviewed-by: Venugopal Shivashankar --- src/corelib/io/qtextstream.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/corelib/io') diff --git a/src/corelib/io/qtextstream.cpp b/src/corelib/io/qtextstream.cpp index 64038695e3..ca3be9b7e0 100644 --- a/src/corelib/io/qtextstream.cpp +++ b/src/corelib/io/qtextstream.cpp @@ -2800,7 +2800,7 @@ QTextStream &scientific(QTextStream &stream) Calls QTextStream::setFieldAlignment(QTextStream::AlignLeft) on \a stream and returns \a stream. - \sa right(), center(), {QTextStream manipulators} + \sa {QTextStream::}{right()}, {QTextStream::}{center()}, {QTextStream manipulators} */ QTextStream &left(QTextStream &stream) { @@ -2814,7 +2814,7 @@ QTextStream &left(QTextStream &stream) Calls QTextStream::setFieldAlignment(QTextStream::AlignRight) on \a stream and returns \a stream. - \sa left(), center(), {QTextStream manipulators} + \sa {QTextStream::}{left()}, {QTextStream::}{center()}, {QTextStream manipulators} */ QTextStream &right(QTextStream &stream) { @@ -2828,7 +2828,7 @@ QTextStream &right(QTextStream &stream) Calls QTextStream::setFieldAlignment(QTextStream::AlignCenter) on \a stream and returns \a stream. - \sa left(), right(), {QTextStream manipulators} + \sa {QTextStream::}{left()}, {QTextStream::}{right()}, {QTextStream manipulators} */ QTextStream ¢er(QTextStream &stream) { -- cgit v1.2.3 From 73b8cd879cd723fbcce42e63f21cc864d13cb91e Mon Sep 17 00:00:00 2001 From: Christian Kandeler Date: Wed, 23 Sep 2015 08:45:08 +0200 Subject: QSettings: Special-case serialization of QDateTime. QDateTime values with a UTC offset are not correctly serialized with QDataStream::Qt_4_0. So use a newer QDataStream format for this type and mark it with "@DateTime" instead of "@Variant". Task-number: QTBUG-46551 Change-Id: I211c89e8cd0211c949ec993e6ffd5192d0eebbb3 Reviewed-by: Joerg Bornemann --- src/corelib/io/qsettings.cpp | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) (limited to 'src/corelib/io') diff --git a/src/corelib/io/qsettings.cpp b/src/corelib/io/qsettings.cpp index da4a02e4e4..b9993c454e 100644 --- a/src/corelib/io/qsettings.cpp +++ b/src/corelib/io/qsettings.cpp @@ -453,14 +453,23 @@ QString QSettingsPrivate::variantToString(const QVariant &v) default: { #ifndef QT_NO_DATASTREAM + QDataStream::Version version; + const char *typeSpec; + if (v.type() == QVariant::DateTime) { + version = QDataStream::Qt_5_6; + typeSpec = "@DateTime("; + } else { + version = QDataStream::Qt_4_0; + typeSpec = "@Variant("; + } QByteArray a; { QDataStream s(&a, QIODevice::WriteOnly); - s.setVersion(QDataStream::Qt_4_0); + s.setVersion(version); s << v; } - result = QLatin1String("@Variant("); + result = QLatin1String(typeSpec); result += QString::fromLatin1(a.constData(), a.size()); result += QLatin1Char(')'); #else @@ -480,11 +489,21 @@ QVariant QSettingsPrivate::stringToVariant(const QString &s) if (s.endsWith(QLatin1Char(')'))) { if (s.startsWith(QLatin1String("@ByteArray("))) { return QVariant(s.toLatin1().mid(11, s.size() - 12)); - } else if (s.startsWith(QLatin1String("@Variant("))) { + } else if (s.startsWith(QLatin1String("@Variant(")) + || s.startsWith(QLatin1String("@DateTime("))) { #ifndef QT_NO_DATASTREAM - QByteArray a(s.toLatin1().mid(9)); + QDataStream::Version version; + int offset; + if (s.at(1) == QLatin1Char('D')) { + version = QDataStream::Qt_5_6; + offset = 10; + } else { + version = QDataStream::Qt_4_0; + offset = 9; + } + QByteArray a(s.toLatin1().mid(offset)); QDataStream stream(&a, QIODevice::ReadOnly); - stream.setVersion(QDataStream::Qt_4_0); + stream.setVersion(version); QVariant result; stream >> result; return result; -- cgit v1.2.3