fix browse add-ons command failing to load on linux

This commit is contained in:
Damien Elmes 2017-06-27 12:04:42 +10:00
parent 1fe86e1bde
commit 2b8987f654

View file

@ -7,6 +7,14 @@ import re, os, sys, urllib.request, urllib.parse, urllib.error, subprocess
import aqt import aqt
from anki.sound import stripSounds from anki.sound import stripSounds
from anki.utils import isWin, isMac, invalidFilename from anki.utils import isWin, isMac, invalidFilename
from contextlib import contextmanager
@contextmanager
def noBundledLibs():
oldlpath = os.environ.pop("LD_LIBRARY_PATH", None)
yield
if oldlpath is not None:
os.environ["LD_LIBRARY_PATH"] = oldlpath
def openHelp(section): def openHelp(section):
link = aqt.appHelpSite link = aqt.appHelpSite
@ -16,7 +24,8 @@ def openHelp(section):
def openLink(link): def openLink(link):
tooltip(_("Loading..."), period=1000) tooltip(_("Loading..."), period=1000)
QDesktopServices.openUrl(QUrl(link)) with noBundledLibs():
QDesktopServices.openUrl(QUrl(link))
def showWarning(text, parent=None, help="", title="Anki"): def showWarning(text, parent=None, help="", title="Anki"):
"Show a small warning with an OK button." "Show a small warning with an OK button."
@ -351,10 +360,8 @@ def openFolder(path):
if isWin: if isWin:
subprocess.Popen(["explorer", "file://"+path]) subprocess.Popen(["explorer", "file://"+path])
else: else:
oldlpath = os.environ.pop("LD_LIBRARY_PATH", None) with noBundledLibs():
QDesktopServices.openUrl(QUrl("file://" + path)) QDesktopServices.openUrl(QUrl("file://" + path))
if oldlpath:
os.environ["LD_LIBRARY_PATH"] = oldlpath
def shortcut(key): def shortcut(key):
if isMac: if isMac: