X Tutup
Skip to content

Commit c546957

Browse files
committed
Fix GetCookieManager 'browser' param NULL exception (cztomczak#429)
1 parent 322389d commit c546957

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

api/RequestHandler.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,9 @@ is the URL of the top-level frame. Cookies managers can be unique
206206
per browser or shared across multiple browsers. The global cookie
207207
manager will be used if this method returns None.
208208

209+
**IMPORTANT**: In some cases the `browser` parameter can be
210+
None, so you should handle such case.
211+
209212
To successfully implement separate cookie manager per browser session,
210213
you have to set ApplicationSettings.`unique_request_context_per_browser`
211214
to True. Otherwise the browser param passed to this callback will
@@ -221,9 +224,6 @@ the window on your own and embed browser in it.
221224
The `CreateAnotherBrowser` function from the old v31 wxpython
222225
example does that.
223226

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

228228

229229
### OnProtocolExecution

docs/Migration-guide.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ Table of contents:
4444
* [v66+ BrowserSettings.javascript_open_windows_disallowed option was removed](#v66-browsersettingsjavascript_open_windows_disallowed-option-was-removed)
4545
* [v66+ Threads removed: TID_DB, TID_PROCESS_LAUNCHER, TID_CACHE](#v66-threads-removed-tid_db-tid_process_launcher-tid_cache)
4646
* [v66+ cef.Request.Flags changed](#v66-cefrequestflags-changed)
47+
* [v66+ RequestHandler.GetCookieManager 'browser' param may be None](#v66-requesthandlergetcookiemanager-browser-param-may-be-none)
4748

4849

4950

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

380+
381+
## v66+ RequestHandler.GetCookieManager 'browser' param may be None
382+
383+
In some cases in RequestHandler.[GetCookieManager](../api/RequestHandler.md#getcookiemanager)
384+
callback, the `browser` parameter may be None due to a race condition.
385+
See Issue [#429](../../../issues/429) for details.
386+

src/handlers/request_handler.pyx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,10 @@ cdef public CefRefPtr[CefCookieManager] RequestHandler_GetCookieManager(
291291
cdef object clientCallback
292292
cdef PyCookieManager returnValue
293293
try:
294-
pyBrowser = GetPyBrowser(cefBrowser, "GetCookieManager")
294+
if cefBrowser.get():
295+
pyBrowser = GetPyBrowser(cefBrowser, "GetCookieManager")
296+
else:
297+
pyBrowser = None
295298
pyMainUrl = CefToPyString(cefMainUrl)
296299
if pyBrowser:
297300
# Browser may be empty.

0 commit comments

Comments
 (0)
X Tutup