Comment 6 for bug 948973

Revision history for this message
Jonathan Thomas (echidnaman) wrote : [kdelibs/KDE/4.8] nepomuk/utils: KMimeType::mimeType() can return null if the mimetype is not found, so check the pointer before we use it to avoid crashing.

Git commit 61e27b31f8f4b10e1378ba700345acecc3b6c9c5 by Jonathan Thomas.
Committed on 02/04/2012 at 00:21.
Pushed by jmthomas into branch 'KDE/4.8'.

KMimeType::mimeType() can return null if the mimetype is not found, so check the pointer before we use it to avoid crashing.

CCMAIL:<email address hidden>

M +2 -1 nepomuk/utils/utils.cpp

http://commits.kde.org/kdelibs/61e27b31f8f4b10e1378ba700345acecc3b6c9c5

diff --git a/nepomuk/utils/utils.cpp b/nepomuk/utils/utils.cpp
index 5dab792..d4c1f28 100644
--- a/nepomuk/utils/utils.cpp
+++ b/nepomuk/utils/utils.cpp
@@ -138,7 +138,8 @@ QString Nepomuk::Utils::formatPropertyValue( const Nepomuk::Types::Property& pro
     }

     else if(property == Vocabulary::NIE::mimeType()) {
- valueString = KMimeType::mimeType(value.toString())->comment();
+ KMimeType::Ptr mimeType = KMimeType::mimeType(value.toString());
+ valueString = (mimeType ? mimeType->comment() : value.toString());
     }

     else {