QMimeType performance fix: don't reload from XML files over and over.

Change-Id: Ie19c338ed6449ea1509306cbda5dc251295783ae
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
This commit is contained in:
David Faure 2012-05-02 23:19:13 +02:00 committed by Qt by Nokia
parent b36666e1ef
commit 4046ec71c8
3 changed files with 8 additions and 1 deletions

View File

@ -529,6 +529,9 @@ QList<QMimeType> QMimeBinaryProvider::allMimeTypes()
void QMimeBinaryProvider::loadMimeTypePrivate(QMimeTypePrivate &data)
{
if (data.loaded)
return;
data.loaded = true;
// load comment and globPatterns
const QString file = data.name + QLatin1String(".xml");

View File

@ -63,6 +63,7 @@ bool qt_isQMimeTypeDebuggingActivated (false);
#endif
QMimeTypePrivate::QMimeTypePrivate()
: loaded(false)
{}
QMimeTypePrivate::QMimeTypePrivate(const QMimeType &other)
@ -70,7 +71,8 @@ QMimeTypePrivate::QMimeTypePrivate(const QMimeType &other)
localeComments(other.d->localeComments),
genericIconName(other.d->genericIconName),
iconName(other.d->iconName),
globPatterns(other.d->globPatterns)
globPatterns(other.d->globPatterns),
loaded(other.d->loaded)
{}
void QMimeTypePrivate::clear()
@ -80,6 +82,7 @@ void QMimeTypePrivate::clear()
genericIconName.clear();
iconName.clear();
globPatterns.clear();
loaded = false;
}
/*!

View File

@ -68,6 +68,7 @@ public:
QString genericIconName;
QString iconName;
QStringList globPatterns;
bool loaded;
};
QT_END_NAMESPACE