diff options
Diffstat (limited to 'src/corelib/io')
-rw-r--r-- | src/corelib/io/qprocess_wince.cpp | 18 | ||||
-rw-r--r-- | src/corelib/io/qstandardpaths_unix.cpp | 30 | ||||
-rw-r--r-- | src/corelib/io/qurl.cpp | 6 | ||||
-rw-r--r-- | src/corelib/io/qwinoverlappedionotifier.cpp | 27 | ||||
-rw-r--r-- | src/corelib/io/qwinoverlappedionotifier_p.h | 2 |
5 files changed, 48 insertions, 35 deletions
diff --git a/src/corelib/io/qprocess_wince.cpp b/src/corelib/io/qprocess_wince.cpp index 9b63ece15c..acacdb8540 100644 --- a/src/corelib/io/qprocess_wince.cpp +++ b/src/corelib/io/qprocess_wince.cpp @@ -235,20 +235,14 @@ bool QProcessPrivate::waitForFinished(int msecs) qDebug("QProcessPrivate::waitForFinished(%d)", msecs); #endif - QIncrementalSleepTimer timer(msecs); - - forever { - if (!pid) - return true; - - if (WaitForSingleObject(pid->hProcess, timer.nextSleepTime()) == WAIT_OBJECT_0) { - _q_processDied(); - return true; - } + if (!pid) + return true; - if (timer.hasTimedOut()) - break; + if (WaitForSingleObject(pid->hProcess, msecs == -1 ? INFINITE : msecs) == WAIT_OBJECT_0) { + _q_processDied(); + return true; } + setError(QProcess::Timedout); return false; } diff --git a/src/corelib/io/qstandardpaths_unix.cpp b/src/corelib/io/qstandardpaths_unix.cpp index ed2faa742a..78f75482ea 100644 --- a/src/corelib/io/qstandardpaths_unix.cpp +++ b/src/corelib/io/qstandardpaths_unix.cpp @@ -113,21 +113,33 @@ QString QStandardPaths::writableLocation(StandardLocation type) { const uid_t myUid = geteuid(); // http://standards.freedesktop.org/basedir-spec/latest/ + QFileInfo fileInfo; QString xdgRuntimeDir = QFile::decodeName(qgetenv("XDG_RUNTIME_DIR")); if (xdgRuntimeDir.isEmpty()) { const QString userName = QFileSystemEngine::resolveUserName(myUid); xdgRuntimeDir = QDir::tempPath() + QLatin1String("/runtime-") + userName; - QDir dir(xdgRuntimeDir); - if (!dir.exists()) { + fileInfo.setFile(xdgRuntimeDir); + if (!fileInfo.isDir()) { if (!QDir().mkdir(xdgRuntimeDir)) { qWarning("QStandardPaths: error creating runtime directory %s: %s", qPrintable(xdgRuntimeDir), qPrintable(qt_error_string(errno))); return QString(); } } qWarning("QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '%s'", qPrintable(xdgRuntimeDir)); + } else { + fileInfo.setFile(xdgRuntimeDir); + if (!fileInfo.exists()) { + qWarning("QStandardPaths: XDG_RUNTIME_DIR points to non-existing path '%s', " + "please create it with 0700 permissions.", qPrintable(xdgRuntimeDir)); + return QString(); + } + if (!fileInfo.isDir()) { + qWarning("QStandardPaths: XDG_RUNTIME_DIR points to '%s' which is not a directory", + qPrintable(xdgRuntimeDir)); + return QString(); + } } // "The directory MUST be owned by the user" - QFileInfo fileInfo(xdgRuntimeDir); if (fileInfo.ownerId() != myUid) { qWarning("QStandardPaths: wrong ownership on runtime directory %s, %d instead of %d", qPrintable(xdgRuntimeDir), fileInfo.ownerId(), myUid); @@ -135,13 +147,15 @@ QString QStandardPaths::writableLocation(StandardLocation type) } // "and he MUST be the only one having read and write access to it. Its Unix access mode MUST be 0700." // since the current user is the owner, set both xxxUser and xxxOwner - QFile file(xdgRuntimeDir); const QFile::Permissions wantedPerms = QFile::ReadUser | QFile::WriteUser | QFile::ExeUser | QFile::ReadOwner | QFile::WriteOwner | QFile::ExeOwner; - if (file.permissions() != wantedPerms && !file.setPermissions(wantedPerms)) { - qWarning("QStandardPaths: could not set correct permissions on runtime directory %s: %s", - qPrintable(xdgRuntimeDir), qPrintable(file.errorString())); - return QString(); + if (fileInfo.permissions() != wantedPerms) { + QFile file(xdgRuntimeDir); + if (!file.setPermissions(wantedPerms)) { + qWarning("QStandardPaths: could not set correct permissions on runtime directory %s: %s", + qPrintable(xdgRuntimeDir), qPrintable(file.errorString())); + return QString(); + } } return xdgRuntimeDir; } diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp index e5c31763f4..8e82f00f74 100644 --- a/src/corelib/io/qurl.cpp +++ b/src/corelib/io/qurl.cpp @@ -2470,8 +2470,10 @@ void QUrl::setPath(const QString &path, ParsingMode mode) mode = TolerantMode; } - data = qt_normalizePathSegments(data, false); - d->setPath(data, 0, data.length()); + int from = 0; + while (from < data.length() - 2 && data.midRef(from, 2) == QLatin1String("//")) + ++from; + d->setPath(data, from, data.length()); // optimized out, since there is no path delimiter // if (path.isNull()) diff --git a/src/corelib/io/qwinoverlappedionotifier.cpp b/src/corelib/io/qwinoverlappedionotifier.cpp index c6ce15c2c9..c9de6671f7 100644 --- a/src/corelib/io/qwinoverlappedionotifier.cpp +++ b/src/corelib/io/qwinoverlappedionotifier.cpp @@ -102,7 +102,8 @@ public: OVERLAPPED *waitForAnyNotified(int msecs); void notify(DWORD numberOfBytes, DWORD errorCode, OVERLAPPED *overlapped); - OVERLAPPED *_q_notified(); + void _q_notified(); + OVERLAPPED *dispatchNextIoResult(); static QWinIoCompletionPort *iocp; static HANDLE iocpInstanceLock; @@ -302,8 +303,7 @@ OVERLAPPED *QWinOverlappedIoNotifierPrivate::waitForAnyNotified(int msecs) const DWORD wfso = WaitForSingleObject(hSemaphore, msecs == -1 ? INFINITE : DWORD(msecs)); switch (wfso) { case WAIT_OBJECT_0: - ReleaseSemaphore(hSemaphore, 1, NULL); - return _q_notified(); + return dispatchNextIoResult(); case WAIT_TIMEOUT: return 0; default: @@ -385,17 +385,20 @@ void QWinOverlappedIoNotifierPrivate::notify(DWORD numberOfBytes, DWORD errorCod emit q->_q_notify(); } -OVERLAPPED *QWinOverlappedIoNotifierPrivate::_q_notified() +void QWinOverlappedIoNotifierPrivate::_q_notified() +{ + if (WaitForSingleObject(hSemaphore, 0) == WAIT_OBJECT_0) + dispatchNextIoResult(); +} + +OVERLAPPED *QWinOverlappedIoNotifierPrivate::dispatchNextIoResult() { Q_Q(QWinOverlappedIoNotifier); - if (WaitForSingleObject(hSemaphore, 0) == WAIT_OBJECT_0) { - WaitForSingleObject(hResultsMutex, INFINITE); - IOResult ioresult = results.dequeue(); - ReleaseMutex(hResultsMutex); - emit q->notified(ioresult.numberOfBytes, ioresult.errorCode, ioresult.overlapped); - return ioresult.overlapped; - } - return 0; + WaitForSingleObject(hResultsMutex, INFINITE); + IOResult ioresult = results.dequeue(); + ReleaseMutex(hResultsMutex); + emit q->notified(ioresult.numberOfBytes, ioresult.errorCode, ioresult.overlapped); + return ioresult.overlapped; } QT_END_NAMESPACE diff --git a/src/corelib/io/qwinoverlappedionotifier_p.h b/src/corelib/io/qwinoverlappedionotifier_p.h index 863f87353e..41945d6556 100644 --- a/src/corelib/io/qwinoverlappedionotifier_p.h +++ b/src/corelib/io/qwinoverlappedionotifier_p.h @@ -58,7 +58,7 @@ class Q_CORE_EXPORT QWinOverlappedIoNotifier : public QObject Q_OBJECT Q_DISABLE_COPY(QWinOverlappedIoNotifier) Q_DECLARE_PRIVATE(QWinOverlappedIoNotifier) - Q_PRIVATE_SLOT(d_func(), OVERLAPPED *_q_notified()) + Q_PRIVATE_SLOT(d_func(), void _q_notified()) friend class QWinIoCompletionPort; public: QWinOverlappedIoNotifier(QObject *parent = 0); |