Summary: | Gwenview opens image as binary stuff instead of showing it when being called from konsole | ||
---|---|---|---|
Product: | [Applications] gwenview | Reporter: | Elias Probst <mail> |
Component: | general | Assignee: | Gwenview Bugs <gwenview-bugs-null> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | sven.burmeister |
Priority: | NOR | ||
Version: | unspecified | ||
Target Milestone: | --- | ||
Platform: | Compiled Sources | ||
OS: | Linux | ||
Latest Commit: | Version Fixed In: | ||
Attachments: | Screenshot showing Gwenview how it displays binary stuff instead of an image |
Description
Elias Probst
2008-06-27 02:50:10 UTC
Created attachment 25641 [details]
Screenshot showing Gwenview how it displays binary stuff instead of an image
I can reproduce this bug on compiled SVN r824835. Looks like KIO::NetAccess::mimetype() can't handle such url and returns "text/html". This hack solves the problem for me, but I'm sure there is better solution: Index: lib/mimetypeutils.cpp =================================================================== --- lib/mimetypeutils.cpp (revision 825004) +++ lib/mimetypeutils.cpp (working copy) @@ -91,6 +91,13 @@ // No luck, look deeper. This can happens with http urls if the filename // does not provide any extension. mimeType = KIO::NetAccess::mimetype(url, KApplication::kApplication()->activeWindow()); + if (mimeType == "text/html") { + QString tmpFile; + if( KIO::NetAccess::download(url, tmpFile, KApplication::kApplication()->activeWindow())) { + mimeType = KMimeType::findByFileContent(tmpFile); + KIO::NetAccess::removeTempFile(tmpFile); + } + } } return mimeType; } Ilya Konkov wrote: [bugs.kde.org quoted mail] If I am not mistaken, this patch will cause the image to be downloaded twice. This is not good. It would be better to use KParts::BrowserRun(). You need to: - Inherit from KParts::BrowserRun() to overload slotBrowserMimeType() so that it notifies the outside world when the mimetype is known. - Modify DocumentView::createPartForUrl() to instantiate your BrowserRun and use the mimetype notification to instantiate the appropriate KPart. You probably need to add an internal event loop [1] to wait for slotBrowserMimeType() to be called. [1] Something like: while (doNotHaveMimeType) { qApp->processEvents(ExcludeUserInput); } SVN commit 832982 by gateau: If we get mimetype=="text/html" from a remote url, download a chunk of it to determine the real mimetype. BUG:165068 M +7 -0 app/documentview.cpp M +41 -1 lib/mimetypeutils.cpp M +5 -0 lib/mimetypeutils.h A lib/mimetypeutils_p.h [License: GPL (v2+)] WebSVN link: http://websvn.kde.org/?view=rev&revision=832982 I still see this: Go to https://forgesvn1.novell.com/svn/opensuse-art/trunk/app-splashes/kde/ right-click on mockup.png, pick open with > gwenview and you will only get binary code showing up in gwenview (2.1.2) Confirmed on latest trunk (r870681). I can reproduce it with Gwenview 2.1.2, but not with latest trunk (r874181). |