Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix inconsistent model refresh threading #126

Merged
merged 1 commit into from
Oct 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading