QGuiApplication crashed when passing Unicode string like Thai parameter?
-
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 aText
component . I want to pass my wantted string to the Text's text property. But, i find it probably crash when i pass in someunicode
string likeThai
. My OS is win7, Qt5.3.1. The app crashs inQCoreApplication::arguments()
. Or the demand is rediculous?How to solve it? Anyone can help me?
-
Hi,
Can you reproduce that with a minimal compilable example ? What is the string that makes your application crash ?
-
Hi,
Can you reproduce that with a minimal compilable example ? What is the string that makes your application crash ?
@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
. -
@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
. -
@dhuta your app is crashing because
argv0
is not terminated by aNULL
pointer. You need to declare it aschar *argv0[argc0 + 1]
and then addargv0[i] = NULL;
after thefor
loop in which you copy fromargv
toargv0
. -
@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.@dhuta what I meant to say is add
argv0[argc + 2] = NULL;
. That part aboutargv0[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;
-
@dhuta what I meant to say is add
argv0[argc + 2] = NULL;
. That part aboutargv0[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;
-
@dhuta Where is the call stack for the crash originating from ? Is it the
QApplication
constructor or theparser.process(app);
call ? Also can you please push the modified code to GitHub so I can have another look ?@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 !
-
@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 !
-
@dhuta That bug is marked as closed, maybe you could try updating to a newer version of Qt.