On Tuesday, 31 de January de 2012 11.57.01, [email protected] 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

Attachment: signature.asc
Description: This is a digitally signed message part.

_______________________________________________
Development mailing list
[email protected]
http://lists.qt-project.org/mailman/listinfo/development

Reply via email to