GApplication: change commandline encoding policy

Clarify in the documentation that the commandline arguments passed
around by GApplication (to local_command_line and returned via
g_application_command_line_get_arguments()) are in the GLib filename
encoding (ie: UTF-8) on Windows, not the system code page.

Fix the mismatch that would result from having argv passed to
g_application_run() in main() on Windows (where it is in the system
code page) by ignoring argc/argv on Windows and calling
g_win32_get_command_line() for ourselves.  Document this.

This might be a slight API break on Windows: we documented that it was
possible to call g_application_run() with arguments other than argc/argv
and now doing that will result in those arguments being ignored.  It has
always been recommended practice to only call g_application_run() from
main() directly, however, and all of our code examples have shown only
this.  We will see if this causes any issues and consider reevaluating
the situation if so.

https://bugzilla.gnome.org/show_bug.cgi?id=722025
This commit is contained in:
Ryan Lortie
2014-01-12 12:31:38 -05:00
parent 643f2b348d
commit e5f91951a1
2 changed files with 27 additions and 12 deletions

View File

@@ -348,7 +348,12 @@ g_application_command_line_class_init (GApplicationCommandLineClass *class)
*
* Gets the list of arguments that was passed on the command line.
*
* The strings in the array may contain non-utf8 data.
* The strings in the array may contain non-UTF-8 data on UNIX (such as
* filenames or arguments given in the system locale) but are always in
* UTF-8 on Windows.
*
* If you wish to use the return value with #GOptionContext, you must
* use g_option_context_parse_strv().
*
* The return value is %NULL-terminated and should be freed using
* g_strfreev().