mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Make ensure_app() thread-safe
This commit is contained in:
parent
7b4fdc0634
commit
681bec7ee0
@ -2,7 +2,7 @@ __license__ = 'GPL v3'
|
|||||||
__copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
|
__copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||||
""" The GUI """
|
""" The GUI """
|
||||||
import os, sys, Queue, threading, glob
|
import os, sys, Queue, threading, glob
|
||||||
from threading import RLock
|
from threading import RLock, Lock
|
||||||
from urllib import unquote
|
from urllib import unquote
|
||||||
from PyQt5.Qt import (
|
from PyQt5.Qt import (
|
||||||
QFileInfo, QObject, QBuffer, Qt, QStyle, QByteArray, QTranslator,
|
QFileInfo, QObject, QBuffer, Qt, QStyle, QByteArray, QTranslator,
|
||||||
@ -1122,13 +1122,16 @@ def open_local_file(path):
|
|||||||
url = QUrl.fromLocalFile(path)
|
url = QUrl.fromLocalFile(path)
|
||||||
open_url(url)
|
open_url(url)
|
||||||
|
|
||||||
|
_ea_lock = Lock()
|
||||||
|
|
||||||
def ensure_app():
|
def ensure_app():
|
||||||
global _store_app
|
global _store_app
|
||||||
if _store_app is None and QApplication.instance() is None:
|
with _ea_lock:
|
||||||
args = sys.argv[:1]
|
if _store_app is None and QApplication.instance() is None:
|
||||||
if islinux or isbsd:
|
args = sys.argv[:1]
|
||||||
args += ['-platformpluginpath', sys.extensions_location, '-platform', 'headless']
|
if islinux or isbsd:
|
||||||
_store_app = QApplication(args)
|
args += ['-platformpluginpath', sys.extensions_location, '-platform', 'headless']
|
||||||
|
_store_app = QApplication(args)
|
||||||
|
|
||||||
def must_use_qt():
|
def must_use_qt():
|
||||||
''' This function should be called if you want to use Qt for some non-GUI
|
''' This function should be called if you want to use Qt for some non-GUI
|
||||||
|
Loading…
x
Reference in New Issue
Block a user