From 80086baace08040c84e842b5fe220b429b701d8e Mon Sep 17 00:00:00 2001 From: Patrick Shriwise <pshriwise@gmail.com> Date: Thu, 21 Nov 2024 18:29:41 -0600 Subject: [PATCH] Add an CML option to clear the application cache (#160) --- README.md | 13 +++++++++++++ openmc_plotter/__main__.py | 6 ++++++ 2 files changed, 19 insertions(+) diff --git a/README.md b/README.md index 8dc6581..7601ab1 100644 --- a/README.md +++ b/README.md @@ -59,6 +59,19 @@ can be used to generate images from the command line without opening the plotter ```console $ openmc-plotter -b view1.pltvw view1.pltvw view1.pltvw ``` +## Troubleshooting + +Updates to the plotter can result in stale references to deprecated features. For example, it's possible that something like the following may appear after an update: + +``` +AttributeError: 'MainWindow' object has no attribute 'shortcutOverlay' +``` + +To address this, the application settings can be cleared, the plotter can be started with the `--clear-config` (or `-c`) to reset the application's settings cache on startup. + +```bash +$ openmc-plotter --clear-cache +``` ## Features diff --git a/openmc_plotter/__main__.py b/openmc_plotter/__main__.py index 32b1cf9..c5facb4 100644 --- a/openmc_plotter/__main__.py +++ b/openmc_plotter/__main__.py @@ -28,6 +28,8 @@ def main(): 'XML files (default is current dir)') ap.add_argument('-b', '--batch-mode', nargs='+', default=False, help='View files used to generate plots in batch mode') + ap.add_argument('-c', '--clear-config', action='store_true', default=False, + help='Clear the Qt application configuration settings') args = ap.parse_args() @@ -45,6 +47,10 @@ def run_app(user_args): app.setWindowIcon(QtGui.QIcon(path_icon)) app.setAttribute(QtCore.Qt.AA_DontShowIconsInMenus, True) + if user_args.clear_config: + settings = QtCore.QSettings() + settings.clear() + splash_pix = QtGui.QPixmap(path_splash) splash = QSplashScreen(splash_pix, QtCore.Qt.WindowStaysOnTopHint) splash.setMask(splash_pix.mask())