Work around a compiler bug that crashes on Windows

This commit is contained in:
Cheng Zhao 2016-06-16 10:54:28 +09:00
parent 9267004b53
commit bb10551d23
3 changed files with 13 additions and 4 deletions

View file

@ -266,13 +266,22 @@ WebContents::WebContents(v8::Isolate* isolate,
WebContents::WebContents(v8::Isolate* isolate, WebContents::WebContents(v8::Isolate* isolate,
const mate::Dictionary& options) const mate::Dictionary& options)
: embedder_(nullptr), : embedder_(nullptr),
type_(BROWSER_WINDOW),
request_id_(0), request_id_(0),
background_throttling_(true) { background_throttling_(true) {
// Read options. // Read options.
options.Get("backgroundThrottling", &background_throttling_); options.Get("backgroundThrottling", &background_throttling_);
type_ = BROWSER_WINDOW; // FIXME(zcbenz): We should read "type" parameter for better design, but
options.Get("type", &type_); // on Windows we have encountered a compiler bug that if we read "type"
// from |options| and then set |type_|, a memory corruption will happen
// and Electron will soon crash.
// Remvoe this after we upgraded to use VS 2015 Update 3.
bool b = false;
if (options.Get("isGuest", &b) && b)
type_ = WEB_VIEW;
else if (options.Get("isBackgroundPage", &b) && b)
type_ = BACKGROUND_PAGE;
// Obtain the session. // Obtain the session.
std::string partition; std::string partition;

View file

@ -78,7 +78,7 @@ const startBackgroundPages = function (manifest) {
const html = new Buffer(`<html><body>${scripts}</body></html>`) const html = new Buffer(`<html><body>${scripts}</body></html>`)
const contents = webContents.create({ const contents = webContents.create({
type: 'backgroundPage', isBackgroundPage: true,
commandLineSwitches: ['--background-page'] commandLineSwitches: ['--background-page']
}) })
backgroundPages[manifest.extensionId] = { html: html, webContents: contents } backgroundPages[manifest.extensionId] = { html: html, webContents: contents }

View file

@ -63,7 +63,7 @@ const createGuest = function (embedder, params) {
const id = getNextInstanceId(embedder) const id = getNextInstanceId(embedder)
const guest = webContents.create({ const guest = webContents.create({
type: 'webview', isGuest: true,
partition: params.partition, partition: params.partition,
embedder: embedder embedder: embedder
}) })