Skip to content

Commit

Permalink
fix: ensure popup and closepopup are posted in order (#20114)
Browse files Browse the repository at this point in the history
  • Loading branch information
codebytere authored and John Kleinschmidt committed Sep 5, 2019
1 parent 8a0a41b commit 20e3c51
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
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

0 comments on commit 20e3c51

Please sign in to comment.