mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Possible workaround for Qt open file dialog in 4.8.2 failling on some linux distros. Fixes #1022019 (Cannot add any book)
This commit is contained in:
parent
f8ea2ce8f0
commit
f7974adef5
@ -581,6 +581,7 @@ class FileDialog(QObject):
|
|||||||
if not isinstance(initial_dir, basestring):
|
if not isinstance(initial_dir, basestring):
|
||||||
initial_dir = os.path.expanduser(default_dir)
|
initial_dir = os.path.expanduser(default_dir)
|
||||||
self.selected_files = []
|
self.selected_files = []
|
||||||
|
with SanitizeLibraryPath():
|
||||||
if mode == QFileDialog.AnyFile:
|
if mode == QFileDialog.AnyFile:
|
||||||
f = unicode(QFileDialog.getSaveFileName(parent, title, initial_dir, ftext, ""))
|
f = unicode(QFileDialog.getSaveFileName(parent, title, initial_dir, ftext, ""))
|
||||||
if f:
|
if f:
|
||||||
@ -857,16 +858,26 @@ class Application(QApplication):
|
|||||||
|
|
||||||
_store_app = None
|
_store_app = None
|
||||||
|
|
||||||
def open_url(qurl):
|
class SanitizeLibraryPath(object):
|
||||||
paths = os.environ.get('LD_LIBRARY_PATH',
|
'''Remove the bundled calibre libraries from LD_LIBRARY_PATH on linux. This
|
||||||
'').split(os.pathsep)
|
is needed to prevent library conflicts when launching external utilities.'''
|
||||||
paths = [x for x in paths if x]
|
|
||||||
|
def __enter__(self):
|
||||||
|
self.orig = os.environ.get('LD_LIBRARY_PATH', '')
|
||||||
|
self.changed = False
|
||||||
|
paths = [x for x in self.orig.split(os.pathsep) if x]
|
||||||
if isfrozen and islinux and paths:
|
if isfrozen and islinux and paths:
|
||||||
npaths = [x for x in paths if x != sys.frozen_path+'/lib']
|
npaths = [x for x in paths if x != sys.frozen_path+'/lib']
|
||||||
os.environ['LD_LIBRARY_PATH'] = os.pathsep.join(npaths)
|
os.environ['LD_LIBRARY_PATH'] = os.pathsep.join(npaths)
|
||||||
|
self.changed = True
|
||||||
|
|
||||||
|
def __exit__(self, *args):
|
||||||
|
if self.changed:
|
||||||
|
os.environ['LD_LIBRARY_PATH'] = self.orig
|
||||||
|
|
||||||
|
def open_url(qurl):
|
||||||
|
with SanitizeLibraryPath():
|
||||||
QDesktopServices.openUrl(qurl)
|
QDesktopServices.openUrl(qurl)
|
||||||
if isfrozen and islinux and paths:
|
|
||||||
os.environ['LD_LIBRARY_PATH'] = os.pathsep.join(paths)
|
|
||||||
|
|
||||||
def get_current_db():
|
def get_current_db():
|
||||||
'''
|
'''
|
||||||
|
Loading…
x
Reference in New Issue
Block a user