Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 7bfa0f1

Browse filesBrowse files
CzarekCzarek
authored andcommitted
Fixes to the OnClose event. Closing any of the windows
exited the application.
1 parent 58002fc commit 7bfa0f1
Copy full SHA for 7bfa0f1

File tree

Expand file treeCollapse file tree

3 files changed

+69
-51
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

3 files changed

+69
-51
lines changed
Open diff view settings
Collapse file

‎cefpython/cef3/mac/binaries_32bit/wxpython.py‎

Copy file name to clipboardExpand all lines: cefpython/cef3/mac/binaries_32bit/wxpython.py
+25-19Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -191,25 +191,31 @@ def CreateMenu(self):
191191
self.SetMenuBar(menubar)
192192

193193
def OnClose(self, event):
194-
if self.browser:
195-
# Calling CloseBrowser will cause that OnClose event occurs again,
196-
# so self.browser must be checked if non-empty.
197-
self.browser.StopLoad()
198-
self.browser.CloseBrowser()
199-
# Remove all CEF browser references so that browser is closed
200-
# cleanly. Otherwise there may be issues for example with cookies
201-
# not being flushed to disk when closing app immediately
202-
# (Issue 158).
203-
del self.javascriptExternal.mainBrowser
204-
del self.clientHandler.mainBrowser
205-
del self.browser
206-
self.Destroy()
207-
# In wx.chromectrl calling browser.CloseBrowser and/or self.Destroy
208-
# may cause crashes when embedding multiple browsers in tab
209-
# (Issue 107). In such case instead of calling CloseBrowser/Destroy
210-
# try this code:
211-
# | self.browser.ParentWindowWillClose()
212-
# | event.Skip()
194+
# Calling CloseBrowser will cause that OnClose event occurs again,
195+
# so self.browser must be checked if non-empty.
196+
if not self.browser:
197+
return
198+
199+
self.browser.StopLoad()
200+
self.browser.CloseBrowser()
201+
202+
# Remove all CEF browser references so that browser is closed
203+
# cleanly. Otherwise there may be issues for example with cookies
204+
# not being flushed to disk when closing app immediately
205+
# (Issue 158).
206+
del self.javascriptExternal.mainBrowser
207+
del self.clientHandler.mainBrowser
208+
del self.browser
209+
210+
# Destroy wx frame, this will complete the destruction of CEF browser
211+
self.Destroy()
212+
213+
# In wx.chromectrl calling browser.CloseBrowser and/or self.Destroy
214+
# may cause crashes when embedding multiple browsers in tab
215+
# (Issue 107). In such case instead of calling CloseBrowser/Destroy
216+
# try this code:
217+
# | self.browser.ParentWindowWillClose()
218+
# | event.Skip()
213219

214220
global g_countWindows
215221
g_countWindows -= 1
Collapse file

‎cefpython/cef3/mac/binaries_64bit/wxpython.py‎

Copy file name to clipboardExpand all lines: cefpython/cef3/mac/binaries_64bit/wxpython.py
+25-19Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -191,25 +191,31 @@ def CreateMenu(self):
191191
self.SetMenuBar(menubar)
192192

193193
def OnClose(self, event):
194-
if self.browser:
195-
# Calling CloseBrowser will cause that OnClose event occurs again,
196-
# so self.browser must be checked if non-empty.
197-
self.browser.StopLoad()
198-
self.browser.CloseBrowser()
199-
# Remove all CEF browser references so that browser is closed
200-
# cleanly. Otherwise there may be issues for example with cookies
201-
# not being flushed to disk when closing app immediately
202-
# (Issue 158).
203-
del self.javascriptExternal.mainBrowser
204-
del self.clientHandler.mainBrowser
205-
del self.browser
206-
self.Destroy()
207-
# In wx.chromectrl calling browser.CloseBrowser and/or self.Destroy
208-
# may cause crashes when embedding multiple browsers in tab
209-
# (Issue 107). In such case instead of calling CloseBrowser/Destroy
210-
# try this code:
211-
# | self.browser.ParentWindowWillClose()
212-
# | event.Skip()
194+
# Calling CloseBrowser will cause that OnClose event occurs again,
195+
# so self.browser must be checked if non-empty.
196+
if not self.browser:
197+
return
198+
199+
self.browser.StopLoad()
200+
self.browser.CloseBrowser()
201+
202+
# Remove all CEF browser references so that browser is closed
203+
# cleanly. Otherwise there may be issues for example with cookies
204+
# not being flushed to disk when closing app immediately
205+
# (Issue 158).
206+
del self.javascriptExternal.mainBrowser
207+
del self.clientHandler.mainBrowser
208+
del self.browser
209+
210+
# Destroy wx frame, this will complete the destruction of CEF browser
211+
self.Destroy()
212+
213+
# In wx.chromectrl calling browser.CloseBrowser and/or self.Destroy
214+
# may cause crashes when embedding multiple browsers in tab
215+
# (Issue 107). In such case instead of calling CloseBrowser/Destroy
216+
# try this code:
217+
# | self.browser.ParentWindowWillClose()
218+
# | event.Skip()
213219

214220
global g_countWindows
215221
g_countWindows -= 1
Collapse file

‎cefpython/cef3/windows/binaries/wxpython.py‎

Copy file name to clipboardExpand all lines: cefpython/cef3/windows/binaries/wxpython.py
+19-13Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -211,19 +211,25 @@ def OnSize(self, event):
211211
cefpython.WindowUtils.OnSize(self.GetHandleForBrowser(), 0, 0, 0)
212212

213213
def OnClose(self, event):
214-
if self.browser:
215-
# Calling CloseBrowser will cause that OnClose event occurs again,
216-
# so self.browser must be checked if non-empty.
217-
self.browser.StopLoad()
218-
self.browser.CloseBrowser()
219-
# Remove all CEF browser references so that browser is closed
220-
# cleanly. Otherwise there may be issues for example with cookies
221-
# not being flushed to disk when closing app immediately
222-
# (Issue 158).
223-
del self.javascriptExternal.mainBrowser
224-
del self.clientHandler.mainBrowser
225-
del self.browser
226-
self.Destroy()
214+
# Calling CloseBrowser will cause that OnClose event occurs again,
215+
# so self.browser must be checked if non-empty.
216+
if not self.browser:
217+
return
218+
219+
self.browser.StopLoad()
220+
self.browser.CloseBrowser()
221+
222+
# Remove all CEF browser references so that browser is closed
223+
# cleanly. Otherwise there may be issues for example with cookies
224+
# not being flushed to disk when closing app immediately
225+
# (Issue 158).
226+
del self.javascriptExternal.mainBrowser
227+
del self.clientHandler.mainBrowser
228+
del self.browser
229+
230+
# Destroy wx frame, this will complete the destruction of CEF browser
231+
self.Destroy()
232+
227233
# In wx.chromectrl calling browser.CloseBrowser and/or self.Destroy
228234
# may cause crashes when embedding multiple browsers in tab
229235
# (Issue 107). In such case instead of calling CloseBrowser/Destroy

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.