Skip to content

Commit 9fd090e

Browse files
authored
Merge pull request #1131 from neutrons/revert/qt-config-xdg
Revert the launcher's Qt config handling to its next_revert form
2 parents bfd2e84 + 171f9a7 commit 9fd090e

2 files changed

Lines changed: 25 additions & 35 deletions

File tree

‎docs/ground_truths.md‎

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -767,8 +767,9 @@ constructing `QApplication` and a `QFileDialog` still wrote
767767
content and by a live, reproduced infinite `.rmlock`-chaining loop against
768768
that exact file). So setting an org/app name does nothing to isolate
769769
`QFileDialog`'s settings — it only affects code that explicitly
770-
constructs its own `QSettings()`/`QSettings(org, app)`, which nothing in
771-
`pyrs/` does.
770+
constructs its own `QSettings()`, which nothing in `pyrs/` does (the
771+
calibration viewer's `QSettings("neutrons", "PyRS")` names its own
772+
org/app, so it is unaffected too).
772773

773774
**Actual root cause, in two parts:**
774775
1. Every Qt/PyQt process on the machine that ever opens a `QFileDialog`
@@ -809,7 +810,8 @@ symptom, just against the now-private file instead of the shared one.
809810
Moving the file off the contention path was necessary but not
810811
sufficient; it needed to also move off NFS.
811812

812-
**Actual fix** ([scripts/pyrsplot.py](../scripts/pyrsplot.py)): redirect
813+
**Fix #3 (reverted 2026-11-20, see below)** (was in
814+
[scripts/pyrsplot.py](../scripts/pyrsplot.py)): redirect
813815
`XDG_CONFIG_HOME` to `<tempfile.gettempdir()>/pyrs-qt-config-<user>` —
814816
i.e. **local disk** (verified here to be `xfs` on `/`, not NFS),
815817
namespaced per OS user (`getpass.getuser()`) so it can't collide with
@@ -827,12 +829,29 @@ Trade-off accepted: this directory is local to whichever compute/login
827829
node the session happens to run on (typical at a shared, multi-node
828830
facility), so "recent places" history does not follow the user between
829831
nodes and may be cleared by OS temp-directory housekeeping. That's a
830-
purely cosmetic loss — nothing in `pyrs/` reads this state — traded for
831-
never hitting an NFS-unrecoverable lock again.
832-
`setOrganizationName()`/`setApplicationName()` calls were kept (correct
832+
purely cosmetic loss — nothing in `pyrs/` reads the dialog history (the
833+
calibration viewer's remembered export folder, added later in #1087, did
834+
live there too) — traded for never hitting an NFS-unrecoverable lock again.
835+
`setOrganizationName()`/`setApplicationName()` calls were kept until the
836+
2026-11-20 revert (correct
833837
practice for any future code that constructs its own `QSettings`), but
834838
were never what fixed this.
835839

840+
**Reverted (2026-11-20):** at the maintainer's request,
841+
[scripts/pyrsplot.py](../scripts/pyrsplot.py) is back to its pre-2026-08
842+
form (the `next_revert` branch): no `XDG_CONFIG_HOME` redirect and no
843+
org/app identity, so PyRS again uses Qt's default `~/.config/QtProject.conf`.
844+
The calibration viewer's remembered export folder
845+
(`QSettings("neutrons", "PyRS")`,
846+
[detector_calibration_viewer.py](../pyrs/interface/detector_calibration/detector_calibration_viewer.py))
847+
moves with it, from `<tmp>/pyrs-qt-config-<user>/neutrons/PyRS.conf` back
848+
to `~/.config/neutrons/PyRS.conf`: it now follows the user between nodes,
849+
but sits on NFS too. The diagnosis above still holds: on an NFS home
850+
directory the "Could not remove our own lock file" failure can return, for
851+
either file, and this section is the place to start if it does. The test-suite redirect in
852+
[tests/conftest.py](../tests/conftest.py) is unchanged — tests still keep
853+
Qt state in a disposable temp directory.
854+
836855
**Why this matters going forward:** if a similar "permission denied /
837856
device or resource busy removing our own lock file" resurfaces
838857
elsewhere, check, in order: (a) whether the affected settings file is

‎scripts/pyrsplot.py‎

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
#!/usr/bin/python
2-
import getpass
3-
import os
42
import sys
5-
import tempfile
6-
from qtpy.QtCore import QCoreApplication # type: ignore
73
from qtpy.QtWidgets import QApplication
84
import pyrs.interface.pyrs_main
95

@@ -12,31 +8,6 @@ def main(argv=None):
128
""" """
139
if argv is None:
1410
argv = sys.argv
15-
# QFileDialog (used by every browse/export dialog) hardcodes
16-
# QSettings(QSettings::UserScope, "QtProject") in its own C++ implementation to
17-
# persist sidebar/history state -- this is NOT influenced by
18-
# setOrganizationName()/setApplicationName() below. That fixed "QtProject.conf"
19-
# file, under XDG_CONFIG_HOME, must not live on an NFS-mounted home directory
20-
# (e.g. ORNL analysis nodes' /SNS/users/<user>): QLockFile's stale-lock
21-
# recovery depends on atomic rename()/link(), which NFS does not guarantee, so
22-
# a crashed/killed PyRS process leaves a lock that every subsequent launch
23-
# fails to clean up ("Could not remove our own lock file ...", "Device or
24-
# resource busy"). Redirecting XDG_CONFIG_HOME to a PyRS-private directory on
25-
# local disk (per-user, so it can't collide with other users on a shared
26-
# login/analysis node; not per-machine-persistent, since local disk is
27-
# node-specific -- losing dialog history when switching nodes is harmless)
28-
# sidesteps this entirely, since local filesystems support the atomic
29-
# operations QLockFile's recovery needs. Must happen before any QFileDialog is
30-
# constructed. See docs/ground_truths.md for how this was diagnosed.
31-
pyrs_config_home = os.path.join(tempfile.gettempdir(), f"pyrs-qt-config-{getpass.getuser()}")
32-
os.makedirs(pyrs_config_home, mode=0o700, exist_ok=True)
33-
os.environ["XDG_CONFIG_HOME"] = pyrs_config_home
34-
# Kept for any future explicit QSettings/QStandardPaths use -- does not affect
35-
# QFileDialog's own settings, which are isolated by the XDG_CONFIG_HOME
36-
# redirect above instead.
37-
QCoreApplication.setOrganizationName("PyRS")
38-
QCoreApplication.setOrganizationDomain("ornl.gov")
39-
QCoreApplication.setApplicationName("PyRS")
4011
if QApplication.instance():
4112
_app = QApplication.instance()
4213
else:

0 commit comments

Comments
 (0)