A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/cztomczak/cefpython/commit/ec1ce788373bb9e0fd2cedd71e900c3877e9185a below:

CreateBrowserSync, Shutdown and others are now called without · cztomczak/cefpython@ec1ce78 · GitHub

53 53

#

54 54

# - Declaring C++ classes in Cython. Storing python callbacks

55 55

# in a C++ class using Py_INCREF, Py_DECREF. Calling from

56 -

# C++ using PyObject_CallMethod.

56 +

# C++ using PyObject_CallMethod.

57 57

# | http://stackoverflow.com/a/17070382/623622

58 -

# Disadvantage: when calling python callback from the C++ class

58 +

# Disadvantage: when calling python callback from the C++ class

59 59

# declared in Cython there is no easy way to propagate the python

60 60

# exceptions when they occur during execution of the callback.

61 61

#

62 62

# - | cdef char* other_c_string = py_string

63 -

# This is a very fast operation after which other_c_string points

64 -

# to the byte string buffer of the Python string itself. It is

65 -

# tied to the life time of the Python string. When the Python

63 +

# This is a very fast operation after which other_c_string points

64 +

# to the byte string buffer of the Python string itself. It is

65 +

# tied to the life time of the Python string. When the Python

66 66

# string is garbage collected, the pointer becomes invalid.

67 67

#

68 68

# - Do not define cpdef functions returning "cpp_bool":

@@ -172,22 +172,20 @@ IF CEF_VERSION == 3:

172 172

include "response_cef3.pyx"

173 173

include "web_request_cef3.pyx"

174 174 175 +

# Linux issue:

176 +

# ------------

175 177

# Try not to run any of the CEF code until Initialize() is called.

176 -

# Do not allocate any memory on the heap until Initialize() is called,

177 -

# that's why we're not instantiating the ClientHandler class here in

178 -

# the declaration. CEF hooks up its own tcmalloc globally when the

179 -

# library is loaded, but the memory allocation implementation may still

180 -

# be changed by another library (wx/gtk) before Initialize() is called.

181 -

cdef CefRefPtr[ClientHandler] g_clientHandler

178 +

# Do not allocate any memory on the heap until Initialize() is called.

179 +

# CEF hooks up its own tcmalloc globally when the library is loaded,

180 +

# but the memory allocation implementation may still be changed by

181 +

# another library (wx/gtk) before Initialize() is called.

182 +

# See Issue 73:

183 +

# https://code.google.com/p/cefpython/issues/detail?id=73

182 184 183 185

def Initialize(applicationSettings=None):

184 186

Debug("-" * 60)

185 187

Debug("Initialize() called")

186 188 187 -

global g_clientHandler

188 -

if not g_clientHandler.get():

189 -

g_clientHandler = <CefRefPtr[ClientHandler]?>new ClientHandler()

190 - 191 189

cdef CefRefPtr[CefApp] cefApp

192 190 193 191

IF CEF_VERSION == 3:

@@ -198,7 +196,9 @@ def Initialize(applicationSettings=None):

198 196

ELIF UNAME_SYSNAME == "Linux":

199 197

# TODO: use the CefMainArgs(int argc, char** argv) constructor.

200 198

cdef CefMainArgs cefMainArgs

201 -

cdef int exitCode = CefExecuteProcess(cefMainArgs, cefApp)

199 +

cdef int exitCode = 1

200 +

with nogil:

201 +

exitCode = CefExecuteProcess(cefMainArgs, cefApp)

202 202

Debug("CefExecuteProcess(): exitCode = %s" % exitCode)

203 203

if exitCode >= 0:

204 204

sys.exit(exitCode)

@@ -224,11 +224,14 @@ def Initialize(applicationSettings=None):

224 224

Debug("CefInitialize()")

225 225

cdef cpp_bool ret

226 226

IF CEF_VERSION == 1:

227 -

ret = CefInitialize(cefApplicationSettings, cefApp)

227 +

with nogil:

228 +

ret = CefInitialize(cefApplicationSettings, cefApp)

228 229

ELIF CEF_VERSION == 3:

229 -

ret = CefInitialize(cefMainArgs, cefApplicationSettings, cefApp)

230 +

with nogil:

231 +

ret = CefInitialize(cefMainArgs, cefApplicationSettings, cefApp)

230 232 231 -

if not ret: Debug("CefInitialize() failed")

233 +

if not ret:

234 +

Debug("CefInitialize() failed")

232 235

return ret

233 236 234 237

def CreateBrowserSync(windowInfo, browserSettings, navigateUrl):

@@ -251,10 +254,13 @@ def CreateBrowserSync(windowInfo, browserSettings, navigateUrl):

251 254

PyToCefString(navigateUrl, cefNavigateUrl)

252 255 253 256

Debug("CefBrowser::CreateBrowserSync()")

254 -

global g_clientHandler

255 -

cdef CefRefPtr[CefBrowser] cefBrowser = cef_browser_static.CreateBrowserSync(

256 -

cefWindowInfo, <CefRefPtr[CefClient]?>g_clientHandler, cefNavigateUrl,

257 -

cefBrowserSettings)

257 +

cdef CefRefPtr[ClientHandler] clientHandler =\

258 +

<CefRefPtr[ClientHandler]?>new ClientHandler()

259 +

cdef CefRefPtr[CefBrowser] cefBrowser

260 +

with nogil:

261 +

cefBrowser = cef_browser_static.CreateBrowserSync(

262 +

cefWindowInfo, <CefRefPtr[CefClient]?>clientHandler,

263 +

cefNavigateUrl, cefBrowserSettings)

258 264 259 265

if <void*>cefBrowser == NULL:

260 266

Debug("CefBrowser::CreateBrowserSync() failed")

@@ -269,7 +275,7 @@ def CreateBrowserSync(windowInfo, browserSettings, navigateUrl):

269 275

# Test whether process message sent before renderer thread is created

270 276

# will be delivered - OK.

271 277

# Debug("Sending 'CreateBrowserSync() done' message to the Renderer")

272 -

# pyBrowser.SendProcessMessage(cef_types.PID_RENDERER,

278 +

# pyBrowser.SendProcessMessage(cef_types.PID_RENDERER,

273 279

# "CreateBrowserSync() done")

274 280 275 281

return pyBrowser

@@ -299,14 +305,18 @@ def SingleMessageLoop():

299 305 300 306

def QuitMessageLoop():

301 307

Debug("QuitMessageLoop()")

302 -

CefQuitMessageLoop()

308 +

with nogil:

309 +

CefQuitMessageLoop()

303 310 304 311

def Shutdown():

305 312

Debug("Shutdown()")

306 -

CefShutdown()

313 +

with nogil:

314 +

CefShutdown()

307 315 308 316

def SetOsModalLoop(py_bool modalLoop):

309 -

CefSetOSModalLoop(bool(modalLoop))

317 +

cdef cpp_bool cefModalLoop = bool(modalLoop)

318 +

with nogil:

319 +

CefSetOSModalLoop(cefModalLoop)

310 320 311 321

cpdef py_void SetGlobalClientCallback(py_string name, object callback):

312 322

global g_globalClientCallbacks


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4