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>
parent
3bc10fb9bb
commit
e01e848df4
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue