[Development] QStandardPath search paths

Alan Alpert 416365416c at gmail.com
Wed Jul 31 20:05:56 CEST 2013


On Wed, Jul 31, 2013 at 10:55 AM, Thiago Macieira
<thiago.macieira at intel.com> wrote:
> On quarta-feira, 31 de julho de 2013 16:33:31, Hausmann Simon wrote:
>> I wonder what Filesystem folks think about it (especially Andreas, who was
>> around when I added the search dirs with Girish)
>
> My opinion is that the search path feature is at the wrong level of
> abstraction. It's also a potential security issue, since filename handling
> might not catch the opening of files outside the specified user parameters. It
> makes the determination of whether a given file path is absolute or not
> ambiguous.
>
> Those problems are shared by the file engines. Which we've fortunately got rid
> of for Qt 5.
>
> In my opinion, the *correct* way of searching for a file is
> QStandardPaths::locate. If you need to determine whether the file should be
> opened or not, the API can return you an absolute file name, which you can
> manipulate.

The problem with using QStandardPaths::locate is that we're trying to
turn this function:
https://qt.gitorious.org/qt-creator/qt-creator/blobs/master/share/qtcreator/templates/qtquick2app/qtquick2applicationviewer/qtquick2applicationviewer.cpp#line58
, including the 20 lines in adjust path, into a single line so that
you can write a cross-platform application with Qt without needing a
fat template.

Search paths make "asset:/main.qml" work on all platforms. I don't see
how QStandardPaths::locate would work here other than

#ifndef Q_OS_ANDROID
QStandardPaths::locate(AssetPath, "main.qml");
#else
"asset:/main.qml";
#endif

--
Alan Alpert



More information about the Development mailing list