summaryrefslogtreecommitdiffstats
path: root/src/corelib/io
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@nokia.com>2009-04-01 15:09:48 (GMT)
committerSimon Hausmann <simon.hausmann@nokia.com>2009-04-01 15:09:48 (GMT)
commitb92516d571eb608e0bb273f0871eeeaf20671b9d (patch)
tree5a711dd58ff0e9abe4523e893340676fe17bdc62 /src/corelib/io
parent815eb0e1d05318dfdd3cadb7f45c7e8e80ff4790 (diff)
parentef46fa38e50b807c6122dc37d84d2944069ef3ea (diff)
downloadQt-b92516d571eb608e0bb273f0871eeeaf20671b9d.zip
Qt-b92516d571eb608e0bb273f0871eeeaf20671b9d.tar.gz
Qt-b92516d571eb608e0bb273f0871eeeaf20671b9d.tar.bz2
Merge branch '4.5' of git@scm.dev.nokia.troll.no:qt/qt
Conflicts: src/gui/inputmethod/qximinputcontext_x11.cpp
Diffstat (limited to 'src/corelib/io')
-rw-r--r--src/corelib/io/qdiriterator.cpp38
-rw-r--r--src/corelib/io/qprocess.cpp34
-rw-r--r--src/corelib/io/qtextstream.cpp2
3 files changed, 45 insertions, 29 deletions
diff --git a/src/corelib/io/qdiriterator.cpp b/src/corelib/io/qdiriterator.cpp
index 46c7dd8..b14f436 100644
--- a/src/corelib/io/qdiriterator.cpp
+++ b/src/corelib/io/qdiriterator.cpp
@@ -116,7 +116,9 @@ public:
QAbstractFileEngine *engine;
QStack<QAbstractFileEngineIterator *> fileEngineIterators;
QString path;
- QFileInfo fileInfo;
+ QFileInfo nextFileInfo;
+ //This fileinfo is the current that we will return from the public API
+ QFileInfo currentFileInfo;
QString currentFilePath;
QDirIterator::IteratorFlags iteratorFlags;
QDir::Filters filters;
@@ -140,8 +142,8 @@ QDirIteratorPrivate::QDirIteratorPrivate(const QString &path, const QStringList
this->filters = filters;
this->nameFilters = nameFilters;
- fileInfo.setFile(path);
- pushSubDirectory(fileInfo.isSymLink() ? fileInfo.canonicalFilePath() : path,
+ nextFileInfo.setFile(path);
+ pushSubDirectory(nextFileInfo.isSymLink() ? nextFileInfo.canonicalFilePath() : path,
nameFilters, filters);
}
@@ -160,12 +162,12 @@ void QDirIteratorPrivate::pushSubDirectory(const QString &path, const QStringLis
QDir::Filters filters)
{
if (iteratorFlags & QDirIterator::FollowSymlinks) {
- if (fileInfo.filePath() != path)
- fileInfo.setFile(path);
- if (fileInfo.isSymLink()) {
- visitedLinks << fileInfo.canonicalFilePath();
+ if (nextFileInfo.filePath() != path)
+ nextFileInfo.setFile(path);
+ if (nextFileInfo.isSymLink()) {
+ visitedLinks << nextFileInfo.canonicalFilePath();
} else {
- visitedLinks << fileInfo.absoluteFilePath();
+ visitedLinks << nextFileInfo.absoluteFilePath();
}
}
@@ -199,8 +201,8 @@ void QDirIteratorPrivate::advance()
QString subDir = it->currentFilePath();
#ifdef Q_OS_WIN
- if (fileInfo.isSymLink())
- subDir = fileInfo.canonicalFilePath();
+ if (currentFileInfo.isSymLink())
+ subDir = currentFileInfo.canonicalFilePath();
#endif
pushSubDirectory(subDir, it->nameFilters(), it->filters());
}
@@ -213,15 +215,16 @@ void QDirIteratorPrivate::advance()
while (it->hasNext()) {
it->next();
if (matchesFilters(it)) {
- fileInfo = it->currentFileInfo();
+ currentFileInfo = nextFileInfo;
+ nextFileInfo = it->currentFileInfo();
// Signal that we want to follow this entry.
- followNextDir = shouldFollowDirectory(fileInfo);
-
+ followNextDir = shouldFollowDirectory(nextFileInfo);
//We found a matching entry.
return;
} else if (iteratorFlags & QDirIterator::Subdirectories) {
QFileInfo fileInfo = it->currentFileInfo();
+
if (!shouldFollowDirectory(fileInfo))
continue;
QString subDir = it->currentFilePath();
@@ -238,6 +241,7 @@ void QDirIteratorPrivate::advance()
if (!foundDirectory)
delete fileEngineIterators.pop();
}
+ currentFileInfo = nextFileInfo;
done = true;
}
@@ -518,9 +522,7 @@ bool QDirIterator::hasNext() const
*/
QString QDirIterator::fileName() const
{
- if (d->fileInfo.path() != d->currentFilePath)
- d->fileInfo.setFile(d->currentFilePath);
- return d->fileInfo.fileName();
+ return d->currentFileInfo.fileName();
}
/*!
@@ -543,9 +545,7 @@ QString QDirIterator::filePath() const
*/
QFileInfo QDirIterator::fileInfo() const
{
- if (d->fileInfo.filePath() != d->currentFilePath)
- d->fileInfo.setFile(d->currentFilePath);
- return d->fileInfo;
+ return d->currentFileInfo;
}
/*!
diff --git a/src/corelib/io/qprocess.cpp b/src/corelib/io/qprocess.cpp
index 759d473..30f4291 100644
--- a/src/corelib/io/qprocess.cpp
+++ b/src/corelib/io/qprocess.cpp
@@ -1555,11 +1555,15 @@ QByteArray QProcess::readAllStandardError()
}
/*!
- Starts the program \a program in a new process, passing the
- command line arguments in \a arguments. The OpenMode is set to \a
- mode. QProcess will immediately enter the Starting state. If the
- process starts successfully, QProcess will emit started();
- otherwise, error() will be emitted.
+ Starts the program \a program in a new process, if one is not already
+ running, passing the command line arguments in \a arguments. The OpenMode
+ is set to \a mode.
+
+ The QProcess object will immediately enter the Starting state. If the
+ process starts successfully, QProcess will emit started(); otherwise,
+ error() will be emitted. If the QProcess object is already running a
+ process, a warning may be printed at the console, and the existing
+ process will continue running.
Note that arguments that contain spaces are not passed to the
process as separate arguments.
@@ -1656,10 +1660,10 @@ static QStringList parseCombinedArgString(const QString &program)
/*!
\overload
- Starts the program \a program in a new process. \a program is a
- single string of text containing both the program name and its
- arguments. The arguments are separated by one or more
- spaces. For example:
+ Starts the program \a program in a new process, if one is not already
+ running. \a program is a single string of text containing both the
+ program name and its arguments. The arguments are separated by one or
+ more spaces. For example:
\snippet doc/src/snippets/code/src_corelib_io_qprocess.cpp 5
@@ -1668,6 +1672,9 @@ static QStringList parseCombinedArgString(const QString &program)
\snippet doc/src/snippets/code/src_corelib_io_qprocess.cpp 6
+ If the QProcess object is already running a process, a warning may be
+ printed at the console, and the existing process will continue running.
+
Note that, on Windows, quotes need to be both escaped and quoted.
For example, the above code would be specified in the following
way to ensure that \c{"My Documents"} is used as the argument to
@@ -1680,6 +1687,13 @@ static QStringList parseCombinedArgString(const QString &program)
void QProcess::start(const QString &program, OpenMode mode)
{
QStringList args = parseCombinedArgString(program);
+ if (args.isEmpty()) {
+ Q_D(QProcess);
+ d->processError = QProcess::FailedToStart;
+ setErrorString(tr("No program defined"));
+ emit error(d->processError);
+ return;
+ }
QString prog = args.first();
args.removeFirst();
@@ -1848,6 +1862,8 @@ bool QProcess::startDetached(const QString &program,
bool QProcess::startDetached(const QString &program)
{
QStringList args = parseCombinedArgString(program);
+ if (args.isEmpty())
+ return false;
QString prog = args.first();
args.removeFirst();
diff --git a/src/corelib/io/qtextstream.cpp b/src/corelib/io/qtextstream.cpp
index 512332e..ed9d0aa 100644
--- a/src/corelib/io/qtextstream.cpp
+++ b/src/corelib/io/qtextstream.cpp
@@ -1370,7 +1370,7 @@ QTextStream::FieldAlignment QTextStream::fieldAlignment() const
\snippet doc/src/snippets/code/src_corelib_io_qtextstream.cpp 5
- The string \a s contains:
+ The string \c s contains:
\snippet doc/src/snippets/code/src_corelib_io_qtextstream.cpp 6