fix: menu should not be garbage-collected when popuping (#21169)
* fix: retain menu when popuping * test: menu should not be garbage-collected when popuping
This commit is contained in:
parent
ea23f18e94
commit
50f2d2b5ab
9 changed files with 82 additions and 33 deletions
|
@ -12,7 +12,6 @@
|
|||
#include "gin/arguments.h"
|
||||
#include "shell/browser/api/atom_api_top_level_window.h"
|
||||
#include "shell/browser/ui/atom_menu_model.h"
|
||||
#include "shell/common/gin_helper/locker.h"
|
||||
#include "shell/common/gin_helper/trackable_object.h"
|
||||
|
||||
namespace electron {
|
||||
|
@ -62,7 +61,7 @@ class Menu : public gin_helper::TrackableObject<Menu>,
|
|||
int x,
|
||||
int y,
|
||||
int positioning_item,
|
||||
const base::Closure& callback) = 0;
|
||||
base::OnceClosure callback) = 0;
|
||||
virtual void ClosePopupAt(int32_t window_id) = 0;
|
||||
|
||||
std::unique_ptr<AtomMenuModel> model_;
|
||||
|
@ -72,6 +71,11 @@ class Menu : public gin_helper::TrackableObject<Menu>,
|
|||
void OnMenuWillClose() override;
|
||||
void OnMenuWillShow() override;
|
||||
|
||||
protected:
|
||||
// Returns a new callback which keeps references of the JS wrapper until the
|
||||
// passed |callback| is called.
|
||||
base::OnceClosure BindSelfToClosure(base::OnceClosure callback);
|
||||
|
||||
private:
|
||||
void InsertItemAt(int index, int command_id, const base::string16& label);
|
||||
void InsertSeparatorAt(int index);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue