diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2019-06-16 16:51:18 +0200 |
---|---|---|
committer | Marc Mutz <marc.mutz@kdab.com> | 2019-06-16 16:56:35 +0200 |
commit | e01e848df4519e8ab9755da41188abdede5b0fb8 (patch) | |
tree | 7a608100a05f7821fc1b430a667016e13902593b /src/corelib/mimetypes | |
parent | 3bc10fb9bb930c4e1baf52f9d0ba97616e8e77f6 (diff) |
QMimeType: towards re-entrancy: do not cache iconName made from mimetype name
To not write into a shared object without mutex protection. If the
stored icon name is empty, just calculate a new one on each call.
Task-number: QTBUG-45684
Change-Id: I01dfb6697b5275e69451da91fdc7346f40bc424e
Reviewed-by: David Faure <david.faure@kdab.com>
Diffstat (limited to 'src/corelib/mimetypes')
-rw-r--r-- | src/corelib/mimetypes/qmimetype.cpp | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/corelib/mimetypes/qmimetype.cpp b/src/corelib/mimetypes/qmimetype.cpp index b60ff8e9df..de450c68f4 100644 --- a/src/corelib/mimetypes/qmimetype.cpp +++ b/src/corelib/mimetypes/qmimetype.cpp @@ -311,6 +311,14 @@ QString QMimeType::genericIconName() const return d->genericIconName; } +static QString make_default_icon_name_from_mimetype_name(QString iconName) +{ + const int slashindex = iconName.indexOf(QLatin1Char('/')); + if (slashindex != -1) + iconName[slashindex] = QLatin1Char('-'); + return iconName; +} + /*! \property QMimeType::iconName \brief the file name of an icon image that represents the MIME type @@ -324,12 +332,7 @@ QString QMimeType::iconName() const { QMimeDatabasePrivate::instance()->loadIcon(const_cast<QMimeTypePrivate&>(*d)); if (d->iconName.isEmpty()) { - // Make default icon name from the mimetype name - QString iconName = name(); - const int slashindex = iconName.indexOf(QLatin1Char('/')); - if (slashindex != -1) - iconName[slashindex] = QLatin1Char('-'); - const_cast<QMimeType*>(this)->d->iconName = std::move(iconName); + return make_default_icon_name_from_mimetype_name(name()); } return d->iconName; } |