Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Possible bug in QString::replace
Forum Updated to NodeBB v4.3 + New Features

Possible bug in QString::replace

Scheduled Pinned Locked Moved General and Desktop
7 Posts 3 Posters 1.6k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    James Bloom-Scheff
    wrote on last edited by
    #1

    I'm new to QT so I don't want to file bug reports unnecessarily. Maybe this is fixed. Maybe I am missing something.

    I believe I am running version 5.4. I see this code at the beginning of QString::replace

    QString& QString::replace(const QRegExp &rx, const QString &after)
    {
    QRegExp rx2(rx);

    if (isEmpty() && rx2.indexIn(*this) == -1)
        return *this;
    

    Unless I am making a stupid mistake, that "&&" should be "||".
    The line is saying that if the string is empty and does not contain the search string, then return. Of course, if the string is empty, we already know it does not contain the search string. I would think that we would want to return if the string is empty or it does not contain the search string.

    1 Reply Last reply
    0
    • K Offline
      K Offline
      koahnig
      wrote on last edited by
      #2

      Hi and welcome to devnet

      Without doing additional research on this, I can follow your arguments. That does not seem to be correct.

      You can check for bug reports on JIRA. This would be also the place to file a bug report yourself.

      Vote the answer(s) that helped you to solve your issue(s)

      1 Reply Last reply
      0
      • J Offline
        J Offline
        James Bloom-Scheff
        wrote on last edited by
        #3

        Correction. I believe I am running version 5.1

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Hi and welcome to devnet,

          It's still present in 5.5

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • J Offline
            J Offline
            James Bloom-Scheff
            wrote on last edited by
            #5

            I just reported it.

            It will be interesting to see the response. Last time I reported an issue showing the actual code that was wrong was many years ago with the MFC. Even being handing the exact line of code and the exact fix, 5 years later it was still there. But I digress.

            1 Reply Last reply
            1
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Thanks, don't forget to share the link to the report, so other user can find it more easily.

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • K Offline
                K Offline
                koahnig
                wrote on last edited by
                #7

                I hope you cannot compare MS with opensource, but you are right that will interesting.

                As SGaist is suggesting, it is good to provide a link to the bug report here. This allows easier finding the report and its status. Furthermore, it helps also because others can vote for it. In the turn-around this may prevent the experience you had with MFC ;)

                Vote the answer(s) that helped you to solve your issue(s)

                1 Reply Last reply
                0

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved