Make sure we append parent->child_windows after InitWith
This commit is contained in:
parent
c090dd2f81
commit
cfed9fa4b9
2 changed files with 18 additions and 7 deletions
|
@ -99,13 +99,6 @@ TopLevelWindow::TopLevelWindow(v8::Isolate* isolate,
|
|||
if (options.Get(options::kIcon, &icon) && !icon.IsEmpty())
|
||||
SetIcon(icon);
|
||||
#endif
|
||||
|
||||
AttachAsUserData(window_.get());
|
||||
|
||||
// We can only append this window to parent window's child windows after this
|
||||
// window's JS wrapper gets initialized.
|
||||
if (!parent.IsEmpty())
|
||||
parent->child_windows_.Set(isolate, weak_map_id(), wrapper);
|
||||
}
|
||||
|
||||
TopLevelWindow::~TopLevelWindow() {
|
||||
|
@ -117,6 +110,21 @@ TopLevelWindow::~TopLevelWindow() {
|
|||
base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, window_.release());
|
||||
}
|
||||
|
||||
void TopLevelWindow::InitWith(v8::Isolate* isolate,
|
||||
v8::Local<v8::Object> wrapper) {
|
||||
AttachAsUserData(window_.get());
|
||||
mate::TrackableObject<TopLevelWindow>::InitWith(isolate, wrapper);
|
||||
|
||||
// We can only append this window to parent window's child windows after this
|
||||
// window's JS wrapper gets initialized.
|
||||
if (!parent_window_.IsEmpty()) {
|
||||
mate::Handle<TopLevelWindow> parent;
|
||||
mate::ConvertFromV8(isolate, GetParentWindow(), &parent);
|
||||
DCHECK(!parent.IsEmpty());
|
||||
parent->child_windows_.Set(isolate, weak_map_id(), wrapper);
|
||||
}
|
||||
}
|
||||
|
||||
void TopLevelWindow::WillCloseWindow(bool* prevent_default) {
|
||||
*prevent_default = Emit("close");
|
||||
}
|
||||
|
|
|
@ -40,6 +40,9 @@ class TopLevelWindow : public mate::TrackableObject<TopLevelWindow>,
|
|||
const mate::Dictionary& options);
|
||||
~TopLevelWindow() override;
|
||||
|
||||
// TrackableObject:
|
||||
void InitWith(v8::Isolate* isolate, v8::Local<v8::Object> wrapper) override;
|
||||
|
||||
// NativeWindowObserver:
|
||||
void WillCloseWindow(bool* prevent_default) override;
|
||||
void OnWindowClosed() override;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue