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

Executor: move image viewer in main thread #460

Merged
merged 1 commit into from
Nov 12, 2024
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
3 changes: 2 additions & 1 deletion Render/imageviewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
QGuiApplication,
QMenu,
QFileDialog,
QApplication,
)
from PySide.QtCore import Qt, Slot, QSize, QPoint

Expand Down Expand Up @@ -260,7 +261,7 @@ def display_image(img_path):
return

# Create widget and subwindow
viewer = ImageViewer(Gui.getMainWindow())
viewer = ImageViewer(None)
mdiarea = Gui.getMainWindow().centralWidget()
subw = mdiarea.addSubWindow(viewer)
subw.setWindowTitle("Rendering result")
Expand Down
15 changes: 13 additions & 2 deletions Render/rdrexecutor.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,10 @@ def __init__(self, cmd, img, cwd, open_after_render):
self.cmd = cmd
self.img = img
self.cwd = cwd
if open_after_render:
self.result_ready.connect(display_image)
self.open_after_render = open_after_render
# TODO
# if open_after_render:
# self.result_ready.connect(display_image)

def run(self):
"""Run worker.
Expand Down Expand Up @@ -211,6 +213,8 @@ def start(self):
self.worker.finished.connect(self.worker.deleteLater)
self.worker.finished.connect(self.thread.exit)
self.thread.finished.connect(self.thread.deleteLater)
if getattr(self.worker, "open_after_render", False):
self.worker.result_ready.connect(self.display_result)
# self.thread.finished.connect(lambda: print("Thread finished")) # Dbg

# Start the thread
Expand All @@ -226,6 +230,13 @@ def join(self):
self.thread.finished.connect(loop.quit, Qt.QueuedConnection)
loop.exec_(flags=QEventLoop.ExcludeUserInputEvents)

@Slot(str)
def display_result(self, img_path):
"""Display result in GUI (slot)."""
# Very important: must execute in main (GUI) thread!
# Therefore, not callable directly from worker
display_image(img_path)


class RendererExecutorCli(threading.Thread):
"""A class to execute a rendering engine in Command Line Interface mode.
Expand Down
Loading