Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 5 additions & 14 deletions shell/platform/linux/fl_engine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -537,11 +537,12 @@ gboolean fl_engine_start(FlEngine* self, GError** error) {
custom_task_runners.platform_task_runner = &platform_task_runner;
custom_task_runners.render_task_runner = &platform_task_runner;

g_autoptr(GPtrArray) command_line_args = fl_engine_get_switches(self);
// FlutterProjectArgs expects a full argv, so when processing it for flags
// the first item is treated as the executable and ignored. Add a dummy value
// so that all switches are used.
g_autoptr(GPtrArray) command_line_args =
g_ptr_array_new_with_free_func(g_free);
g_ptr_array_insert(command_line_args, 0, g_strdup("flutter"));
for (const auto& env_switch : flutter::GetSwitchesFromEnvironment()) {
g_ptr_array_add(command_line_args, g_strdup(env_switch.c_str()));
}

gchar** dart_entrypoint_args =
fl_dart_project_get_dart_entrypoint_arguments(self->project);
Expand Down Expand Up @@ -1026,16 +1027,6 @@ void fl_engine_update_accessibility_features(FlEngine* self, int32_t flags) {
self->engine, static_cast<FlutterAccessibilityFeature>(flags));
}

GPtrArray* fl_engine_get_switches(FlEngine* self) {
g_return_val_if_fail(FL_IS_ENGINE(self), nullptr);

GPtrArray* switches = g_ptr_array_new_with_free_func(g_free);
for (const auto& env_switch : flutter::GetSwitchesFromEnvironment()) {
g_ptr_array_add(switches, g_strdup(env_switch.c_str()));
}
return switches;
}

void fl_engine_request_app_exit(FlEngine* self) {
g_return_if_fail(FL_IS_ENGINE(self));
fl_platform_handler_request_app_exit(self->platform_handler);
Expand Down
10 changes: 0 additions & 10 deletions shell/platform/linux/fl_engine_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -416,16 +416,6 @@ gboolean fl_engine_unregister_external_texture(FlEngine* engine,
*/
void fl_engine_update_accessibility_features(FlEngine* engine, int32_t flags);

/**
* fl_engine_get_switches:
* @engine: an #FlEngine.
*
* Determines the switches that should be passed to the Flutter engine.
*
* Returns: an array of switches to pass to the Flutter engine.
*/
GPtrArray* fl_engine_get_switches(FlEngine* engine);

/**
* fl_engine_request_app_exit:
* @engine: an #FlEngine.
Expand Down
32 changes: 0 additions & 32 deletions shell/platform/linux/fl_engine_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -537,17 +537,6 @@ TEST(FlEngineTest, EmptyLocales) {
}
}

TEST(FlEngineTest, SwitchesEmpty) {
g_autoptr(FlEngine) engine = make_mock_engine();

// Clear the main environment variable, since test order is not guaranteed.
unsetenv("FLUTTER_ENGINE_SWITCHES");

g_autoptr(GPtrArray) switches = fl_engine_get_switches(engine);

EXPECT_EQ(switches->len, 0U);
}

static void add_view_cb(GObject* object,
GAsyncResult* result,
gpointer user_data) {
Expand Down Expand Up @@ -759,25 +748,4 @@ TEST(FlEngineTest, RemoveViewEngineError) {
g_main_loop_run(loop);
}

#ifndef FLUTTER_RELEASE
TEST(FlEngineTest, Switches) {
g_autoptr(FlEngine) engine = make_mock_engine();

setenv("FLUTTER_ENGINE_SWITCHES", "2", 1);
setenv("FLUTTER_ENGINE_SWITCH_1", "abc", 1);
setenv("FLUTTER_ENGINE_SWITCH_2", "foo=\"bar, baz\"", 1);

g_autoptr(GPtrArray) switches = fl_engine_get_switches(engine);
EXPECT_EQ(switches->len, 2U);
EXPECT_STREQ(static_cast<const char*>(g_ptr_array_index(switches, 0)),
"--abc");
EXPECT_STREQ(static_cast<const char*>(g_ptr_array_index(switches, 1)),
"--foo=\"bar, baz\"");

unsetenv("FLUTTER_ENGINE_SWITCHES");
unsetenv("FLUTTER_ENGINE_SWITCH_1");
unsetenv("FLUTTER_ENGINE_SWITCH_2");
}
#endif // !FLUTTER_RELEASE

// NOLINTEND(clang-analyzer-core.StackAddressEscape)