Skip to content

Commit

Permalink
destroying windows causes crashes on MS Windows
Browse files Browse the repository at this point in the history
it is safer to call close, especially when we don't have to worry about leaking
  • Loading branch information
totaam committed Oct 4, 2023
1 parent cb7dfe6 commit ddd9545
Show file tree
Hide file tree
Showing 17 changed files with 42 additions and 43 deletions.
2 changes: 1 addition & 1 deletion xpra/client/gl/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,6 @@ def window_close_event(*_args):
}
finally:
if window:
window.destroy()
window.close()
log("test_gl_client_window(..) draw_result=%s", draw_result)
return draw_result or {"success" : False, "message" : "not painted on screen"}
22 changes: 11 additions & 11 deletions xpra/client/gtk3/client_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,23 +196,23 @@ def cleanup(self) -> None:
log("GTKXpraClient.cleanup()")
self.stop_pinentry()
if self.shortcuts_info:
self.shortcuts_info.destroy()
self.shortcuts_info.close()
self.shortcuts_info = None
if self.session_info:
self.session_info.destroy()
self.session_info.close()
self.session_info = None
if self.bug_report:
self.bug_report.destroy()
self.bug_report.close()
self.bug_report = None
self.close_file_size_warning()
self.close_file_upload_dialog()
self.close_ask_data_dialog()
self.cancel_clipboard_notification_timer()
if self.start_new_command:
self.start_new_command.destroy()
self.start_new_command.close()
self.start_new_command = None
if self.server_commands:
self.server_commands.destroy()
self.server_commands.close()
self.server_commands = None
uw = self.UI_watcher
if uw:
Expand Down Expand Up @@ -385,7 +385,7 @@ def handle_response(dialog, response):
disable_focus_workaround()
password = dialog.password_input.get_text()
dialog.hide()
dialog.destroy()
dialog.close()
response_str = {getattr(Gtk.ResponseType, k, ""): k for k in (
"ACCEPT", "APPLY", "CANCEL", "CLOSE", "DELETE_EVENT", "HELP", "NO", "NONE", "OK", "REJECT", "YES")}
log(f"handle_response({dialog}, {response}) response={response_str.get(response)}")
Expand Down Expand Up @@ -532,7 +532,7 @@ def close_ask_data_dialog(self):
fad = self.file_ask_dialog
if fad:
self.file_ask_dialog = None
fad.destroy()
fad.close()

def show_ask_data_dialog(self, *_args):
from xpra.gtk.dialogs.open_requests import getOpenRequestsWindow
Expand Down Expand Up @@ -570,7 +570,7 @@ def accept_data(self, send_id, dtype, url, printit, openit):
def file_size_warning(self, action, location, basefilename, filesize, limit):
if self.file_size_dialog:
#close previous warning
self.file_size_dialog.destroy()
self.file_size_dialog.close()
self.file_size_dialog = None
parent = None
msgs = (
Expand All @@ -592,7 +592,7 @@ def close_file_size_warning(self, *_args):
fsd = self.file_size_dialog
if fsd:
self.file_size_dialog = None
fsd.destroy()
fsd.close()

def download_server_log(self, callback=None):
filename = "${XPRA_SERVER_LOG}"
Expand Down Expand Up @@ -625,7 +625,7 @@ def show_file_upload(self, *args):
def close_file_upload_dialog(self):
fd = self.file_dialog
if fd:
fd.destroy()
fd.close()
self.file_dialog = None

def file_upload_dialog_response(self, dialog, v):
Expand Down Expand Up @@ -1476,7 +1476,7 @@ def destroy_window(self, wid:int, window) -> None:
for ref in refs:
del self._ref_to_group_leader[ref]
log("last window for refs %s is gone, destroying the group leader %s", refs, group_leader)
group_leader.destroy()
group_leader.close()


def setup_clipboard_helper(self, helperClass):
Expand Down
2 changes: 1 addition & 1 deletion xpra/client/gtk3/launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ def mdns(*_args):
from xpra.client.gtk3.mdns_gui import mdns_sessions
self.mdns_gui = mdns_sessions(self.config)
def close_mdns():
self.mdns_gui.destroy()
self.mdns_gui.close()
self.mdns_gui = None
self.mdns_gui.do_quit = close_mdns
else:
Expand Down
4 changes: 2 additions & 2 deletions xpra/gtk/dialogs/bug_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ def run():

def quit(self, *args):
log("quit%s", args)
self.destroy()
self.close()
Gtk.main_quit()


Expand Down Expand Up @@ -381,7 +381,7 @@ def do_save(self, filename):
Gtk.ButtonsType.CLOSE, "Failed to save ZIP file")
dialog.format_secondary_text("%s" % e)
def close(*_args):
dialog.destroy()
dialog.close()
dialog.connect("response", close)
dialog.show_all()
finally:
Expand Down
2 changes: 1 addition & 1 deletion xpra/gtk/dialogs/confirm_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def al(text, font="sans 14", xalign=0.0):

def quit(self, *args):
log("quit%s", args)
self.destroy()
self.close()
return True


Expand Down
2 changes: 1 addition & 1 deletion xpra/gtk/dialogs/desktop_greeter.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def run_command(self, *_args):
log.warn("no command found for '%s'", name)
return
argv = [cmd]
self.destroy()
self.close()
os.execv(cmd, argv)

def wait_for_subprocess(self, proc):
Expand Down
2 changes: 1 addition & 1 deletion xpra/gtk/dialogs/open_requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ def run(self):

def quit(self, *args):
log("quit%s", args)
self.destroy()
self.close()
Gtk.main_quit()


Expand Down
2 changes: 1 addition & 1 deletion xpra/gtk/dialogs/pass_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def run(self) -> str:

def quit(self, *args):
log("quit%s", args)
self.destroy()
self.close()
return True

def cancel(self, *args):
Expand Down
4 changes: 2 additions & 2 deletions xpra/gtk/dialogs/qrcode.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ def show_qr(uri:str, width:int=640, height:int=640):
window.set_size_request(width, height)
window.set_resizable(False)
def close(*_args):
window.destroy()
window.close()
add_close_accel(window, close)
window.show_all()
if Gtk.main_level()<=0:
def gtk_quit(*_args):
window.destroy()
close()
Gtk.main_quit()
window.connect("delete-event", gtk_quit)
Gtk.main()
Expand Down
9 changes: 5 additions & 4 deletions xpra/gtk/dialogs/server_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,15 +175,16 @@ def show(self):

def close(self, *args):
log("close%s", args)
self.window.hide()
if self.window:
self.window.hide()
self.cancel_timer()
return True

def destroy(self, *args):
log("destroy%s", args)
log("close%s", args)
self.cancel_timer()
if self.window:
self.window.destroy()
self.window.close()
self.window = None


Expand All @@ -194,7 +195,7 @@ def run(self):

def quit(self, *args):
log("quit%s", args)
self.destroy()
self.close()
Gtk.main_quit()


Expand Down
12 changes: 6 additions & 6 deletions xpra/gtk/dialogs/session_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ def window_deleted(*_args):
GLib.timeout_add(100, self.populate_tab)
if features.audio and SHOW_SOUND_STATS and show_client:
GLib.timeout_add(100, self.populate_audio_stats)
add_close_accel(self, self.destroy)
add_close_accel(self, self.close)


def get_window_title(self):
Expand Down Expand Up @@ -1221,7 +1221,7 @@ def save_graph(self, _ebox, btn, graph):
response = chooser.run()
filenames = chooser.get_filenames()
chooser.hide()
chooser.destroy()
chooser.close()
if response == Gtk.ResponseType.OK:
if len(filenames)==1:
filename = filenames[0]
Expand All @@ -1242,11 +1242,11 @@ def save_file():
else:
log.warn("unknown chooser response: %d" % response)

def destroy(self, *args):
log("SessionInfo.destroy(%s) is_closed=%s", args, self.is_closed)
def close(self, *args):
log("SessionInfo.close(%s) is_closed=%s", args, self.is_closed)
self.is_closed = True
super().destroy()
log("SessionInfo.destroy(%s) done", args)
super().close()
log("SessionInfo.close(%s) done", args)


class SessionInfoClient(InfoTimerClient):
Expand Down
2 changes: 1 addition & 1 deletion xpra/gtk/dialogs/sessions_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def app_signal(self, signum):
self.do_quit()

def cleanup(self):
self.destroy()
self.close()


def show_about(self, *_args):
Expand Down
2 changes: 1 addition & 1 deletion xpra/gtk/dialogs/start_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -705,7 +705,7 @@ def populate_form(self):

def close(self, *_args): #pylint: disable=arguments-differ
self.set_value_from_widgets()
self.destroy()
super().close()

def sep(self, tb):
tb.inc()
Expand Down
7 changes: 4 additions & 3 deletions xpra/gtk/dialogs/start_new_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,15 +142,16 @@ def show(self):

def hide(self):
log("hide()")
self.window.hide()
if self.window:
self.window.hide()

def close(self, *args):
log("close%s", args)
self.hide()
return True

def destroy(self, *args):
log("destroy%s", args)
log("close%s", args)
if self.window:
self.window.destroy()
self.window = None
Expand All @@ -162,7 +163,7 @@ def run(self):

def quit(self, *args):
log("quit%s", args)
self.destroy()
self.close()
Gtk.main_quit()


Expand Down
2 changes: 1 addition & 1 deletion xpra/gtk/dialogs/update_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def run(self):

def quit(self, *args):
log("quit%s", args)
self.destroy()
self.close()
Gtk.main_quit()


Expand Down
2 changes: 1 addition & 1 deletion xpra/gtk/notifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ def hide_notification(self):
GLib.source_remove(v)
#destroy window from the UI thread:
GLib.idle_add(self.destroy)
self.destroy()
self.close()
self.destroy_cb(self)


Expand Down
7 changes: 2 additions & 5 deletions xpra/scripts/pinentry.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,12 +212,9 @@ def do_run_dialog(dialog):
try:
force_focus()
dialog.show()
try:
return dialog.run()
finally:
dialog.destroy()
return dialog.run()
finally:
dialog.destroy()
dialog.close()

def dialog_pass(title:str="Password Input", prompt:str="enter password", icon:str="") -> str:
log("dialog_pass%s PINENTRY=%s", (title, prompt, icon), PINENTRY)
Expand Down

0 comments on commit ddd9545

Please sign in to comment.