Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Does QString has any limitation in Android environment for Qt 5.15.2?
QtWS25 Last Chance

Does QString has any limitation in Android environment for Qt 5.15.2?

Scheduled Pinned Locked Moved Solved Mobile and Embedded
qt5.15.2androidqstringbugqtcore
13 Posts 4 Posters 791 Views
  • 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.
  • S Offline
    S Offline
    SevenM
    wrote on last edited by
    #1

    Hi,
    I recently moved my Windows/Android application to Qt 5.15.2 from Qt 5.12.9. I see no issues for Windows part, however, i observed a strange behaviour of QString in Android environment. It seems like there is a limitation on the length of the string.
    eg.

    QString temp =
            "rR64dZUTT8o1cn2QPZgz5XLtniNCo2vzKmyYEn23apgxlpmYVuRuVOB0utOVP7P4N6RHuv"
            "FMM2JnFnTJZPGBOxclYFTocyv0YEC17hTOGM5s0KpPI707xxBP4AcYTuq7AKhFXhUjNRnJ"
            "nyb4kPDukgVEk2GWuaCMIIKytmlEVRKGeKO3EJp5FdrdfXOth67Foa97n8ASopJeoXOL1x"
            "Jz7EjqUXz7tGmQT55RG7s5Qv701Kbfo7X4KE4cu8P9GM48tlCePLo0e7xsxyM9qzaW33Wx"
            "XHqEesSiQLpNR8S8Be0MpD5p7IYvWjUDl05oNXcjMJfKauZ3HiSC0FK6JZfxck8ttKbeF9"
            "N5X5pnLrn9xf0G06iFlULg0zg83SAHp5kHJC5sjKOUWt8vsBavbBIANARwX0bCEsk7Ai1I"
            "RxY91mNcVO4cjiDDXi5nzxd4HQLa5LvVjCsdrCgZm23CD1kCVjfaQXvGUTBEResApiwAmN"
            "ZDmj8KCFZSrztl2lGsYJOgmfgZXtjShO5VtOJo6OBZjzhoQ10RbLzB0rUwMFSSudOFgnd0"
            "A79HYEeTcvjyJmwGUjNw6JG7Qt8T2kgkA961Uc6JsBp5M3zrDqmRP3SLSlv5V3bVXdpvP7"
            "SGY8K0sZuIRqXKp7MJlBu3u56Z55VeDNkeQdDJBfaTWfcUF5Xb6LziqprsyBxGsUjebjJP"
            "cgrrEMPqDDxaUKKJ93pUG2rStclUd9XWr3Y1NFr4DgZyNgUIaUbqgPHiNNy9B9b1aOjhJZ"
            "UX2MD7tSp8HAfInhCvrUbQoUqWe6u5jr8yAeS4Q5IhqC8jw858Kflu6nJlMtCXv3jbe2Q0"
            "V0cngDkZ32SLS57g35Iu1rpXP6DLxrCtpu4H9FyTv3rcfyR92RLwa2sjKvb4qC3hGEYNEb"
            "GTqYifaGx2o0WNPcseYllTxRdO4YoQXvCddksz25iC7X2VEfnkZDO5hG1EZvg2LzmG9ASH"
            "8Ve0WMOhc09fPZFkdFzrNwULWXFVjNyWMklyIsto44HhfGWbn7xW3umDGsMyJRFKqannYG"
            "5Aj3hoMnuANActvGVrVG0eGc710vF4RK9yHFQq3y2xPGtUghy6pvMWf1CKTZeZvNTm8xeO"
            "WtrOGcGflKJ3g7mxYCLxsxMttA5AkcyRzs0m2egTADxVLHgsfacvqwStr189nZbyYgHg2v"
            "UlqeFraw7ZKZDOP1u28ZLhdnU2ZDh3vAWQUIUwPFLLpKWgR6eWAS9FSRzIwsln4oi4jLYq"
            "NSu7mVyqawHgaeggOv36oO40wugzThi34n5bmClMlYWXzCCiXoVjsX34MKjNXNhGaZvh5B"
            "WQkD5oQ7vY095GoFvg8ao6MMK00wLC05L8i7dcQXuD6rky9JrxuC3hta0ju38jx0X673oH"
            "potqo0DX7N7lSme7JC0gzuo5RUonMlKh9uy7IXUQV6yAkKNViLa3Wsj6r76WoxqFjUJPlT"
            "KEuzEGjPCubGQR8u1UPIYiYp0KirlZ";
    
        qDebug() << "Random string" << temp;
    

    will yield me:
    Random string "rR64dZUTT8o1cn2QPZgz5XLtniNCo2vzKmyYEn23apgxlpmYVuRuVOB0utOVP7P4N6RHuvFMM2JnFnTJZPGBOxclYFTocyv0YEC17hTOGM5s0KpPI707xxBP4AcYTuq7AKhFXhUjNRnJnyb4kPDukgVEk2GWuaCMIIKytmlEVRKGeKO3EJp5FdrdfXOth67Foa97n8ASopJeoXOL1xJz7EjqUXz7tGmQT55RG7s5Qv701Kbfo7X4KE4cu8P9GM48tlCePLo0e7xsxyM9qzaW33WxXHqEesSiQLpNR8S8Be0MpD5p7IYvWjUDl05oNXcjMJfKauZ3HiSC0FK6JZfxck8ttKbeF9N5X5pnLrn9xf0G06iFlULg0zg83SAHp5kHJC5sjKOUWt8vsBavbBIANARwX0bCEsk7Ai1IRxY91mNcVO4cjiDDXi5nzxd4HQLa5LvVjCsdrCgZm23CD1kCVjfaQXvGUTBEResApiwAmNZDmj8KCFZSrztl2lGsYJOgmfgZXtjShO5VtOJo6OBZjzhoQ10RbLzB0rUwMFSSudOFgnd0A79HYEeTcvjyJmwGUjNw6JG7Qt8T2kgkA961Uc6JsBp5M3zrDqmRP3SLSlv5V3bVXdpvP7SGY8K0sZuIRqXKp7MJlBu3u56Z55VeDNkeQdDJBfaTWfcUF5Xb6LziqprsyBxGsUjebjJPcgrrEMPqDDxaUKKJ93pUG2rStclUd9XWr3Y1NFr4DgZyNgUIaUbqgPHiNNy9B9b1aOjhJZUX2MD7tSp8HAfInhCvrUbQoUqWe6u5jr8yAeS4Q5IhqC8jw858Kflu6nJlMtCXv3jbe2Q0V0cngDkZ32SLS57g35Iu1rpXP6DLxrCtpu4H9FyTv3rcfyR92RLwa2sjKvb4qC3hGEYNEbGTqYifaGx2o0WNPcseYllTxRdO4YoQXvCddksz25iC7X2VEfnkZDO5hG1EZvg2LzmG9ASH8Ve0WMOhc09fPZFkdFzrNwULWXFV

    I checked in the Qt bug list but could find any reference of the same.

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      Please check if temp.size() returns the same value on desktop and Android. Perhaps the string is only truncated during printing but internally the whole data is still there.

      Also a general remark: since this is an ASCI string you can save a lot of memory by using QLatin1String here instead of QString.

      (Z(:^

      S 1 Reply Last reply
      2
      • hskoglundH Offline
        hskoglundH Offline
        hskoglund
        wrote on last edited by
        #3

        Hi, couldn't resist counting # of chars that survived: 1008
        if every char uses 2 bytes (I think) and we add 32 bytes for the QString class storage (again just a guess :-) then we end up at 2048, interesting ...

        1 Reply Last reply
        3
        • sierdzioS Offline
          sierdzioS Offline
          sierdzio
          Moderators
          wrote on last edited by
          #4

          Hm yes the number is very interesting indeed, looks like it is no coincidence.

          ... but I still think the string itself is fine and only in printing it is misrepresented. Otherwise it would be a very, very serious issue in Qt and I imagine it would have been detected earlier.

          (Z(:^

          1 Reply Last reply
          2
          • sierdzioS sierdzio

            Please check if temp.size() returns the same value on desktop and Android. Perhaps the string is only truncated during printing but internally the whole data is still there.

            Also a general remark: since this is an ASCI string you can save a lot of memory by using QLatin1String here instead of QString.

            S Offline
            S Offline
            SevenM
            wrote on last edited by
            #5

            @sierdzio Yes, you are right! The size of temp is correct on both the platforms. Only in case of window the string is printed completely. Perhaps the limitation of qDebug in Android environment.
            However, my quest to identify the source of crash remains! I am using Qstring to save a large Sqlite query and only in the case on Android, I am getting this crash during execSql.
            Anyways, thanks for your inputs!

            Best Regards,
            M

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

              Hi,

              What do you mean by large SQLite query ? How large ? What makes it so large ?

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

              S 1 Reply Last reply
              0
              • SGaistS SGaist

                Hi,

                What do you mean by large SQLite query ? How large ? What makes it so large ?

                S Offline
                S Offline
                SevenM
                wrote on last edited by SevenM
                #7

                @SGaist It is an insert query with 1612 characters. Works perfectly well in windows but fail when cross-compile in Android and perform the same action.
                If I replace the query with something smaller, it works in Android. That's why I suspected QString can be an issue here.

                1 Reply Last reply
                0
                • sierdzioS Offline
                  sierdzioS Offline
                  sierdzio
                  Moderators
                  wrote on last edited by
                  #8

                  Try running it with debugger attached, should show you where the issue occurs.

                  (Z(:^

                  S 1 Reply Last reply
                  0
                  • sierdzioS sierdzio

                    Try running it with debugger attached, should show you where the issue occurs.

                    S Offline
                    S Offline
                    SevenM
                    wrote on last edited by
                    #9

                    @sierdzio I just did that. Interesting, I see this at the point of crash:
                    f2b8e7d6-abdb-4f76-97bd-adede0927bf7-image.png

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

                      Just to help narrow things, are you building the whole query string or are you binding values ?

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

                      S 1 Reply Last reply
                      0
                      • SGaistS SGaist

                        Just to help narrow things, are you building the whole query string or are you binding values ?

                        S Offline
                        S Offline
                        SevenM
                        wrote on last edited by
                        #11

                        @SGaist I am building the whole query string, there are no binding values.

                        1 Reply Last reply
                        0
                        • S Offline
                          S Offline
                          SevenM
                          wrote on last edited by SevenM
                          #12

                          I think I identified the problem. The codebase doesn't solely rely on Sqlite plugin of Qt but also on external sqlite Library for certain operations while still using Qt connections to execute the query. Due to this shift in Qt version, maybe the Qt plugin and external lib were incompatible.
                          Qt 5.12.9 uses sqlite 3.32.1 in the sources while Qt 5.15.9 uses sqlite 3.33.0.
                          I simply changed to external lib to 3.33.0 (same as what Qt uses) and the query was handled correctly.

                          Anyways, Thank you so much for your help!

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

                            That was a nasty one. Glad you found out and thanks for sharing !

                            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
                            • S SevenM has marked this topic as solved on

                            • Login

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