Skip to content

Commit

Permalink
#864: disable the tray menu workaround when not used from a tray, as …
Browse files Browse the repository at this point in the history
…this causes crashes on win32!

git-svn-id: https://xpra.org/svn/Xpra/trunk@9439 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed May 18, 2015
1 parent 9ccda38 commit ef1609d
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 10 deletions.
12 changes: 9 additions & 3 deletions src/xpra/client/gtk_base/client_launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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")
Expand Down
23 changes: 16 additions & 7 deletions src/xpra/client/gtk_base/gtk_tray_menu_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,22 @@ 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():
#toggle did not fire after the button release, so force it:
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
Expand All @@ -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)
Expand Down Expand Up @@ -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)"
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit ef1609d

Please sign in to comment.