Skip to content

Commit b875d09

Browse files
committed
Free window object on shell destruction
Fix nwjs#1364
1 parent df3473d commit b875d09

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

src/api/dispatcher_host.cc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,12 +156,13 @@ void DispatcherHost::OnCallObjectMethod(
156156
<< " arguments:" << arguments;
157157

158158
Base* object = GetApiObject(object_id);
159-
DLOG(WARNING) << "Unknown object: " << object_id
159+
if (object)
160+
object->Call(method, arguments);
161+
else
162+
DLOG(WARNING) << "Unknown object: " << object_id
160163
<< " type:" << type
161164
<< " method:" << method
162165
<< " arguments:" << arguments;
163-
if (object)
164-
object->Call(method, arguments);
165166
}
166167

167168
void DispatcherHost::OnCallObjectMethodSync(

src/api/window/window.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,6 @@ exports.Window = {
6464
options.object_id = id;
6565
var routing_id = nw.createShell(url, options);
6666

67-
return new global.Window(routing_id, options['new-instance'], id);
67+
return new global.Window(routing_id, true, id);
6868
}
6969
};

src/nw_shell.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,11 @@ Shell::~Shell() {
191191
}
192192
}
193193

194+
if (!is_devtools_ && id_ > 0) {
195+
nwapi::DispatcherHost* dhost = nwapi::FindDispatcherHost(web_contents_->GetRenderViewHost());
196+
dhost->OnDeallocateObject(id_);
197+
}
198+
194199
for (size_t i = 0; i < windows_.size(); ++i) {
195200
if (windows_[i] == this) {
196201
windows_.erase(windows_.begin() + i);

0 commit comments

Comments
 (0)