|
Medical Imaging Interaction Toolkit
2026.06.00
Medical Imaging Interaction Toolkit
|
Helpers for running an executable from a MITK-managed Python virtual environment as a subprocess. More...
Classes | |
| struct | Result |
Functions | |
| MITKPYTHONSEGMENTATIONUI_EXPORT QProcessEnvironment | CleanEnvironment () |
| The current process environment with PYTHONHOME and PYTHONPATH removed. More... | |
| MITKPYTHONSEGMENTATIONUI_EXPORT QString | ToQString (const fs::path &path) |
| Lossless conversion of a filesystem path to a QString. More... | |
| MITKPYTHONSEGMENTATIONUI_EXPORT Result | Run (const QString &executable, const QStringList &args, int finishedTimeoutMs=-1) |
Runs executable with args in a clean environment and blocks until it finishes. More... | |
Helpers for running an executable from a MITK-managed Python virtual environment as a subprocess.
Centralises the one invariant every such call must honour: the child runs with PYTHONHOME / PYTHONPATH stripped, so it resolves its environment from the venv's own layout (pyvenv.cfg and site-packages) instead of MITK's embedded interpreter. Keeping that in a single place stops the historically duplicated copies of the pattern from drifting.
| MITKPYTHONSEGMENTATIONUI_EXPORT QProcessEnvironment QmitkVenvProcess::CleanEnvironment | ( | ) |
The current process environment with PYTHONHOME and PYTHONPATH removed.
| MITKPYTHONSEGMENTATIONUI_EXPORT Result QmitkVenvProcess::Run | ( | const QString & | executable, |
| const QStringList & | args, | ||
| int | finishedTimeoutMs = -1 |
||
| ) |
Runs executable with args in a clean environment and blocks until it finishes.
Blocks the calling thread, so run it from a worker thread (e.g. via QmitkRunAsyncBlocking) rather than directly on the GUI thread.
| executable | The executable to run. |
| args | Command-line arguments passed to executable. |
| finishedTimeoutMs | Milliseconds to wait for completion; a negative value waits indefinitely. On start failure or timeout the process is killed and Result::success stays false. |
| MITKPYTHONSEGMENTATIONUI_EXPORT QString QmitkVenvProcess::ToQString | ( | const fs::path & | path | ) |
Lossless conversion of a filesystem path to a QString.
fs::path::string() re-encodes to the native narrow code page on Windows, which corrupts non-ASCII paths (e.g. a venv under a user profile with accented characters) before they reach QProcess. Convert from the wide / native representation instead.