Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Qt Creator, Linux, goes wrong adding a filename with a space - bug?



  • Ubuntu 19.04, Qt Creator 4.8.1, Qt 5.12.2 (last one should not be relevant).

    C++ project. Trying to add an "asset" file to the project, which is a .jpg with a space in it, in another directory. Creator successfully creates Other files node, with my directory under it, and a file in there which does not have a space:
    Screenshot from 2020-02-25 09-37-30.png

    But another file there I want to add has spaces, e.g. After the Holocaust.jpg. Upon trying to add this, Creator does its "hour-glass think" on the Project files, but never shows the file. Exiting and re-entering does not help. However, renaming it to not have any spaces does work.

    Looking into what it's doing in the .pro file, I see:

    DISTFILES += \
        docs/AftertheHolocaust.pdf \
        docs/After The Holocaust Map.jpg \
        ../docs/After The Holocaust Map.jpg \
        ../docs/After The Holocaust Map.jpg \
        ../docs/After The Holocaust Map.jpg \
        ../docs/After The.jpg \
        ../docs/After The.jpg
    

    So it's adding it multiple times (yes, I do do Remove... each time before trying to re-add, if that's supposed to remove it from the list that does not work either.). And for all files in that directory, if they contain a space it never shows up in Creator, but if I remove spaces it does.

    Note that I have only tried with this Other files. I have not tried e.g. with a source file (I don't intend by those to have spaces).

    To put those lines into the .pro, is Creator supposed to maybe quote/backslash each name which has a space, and because it's not doing so does not parse back correctly? Just a thought....

    For now I'll have to rename that asset if I want to include it, but that's not right....



  • Just wrap it inside double quotes DISTFILES += "../docs/After The Holocaust Map.jpg"



  • Just wrap it inside double quotes DISTFILES += "../docs/After The Holocaust Map.jpg"



  • @VRonin
    So every time I add a file with a space through picking it via the File Chooser in Qt Creator, I need to go off and edit the .pro file to correct it? This is a cross-platform asset, emanating from PC with spaces, I expect it to work. I'm not complaining about your workaround --- for which many thanks, I have checked that seems to work --- but is this not a bug in Creator (under Linux at least) then?



  • The management of spaces by qmake (and hence Qt Creator) has been a challenge for a while some people tried to fix it but it's one of the cases where the below rule is true.
    The system is transitioning to CMake anyway as primary project manager so I'm not expecting the issue to get solved

    99 Little Bugs



  • @VRonin
    Thank you for replying. Yes, spaces are a mess even under Windoze, I know how that can be for Linux :)

    I will just mark your earlier answer as accepted then, thanks.

    P.S.
    Your pic is about what happens to me when my cat walks across the keyboard when I'm editing code... ;-)


Log in to reply