From 9908cc363a9522937f8bb47579efae241525ed70 Mon Sep 17 00:00:00 2001 From: Mimi <1119186082@qq.com> Date: Thu, 10 Dec 2020 07:28:56 +0800 Subject: [PATCH] fix: message box missing an "OK" button in GTK (#26857) --- shell/browser/ui/message_box_gtk.cc | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/shell/browser/ui/message_box_gtk.cc b/shell/browser/ui/message_box_gtk.cc index b74d6d0c59f0..739f4a8de8e2 100644 --- a/shell/browser/ui/message_box_gtk.cc +++ b/shell/browser/ui/message_box_gtk.cc @@ -87,9 +87,13 @@ class GtkMessageBox : public NativeWindowObserver { // Add buttons. GtkDialog* dialog = GTK_DIALOG(dialog_); - for (size_t i = 0; i < settings.buttons.size(); ++i) { - gtk_dialog_add_button(dialog, TranslateToStock(i, settings.buttons[i]), - i); + if (settings.buttons.size() == 0) { + gtk_dialog_add_button(dialog, TranslateToStock(0, "OK"), 0); + } else { + for (size_t i = 0; i < settings.buttons.size(); ++i) { + gtk_dialog_add_button(dialog, TranslateToStock(i, settings.buttons[i]), + i); + } } gtk_dialog_set_default_response(dialog, settings.default_id); @@ -220,7 +224,7 @@ void ShowErrorBox(const base::string16& title, const base::string16& content) { if (Browser::Get()->is_ready()) { electron::MessageBoxSettings settings; settings.type = electron::MessageBoxType::kError; - settings.buttons = {"OK"}; + settings.buttons = {}; settings.title = "Error"; settings.message = base::UTF16ToUTF8(title); settings.detail = base::UTF16ToUTF8(content);