Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Showing the about panel is async on all platforms #37508

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/api/app.md
Expand Up @@ -1357,7 +1357,7 @@ This API must be called after the `ready` event is emitted.

### `app.showAboutPanel()`

Show the app's about panel options. These options can be overridden with `app.setAboutPanelOptions(options)`.
Show the app's about panel options. These options can be overridden with `app.setAboutPanelOptions(options)`. This function runs asynchronously.

### `app.setAboutPanelOptions(options)`

Expand Down
7 changes: 5 additions & 2 deletions shell/browser/browser_linux.cc
Expand Up @@ -212,8 +212,11 @@ void Browser::ShowAboutPanel() {
}
}

gtk_dialog_run(GTK_DIALOG(dialog));
gtk_widget_destroy(dialogWidget);
// destroy the widget when it closes
g_signal_connect_swapped(dialogWidget, "response",
G_CALLBACK(gtk_widget_destroy), dialogWidget);

gtk_widget_show_all(dialogWidget);
}

void Browser::SetAboutPanelOptions(base::Value::Dict options) {
Expand Down
4 changes: 3 additions & 1 deletion shell/browser/browser_win.cc
Expand Up @@ -2,6 +2,7 @@
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.

#include "base/functional/bind.h"
#include "shell/browser/browser.h"

// must come before other includes. fixes bad #defines from <shlwapi.h>.
Expand Down Expand Up @@ -765,7 +766,8 @@ void Browser::ShowAboutPanel() {
settings.message = aboutMessage;
settings.icon = image;
settings.type = electron::MessageBoxType::kInformation;
electron::ShowMessageBoxSync(settings);
electron::ShowMessageBox(settings,
base::BindOnce([](int, bool) { /* do nothing. */ }));
}

void Browser::SetAboutPanelOptions(base::Value::Dict options) {
Expand Down
4 changes: 4 additions & 0 deletions spec/api-app-spec.ts
Expand Up @@ -1871,6 +1871,10 @@ describe('app module', () => {
version: '1.2.3'
});
});

it('app.showAboutPanel() does not crash & runs asynchronously', () => {
app.showAboutPanel();
});
});
});

Expand Down