@@ -438,12 +438,12 @@ from cef_image cimport *
438438from main_message_loop cimport *
439439# noinspection PyUnresolvedReferences
440440from cef_views cimport *
441+ from cef_log cimport *
441442
442443# -----------------------------------------------------------------------------
443444# GLOBAL VARIABLES
444445
445446g_debug = False
446- g_debugFile = " debug.log"
447447
448448# When put None here and assigned a local dictionary in Initialize(), later
449449# while running app this global variable was garbage collected, see topic:
@@ -462,6 +462,7 @@ cdef scoped_ptr[MainMessageLoopExternalPump] g_external_message_pump
462462
463463cdef py_bool g_MessageLoop_called = False
464464cdef py_bool g_MessageLoopWork_called = False
465+ cdef py_bool g_cef_initialized = False
465466
466467cdef dict g_globalClientCallbacks = {}
467468
@@ -530,14 +531,11 @@ include "handlers/v8function_handler.pyx"
530531# Utility functions to provide settings to the C++ browser process code.
531532
532533cdef public void cefpython_GetDebugOptions(
533- cpp_bool* debug,
534- cpp_string* debugFile
534+ cpp_bool* debug
535535 ) except * with gil:
536536 # Called from subprocess/cefpython_app.cpp -> CefPythonApp constructor.
537- cdef cpp_string cppString = PyStringToChar(g_debugFile)
538537 try :
539538 debug[0 ] = < cpp_bool> bool (g_debug)
540- debugFile.assign(cppString)
541539 except :
542540 (exc_type, exc_value, exc_trace) = sys.exc_info()
543541 sys.excepthook(exc_type, exc_value, exc_trace)
@@ -618,16 +616,17 @@ def Initialize(applicationSettings=None, commandLineSwitches=None, **kwargs):
618616 # Debug settings need to be set before Debug() is called
619617 # and before the CefPythonApp class is instantiated.
620618 global g_debug
621- global g_debugFile
622619 if " --debug" in sys.argv:
623620 application_settings[" debug" ] = True
624- application_settings[" log_file" ] = " debug.log"
625- application_settings[" log_severity" ] = LOGSEVERITY_WARNING
621+ application_settings[" log_file" ] = os.path.join(os.getcwd(),
622+ " debug.log" )
623+ application_settings[" log_severity" ] = LOGSEVERITY_INFO
626624 sys.argv.remove(" --debug" )
627625 if " debug" in application_settings:
628626 g_debug = bool (application_settings[" debug" ])
629- if " log_file" in application_settings:
630- g_debugFile = application_settings[" log_file" ]
627+ if " log_severity" in application_settings:
628+ if application_settings[" log_severity" ] <= LOGSEVERITY_INFO:
629+ g_debug = True
631630
632631 Debug(" Initialize() called" )
633632
@@ -719,11 +718,9 @@ def Initialize(applicationSettings=None, commandLineSwitches=None, **kwargs):
719718 # TODO: use the CefMainArgs(int argc, char** argv) constructor.
720719 cdef CefMainArgs cefMainArgs
721720 cdef int exitCode = 1
722- with nogil:
723- exitCode = CefExecuteProcess(cefMainArgs, cefApp, NULL )
724- Debug(" CefExecuteProcess(): exitCode = %s " % exitCode)
725- if exitCode >= 0 :
726- sys.exit(exitCode)
721+
722+ # NOTE: CefExecuteProcess shall not be called here. It should
723+ # be called only in the subprocess main.cpp.
727724
728725 # Make a copy as applicationSettings is a reference only
729726 # that might get destroyed later.
@@ -755,6 +752,9 @@ def Initialize(applicationSettings=None, commandLineSwitches=None, **kwargs):
755752 with nogil:
756753 ret = CefInitialize(cefMainArgs, cefApplicationSettings, cefApp, NULL )
757754
755+ global g_cef_initialized
756+ g_cef_initialized = True
757+
758758 if not ret:
759759 Debug(" CefInitialize() failed" )
760760
0 commit comments