Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-23027

Terrible QString arg formatting bug when using args not in order

    XMLWordPrintable

Details

    • Bug
    • Resolution: Duplicate
    • P2: Important
    • None
    • 4.7.4, 4.8.x, 5.1.1
    • None
    • Windows 7, Meego, Symbian

    Description

      Simple case:

          const QString server_url("http://XXXXXX/");
          QString fmt1("%2%1,YYY.xml");
          QString fmt2("%1%2,YYY.xml");
      
          quint64 oid = 1726898;
          QString oid_str("1726898");
          QString some_other_str("QUICKBROWNFOX");
          QString some_other_str2("1QUICKBROWNFOX");
          QString some_other_str3("-1QUICKBROWNFOX");
      
          qDebug() << fmt1.arg(oid).arg(server_url);
          qDebug() << fmt2.arg(server_url).arg(oid);
      
          qDebug() << fmt1.arg(oid_str).arg(server_url);
          qDebug() << fmt2.arg(server_url).arg(oid_str);
      
          qDebug() << fmt1.arg(some_other_str).arg(server_url);
          qDebug() << fmt2.arg(server_url).arg(some_other_str);
      
          qDebug() << fmt1.arg(some_other_str2).arg(server_url);
          qDebug() << fmt2.arg(server_url).arg(some_other_str2);
      
          qDebug() << fmt1.arg(some_other_str3).arg(server_url);
          qDebug() << fmt2.arg(server_url).arg(some_other_str3);
      

      Expected result:

      "http://XXXXXX/1726898,YYY.xml"
      "http://XXXXXX/1726898,YYY.xml"
      "http://XXXXXX/1726898,YYY.xml"
      "http://XXXXXX/1726898,YYY.xml"
      "http://XXXXXX/QUICKBROWNFOX,YYY.xml"
      "http://XXXXXX/QUICKBROWNFOX,YYY.xml"
      "http://XXXXXX/1QUICKBROWNFOX,YYY.xml"
      "http://XXXXXX/1QUICKBROWNFOX,YYY.xml"
      "http://XXXXXX/-1QUICKBROWNFOX,YYY.xml"
      "http://XXXXXX/-1QUICKBROWNFOX,YYY.xml"

      Got:

      "http://XXXXXX/726898,YYY.xml"
      "http://XXXXXX/1726898,YYY.xml"
      "http://XXXXXX/726898,YYY.xml"
      "http://XXXXXX/1726898,YYY.xml"
      "http://XXXXXX/QUICKBROWNFOX,YYY.xml"
      "http://XXXXXX/QUICKBROWNFOX,YYY.xml"
      "http://XXXXXX/QUICKBROWNFOX,YYY.xml"
      "http://XXXXXX/1QUICKBROWNFOX,YYY.xml"
      "http://XXXXXX/-1QUICKBROWNFOX,YYY.xml"
      "http://XXXXXX/-1QUICKBROWNFOX,YYY.xml"

      Attachments

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

        Activity

          People

            biochimia João Abecasis
            jpelczar Jarek Pelczar
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes