diff --git a/doc/changes/0.24.inc b/doc/changes/0.24.inc index 08899b35bfe..6e36c0c03d0 100644 --- a/doc/changes/0.24.inc +++ b/doc/changes/0.24.inc @@ -45,6 +45,8 @@ Version 0.24.1 (2021-12-01) - Fix automatic channel type detection from channel labels in :func:`mne.io.read_raw_edf` and :func:`mne.io.read_raw_bdf` (and disable this functionality from :func:`mne.io.read_raw_gdf`) (:gh:`10058` by `Clemens Brunner`_) +- When opening a saved report and saving it to a different filename again, don't change ``Report.fname`` to avoid a regression when using :func:`~mne.open_report` as a context manager (:gh:`9998` by `Marijn van Vliet`_) + .. _changes_0_24_0: Version 0.24.0 (2021-11-03) diff --git a/mne/report/report.py b/mne/report/report.py index 1998cfce0dd..d79203e0094 100644 --- a/mne/report/report.py +++ b/mne/report/report.py @@ -741,7 +741,8 @@ def _get_state_params(): return ( 'baseline', 'cov_fname', 'include', '_content', 'image_format', 'info_fname', '_dom_id', 'raw_psd', 'projs', - 'subjects_dir', 'subject', 'title', 'data_path', 'lang', 'verbose' + 'subjects_dir', 'subject', 'title', 'data_path', 'lang', 'verbose', + 'fname' ) def _get_dom_id(self): @@ -2843,7 +2844,8 @@ def save(self, fname=None, open_browser=True, overwrite=False, if open_browser and not is_hdf5 and not building_doc: webbrowser.open_new_tab('file://' + fname) - self.fname = fname + if self.fname is None: + self.fname = fname return fname def __enter__(self):