From b9edbb5d54290331f89a7ced4e4d7807098b61d7 Mon Sep 17 00:00:00 2001 From: David Faure Date: Wed, 21 Dec 2016 12:49:53 +0100 Subject: QLockFile: make sure we encode the hostname as UTF-8 in the lock file We chose to use UTF-8 as it allows us to ensure there's no mistaking the hostname in case the locale is changed, if the host name contains characters outside of US-ASCII. But this didn't work because the code that wrote the hostname always used the local 8-bit codec instead of UTF-8. On Unix, we used the result of gethostname(3) directly, which is supposedly on the locale codec. This commit doesn't fix Windows, which requires _wgetenv, the plan being to encapsulate that with a qEnvironmentVariable() method. [ChangeLog][QtCore][QLockFile] Fixed a bug that caused QLockFile not to recognize a stale lock file if the machine's hostname contained non-US- ASCII characters, on Unix. A Windows fix is still pending. Task-number: QTBUG-49640 Change-Id: Ib9d045544ff370ec901626658a84ec4e6575fe21 Reviewed-by: Thiago Macieira --- src/corelib/io/qlockfile_unix.cpp | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) (limited to 'src/corelib/io') diff --git a/src/corelib/io/qlockfile_unix.cpp b/src/corelib/io/qlockfile_unix.cpp index 82beb15912..3a80014c00 100644 --- a/src/corelib/io/qlockfile_unix.cpp +++ b/src/corelib/io/qlockfile_unix.cpp @@ -81,15 +81,6 @@ QT_BEGIN_NAMESPACE -static QByteArray localHostName() // from QHostInfo::localHostName(), modified to return a QByteArray -{ - QByteArray hostName(512, Qt::Uninitialized); - if (gethostname(hostName.data(), hostName.size()) == -1) - return QByteArray(); - hostName.truncate(strlen(hostName.data())); - return hostName; -} - // ### merge into qt_safe_write? static qint64 qt_write_loop(int fd, const char *data, qint64 len) { @@ -185,7 +176,7 @@ QLockFile::LockError QLockFilePrivate::tryLock_sys() // Use operator% from the fast builder to avoid multiple memory allocations. QByteArray fileData = QByteArray::number(QCoreApplication::applicationPid()) % '\n' % QCoreApplication::applicationName().toUtf8() % '\n' - % localHostName() % '\n'; + % QSysInfo::machineHostName().toUtf8() % '\n'; const QByteArray lockFileName = QFile::encodeName(fileName); const int fd = qt_safe_open(lockFileName.constData(), O_WRONLY | O_CREAT | O_EXCL, 0666); @@ -242,7 +233,7 @@ bool QLockFilePrivate::isApparentlyStale() const qint64 pid; QString hostname, appname; if (getLockInfo(&pid, &hostname, &appname)) { - if (hostname.isEmpty() || hostname == QString::fromLocal8Bit(localHostName())) { + if (hostname.isEmpty() || hostname == QSysInfo::machineHostName()) { if (::kill(pid, 0) == -1 && errno == ESRCH) return true; // PID doesn't exist anymore const QString processName = processNameByPid(pid); -- cgit v1.2.3 From 69ce68cb899da31d96ce7b9337600ebdc910e024 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 22 Dec 2016 10:02:26 -0200 Subject: Doc: add a quick note about unfixed Windows encoding bug Task-number: QTBUG-49640 Change-Id: Icb0289e3118a41dd9438fffd1492925b03de62d6 Reviewed-by: David Faure --- src/corelib/io/qlockfile.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/corelib/io') diff --git a/src/corelib/io/qlockfile.cpp b/src/corelib/io/qlockfile.cpp index ae3a7c6abc..cb1ff93ad3 100644 --- a/src/corelib/io/qlockfile.cpp +++ b/src/corelib/io/qlockfile.cpp @@ -84,6 +84,9 @@ QT_BEGIN_NAMESPACE For the use case of protecting a resource over a long time, you should therefore call setStaleLockTime(0), and when tryLock() returns LockFailedError, inform the user that the document is locked, possibly using getLockInfo() for more details. + + \note On Windows, this class has problems detecting a stale lock if the + machine's hostname contains characters outside the US-ASCII character set. */ /*! -- cgit v1.2.3 From 1b82a9aea5e2385c08543f3a9ebbed71a0bae3cc Mon Sep 17 00:00:00 2001 From: Aleksey Lysenko Date: Tue, 3 Jan 2017 22:41:20 +0200 Subject: Doc: add note about unsupported platforms for QProcess Task-number: QTBUG-57840 Change-Id: I46a26a9c4c6ad0aa6994945091a2904c3b51080f Reviewed-by: Martin Smith Reviewed-by: Jake Petroules --- src/corelib/io/qprocess.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/corelib/io') diff --git a/src/corelib/io/qprocess.cpp b/src/corelib/io/qprocess.cpp index 23a3cc1a16..c7d6cb426d 100644 --- a/src/corelib/io/qprocess.cpp +++ b/src/corelib/io/qprocess.cpp @@ -509,6 +509,9 @@ void QProcessPrivate::Channel::clear() You can also call error() to find the type of error that occurred last, and state() to find the current process state. + \note QProcess is not supported on VxWorks, iOS, tvOS, watchOS, + or the Universal Windows Platform. + \section1 Communicating via Channels Processes have two predefined output channels: The standard -- cgit v1.2.3 From 389165dd25a30a0ff9ea368555ecb84d40ceacfa Mon Sep 17 00:00:00 2001 From: Kavindra Palaraja Date: Sun, 8 Jan 2017 10:32:52 +0100 Subject: Clarify StripTrailingSlash behavior StripTrailingSlash removes trailing slashes from the path, but not the entire URL. Task-number: QTBUG-47607 Change-Id: Id62b971e563e290b7ca000576bcc328616a3f1a2 Reviewed-by: David Faure --- src/corelib/io/qurl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/corelib/io') diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp index 066052ade9..38f2a708b5 100644 --- a/src/corelib/io/qurl.cpp +++ b/src/corelib/io/qurl.cpp @@ -240,7 +240,7 @@ Only valid if RemovePath is not set. \value PreferLocalFile If the URL is a local file according to isLocalFile() and contains no query or fragment, a local file path is returned. - \value StripTrailingSlash The trailing slash is removed if one is present. + \value StripTrailingSlash The trailing slash is removed from the path, if one is present. \value NormalizePathSegments Modifies the path to remove redundant directory separators, and to resolve "."s and ".."s (as far as possible). -- cgit v1.2.3