summaryrefslogtreecommitdiffstats
path: root/src/corelib/io/qprocess.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/io/qprocess.cpp')
-rw-r--r--src/corelib/io/qprocess.cpp38
1 files changed, 30 insertions, 8 deletions
diff --git a/src/corelib/io/qprocess.cpp b/src/corelib/io/qprocess.cpp
index 59b6db7c79..b1861d8038 100644
--- a/src/corelib/io/qprocess.cpp
+++ b/src/corelib/io/qprocess.cpp
@@ -265,7 +265,13 @@ QProcessEnvironment &QProcessEnvironment::operator=(const QProcessEnvironment &o
*/
bool QProcessEnvironment::operator==(const QProcessEnvironment &other) const
{
- return d == other.d || (d && other.d && d->hash == other.d->hash);
+ if (d == other.d)
+ return true;
+ if (d && other.d) {
+ QProcessEnvironmentPrivate::OrderedMutexLocker locker(d, other.d);
+ return d->hash == other.d->hash;
+ }
+ return false;
}
/*!
@@ -276,6 +282,7 @@ bool QProcessEnvironment::operator==(const QProcessEnvironment &other) const
*/
bool QProcessEnvironment::isEmpty() const
{
+ // Needs no locking, as no hash nodes are accessed
return d ? d->hash.isEmpty() : true;
}
@@ -302,7 +309,10 @@ void QProcessEnvironment::clear()
*/
bool QProcessEnvironment::contains(const QString &name) const
{
- return d ? d->hash.contains(d->prepareName(name)) : false;
+ if (!d)
+ return false;
+ QProcessEnvironmentPrivate::MutexLocker locker(d);
+ return d->hash.contains(d->prepareName(name));
}
/*!
@@ -319,7 +329,8 @@ bool QProcessEnvironment::contains(const QString &name) const
*/
void QProcessEnvironment::insert(const QString &name, const QString &value)
{
- // d detaches from null
+ // our re-impl of detach() detaches from null
+ d.detach(); // detach before prepareName()
d->hash.insert(d->prepareName(name), d->prepareValue(value));
}
@@ -333,8 +344,10 @@ void QProcessEnvironment::insert(const QString &name, const QString &value)
*/
void QProcessEnvironment::remove(const QString &name)
{
- if (d)
+ if (d) {
+ d.detach(); // detach before prepareName()
d->hash.remove(d->prepareName(name));
+ }
}
/*!
@@ -349,6 +362,7 @@ QString QProcessEnvironment::value(const QString &name, const QString &defaultVa
if (!d)
return defaultValue;
+ QProcessEnvironmentPrivate::MutexLocker locker(d);
QProcessEnvironmentPrivate::Hash::ConstIterator it = d->hash.constFind(d->prepareName(name));
if (it == d->hash.constEnd())
return defaultValue;
@@ -371,7 +385,10 @@ QString QProcessEnvironment::value(const QString &name, const QString &defaultVa
*/
QStringList QProcessEnvironment::toStringList() const
{
- return d ? d->toList() : QStringList();
+ if (!d)
+ return QStringList();
+ QProcessEnvironmentPrivate::MutexLocker locker(d);
+ return d->toList();
}
/*!
@@ -382,7 +399,10 @@ QStringList QProcessEnvironment::toStringList() const
*/
QStringList QProcessEnvironment::keys() const
{
- return d ? d->keys() : QStringList();
+ if (!d)
+ return QStringList();
+ QProcessEnvironmentPrivate::MutexLocker locker(d);
+ return d->keys();
}
/*!
@@ -397,7 +417,8 @@ void QProcessEnvironment::insert(const QProcessEnvironment &e)
if (!e.d)
return;
- // d detaches from null
+ // our re-impl of detach() detaches from null
+ QProcessEnvironmentPrivate::MutexLocker locker(e.d);
d->insert(*e.d);
}
@@ -1006,6 +1027,7 @@ bool QProcessPrivate::_q_processDied()
return false;
#endif
#ifdef Q_OS_WIN
+ drainOutputPipes();
if (processFinishedNotifier)
processFinishedNotifier->setEnabled(false);
#endif
@@ -2339,7 +2361,7 @@ bool QProcess::startDetached(const QString &program)
}
QT_BEGIN_INCLUDE_NAMESPACE
-#if defined(Q_OS_MAC) && !defined(Q_OS_IOS)
+#if defined(Q_OS_MACX)
# include <crt_externs.h>
# define environ (*_NSGetEnviron())
#elif defined(Q_OS_WINCE) || defined(Q_OS_IOS)