Skip to content

Commit

Permalink
Add braces around multi-line branches to match code style (flutter#18719
Browse files Browse the repository at this point in the history
)
  • Loading branch information
robert-ancell authored Jun 2, 2020
1 parent 6589dcb commit 1b4d958
Show file tree
Hide file tree
Showing 12 changed files with 42 additions and 25 deletions.
3 changes: 2 additions & 1 deletion shell/platform/linux/fl_basic_message_channel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions shell/platform/linux/fl_binary_messenger.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
3 changes: 2 additions & 1 deletion shell/platform/linux/fl_dart_project.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
12 changes: 8 additions & 4 deletions shell/platform/linux/fl_engine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;

Expand Down Expand Up @@ -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;
Expand All @@ -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<const uint8_t*>(g_bytes_get_data(response, &data_length));
}
FlutterEngineResult result = FlutterEngineSendPlatformMessageResponse(
self->engine, handle, data, data_length);

Expand Down
3 changes: 2 additions & 1 deletion shell/platform/linux/fl_json_message_codec.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
10 changes: 6 additions & 4 deletions shell/platform/linux/fl_json_method_codec_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 2 additions & 1 deletion shell/platform/linux/fl_key_event_plugin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion shell/platform/linux/fl_method_channel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
10 changes: 6 additions & 4 deletions shell/platform/linux/fl_method_codec_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion shell/platform/linux/fl_method_response.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
10 changes: 6 additions & 4 deletions shell/platform/linux/fl_standard_method_codec_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion shell/platform/linux/fl_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 1b4d958

Please sign in to comment.