Move call to XInitThreads for linux-vlc setup to module-load. Fixes bug 1473632.

Fixes: https://launchpad.net/bugs/1473632
This commit is contained in:
Tomas Groth 2015-07-20 21:33:58 +01:00
parent 62aef46b55
commit 5940a77b20
1 changed files with 12 additions and 10 deletions

View File

@ -84,7 +84,6 @@ def get_vlc():
pass
else:
raise
if is_vlc_available:
try:
VERSION = vlc.libvlc_get_version().decode('UTF-8')
@ -95,21 +94,24 @@ def get_vlc():
if LooseVersion(VERSION.split()[0]) < LooseVersion('1.1.0'):
is_vlc_available = False
log.debug('VLC could not be loaded, because the vlc version is too old: %s' % VERSION)
# On linux we need to initialise X threads, but not when running tests.
if is_vlc_available and is_linux() and 'nose' not in sys.argv[0]:
import ctypes
try:
x11 = ctypes.cdll.LoadLibrary('libX11.so')
x11.XInitThreads()
except:
log.exception('Failed to run XInitThreads(), VLC might not work properly!')
if is_vlc_available:
return vlc
else:
return None
# On linux we need to initialise X threads, but not when running tests.
# This needs to happen on module load and not in get_vlc(), otherwise it can cause crashes on some DE on some setups
# (reported on Gnome3, Unity, Cinnamon, all GTK+ based) when using native filedialogs...
if get_vlc() and is_linux() and 'nose' not in sys.argv[0]:
import ctypes
try:
x11 = ctypes.cdll.LoadLibrary('libX11.so')
x11.XInitThreads()
except:
log.exception('Failed to run XInitThreads(), VLC might not work properly!')
class VlcPlayer(MediaPlayer):
"""
A specialised version of the MediaPlayer class, which provides a VLC display.