diff --git a/gio/gapplication.c b/gio/gapplication.c index 96c565019..cbc467a92 100644 --- a/gio/gapplication.c +++ b/gio/gapplication.c @@ -434,7 +434,8 @@ g_application_pack_option_entries (GApplication *application, break; case G_OPTION_ARG_INT: - value = g_variant_new_int32 (*(gint32 *) entry->arg_data); + if (*(gint32 *) entry->arg_data) + value = g_variant_new_int32 (*(gint32 *) entry->arg_data); break; case G_OPTION_ARG_FILENAME: @@ -453,11 +454,13 @@ g_application_pack_option_entries (GApplication *application, break; case G_OPTION_ARG_DOUBLE: - value = g_variant_new_double (*(gdouble *) entry->arg_data); + if (*(gdouble *) entry->arg_data) + value = g_variant_new_double (*(gdouble *) entry->arg_data); break; case G_OPTION_ARG_INT64: - value = g_variant_new_int64 (*(gint64 *) entry->arg_data); + if (*(gint64 *) entry->arg_data) + value = g_variant_new_int64 (*(gint64 *) entry->arg_data); break; default: @@ -696,10 +699,6 @@ add_packed_option (GApplication *application, * consumed, they will no longer be visible to the default handling * (which treats them as filenames to be opened). * - * The dict includes options that have been explicitly specified on the parsed - * commandline, as well as zero values for numeric options that were not - * necessarily specified. - * * It is important to use the proper GVariant format when retrieving * the options with g_variant_dict_lookup(): * - for %G_OPTION_ARG_NONE, use `b` diff --git a/gio/tests/gapplication.c b/gio/tests/gapplication.c index f9a95cd31..6f1a27e0f 100644 --- a/gio/tests/gapplication.c +++ b/gio/tests/gapplication.c @@ -1020,53 +1020,6 @@ test_handle_local_options_passthrough (void) g_test_trap_assert_passed (); } -static gint -test_local_options_double (GApplication *app, - GVariantDict *options, - gpointer data) -{ - gboolean *called = data; - gdouble number = 1.0; - - *called = TRUE; - - g_assert_true (g_variant_dict_lookup (options, "number", "d", &number)); - g_assert_cmpfloat (number, ==, 0.0); - - return 0; -} - -static void -test_handle_local_options_double (void) -{ - g_test_summary ("Test that a double of value 0.0 can be parsed using the options handling"); - g_test_bug ("https://gitlab.gnome.org/GNOME/glib/-/issues/2329"); - - if (g_test_subprocess ()) - { - char *binpath = g_test_build_filename (G_TEST_BUILT, "unimportant", NULL); - gchar *argv[] = { binpath, "--number", "0.0", NULL }; - GApplication *app; - gboolean called = FALSE; - int status; - - app = g_application_new ("org.gtk.TestApplication", 0); - g_application_add_main_option (app, "number", 0, G_OPTION_FLAG_NONE, G_OPTION_ARG_DOUBLE, "", ""); - g_signal_connect (app, "handle-local-options", G_CALLBACK (test_local_options_double), &called); - - status = g_application_run (app, G_N_ELEMENTS (argv) -1, argv); - g_assert_true (called); - g_assert_cmpint (status, ==, 0); - - g_object_unref (app); - g_free (binpath); - return; - } - - g_test_trap_subprocess (NULL, 0, G_TEST_SUBPROCESS_INHERIT_STDOUT | G_TEST_SUBPROCESS_INHERIT_STDERR); - g_test_trap_assert_passed (); -} - static void test_api (void) { @@ -1269,7 +1222,6 @@ main (int argc, char **argv) g_test_add_func ("/gapplication/test-handle-local-options1", test_handle_local_options_success); g_test_add_func ("/gapplication/test-handle-local-options2", test_handle_local_options_failure); g_test_add_func ("/gapplication/test-handle-local-options3", test_handle_local_options_passthrough); - g_test_add_func ("/gapplication/test-handle-local-options4", test_handle_local_options_double); g_test_add_func ("/gapplication/api", test_api); g_test_add_data_func ("/gapplication/replace", GINT_TO_POINTER (TRUE), test_replace); g_test_add_data_func ("/gapplication/no-replace", GINT_TO_POINTER (FALSE), test_replace);