KMimeType::findByUrl() returning null pointer
faure at kde.org
Mon Sep 18 08:08:18 BST 2006
On Saturday 16 September 2006 14:04, Hamish Rodda wrote:
> I'm encountering a crash in KFileInfo from a dereference of a null mimetype
> pointer in QString KFileItem::mimetype() const. It turns out that the file
> (kdelibs/kate/tests/highlight.asm-avr) is detected as text/x-assembler, and
> there is no corresponding desktop file so findByUrl() returns null.
How does it get detected as such? I see no mention of text/x-assembler in kdelibs/kio/magic.
> What is the correct fix here (other than creating the x-assembler desktop
> file, of course)... should KMimeType::findByUrl() check that the mimetype it
> has looked up is valid before returning it? (The docs say that a null pointer
> cannot be returned)
Ah. Yes. In KDE4 I changed KMimeType::mimeType(name) to return null if a mimetype
of that name doesn't exist (it was just too confusing and broken in kde3), but findByUrl
should still return application/octet-stream if it can't determine the mimetype. So ensuring
that it doesn't return null would be a good idea; but I'm still wondering where it got
David Faure, faure at kde.org, sponsored by Trolltech to work on KDE,
Konqueror (http://www.konqueror.org), and KOffice (http://www.koffice.org).
More information about the kde-core-devel