Bug 749213 - QUrl.toLocalFile behavior change, regression
QUrl.toLocalFile behavior change, regression
Status: CLOSED ERRATA
Product: Fedora
Classification: Fedora
Component: qt (Show other bugs)
rawhide
Unspecified Unspecified
unspecified Severity unspecified
: ---
: ---
Assigned To: Ngo Than
Fedora Extras Quality Assurance
:
Depends On:
Blocks: qt-4.8
  Show dependency treegraph
 
Reported: 2011-10-26 09:47 EDT by Rex Dieter
Modified: 2013-10-04 08:33 EDT (History)
8 users (show)

See Also:
Fixed In Version: qt-4.8.0-0.23.rc1.fc16
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2011-10-29 02:30:38 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:


Attachments (Terms of Use)


External Trackers
Tracker ID Priority Status Summary Last Updated
KDE Software Compilation 285028 None None None Never
Qt Bug Tracker QTBUG-22380 None None None Never
Qt Bug Tracker QTBUG-22382 None None None Never

  None (edit)
Description Rex Dieter 2011-10-26 09:47:16 EDT
Test case:


python -c "from PyQt4 import QtCore; print 'File: %s' % QtCore.QUrl('KDE-K3B-Finish-Success.ogg').toLocalFile()"

In qt-4.7.x:

File: KDE-K3B-Finish-Success.ogg

In qt-4.8.0-rc1:

File:



The impact is this affects KUrl too, and audio system notifications without full paths fail.
Comment 1 Rex Dieter 2011-10-26 10:03:56 EDT
Filed upstream,
https://bugreports.qt.nokia.com/browse/QTBUG-22380
Comment 2 Rex Dieter 2011-10-26 11:25:31 EDT
sorry, closed the older one too quick, cloned/re-opened as
https://bugreports.qt.nokia.com/browse/QTBUG-22382
Comment 3 Rex Dieter 2011-10-26 14:13:06 EDT
and tracking KUrl impact upstream,
http://bugs.kde.org/285028
Comment 4 Rex Dieter 2011-10-26 16:03:01 EDT
Pretty sure this is the upstream Qt commit the introduced this:

http://qt.gitorious.org/qt/qt/commit/a2f797b52c4274a62a7cf1f0939aca1429afe211
Comment 5 Kevin Kofler 2011-10-26 16:54:05 EDT
Easiest fix (reverting the logic change only without reverting the API addition and the cleanups):

In the (new) isLocalFile function, before:

if (d->scheme.compare(QLatin1String("file"), Qt::CaseInsensitive) != 0)

add the following:

// Treat URLs with no scheme as local for backwards compatibility
if (d->scheme.isEmpty())
    return true;

(Not tested yet, but looking at the offending commit, it should fix this.)
Comment 6 Kevin Kofler 2011-10-27 12:19:25 EDT
It turns out that the behavior of the new QUrl::isLocalFile() is consistent with the existing KUrl::isLocalFile() and Q3Url::isLocalFile() functions, so an alternative easy fix:

In the toLocalFile function, change:

if (!isLocalFile())

to:

// Treat URLs with no scheme as local for backwards compatibility
if (!d->scheme.isEmpty() && !isLocalFile())

(Again, not tested yet, but should work based on my proofreading, and fix this regression in the least invasive way possible.)
Comment 7 Kevin Kofler 2011-10-27 15:08:56 EDT
Actually, please use:

// Treat URLs with no scheme as local for backwards compatibility
if (!isLocalFile() && !d->scheme.isEmpty())

in this order, because isLocalFile() also ensures the URL is parsed (as written in the comment above the line we're changing).
Comment 8 Kevin Kofler 2011-10-27 17:50:07 EDT
Actually, please use:

// Treat URLs with no scheme as local for backwards compatibility
if (!isLocalFile() && (!d || !d->scheme.isEmpty()))

Some code (e.g. in Digikam) is calling isLocalFile() on a null QUrl(), without the added !d check, it crashes trying to check !d->scheme.isEmpty().

(I use !d || rather than d && because if d is NULL, we really SHOULD return a QString() (what else?).)
Comment 9 Fedora Update System 2011-10-28 10:58:02 EDT
qt-4.8.0-0.21.rc1.fc16 has been submitted as an update for Fedora 16.
https://admin.fedoraproject.org/updates/qt-4.8.0-0.21.rc1.fc16
Comment 10 Fedora Update System 2011-10-28 18:02:58 EDT
qt-4.8.0-0.23.rc1.fc16 has been submitted as an update for Fedora 16.
https://admin.fedoraproject.org/updates/qt-4.8.0-0.23.rc1.fc16
Comment 11 Fedora Update System 2011-10-29 02:30:38 EDT
qt-4.8.0-0.23.rc1.fc16 has been pushed to the Fedora 16 stable repository.  If problems still persist, please make note of it in this bug report.
Comment 12 Red Hat Bugzilla 2013-10-03 20:21:23 EDT
Removing external tracker bug with the id '22380' as it is not valid for this tracker
Comment 13 Red Hat Bugzilla 2013-10-03 20:21:27 EDT
Removing external tracker bug with the id '22382' as it is not valid for this tracker

Note You need to log in before you can comment on or make changes to this bug.