Make ensure_app() thread-safe

This commit is contained in:
Kovid Goyal 2014-09-14 16:03:30 +05:30
parent 7b4fdc0634
commit 681bec7ee0

View File

@ -2,7 +2,7 @@ __license__ = 'GPL v3'
__copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
""" The GUI """
import os, sys, Queue, threading, glob
from threading import RLock
from threading import RLock, Lock
from urllib import unquote
from PyQt5.Qt import (
QFileInfo, QObject, QBuffer, Qt, QStyle, QByteArray, QTranslator,
@ -1122,8 +1122,11 @@ def open_local_file(path):
url = QUrl.fromLocalFile(path)
open_url(url)
_ea_lock = Lock()
def ensure_app():
global _store_app
with _ea_lock:
if _store_app is None and QApplication.instance() is None:
args = sys.argv[:1]
if islinux or isbsd: