Skip to content

Commit ffaff82

Browse files
Merge release-next into main
2 parents fc33ef8 + 1743ddd commit ffaff82

File tree

2 files changed

+36
-2
lines changed

2 files changed

+36
-2
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Opening the help window will no longer cause a crash in Windows conda installs of mantidworkbench.

qt/applications/workbench/workbench/app/mantidworkbench_launch_wrapper.py

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,42 @@
66
# SPDX - License - Identifier: GPL - 3.0 +
77
# This file is part of the mantid workbench.
88
import os
9+
from pathlib import Path
10+
import shutil
911
import subprocess
1012
import sys
1113

1214
from workbench.app.main import main
1315

1416

17+
def _patch_qtwebengine_files(prefix: str):
18+
"""
19+
Copy Qt WebEngine executable, resources, locales, and ICU data into the environment
20+
root so Qt can find them when launching from a conda environment on Windows.
21+
"""
22+
env_root = Path(prefix) # Python executable directory
23+
library = env_root / "Library"
24+
25+
# Copy QtWebEngineProcess.exe
26+
src_exe = library / "bin" / "QtWebEngineProcess.exe"
27+
dst_exe = env_root / "QtWebEngineProcess.exe"
28+
if src_exe.exists() and not dst_exe.exists():
29+
shutil.copy2(src_exe, dst_exe)
30+
31+
# Copy the contents of the resources directory
32+
src_resources = library / "resources"
33+
for f in src_resources.glob("*"):
34+
dst = env_root / f.name
35+
if not dst.exists():
36+
shutil.copy2(f, dst)
37+
38+
# Copy locales directory
39+
src_locales = library / "translations" / "qtwebengine_locales"
40+
dst_locales = env_root / "qtwebengine_locales"
41+
if src_locales.exists() and not dst_locales.exists():
42+
shutil.copytree(src_locales, dst_locales)
43+
44+
1545
def launch(args=None):
1646
if args is None:
1747
args = sys.argv
@@ -20,9 +50,12 @@ def launch(args=None):
2050
subprocess.run(command)
2151
else:
2252
if sys.platform.startswith("win"):
23-
# Windows conda installs require us to set the QT_PLUGIN_PATH variable.
53+
# Windows conda installs require us to set the QT_PLUGIN_PATH variable and copy QtWebEngine files
54+
# to the root directory of the conda environment.
2455
if "CONDA_PREFIX" in os.environ:
25-
os.environ["QT_PLUGIN_PATH"] = f"{os.environ.get('CONDA_PREFIX')}\\Library\\plugins"
56+
prefix = os.environ.get("CONDA_PREFIX")
57+
os.environ["QT_PLUGIN_PATH"] = f"{prefix}\\Library\\plugins"
58+
_patch_qtwebengine_files(prefix)
2659
main(args[1:])
2760

2861

0 commit comments

Comments
 (0)