@@ -373,8 +373,17 @@ def CreateMenu(self):
373373 self .SetMenuBar (menubar )
374374
375375 def OnClose (self , event ):
376- self .browser .CloseBrowser ()
377- self .Destroy ()
376+ # In wx.chromectrl calling browser.CloseBrowser() and/or
377+ # self.Destroy() in OnClose is causing crashes when embedding
378+ # multiple browser tabs. The solution is to call only
379+ # browser.ParentWindowWillClose. Behavior of this example
380+ # seems different as it extends wx.Frame, while ChromeWindow
381+ # from chromectrl extends wx.Window. Calling CloseBrowser
382+ # and Destroy does not cause crashes, but is not recommended.
383+ # Call ParentWindowWillClose and event.Skip() instead. See
384+ # also Issue 107.
385+ self .browser .ParentWindowWillClose ()
386+ event .Skip ()
378387
379388 def OnIdle (self , event ):
380389 cefpython .MessageLoopWork ()
@@ -415,7 +424,7 @@ def OnExit(self):
415424if __name__ == '__main__' :
416425 sys .excepthook = ExceptHook
417426 settings = {
418- "debug" : False # cefpython debug messages in console and in log_file
427+ "debug" : False , # cefpython debug messages in console and in log_file
419428 "log_severity" : cefpython .LOGSEVERITY_INFO , # LOGSEVERITY_VERBOSE
420429 "log_file" : GetApplicationPath ("debug.log" ), # Set to "" to disable.
421430 "release_dcheck_enabled" : True , # Enable only when debugging.
0 commit comments