mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Add braces around multi-line branches to match code style (#18719)
This commit is contained in:
parent
6589dcb2d4
commit
1b4d958f98
@ -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);
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
@ -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<const uint8_t*>(g_bytes_get_data(response, &data_length));
|
||||
}
|
||||
FlutterEngineResult result = FlutterEngineSendPlatformMessageResponse(
|
||||
self->engine, handle, data, data_length);
|
||||
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
|
||||
@ -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.
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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 =
|
||||
|
||||
@ -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,
|
||||
|
||||
@ -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,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user