|
2 | 2 | # License: New BSD License. |
3 | 3 | # Website: http://code.google.com/p/cefpython/ |
4 | 4 |
|
5 | | -# PyWebRequests are kept int a C++ map and not in a Python Dict, |
6 | | -# as we do not want to increase references for them, the |
7 | | -# deallocation will happen in PyRequest.__dealloc__(). We must |
8 | | -# keep callbacks (OnStateChange and others) and they must be |
9 | | -# callable from C++ code, thus we need to keep PyWebRequests |
10 | | -# objects in some global scope, if we put PyWebRequests in a |
11 | | -# Python Dict then we would never know of when PyWebRequest |
12 | | -# global reference can be released, thus the memory for these |
13 | | -# objects would live forever. |
14 | | -# - using uintptr_t instead of void* as it resulted in compiler |
15 | | -# crash |
16 | | -# - Casting void* to python object example (see PyWebRequest.__dealloc__): |
17 | | -# cdef void* a |
18 | | -# cdef PyWebRequest b = <PyWebRequest>a |
19 | | -# - todo: instead of the C++ map and __dealloc__, try using |
20 | | -# WeakValueDictionary and cdef object __weakref__ on PyWebRequest, |
21 | | -# see weak referencing: |
22 | | -# http://docs.cython.org/src/reference/extension_types.html#weak-referencing |
23 | | -#cdef cpp_map[int, PyObject*] g_pyWebRequests |
24 | | - |
25 | 5 | # TODO: temporarily removed weakref.WeakValueDictionary() |
26 | 6 | cdef object g_pyWebRequests = {} |
27 | 7 | cdef int g_webRequestMaxId = 0 |
@@ -69,9 +49,7 @@ cdef PyWebRequest CreatePyWebRequest(PyRequest request, |
69 | 49 | cdef PyWebRequest GetPyWebRequest(int webRequestId): |
70 | 50 | global g_pyWebRequests |
71 | 51 | if webRequestId in g_pyWebRequests: |
72 | | - # Debug("GetPyWebRequest(): found webRequestId = %s" % webRequestId) |
73 | 52 | return g_pyWebRequests[webRequestId] |
74 | | - # Debug("GetPyWebRequest(): not found webRequestId = %s" % webRequestId) |
75 | 53 | return None |
76 | 54 |
|
77 | 55 | cdef class PyWebRequest: |
|
0 commit comments