Version: SVN r824722 (using Devel) Installed from: Compiled sources How to reproduce: - Open a konsole - Paste an URL like this http://bugs.kde.org/attachment.cgi?id=25418&action=view - Rightclick on the URL → Open Link Now Gwenview starts, but instead of displaying the image, it just shows strange binary stuff (see following attachment). This doesn't happen when the MIMEtype of the URL can be directly determined by Konsole like in this one: http://eliasprobst.eu/~elias/stuff/screenshots/kde4-issues/gwenview/zooming-widget-preview-plasmoid.png
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).