Skip to content

Commit

Permalink
Fix GetCookieManager 'browser' param NULL exception (#429)
Browse files Browse the repository at this point in the history
  • Loading branch information
cztomczak committed May 25, 2018
1 parent 322389d commit c546957
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
6 changes: 3 additions & 3 deletions api/RequestHandler.md
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,9 @@ is the URL of the top-level frame. Cookies managers can be unique
per browser or shared across multiple browsers. The global cookie
manager will be used if this method returns None.

**IMPORTANT**: In some cases the `browser` parameter can be
None, so you should handle such case.

To successfully implement separate cookie manager per browser session,
you have to set ApplicationSettings.`unique_request_context_per_browser`
to True. Otherwise the browser param passed to this callback will
Expand All @@ -221,9 +224,6 @@ the window on your own and embed browser in it.
The `CreateAnotherBrowser` function from the old v31 wxpython
example does that.

IMPORTANT: in an exceptional case the `browser` parameter could be
None, so you should handle such case. During testing this issue did
not occur, but it may happen in some yet unknown scenarios.


### OnProtocolExecution
Expand Down
8 changes: 8 additions & 0 deletions docs/Migration-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ Table of contents:
* [v66+ BrowserSettings.javascript_open_windows_disallowed option was removed](#v66-browsersettingsjavascript_open_windows_disallowed-option-was-removed)
* [v66+ Threads removed: TID_DB, TID_PROCESS_LAUNCHER, TID_CACHE](#v66-threads-removed-tid_db-tid_process_launcher-tid_cache)
* [v66+ cef.Request.Flags changed](#v66-cefrequestflags-changed)
* [v66+ RequestHandler.GetCookieManager 'browser' param may be None](#v66-requesthandlergetcookiemanager-browser-param-may-be-none)



Expand Down Expand Up @@ -376,3 +377,10 @@ Flags added:
See a complete list of flags in the description of
cef.Request.[GetFlags](../api/Request.md#getflags) method.


## v66+ RequestHandler.GetCookieManager 'browser' param may be None

In some cases in RequestHandler.[GetCookieManager](../api/RequestHandler.md#getcookiemanager)
callback, the `browser` parameter may be None due to a race condition.
See Issue [#429](../../../issues/429) for details.

5 changes: 4 additions & 1 deletion src/handlers/request_handler.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,10 @@ cdef public CefRefPtr[CefCookieManager] RequestHandler_GetCookieManager(
cdef object clientCallback
cdef PyCookieManager returnValue
try:
pyBrowser = GetPyBrowser(cefBrowser, "GetCookieManager")
if cefBrowser.get():
pyBrowser = GetPyBrowser(cefBrowser, "GetCookieManager")
else:
pyBrowser = None
pyMainUrl = CefToPyString(cefMainUrl)
if pyBrowser:
# Browser may be empty.
Expand Down

0 comments on commit c546957

Please sign in to comment.