Windows cross build
Thiago Macieira
thiago at macieira.org
Mon Oct 7 10:47:55 UTC 2013
On segunda-feira, 7 de outubro de 2013 16:04:03, Lubomir I. Ivanov wrote:
> On 7 October 2013 09:26, Thiago Macieira <thiago at macieira.org> wrote:
> > On segunda-feira, 7 de outubro de 2013 04:06:45, Hohndel, Dirk wrote:
> >> Lubomir
> >>
> >> removing the glib dependency took away the helper functions that you
> >> used in windows.c to address the command line argument problem.
> >>
> >> Can you look at ways to do this without glib?
>
> i'm guessing our goal is still to parse the UTF-16 argument list on
> windows, but the question here is do we still need to convert it to
> UTF-8 given QString uses UTF-16 internally?
We don't need to. QString can take the UTF-16 string directly:
QString::fromUtf16 is a simple memcpy.
However, QApplication still needs to receive a char**. So either we pass a
dummy or we still need to convert.
> looking at main.cpp, what happens currently is:
> subsurface_command_line_init(&argc, &argv); // would convert
> UTF16->UTF8 with wildcard expansion
> init_ui(&argc, &argv); // these are now UTF-8 arguments and we pass
> them to QApplication.
> ...
> importedFiles.push_back( QString(a) ); // which i don't think will
> work without ::fromUtf8() for 'a'?
> // so perhaps the list should be obtained with
> QCoreApplication::arguments() here?
Yup.
If we use libqtmain.a on Windows, we don't have to do anything. It will parse
the command-line for us and it will pass a proper argc/argv pair to our main()
function.
Then QCoreApplication::arguments() will return the expanded UTF-16 command-
line for us, on Qt 4!
On Qt 5, there's the bug I need to fix. I'll probably get to it when we port
Subsurface to Qt 5 :-)
> i tested my code using Qt5.0 with mingw-gcc-4.7.2 (sjlj), and it's
> mainly based around __wgetmainargs() and WideCharToMultiByte().
> i've just read that someone has submitted a new class for Qt 5.2 that
> handles the windows argument list correctly, but i lost the link.
That's the QCommandLineParser class for Qt 5.2. But it still requires a
QStringList to operate.
--
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
Software Architect - Intel Open Source Technology Center
PGP/GPG: 0x6EF45358; fingerprint:
E067 918B B660 DBD1 105C 966C 33F5 F005 6EF4 5358
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.hohndel.org/pipermail/subsurface/attachments/20131007/5032a019/attachment.sig>
More information about the subsurface
mailing list