fix: about panel crash (#37373)

* fix: about panel is a base::Value::Dict

* nix this test for a diff PR
This commit is contained in:
Calvin 2023-02-28 15:26:00 -07:00 committed by GitHub
parent 3a5ae28c95
commit 2e03bdb9b6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 30 additions and 29 deletions

View file

@ -162,31 +162,25 @@ bool Browser::IsEmojiPanelSupported() {
void Browser::ShowAboutPanel() {
const auto& opts = about_panel_options_;
if (!opts.is_dict()) {
LOG(WARNING) << "Called showAboutPanel(), but didn't use "
"setAboutPanelSettings() first";
return;
}
GtkWidget* dialogWidget = gtk_about_dialog_new();
GtkAboutDialog* dialog = GTK_ABOUT_DIALOG(dialogWidget);
const std::string* str;
const base::Value* val;
const base::Value::List* list;
if ((str = opts.FindStringKey("applicationName"))) {
if ((str = opts.FindString("applicationName"))) {
gtk_about_dialog_set_program_name(dialog, str->c_str());
}
if ((str = opts.FindStringKey("applicationVersion"))) {
if ((str = opts.FindString("applicationVersion"))) {
gtk_about_dialog_set_version(dialog, str->c_str());
}
if ((str = opts.FindStringKey("copyright"))) {
if ((str = opts.FindString("copyright"))) {
gtk_about_dialog_set_copyright(dialog, str->c_str());
}
if ((str = opts.FindStringKey("website"))) {
if ((str = opts.FindString("website"))) {
gtk_about_dialog_set_website(dialog, str->c_str());
}
if ((str = opts.FindStringKey("iconPath"))) {
if ((str = opts.FindString("iconPath"))) {
GError* error = nullptr;
constexpr int width = 64; // width of about panel icon in pixels
constexpr int height = 64; // height of about panel icon in pixels
@ -203,9 +197,9 @@ void Browser::ShowAboutPanel() {
}
}
if ((val = opts.FindListKey("authors"))) {
if ((list = opts.FindList("authors"))) {
std::vector<const char*> cstrs;
for (const auto& authorVal : val->GetList()) {
for (const auto& authorVal : *list) {
if (authorVal.is_string()) {
cstrs.push_back(authorVal.GetString().c_str());
}
@ -223,7 +217,7 @@ void Browser::ShowAboutPanel() {
}
void Browser::SetAboutPanelOptions(base::Value::Dict options) {
about_panel_options_ = base::Value(std::move(options));
about_panel_options_ = std::move(options);
}
} // namespace electron