Skip to content

Commit fc2ea43

Browse files
committed
Disable pinning process for dev reload
Fix nwjs#294. And previous process pinning commit a6493b3 breaks dev reload
1 parent 3f6cbbb commit fc2ea43

File tree

5 files changed

+24
-3
lines changed

5 files changed

+24
-3
lines changed

src/api/window/window.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ Window::Window(int id,
3939
}
4040

4141
Window::~Window() {
42+
// Window object got deleted when we launch new render view host and
43+
// delete the old one; at this time the Shell should be decoupled
44+
// with the renderer side
45+
shell_->set_id(-1);
4246
}
4347

4448
void Window::Call(const std::string& method,

src/nw_shell.cc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
#include "content/nw/src/common/shell_switches.h"
4949
#include "content/nw/src/media/media_stream_devices_controller.h"
5050
#include "content/nw/src/nw_package.h"
51+
#include "content/nw/src/shell_browser_context.h"
5152
#include "content/nw/src/shell_browser_main_parts.h"
5253
#include "content/nw/src/shell_content_browser_client.h"
5354
#include "grit/nw_resources.h"
@@ -208,6 +209,9 @@ void Shell::GoBackOrForward(int offset) {
208209
}
209210

210211
void Shell::Reload(ReloadType type) {
212+
ShellBrowserContext* browser_context =
213+
static_cast<ShellBrowserContext*>(web_contents_->GetBrowserContext());
214+
211215
switch (type) {
212216
case RELOAD:
213217
web_contents_->GetController().Reload(false);
@@ -219,7 +223,11 @@ void Shell::Reload(ReloadType type) {
219223
web_contents_->GetController().ReloadOriginalRequestURL(false);
220224
break;
221225
case RELOAD_DEV:
226+
// ShellContentBrowserClient always tries to use the existing
227+
// process so we need to overwrite it here
228+
browser_context->set_pending_devreload(true);
222229
web_contents_->GetController().ReloadDev(false);
230+
browser_context->set_pending_devreload(false);
223231
break;
224232
}
225233

src/shell_browser_context.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,9 @@ namespace content {
4444

4545
ShellBrowserContext::ShellBrowserContext(bool off_the_record,
4646
nw::Package* package)
47-
: off_the_record_(off_the_record),
48-
package_(package) {
47+
: is_pending_devreload_(false),
48+
off_the_record_(off_the_record),
49+
package_(package) {
4950
InitWhileIOAllowed();
5051
}
5152

src/shell_browser_context.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,14 @@ class ShellBrowserContext : public BrowserContext {
5252
GetSpeechRecognitionPreferences() OVERRIDE;
5353
virtual quota::SpecialStoragePolicy* GetSpecialStoragePolicy() OVERRIDE;
5454

55+
bool pending_devreload() { return is_pending_devreload_; }
56+
void set_pending_devreload(bool val) { is_pending_devreload_ = val; }
5557
private:
5658
// Performs initialization of the ShellBrowserContext while IO is still
5759
// allowed on the current thread.
5860
void InitWhileIOAllowed();
5961

62+
bool is_pending_devreload_; // whether dev reload is in process
6063
bool off_the_record_;
6164
nw::Package* package_;
6265
ScopedTempDir testing_path_;

src/shell_content_browser_client.cc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,12 @@ void ShellContentBrowserClient::OverrideWebkitPrefs(
179179

180180
bool ShellContentBrowserClient::ShouldTryToUseExistingProcessHost(
181181
BrowserContext* browser_context, const GURL& url) {
182-
return true;
182+
ShellBrowserContext* shell_browser_context =
183+
static_cast<ShellBrowserContext*>(browser_context);
184+
if (shell_browser_context->pending_devreload())
185+
return false;
186+
else
187+
return true;
183188
}
184189

185190
bool ShellContentBrowserClient::IsSuitableHost(RenderProcessHost* process_host,

0 commit comments

Comments
 (0)