Merge branch 'fix-macos-issues' into 'master'

Fix some issues with building on macOS

See merge request openlp/openlp!656
This commit is contained in:
Raoul Snyman 2023-08-26 15:21:36 +00:00
commit 88f42b1075
3 changed files with 20 additions and 7 deletions

View File

@ -1 +1 @@
3.0.3.dev75+gf40ffd377
3.0.3.dev75+gf40ffd377

View File

@ -415,6 +415,12 @@ def main():
# support dark mode on windows 10. This makes the titlebar dark, the rest is setup later
# by calling set_windows_darkmode
qt_args.extend(['-platform', 'windows:darkmode=1'])
elif is_macosx() and getattr(sys, 'frozen', False) and not os.environ.get('QTWEBENGINEPROCESS_PATH'):
# Work around an issue where PyInstaller is not setting this environment variable
os.environ['QTWEBENGINEPROCESS_PATH'] = str(AppLocation.get_directory(AppLocation.AppDir) / 'PyQt5' / 'Qt5' /
'lib' / 'QtWebEngineCore.framework' / 'Versions' / '5' /
'Helpers' / 'QtWebEngineProcess.app' / 'Contents' / 'MacOS' /
'QtWebEngineProcess')
# Initialise the resources
qInitResources()
# Now create and actually run the application.
@ -460,13 +466,16 @@ def main():
if getattr(sys, 'frozen', False):
# Path to libvlc and the plugins
vlc_dir = AppLocation.get_directory(AppLocation.AppDir) / 'vlc'
vlc_lib = None
if is_win():
os.environ['PYTHON_VLC_LIB_PATH'] = str(vlc_dir / 'libvlc.dll')
vlc_lib = 'libvlc.dll'
elif is_macosx():
os.environ['PYTHON_VLC_LIB_PATH'] = str(vlc_dir / 'libvlc.dylib')
os.environ['PYTHON_VLC_MODULE_PATH'] = str(vlc_dir)
os.environ['PATH'] += ';' + str(vlc_dir)
log.debug('VLC Path: {}'.format(os.environ.get('PYTHON_VLC_LIB_PATH', '')))
vlc_lib = 'libvlc.dylib'
if vlc_lib and vlc_dir.joinpath(vlc_lib).exists():
os.environ['PYTHON_VLC_LIB_PATH'] = str(vlc_dir / vlc_lib)
os.environ['PYTHON_VLC_MODULE_PATH'] = str(vlc_dir)
os.environ['PATH'] += ';' + str(vlc_dir)
log.debug('VLC Path: {}'.format(os.environ.get('PYTHON_VLC_LIB_PATH', '')))
app = OpenLP()
# Initialise the Registry
Registry.create()

View File

@ -52,7 +52,11 @@ def run_thread(worker, thread_name, can_start=True):
if not thread_name:
raise ValueError('A thread_name is required when calling the "run_thread" function')
application = Registry().get('application')
main_window = Registry().get('main_window')
try:
# In some cases (see First Time Form), the main window does not exist yet
main_window = Registry().get('main_window')
except KeyError:
main_window = None
if thread_name in application.worker_threads:
raise KeyError('A thread with the name "{}" has already been created, please use another'.format(thread_name))
# Create the thread and add the thread and the worker to the parent