From ef1609dc0db331339eb9a77e8e3156ab757e4c18 Mon Sep 17 00:00:00 2001 From: Antoine Martin Date: Mon, 18 May 2015 13:23:18 +0000 Subject: [PATCH] #864: disable the tray menu workaround when not used from a tray, as this causes crashes on win32! git-svn-id: https://xpra.org/svn/Xpra/trunk@9439 3bb7dfac-3a0b-4e04-842a-767bc560f471 --- src/xpra/client/gtk_base/client_launcher.py | 12 +++++++--- .../client/gtk_base/gtk_tray_menu_base.py | 23 +++++++++++++------ 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/src/xpra/client/gtk_base/client_launcher.py b/src/xpra/client/gtk_base/client_launcher.py index 0f184c2bc8..fb939c92c2 100755 --- a/src/xpra/client/gtk_base/client_launcher.py +++ b/src/xpra/client/gtk_base/client_launcher.py @@ -39,7 +39,7 @@ DIALOG_DESTROY_WITH_PARENT, MESSAGE_INFO, BUTTONS_CLOSE, \ FILE_CHOOSER_ACTION_SAVE, FILE_CHOOSER_ACTION_OPEN from xpra.os_util import thread -from xpra.client.gtk_base.gtk_tray_menu_base import make_min_auto_menu, make_encodingsmenu, \ +from xpra.client.gtk_base.gtk_tray_menu_base import make_min_auto_menu, make_encodingsmenu, set_use_tray_workaround, \ MIN_QUALITY_OPTIONS, QUALITY_OPTIONS, MIN_SPEED_OPTIONS, SPEED_OPTIONS from xpra.client.gtk_base.about import about from xpra.scripts.main import connect_to, make_client @@ -400,8 +400,9 @@ def get_selected_encoding(self, *args): def encoding_changed(self, *args): encoding = self.get_selected_encoding() - log("encoding_changed(%s) encoding=%s", args, encoding) uses_quality_option = encoding in ["jpeg", "webp", "h264"] + log("encoding_changed(%s) uses_quality_option(%s)=%s", args, encoding, uses_quality_option) + #to prevent win32 crashes: if uses_quality_option: self.quality_combo.show() self.quality_label.show() @@ -761,7 +762,12 @@ def show_signal(): if debug: for x in debug.split(","): enable_debug_for(x) - app.create_window() + #suspend tray workaround for our window widgets: + try: + set_use_tray_workaround(False) + app.create_window() + finally: + set_use_tray_workaround(True) app.update_gui_from_config() except Exception: exception_dialog("Error creating launcher form") diff --git a/src/xpra/client/gtk_base/gtk_tray_menu_base.py b/src/xpra/client/gtk_base/gtk_tray_menu_base.py index e4583766c2..d024cb03af 100644 --- a/src/xpra/client/gtk_base/gtk_tray_menu_base.py +++ b/src/xpra/client/gtk_base/gtk_tray_menu_base.py @@ -70,6 +70,7 @@ def on_button_release_event(self, *args): log("TrayCheckMenuItem.on_button_release_event(%s) label=%s", args, self.label) self.active_state = self.get_active() def recheck(): + log("TrayCheckMenuItem: recheck() active_state=%s, get_active()=%s", self.active_state, self.get_active()) state = self.active_state self.active_state = None if state is not None and state==self.get_active(): @@ -77,6 +78,14 @@ def recheck(): self.set_active(not state) glib.idle_add(recheck) +CheckMenuItem = TrayCheckMenuItem +def set_use_tray_workaround(enabled): + global CheckMenuItem + if enabled: + CheckMenuItem = TrayCheckMenuItem + else: + CheckMenuItem = gtk.CheckMenuItem + def make_min_auto_menu(title, min_options, options, get_current_min_value, get_current_value, set_min_value_cb, set_value_cb): #note: we must keep references to the parameters on the submenu @@ -98,7 +107,7 @@ def populate_menu(options, value, set_fn): options[value] = "%s%%" % value for s in sorted(options.keys()): t = options.get(s) - qi = TrayCheckMenuItem(t) + qi = CheckMenuItem(t) qi.set_draw_as_radio(True) candidate_match = s>=max(0, value) qi.set_active(not found_match and candidate_match) @@ -181,7 +190,7 @@ def populate_encodingsmenu(encodings_submenu, get_current_encoding, set_encoding name = ENCODINGS_TO_NAME.get(encoding, encoding) descr = ENCODINGS_HELP.get(encoding) NAME_TO_ENCODING[name] = encoding - encoding_item = TrayCheckMenuItem(name) + encoding_item = CheckMenuItem(name) if descr: if encoding not in server_encodings: descr += "\n(not available on this server)" @@ -323,8 +332,8 @@ def menuitem(self, title, icon_name=None, tooltip=None, cb=None): return menuitem(title, image, tooltip, cb) def checkitem(self, title, cb=None, active=False): - """ Utility method for easily creating a TrayCheckMenuItem """ - check_item = TrayCheckMenuItem(title) + """ Utility method for easily creating a CheckMenuItem """ + check_item = CheckMenuItem(title) check_item.set_active(active) if cb: check_item.connect("toggled", cb) @@ -467,7 +476,7 @@ def set_clipboard_menu(*args): "Secondary" : "SECONDARY"} from xpra.clipboard.translated_clipboard import TranslatedClipboardProtocolHelper for label, remote_clipboard in LABEL_TO_NAME.items(): - clipboard_item = TrayCheckMenuItem(label) + clipboard_item = CheckMenuItem(label) def remote_clipboard_changed(item): assert can_clipboard ensure_item_selected(clipboard_submenu, item) @@ -746,7 +755,7 @@ def make_soundsubmenu(self, is_on_cb, on_cb, off_cb, client_signal): menu = gtk.Menu() menu.ignore_events = False def onoffitem(label, active, cb): - c = TrayCheckMenuItem(label) + c = CheckMenuItem(label) c.set_draw_as_radio(True) c.set_active(active) def submenu_uncheck(item, menu): @@ -886,7 +895,7 @@ def set_compression(item): log("setting compression level to %s", c) self.client.set_deflate_level(c) for i in range(0, 10): - c = TrayCheckMenuItem(str(compression_options.get(i, i))) + c = CheckMenuItem(str(compression_options.get(i, i))) c.set_draw_as_radio(True) c.set_active(i==self.client.compression_level) c.connect('activate', set_compression)