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: ensure popup and closepopup are threaded correctly #20114

Merged
merged 1 commit into from Sep 5, 2019
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
1 change: 1 addition & 0 deletions shell/browser/api/atom_api_menu_mac.h
Expand Up @@ -35,6 +35,7 @@ class MenuMac : public Menu {
int positioning_item,
base::Closure callback);
void ClosePopupAt(int32_t window_id) override;
void ClosePopupOnUI(int32_t window_id);

private:
friend class Menu;
Expand Down
9 changes: 8 additions & 1 deletion shell/browser/api/atom_api_menu_mac.mm
Expand Up @@ -48,7 +48,7 @@
base::BindOnce(&MenuMac::PopupOnUI, weak_factory_.GetWeakPtr(),
native_window->GetWeakPtr(), window->weak_map_id(), x, y,
positioning_item, callback);
base::PostTaskWithTraits(FROM_HERE, {BrowserThread::UI}, std::move(popup));
base::SequencedTaskRunnerHandle::Get()->PostTask(FROM_HERE, std::move(popup));
}

void MenuMac::PopupOnUI(const base::WeakPtr<NativeWindow>& native_window,
Expand Down Expand Up @@ -117,6 +117,13 @@
}

void MenuMac::ClosePopupAt(int32_t window_id) {
auto close_popup = base::BindOnce(&MenuMac::ClosePopupOnUI,
weak_factory_.GetWeakPtr(), window_id);
base::SequencedTaskRunnerHandle::Get()->PostTask(FROM_HERE,
std::move(close_popup));
}

void MenuMac::ClosePopupOnUI(int32_t window_id) {
auto controller = popup_controllers_.find(window_id);
if (controller != popup_controllers_.end()) {
// Close the controller for the window.
Expand Down