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. QGuiApplication crashed when passing Unicode string like Thai parameter?

QGuiApplication crashed when passing Unicode string like Thai parameter?

Scheduled Pinned Locked Moved General and Desktop
qguiapplicationunicodeparameterqquickview
11 Posts 3 Posters 3.8k 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.
  • D Offline
    D Offline
    dhuta
    wrote on 25 May 2015, 09:42 last edited by dhuta
    #1

    I have a gui app, which want to grab an image of QQuickView, though gui app, i want to control it in terminal. At the same time, the only component in qml passed to QQuickView is just a Text component . I want to pass my wantted string to the Text's text property. But, i find it probably crash when i pass in some unicode string like Thai. My OS is win7, Qt5.3.1. The app crashs in QCoreApplication::arguments(). Or the demand is rediculous?

    How to solve it? Anyone can help me?

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 25 May 2015, 21:46 last edited by
      #2

      Hi,

      Can you reproduce that with a minimal compilable example ? What is the string that makes your application crash ?

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

      D 1 Reply Last reply 26 May 2015, 05:45
      0
      • S SGaist
        25 May 2015, 21:46

        Hi,

        Can you reproduce that with a minimal compilable example ? What is the string that makes your application crash ?

        D Offline
        D Offline
        dhuta
        wrote on 26 May 2015, 05:45 last edited by dhuta
        #3

        @SGaist Sample code is at https://github.com/EightFingerDhuta/qt/tree/master/crashArgs。
        Test string is "สวัสดี" in thai. But it will be ok when pass "你好" etc.

        This simplified sample runs ok in qtcreator (parameter passed in qtcreator), but fails when run it in cmd terminal after deploy it.

        In fact, my original app even cannot run in qtcreator. When delete all build files manually and rebuild it, it can run successfully only once.

        I 1 Reply Last reply 26 May 2015, 05:56
        0
        • D dhuta
          26 May 2015, 05:45

          @SGaist Sample code is at https://github.com/EightFingerDhuta/qt/tree/master/crashArgs。
          Test string is "สวัสดี" in thai. But it will be ok when pass "你好" etc.

          This simplified sample runs ok in qtcreator (parameter passed in qtcreator), but fails when run it in cmd terminal after deploy it.

          In fact, my original app even cannot run in qtcreator. When delete all build files manually and rebuild it, it can run successfully only once.

          I Offline
          I Offline
          ileonte
          wrote on 26 May 2015, 05:56 last edited by
          #4

          @dhuta your app is crashing because argv0 is not terminated by a NULL pointer. You need to declare it as char *argv0[argc0 + 1] and then add argv0[i] = NULL; after the for loop in which you copy from argv to argv0.

          D 1 Reply Last reply 26 May 2015, 06:08
          0
          • I ileonte
            26 May 2015, 05:56

            @dhuta your app is crashing because argv0 is not terminated by a NULL pointer. You need to declare it as char *argv0[argc0 + 1] and then add argv0[i] = NULL; after the for loop in which you copy from argv to argv0.

            D Offline
            D Offline
            dhuta
            wrote on 26 May 2015, 06:08 last edited by dhuta
            #5

            @ileonte It really a bug. But the sample code still failed when i not modify these parameters or add the NULL pointer as you said.

            I 1 Reply Last reply 26 May 2015, 06:21
            0
            • D dhuta
              26 May 2015, 06:08

              @ileonte It really a bug. But the sample code still failed when i not modify these parameters or add the NULL pointer as you said.

              I Offline
              I Offline
              ileonte
              wrote on 26 May 2015, 06:21 last edited by
              #6

              @dhuta what I meant to say is add argv0[argc + 2] = NULL;. That part about argv0[i] = NULL; is wrong. Your code should look like this:

                  int argc0 = argc + 2;
                  char *argv0[argc0 + 1];
              
                  for (int i = 0; i < argc; i++) {
                      argv0[i] = argv[i];
                  }
              
                  argv0[argc] = arg1;
                  argv0[argc + 1] = arg2;
                  argv0[argc + 2] = NULL;
              
              D 1 Reply Last reply 26 May 2015, 06:26
              0
              • I ileonte
                26 May 2015, 06:21

                @dhuta what I meant to say is add argv0[argc + 2] = NULL;. That part about argv0[i] = NULL; is wrong. Your code should look like this:

                    int argc0 = argc + 2;
                    char *argv0[argc0 + 1];
                
                    for (int i = 0; i < argc; i++) {
                        argv0[i] = argv[i];
                    }
                
                    argv0[argc] = arg1;
                    argv0[argc + 1] = arg2;
                    argv0[argc + 2] = NULL;
                
                D Offline
                D Offline
                dhuta
                wrote on 26 May 2015, 06:26 last edited by
                #7

                @ileonte Yeah. I just add it exactly as you do. But the sample still crash.

                I 1 Reply Last reply 26 May 2015, 06:29
                0
                • D dhuta
                  26 May 2015, 06:26

                  @ileonte Yeah. I just add it exactly as you do. But the sample still crash.

                  I Offline
                  I Offline
                  ileonte
                  wrote on 26 May 2015, 06:29 last edited by
                  #8

                  @dhuta Where is the call stack for the crash originating from ? Is it the QApplication constructor or the parser.process(app); call ? Also can you please push the modified code to GitHub so I can have another look ?

                  D 1 Reply Last reply 26 May 2015, 07:08
                  0
                  • I ileonte
                    26 May 2015, 06:29

                    @dhuta Where is the call stack for the crash originating from ? Is it the QApplication constructor or the parser.process(app); call ? Also can you please push the modified code to GitHub so I can have another look ?

                    D Offline
                    D Offline
                    dhuta
                    wrote on 26 May 2015, 07:08 last edited by
                    #9

                    @ileonte I have already push the modified code. When i run it under debug mode, it crashs with a message: ASSERT: "allArguments.size() == origArgc" in file kernel\qtcoreapplication.cpp line 2191. I google it, it seems that this is an already known bug: https://bugreports.qt.io/browse/QTBUG-30330. Maybe i should found another way to get my wanted result.

                    Thanks a lot !

                    I 1 Reply Last reply 26 May 2015, 07:10
                    0
                    • D dhuta
                      26 May 2015, 07:08

                      @ileonte I have already push the modified code. When i run it under debug mode, it crashs with a message: ASSERT: "allArguments.size() == origArgc" in file kernel\qtcoreapplication.cpp line 2191. I google it, it seems that this is an already known bug: https://bugreports.qt.io/browse/QTBUG-30330. Maybe i should found another way to get my wanted result.

                      Thanks a lot !

                      I Offline
                      I Offline
                      ileonte
                      wrote on 26 May 2015, 07:10 last edited by
                      #10

                      @dhuta That bug is marked as closed, maybe you could try updating to a newer version of Qt.

                      D 1 Reply Last reply 26 May 2015, 07:17
                      0
                      • I ileonte
                        26 May 2015, 07:10

                        @dhuta That bug is marked as closed, maybe you could try updating to a newer version of Qt.

                        D Offline
                        D Offline
                        dhuta
                        wrote on 26 May 2015, 07:17 last edited by
                        #11

                        @ileonte Uh, i must use Qt5.3.1, coz our project demands this version....I think i have to read file to get target text string.

                        Anyway, thank you~ :)

                        1 Reply Last reply
                        0

                        2/11

                        25 May 2015, 21:46

                        topic:navigator.unread, 9
                        • Login

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