summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/gvcore/imageloader.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/gvcore/imageloader.cpp b/src/gvcore/imageloader.cpp
index 406a378..17aedf2 100644
--- a/src/gvcore/imageloader.cpp
+++ b/src/gvcore/imageloader.cpp
@@ -444,7 +444,12 @@ static TQString mimeTypeFromFormat(const char* format) {
TQStringList formats = KImageIO::types(KImageIO::Reading);
TQStringList mimeTypes = KImageIO::mimeTypes(KImageIO::Reading);
int pos = formats.findIndex(TQString::fromAscii(format));
- Q_ASSERT(pos != -1);
+ if(pos < 0) {
+ // TQImageIO::imageFormat() nay return some different types than listed by
+ // TQImage::inputFormats(), e.g. "PPMRAW". Also TDE might simly be ignorant
+ // abous some types known to TQt.
+ return TQString::null;
+ }
return mimeTypes[pos];
}
@@ -463,13 +468,18 @@ void ImageLoader::slotDataReceived(TDEIO::Job* job, const TQByteArray& chunk) {
const char* format = TQImageIO::imageFormat(&buffer);
if (format) {
// This is a raster image, get the mime type now
- d->mURLKind = MimeTypeUtils::KIND_RASTER_IMAGE;
d->mMimeType = mimeTypeFromFormat(format);
+ if(d->mMimeType.isNull()) { // fall back to TDE's autoguess of mime by content
+ KMimeType::Ptr ptr = KMimeType::findByContent(d->mRawData);
+ d->mMimeType = ptr->name();
+ }
+ d->mURLKind = MimeTypeUtils::KIND_RASTER_IMAGE;
} else {
KMimeType::Ptr ptr = KMimeType::findByContent(d->mRawData);
d->mMimeType = ptr->name();
d->mURLKind = MimeTypeUtils::mimeTypeKind(d->mMimeType);
}
+
if (d->mURLKind!=MimeTypeUtils::KIND_RASTER_IMAGE) {
Q_ASSERT(!d->mDecoderTimer.isActive());
job->kill(true /* quietly */);