[Development] Compatability break in QUrl in Qt 4.8

lars.knoll at nokia.com lars.knoll at nokia.com
Wed Feb 1 18:57:57 CET 2012


I'm also in favor of keeping the 4.7 behavior if it causes quite some apps
to break. It's not really important enough to break this in the last minor
release we do in 4.x.

Let's get this sorted and fully fixed in 5.0

Cheers,
Lars

On 1/31/12 1:24 PM, "ext Thiago Macieira" <thiago.macieira at intel.com>
wrote:

>On Tuesday, 31 de January de 2012 11.57.01, shane.kearns at accenture.com
>wrote:
>> The documentation note about the dangers of constructing QUrl from
>>QString
>> was already there in 4.6 (at the bottom of the page) However,
>> QT_NO_URL_CAST_FROM_STRING is not defined by default, so there are no
>> compiler errors or warnings when using unsafe construction.
>
>My new qurl.h has:
>
>#ifdef QT_NO_URL_CAST_FROM_STRING
>    explicit QUrl(const QString &url, ParsingMode mode = TolerantMode);
>#else
>    QUrl(const QString &url, ParsingMode mode = TolerantMode);
>    QUrl &operator=(const QString &url);
>#endif
>
>I think we may want to remove the #ifdef and go with the explicit as the
>only 
>option.
>
>> So I am in favour of keeping the 4.7 behaviour in 4.x releases.
>
>Ok.
>
>> int main(int argc, char *argv[])
>> {
>>     QApplication app(argc, argv);
>> 
>>     Html5ApplicationViewer viewer;
>>     
>>viewer.setOrientation(Html5ApplicationViewer::ScreenOrientationAuto);
>>     viewer.showExpanded();
>>     viewer.loadFile(QLatin1String("html/index.html")); // <-- relative
>>path
>
>This here is not technically *wrong*. The viewer might have its own
>treatment 
>of local file paths for some reason. When loading the file, it might do:
>
>	QUrl base("file:");
>	QUrl resolved = base.resolved(source);
>	// here, the URL is "file:html/index.html", which is still relative but
>is 
>	// definitely a local file path
>
>> 
>>     return app.exec();
>> }
>> 
>> QString Html5ApplicationViewerPrivate::adjustPath(const QString &path)
>> {
>> #ifdef Q_OS_UNIX
>> #ifdef Q_OS_MAC
>>     if (!QDir::isAbsolutePath(path))
>>         return QCoreApplication::applicationDirPath()
>>                 + QLatin1String("/../Resources/") + path;
>> #else
>>     const QString pathInInstallDir =
>>QCoreApplication::applicationDirPath()
>>         + QLatin1String("/../") + path;
>>     if (pathInInstallDir.contains(QLatin1String("opt"))
>>             && pathInInstallDir.contains(QLatin1String("bin"))
>>             && QFileInfo(pathInInstallDir).exists()) { // <-- condition
>>is
>> false on symbian return pathInInstallDir;
>>     }
>> #endif
>> #endif
>>     return path; // <-- path is unmodified
>> }
>
>This function is manipulating strings when it should be using
>QUrl::resolved.
>
>	QUrl resourceBase;
>#ifdef Q_OS_MAC
>	resourceBase = 
>QUrl::fromLocalFile(QCoreApplication::applicationDirPath()
>		+ QLatin1String("/../Resources/"));
>#elif defined Q_OS_UNIX
>	resourceBase = 
>QUrl::fromLocalFile(QCoreApplication::applicationDirPath()
>		+ QLatin1String("/../share/")
>		+ QCoreApplication::applicationName());
>#endif
>	return resourceBase.resolved(uri);
>
>Or it's a job for QStandardPaths.
>
>-- 
>Thiago Macieira - thiago.macieira (AT) intel.com
>  Software Architect - Intel Open Source Technology Center
>     Intel Sweden AB - Registration Number: 556189-6027
>     Knarrarnäsgatan 15, 164 40 Kista, Stockholm, Sweden
>_______________________________________________
>Development mailing list
>Development at qt-project.org
>http://lists.qt-project.org/mailman/listinfo/development




More information about the Development mailing list