Bug 318735 - Legend images not shown on windows
Summary: Legend images not shown on windows
Status: RESOLVED FIXED
Alias: None
Product: marble
Classification: Applications
Component: general (show other bugs)
Version: 1.6 (KDE 4.11)
Platform: Microsoft Windows Microsoft Windows
: NOR normal
Target Milestone: ---
Assignee: Dennis Nienhüser
URL: https://forum.kde.org/viewtopic.php?f...
Keywords:
Depends on:
Blocks:
 
Reported: 2013-04-22 19:47 UTC by Dennis Nienhüser
Modified: 2013-04-22 20:16 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dennis Nienhüser 2013-04-22 19:47:30 UTC
Quoting the forum thread:

2) Next fix is... obscure? Problem occurs in MarbleLegendBrowser::generateSectionsHtml (file MarbleLegendBrowser.cpp). Generating html from dgml, we add image properties tags. Among these properties is the path to the image file. Path generated by adding two strings - "file://" and canonical path. On Linux all seems to be ok, because Linux canonical paths begins with '/' symbol. The result is an url like "file:///opt/marble/data/bitmaps/flag.png", according to this article.
But on Windows the result is invalid, like "file://c:/marble/data/bitmaps/flag.png". This result cannot be shown correctly in LegendWidget. We must add one more '/' to get normal "file:///c:/marble/data/bitmaps/flag.png" url.
When we fix this, we fall into another problem. When image file is not used and canonical path is null, we finally get a stupid url like "file:///". On Windows, in release build such urls provokes an internal crash in Qt, resulting in application crash with error message from Microsoft Visual C++ Runtime Library: "Runtime error! <...> This application has requested the Runtime to terminate it in an unusual way. <...>".
See Atlas theme (data/maps/earth/srtm/srtm.dgml - elevation explanation section) for such imageless elements.
Consider to check is the following fix correct:
Code: Select all
///-            QString src  =  "file://" + path;
            QString src;                                                    ///+
            if( !path.isEmpty() ) {                                         ///+
                src = "file://";                                            ///+
                if( path.at( 0 ) != '/' )                                   ///+
                    path.push_front( '/' );                                 ///+
                src += path;                                                ///+
            }                                                               ///+
Comment 1 Dennis Nienhüser 2013-04-22 20:16:17 UTC
Git commit cbeb5a0e7e9c4f7a0defed8a87fb309618130317 by Dennis Nienhüser.
Committed on 22/04/2013 at 22:04.
Pushed by nienhueser into branch 'master'.

Use QUrl to generate URLs from local filenames.

This should fix URL generation on windows, where e.g. c:/foo should
be file:///c:/foo, not file://c:/foo.

M  +1    -1    src/lib/MarbleLegendBrowser.cpp

http://commits.kde.org/marble/cbeb5a0e7e9c4f7a0defed8a87fb309618130317