From 1b4d958f989d0406bf2d00edf085506ed57787f7 Mon Sep 17 00:00:00 2001 From: Robert Ancell Date: Wed, 3 Jun 2020 06:22:24 +1200 Subject: [PATCH] Add braces around multi-line branches to match code style (#18719) --- shell/platform/linux/fl_basic_message_channel.cc | 3 ++- shell/platform/linux/fl_binary_messenger.cc | 4 ++-- shell/platform/linux/fl_dart_project.cc | 3 ++- shell/platform/linux/fl_engine.cc | 12 ++++++++---- shell/platform/linux/fl_json_message_codec.cc | 3 ++- shell/platform/linux/fl_json_method_codec_test.cc | 10 ++++++---- shell/platform/linux/fl_key_event_plugin.cc | 3 ++- shell/platform/linux/fl_method_channel.cc | 3 ++- shell/platform/linux/fl_method_codec_test.cc | 10 ++++++---- shell/platform/linux/fl_method_response.cc | 3 ++- .../platform/linux/fl_standard_method_codec_test.cc | 10 ++++++---- shell/platform/linux/fl_view.cc | 3 ++- 12 files changed, 42 insertions(+), 25 deletions(-) diff --git a/shell/platform/linux/fl_basic_message_channel.cc b/shell/platform/linux/fl_basic_message_channel.cc index c9195aaa0ad..405ae0e0427 100644 --- a/shell/platform/linux/fl_basic_message_channel.cc +++ b/shell/platform/linux/fl_basic_message_channel.cc @@ -127,9 +127,10 @@ static void channel_closed_cb(gpointer user_data) { static void fl_basic_message_channel_dispose(GObject* object) { FlBasicMessageChannel* self = FL_BASIC_MESSAGE_CHANNEL(object); - if (self->messenger != nullptr) + if (self->messenger != nullptr) { fl_binary_messenger_set_message_handler_on_channel( self->messenger, self->name, nullptr, nullptr, nullptr); + } g_clear_object(&self->messenger); g_clear_pointer(&self->name, g_free); diff --git a/shell/platform/linux/fl_binary_messenger.cc b/shell/platform/linux/fl_binary_messenger.cc index 49e53e9aed5..ed20702acde 100644 --- a/shell/platform/linux/fl_binary_messenger.cc +++ b/shell/platform/linux/fl_binary_messenger.cc @@ -185,11 +185,11 @@ G_MODULE_EXPORT void fl_binary_messenger_set_message_handler_on_channel( return; } - if (handler != nullptr) + if (handler != nullptr) { g_hash_table_replace( self->platform_message_handlers, g_strdup(channel), platform_message_handler_new(handler, user_data, destroy_notify)); - else + } else g_hash_table_remove(self->platform_message_handlers, channel); } diff --git a/shell/platform/linux/fl_dart_project.cc b/shell/platform/linux/fl_dart_project.cc index e57f4ca626b..c801f7896ab 100644 --- a/shell/platform/linux/fl_dart_project.cc +++ b/shell/platform/linux/fl_dart_project.cc @@ -24,9 +24,10 @@ static void fl_dart_project_set_path(FlDartProject* self, const gchar* path) { else { g_autoptr(GError) error = nullptr; g_autofree gchar* exe_path = g_file_read_link("/proc/self/exe", &error); - if (exe_path == nullptr) + if (exe_path == nullptr) { g_critical("Failed to determine location of executable: %s", error->message); + } g_autofree gchar* dir = g_path_get_dirname(exe_path); self->path = g_build_filename(dir, path, nullptr); } diff --git a/shell/platform/linux/fl_engine.cc b/shell/platform/linux/fl_engine.cc index 010cb3ab9ca..27ee1a608ff 100644 --- a/shell/platform/linux/fl_engine.cc +++ b/shell/platform/linux/fl_engine.cc @@ -143,9 +143,10 @@ static void fl_engine_platform_message_cb(const FlutterPlatformMessage* message, self->platform_message_handler_data); } - if (!handled) + if (!handled) { fl_engine_send_platform_message_response(self, message->response_handle, nullptr, nullptr); + } } // Called when a response to a sent platform message is received from the @@ -167,9 +168,10 @@ static void fl_engine_dispose(GObject* object) { g_clear_object(&self->renderer); g_clear_object(&self->binary_messenger); - if (self->platform_message_handler_destroy_notify) + if (self->platform_message_handler_destroy_notify) { self->platform_message_handler_destroy_notify( self->platform_message_handler_data); + } self->platform_message_handler_data = nullptr; self->platform_message_handler_destroy_notify = nullptr; @@ -257,9 +259,10 @@ void fl_engine_set_platform_message_handler( g_return_if_fail(FL_IS_ENGINE(self)); g_return_if_fail(handler != nullptr); - if (self->platform_message_handler_destroy_notify) + if (self->platform_message_handler_destroy_notify) { self->platform_message_handler_destroy_notify( self->platform_message_handler_data); + } self->platform_message_handler = handler; self->platform_message_handler_data = user_data; @@ -276,9 +279,10 @@ gboolean fl_engine_send_platform_message_response( gsize data_length = 0; const uint8_t* data = nullptr; - if (response != nullptr) + if (response != nullptr) { data = static_cast(g_bytes_get_data(response, &data_length)); + } FlutterEngineResult result = FlutterEngineSendPlatformMessageResponse( self->engine, handle, data, data_length); diff --git a/shell/platform/linux/fl_json_message_codec.cc b/shell/platform/linux/fl_json_message_codec.cc index 20e1008029f..d840264b6ee 100644 --- a/shell/platform/linux/fl_json_message_codec.cc +++ b/shell/platform/linux/fl_json_message_codec.cc @@ -259,10 +259,11 @@ static FlValue* fl_json_message_codec_decode_message(FlMessageCodec* codec, if (handler.error != nullptr) { g_propagate_error(error, handler.error); handler.error = nullptr; - } else + } else { g_set_error(error, FL_JSON_MESSAGE_CODEC_ERROR, FL_JSON_MESSAGE_CODEC_ERROR_INVALID_JSON, "Message is not valid JSON"); + } return nullptr; } diff --git a/shell/platform/linux/fl_json_method_codec_test.cc b/shell/platform/linux/fl_json_method_codec_test.cc index c994500ca42..1b662cf0c24 100644 --- a/shell/platform/linux/fl_json_method_codec_test.cc +++ b/shell/platform/linux/fl_json_method_codec_test.cc @@ -119,22 +119,24 @@ static void decode_response_with_error(const char* text, EXPECT_STREQ( fl_method_error_response_get_code(FL_METHOD_ERROR_RESPONSE(response)), code); - if (error_message == nullptr) + if (error_message == nullptr) { EXPECT_EQ(fl_method_error_response_get_message( FL_METHOD_ERROR_RESPONSE(response)), nullptr); - else + } else { EXPECT_STREQ(fl_method_error_response_get_message( FL_METHOD_ERROR_RESPONSE(response)), error_message); - if (details == nullptr) + } + if (details == nullptr) { EXPECT_EQ(fl_method_error_response_get_details( FL_METHOD_ERROR_RESPONSE(response)), nullptr); - else + } else { EXPECT_TRUE(fl_value_equal(fl_method_error_response_get_details( FL_METHOD_ERROR_RESPONSE(response)), details)); + } } // Decode a response using JsonMethodCodec. Expect the given error. diff --git a/shell/platform/linux/fl_key_event_plugin.cc b/shell/platform/linux/fl_key_event_plugin.cc index 2a436c33404..dbab7cac642 100644 --- a/shell/platform/linux/fl_key_event_plugin.cc +++ b/shell/platform/linux/fl_key_event_plugin.cc @@ -246,9 +246,10 @@ void fl_key_event_plugin_send_key_event(FlKeyEventPlugin* self, fl_value_new_string(kGLFWToolkit)); fl_value_set_string_take(message, kKeyCodeKey, fl_value_new_int(key_code)); fl_value_set_string_take(message, kModifiersKey, fl_value_new_int(modifiers)); - if (unicodeScalarValues != 0) + if (unicodeScalarValues != 0) { fl_value_set_string_take(message, kUnicodeScalarValuesKey, fl_value_new_int(unicodeScalarValues)); + } fl_basic_message_channel_send(self->channel, message, nullptr, nullptr, nullptr); diff --git a/shell/platform/linux/fl_method_channel.cc b/shell/platform/linux/fl_method_channel.cc index 843c0b042da..3d130083dc5 100644 --- a/shell/platform/linux/fl_method_channel.cc +++ b/shell/platform/linux/fl_method_channel.cc @@ -86,9 +86,10 @@ static void channel_closed_cb(gpointer user_data) { static void fl_method_channel_dispose(GObject* object) { FlMethodChannel* self = FL_METHOD_CHANNEL(object); - if (self->messenger != nullptr) + if (self->messenger != nullptr) { fl_binary_messenger_set_message_handler_on_channel( self->messenger, self->name, nullptr, nullptr, nullptr); + } g_clear_object(&self->messenger); g_clear_pointer(&self->name, g_free); diff --git a/shell/platform/linux/fl_method_codec_test.cc b/shell/platform/linux/fl_method_codec_test.cc index b52e91c31b8..361244a1b21 100644 --- a/shell/platform/linux/fl_method_codec_test.cc +++ b/shell/platform/linux/fl_method_codec_test.cc @@ -46,10 +46,10 @@ static GBytes* fl_test_codec_encode_method_call(FlMethodCodec* codec, g_autofree gchar* text = nullptr; if (args == nullptr || fl_value_get_type(args) == FL_VALUE_TYPE_NULL) text = g_strdup_printf("%s()", name); - else if (fl_value_get_type(args) == FL_VALUE_TYPE_INT) + else if (fl_value_get_type(args) == FL_VALUE_TYPE_INT) { text = g_strdup_printf("%s(%" G_GINT64_FORMAT ")", name, fl_value_get_int(args)); - else { + } else { g_set_error(error, FL_MESSAGE_CODEC_ERROR, FL_MESSAGE_CODEC_ERROR_FAILED, "ERROR"); return nullptr; @@ -117,15 +117,17 @@ static GBytes* fl_test_codec_encode_error_envelope(FlMethodCodec* codec, if (message == nullptr) { if (details == nullptr || fl_value_get_type(details) == FL_VALUE_TYPE_NULL) text = g_strdup_printf("Error_%s()", code); - else + else { text = g_strdup_printf("Error_%s(%" G_GINT64_FORMAT ")", code, fl_value_get_int(details)); + } } else { if (details == nullptr || fl_value_get_type(details) == FL_VALUE_TYPE_NULL) text = g_strdup_printf("Error_%s(%s)", code, message); - else + else { text = g_strdup_printf("Error_%s(%s,%" G_GINT64_FORMAT ")", code, message, fl_value_get_int(details)); + } } return text_to_message(text); diff --git a/shell/platform/linux/fl_method_response.cc b/shell/platform/linux/fl_method_response.cc index 6f7f09ee867..cc0964b1223 100644 --- a/shell/platform/linux/fl_method_response.cc +++ b/shell/platform/linux/fl_method_response.cc @@ -81,9 +81,10 @@ static void fl_method_not_implemented_response_init( G_MODULE_EXPORT FlValue* fl_method_response_get_result(FlMethodResponse* self, GError** error) { - if (FL_IS_METHOD_SUCCESS_RESPONSE(self)) + if (FL_IS_METHOD_SUCCESS_RESPONSE(self)) { return fl_method_success_response_get_result( FL_METHOD_SUCCESS_RESPONSE(self)); + } if (FL_IS_METHOD_ERROR_RESPONSE(self)) { const gchar* code = diff --git a/shell/platform/linux/fl_standard_method_codec_test.cc b/shell/platform/linux/fl_standard_method_codec_test.cc index ef0b55458dc..8309b7bccc2 100644 --- a/shell/platform/linux/fl_standard_method_codec_test.cc +++ b/shell/platform/linux/fl_standard_method_codec_test.cc @@ -114,22 +114,24 @@ static void decode_response_with_error(const char* hex_string, EXPECT_STREQ( fl_method_error_response_get_code(FL_METHOD_ERROR_RESPONSE(response)), code); - if (error_message == nullptr) + if (error_message == nullptr) { EXPECT_EQ(fl_method_error_response_get_message( FL_METHOD_ERROR_RESPONSE(response)), nullptr); - else + } else { EXPECT_STREQ(fl_method_error_response_get_message( FL_METHOD_ERROR_RESPONSE(response)), error_message); - if (details == nullptr) + } + if (details == nullptr) { EXPECT_EQ(fl_method_error_response_get_details( FL_METHOD_ERROR_RESPONSE(response)), nullptr); - else + } else { EXPECT_TRUE(fl_value_equal(fl_method_error_response_get_details( FL_METHOD_ERROR_RESPONSE(response)), details)); + } } static void decode_error_response(const char* hex_string, diff --git a/shell/platform/linux/fl_view.cc b/shell/platform/linux/fl_view.cc index 9703e528031..582d08b32e2 100644 --- a/shell/platform/linux/fl_view.cc +++ b/shell/platform/linux/fl_view.cc @@ -209,10 +209,11 @@ static void fl_view_size_allocate(GtkWidget* widget, gtk_widget_set_allocation(widget, allocation); - if (gtk_widget_get_realized(widget) && gtk_widget_get_has_window(widget)) + if (gtk_widget_get_realized(widget) && gtk_widget_get_has_window(widget)) { gdk_window_move_resize(gtk_widget_get_window(widget), allocation->x, allocation->y, allocation->width, allocation->height); + } // TODO(robert-ancell): This pixel ratio won't work on hidpi displays. fl_engine_send_window_metrics_event(self->engine, allocation->width,