Skip to content

Commit 0298d5f

Browse files
committed
Clear object registry before quit
1 parent 070cec8 commit 0298d5f

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

src/api/dispatcher_host.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ FindDispatcherHost(content::RenderViewHost* render_view_host) {
6767
return it->second;
6868
}
6969

70+
void DispatcherHost::ClearObjectRegistry() {
71+
objects_registry_.Clear();
72+
}
73+
7074
Base* DispatcherHost::GetApiObject(int id) {
7175
return objects_registry_.Lookup(id);
7276
}

src/api/dispatcher_host.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ class DispatcherHost : public content::RenderViewHostObserver {
5959
return static_cast<T*>(GetApiObject(id));
6060
}
6161

62+
static void ClearObjectRegistry();
63+
6264
// Send event to C++ object's corresponding js object.
6365
void SendEvent(Base* object,
6466
const std::string& event,

src/nw_shell.cc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,13 @@ Shell::~Shell() {
202202
}
203203
}
204204

205-
if (windows_.empty() && quit_message_loop_)
205+
if (windows_.empty() && quit_message_loop_) {
206+
// If Window object is not clearred here, the Window destructor
207+
// will be called at exit and block the thread exiting on
208+
// Notification registrar destruction
209+
nwapi::DispatcherHost::ClearObjectRegistry();
206210
nwapi::App::Quit(web_contents()->GetRenderProcessHost());
211+
}
207212
}
208213

209214
void Shell::SendEvent(const std::string& event, const std::string& arg1) {

0 commit comments

Comments
 (0)