Skip to content

Commit

Permalink
Fix inconsistent model refresh threading
Browse files Browse the repository at this point in the history
  • Loading branch information
johvincau committed Oct 10, 2023
1 parent 51a1f19 commit 20e6b9b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion openmc_plotter/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def run_app(user_args):

font_metric = QtGui.QFontMetrics(app.font())
screen_size = app.primaryScreen().size()
mainWindow = MainWindow(font_metric, screen_size, user_args.model_path)
mainWindow = MainWindow(font_metric, screen_size, user_args.model_path, user_args.threads)
# connect splashscreen to main window, close when main window opens
mainWindow.loadGui(use_settings_pkl=user_args.ignore_settings)

Expand Down
7 changes: 5 additions & 2 deletions openmc_plotter/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,14 @@ class MainWindow(QMainWindow):
def __init__(self,
font=QtGui.QFontMetrics(QtGui.QFont()),
screen_size=QtCore.QSize(),
model_path='.'):
model_path='.', threads=None):
super().__init__()

self.screen = screen_size
self.font_metric = font
self.setWindowTitle('OpenMC Plot Explorer')
self.model_path = Path(model_path)
self.threads = threads

def loadGui(self, use_settings_pkl=True):

Expand Down Expand Up @@ -478,8 +479,10 @@ def loadModel(self, reload=False, use_settings_pkl=True):
self.cellsModel = DomainTableModel(self.model.activeView.cells)
self.materialsModel = DomainTableModel(self.model.activeView.materials)

openmc_args = {'threads': self.threads, 'model_path': self.model_path}

if reload:
loader_thread = Thread(target=_openmcReload)
loader_thread = Thread(target=_openmcReload, kwargs=openmc_args)
loader_thread.start()
while loader_thread.is_alive():
self.statusBar().showMessage("Reloading model...")
Expand Down

0 comments on commit 20e6b9b

Please sign in to comment.