Bug 382239 - QUrl::path() returns invalid pathes on Windows
Summary: QUrl::path() returns invalid pathes on Windows
Status: RESOLVED FIXED
Alias: None
Product: umbrello
Classification: Applications
Component: general (show other bugs)
Version: frameworks5
Platform: Other Microsoft Windows
: NOR normal
Target Milestone: ---
Assignee: Umbrello Development Group
URL:
Keywords:
Depends on:
Blocks: 373932
  Show dependency treegraph
 
Reported: 2017-07-11 13:55 UTC by Ralf Habacker
Modified: 2018-03-26 09:09 UTC (History)
1 user (show)

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 Ralf Habacker 2017-07-11 13:55:43 UTC
On porting KUrl::path() references directly to QUrl::path() the related locations returns invalid file pathes on Windows as shown with following examples:

    QUrl b = QUrl::fromLocalFile("/test/test.xyz");
    qDebug() << b.path() << b.toLocalFile();
    b = QUrl::fromLocalFile("c:/test/test.xyz");
    qDebug() << b.path() << b.toLocalFile();
    b = QUrl::fromLocalFile("c:\\test\\test.xyz");
    qDebug() << b.path() << b.toLocalFile();

Running this code on Windows returns 

"/test/test.xyz" "/test/test.xyz"
"/c:/test/test.xyz" "c:/test/test.xyz"
"/c:/test/test.xyz" "c:/test/test.xyz"

line 2 and 3  column 1 shows that QUrl::path() always prefixes the path with '/' which is incorrect.

KUrl from KDE4 does not have this problem because it covers the "local file case" (see https://github.com/KDE/kdelibs/blob/KDE/4.14/kdecore/io/kurl.cpp#L873 for details).

Instead QUrl::toLocalFile() should be used, which is also safe to use on non Windows OS.
Comment 1 Ralf Habacker 2018-03-26 09:09:03 UTC
umbrello source code does not use QUrl::path() anymore.