diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-10-15 13:23:02 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-10-16 09:48:09 +0200 |
commit | ada6e4fbe9f363a33d4f9341bbc468d22c0c1442 (patch) | |
tree | 41abb0dfbd9c3dc5566d4679ceee6a6f673e97de /src/corelib/io | |
parent | b002c48cc799ebe613ed5fadebd0f5956e214388 (diff) |
Fix some bad uses of QSharedPointerData::operator T*
Avoid detaching where possible
Change-Id: I438d3e66689aeef05951af86a48af2a6910da7c2
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Diffstat (limited to 'src/corelib/io')
-rw-r--r-- | src/corelib/io/qprocess.cpp | 8 | ||||
-rw-r--r-- | src/corelib/io/qurlquery.cpp | 14 |
2 files changed, 12 insertions, 10 deletions
diff --git a/src/corelib/io/qprocess.cpp b/src/corelib/io/qprocess.cpp index 826f421eee..8b29a8964f 100644 --- a/src/corelib/io/qprocess.cpp +++ b/src/corelib/io/qprocess.cpp @@ -290,7 +290,7 @@ bool QProcessEnvironment::isEmpty() const */ void QProcessEnvironment::clear() { - if (d) + if (d.constData()) d->vars.clear(); // Unix: Don't clear d->nameMap, as the environment is likely to be // re-populated with the same keys again. @@ -339,9 +339,9 @@ void QProcessEnvironment::insert(const QString &name, const QString &value) */ void QProcessEnvironment::remove(const QString &name) { - if (d) { - d.detach(); // detach before prepareName() - d->vars.remove(d->prepareName(name)); + if (d.constData()) { + QProcessEnvironmentPrivate *p = d.data(); + p->vars.remove(p->prepareName(name)); } } diff --git a/src/corelib/io/qurlquery.cpp b/src/corelib/io/qurlquery.cpp index b889eb131b..a836fb2e99 100644 --- a/src/corelib/io/qurlquery.cpp +++ b/src/corelib/io/qurlquery.cpp @@ -743,9 +743,10 @@ QStringList QUrlQuery::allQueryItemValues(const QString &key, QUrl::ComponentFor void QUrlQuery::removeQueryItem(const QString &key) { if (d.constData()) { - Map::iterator it = d->findKey(key); - if (it != d->itemList.end()) - d->itemList.erase(it); + auto *p = d.data(); + Map::iterator it = p->findKey(key); + if (it != p->itemList.end()) + p->itemList.erase(it); } } @@ -758,12 +759,13 @@ void QUrlQuery::removeQueryItem(const QString &key) void QUrlQuery::removeAllQueryItems(const QString &key) { if (d.constData()) { - const QString encodedKey = d->recodeFromUser(key); + auto *p = d.data(); + const QString encodedKey = p->recodeFromUser(key); auto firstEqualsEncodedKey = [&encodedKey](const QPair<QString, QString> &item) { return item.first == encodedKey; }; - const auto end = d->itemList.end(); - d->itemList.erase(std::remove_if(d->itemList.begin(), end, firstEqualsEncodedKey), end); + const auto end = p->itemList.end(); + p->itemList.erase(std::remove_if(p->itemList.begin(), end, firstEqualsEncodedKey), end); } } |