Qt
  1. Qt
  2. QTBUG-35480

moc @<file> feature fails if <file> contains cyrillic (UTF-8) symbols

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Not Evaluated Not Evaluated
    • Resolution: Out of scope
    • Affects Version/s: 4.8.5
    • Fix Version/s: None
    • Component/s: Build tools: moc
    • Labels:
      None
    • Environment:

      Fedora release 19 (Schrödinger's Cat)

      Description

      Probably it affects Qt5 too.

      moc fails if file name contains cyrillic parts(my locale is ru_RU.UTF-8). Example:

      /usr/lib64/qt4/bin/moc-qt4 @/home/lyokha/Загрузки/geant4.10.00-build/source/interfaces/basic/include/moc_G4UIQt.cxx_parameters
      moc: Cannot open options file specified with @
      Usage: moc [options] <header-file>
      -o<file> write output to file rather than stdout
      -I<dir> add dir to the include path for header files
      -E preprocess only; do not generate meta object code
      -D<macro>[=<def>] define macro, with optional definition
      -U<macro> undefine macro
      -i do not generate an #include statement
      -p<path> path prefix for included file
      -f[<file>] force #include, optional file name
      -nn do not display notes
      -nw do not display warnings
      @<file> read additional options from file
      -v display version of moc

      The file exists and has russian part in its path (Загрузки). Looks like the issue arises from using unneeded QString::fromLatin1() call in src/tools/moc/main.cpp at line 212 where a QFile object is created. It seems that this conversion is not needed in this case as soon as this value is passed from console arguments.

      A simple patch could be:

      — tools/moc/main.cpp 2013-06-07 09:17:00.000000000 +0400
      +++ tools/moc/main.cpp.new 2013-12-09 19:25:22.709456297 +0400
      @@ -209,7 +209,7 @@
      optionsFile.remove(0, 1);
      if (optionsFile.isEmpty())
      error("The @ option requires an input file");

      • QFile f(QString::fromLatin1(optionsFile.constData()));
        + QFile f(optionsFile.constData());
        if (!f.open(QIODevice::ReadOnly | QIODevice::Text))
        error("Cannot open options file specified with @");
        argv.remove;

      but i did not check this solution.

      No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

        Hide
        Alexey Radkov added a comment -

        Sorry, here is formatted patch:

        --- tools/moc/main.cpp	2013-06-07 09:17:00.000000000 +0400
        +++ tools/moc/main.cpp.new	2013-12-09 19:25:22.709456297 +0400
        @@ -209,7 +209,7 @@
                     optionsFile.remove(0, 1);
                     if (optionsFile.isEmpty())
                         error("The @ option requires an input file");
        -            QFile f(QString::fromLatin1(optionsFile.constData()));
        +            QFile f(optionsFile.constData());
                     if (!f.open(QIODevice::ReadOnly | QIODevice::Text))
                         error("Cannot open options file specified with @");
                     argv.remove(n);
        
        Show
        Alexey Radkov added a comment - Sorry, here is formatted patch: --- tools/moc/main.cpp 2013-06-07 09:17:00.000000000 +0400 +++ tools/moc/main.cpp.new 2013-12-09 19:25:22.709456297 +0400 @@ -209,7 +209,7 @@ optionsFile.remove(0, 1); if (optionsFile.isEmpty()) error("The @ option requires an input file"); - QFile f(QString::fromLatin1(optionsFile.constData())); + QFile f(optionsFile.constData()); if (!f.open(QIODevice::ReadOnly | QIODevice::Text)) error("Cannot open options file specified with @"); argv.remove(n);
        Hide
        Olivier Goffart (Woboq GmbH) added a comment -

        This is already fixed in Qt 5.2 which now uses the QCommandLineParser which uses the proper decoding.

        I don't think it is worth fixing it in Qt 4.8, but if you insist you can submit your patch on gerrit. (It will need a test. And the correct fix is to use QString::fromLocal8Bit)

        Show
        Olivier Goffart (Woboq GmbH) added a comment - This is already fixed in Qt 5.2 which now uses the QCommandLineParser which uses the proper decoding. I don't think it is worth fixing it in Qt 4.8, but if you insist you can submit your patch on gerrit. (It will need a test. And the correct fix is to use QString::fromLocal8Bit)
        Hide
        Alexey Radkov added a comment -

        Thank you. I do not think to insist on this fix if it does not affect current release.

        Show
        Alexey Radkov added a comment - Thank you. I do not think to insist on this fix if it does not affect current release.
        Hide
        tienan zhang added a comment -

        chinese has the same problem.
        Thankyou for your article, I move my code to an english name path.

        Show
        tienan zhang added a comment - chinese has the same problem. Thankyou for your article, I move my code to an english name path.

          People

          • Assignee:
            Olivier Goffart (Woboq GmbH)
            Reporter:
            Alexey Radkov
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Gerrit Reviews

              There are no open Gerrit changes