Commit 09030c36 authored by David Narváez's avatar David Narváez
Browse files

Ensure MimeType's XML Data is Loaded before Returning Properties

Comment information is found in the XML data so needs to be loaded
before returning property values. The same would apply for the Patterns
property if you were to query that from the property name instead of the
KMimeType::patterns() method.

BUG: 322578
FIXED-IN: 4.11
REVIEW: 111852
parent d14f51f2
......@@ -436,7 +436,9 @@ void KMimeTypePrivate::save( QDataStream& _str )
QVariant KMimeTypePrivate::property( const QString& _name ) const
{
if ( _name == QLatin1String("Patterns") )
return QVariant( m_lstPatterns );
return patterns();
if ( _name == QLatin1String("Comment") )
return comment();
if ( _name == QLatin1String("Icon") )
return QVariant( iconName(KUrl()) );
......@@ -608,8 +610,7 @@ QString KMimeType::iconName( const KUrl& url) const
QStringList KMimeType::patterns() const
{
Q_D(const KMimeType);
d->ensureXmlDataLoaded();
return d->m_lstPatterns;
return d->patterns();
}
// loads comment, icon, mainPattern, m_lstPatterns
......
......@@ -45,6 +45,12 @@ public:
return m_strComment;
}
QStringList patterns() const
{
ensureXmlDataLoaded();
return m_lstPatterns;
}
// virtual because reimplemented in KFolderMimeType
virtual QString iconName(const KUrl &) const;
......
......@@ -990,4 +990,14 @@ void KMimeTypeTest::testThreads()
f.waitForFinished();
}
void KMimeTypeTest::testProperties()
{
KMimeType::Ptr pngMimeType = KMimeType::mimeType("image/png");
QVariant comment = pngMimeType->property("Comment");
QVariant patterns = pngMimeType->property("Patterns");
QCOMPARE(comment.toString(), pngMimeType->comment());
QCOMPARE(patterns.toStringList(), pngMimeType->patterns());
}
#include "kmimetypetest.moc"
......@@ -60,8 +60,8 @@ private Q_SLOTS:
void testParseMagicFile();
void testHelperProtocols();
void testFromThread();
void testThreads();
void testProperties();
private:
QList<KMimeMagicRule> m_rules;
QString m_nonKdeApp;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment