Skip to content

Run trajectory plots after analysis completes - #3466

Draft
C-Achard wants to merge 1 commit into
mainfrom
cy/fix-plot-thread-gui-freeze
Draft

Run trajectory plots after analysis completes#3466
C-Achard wants to merge 1 commit into
mainfrom
cy/fix-plot-thread-gui-freeze

Conversation

@C-Achard

Copy link
Copy Markdown
Collaborator

Store plotting options before starting the worker and defer plot_trajectories(showfigures=True) to a main-thread finished slot.

The analysis pipeline now always runs with showfigures=False, only opens trajectory plots when analysis succeeds, and centralizes button/progress-bar reset in the completion handler.

This fixes the GUI freezing due to plots opening in the wrong thread.

Closes #3462.

Store plotting options before starting the worker and defer `plot_trajectories(showfigures=True)` to a main-thread finished slot. The analysis pipeline now always runs with `showfigures=False`, only opens trajectory plots when analysis succeeds, and centralizes button/progress-bar reset in the completion handler.
@C-Achard C-Achard added this to the v3.1.0 milestone Aug 28, 2026
@C-Achard
C-Achard requested a lite review from Copilot August 28, 2026 11:43
@C-Achard C-Achard self-assigned this Aug 28, 2026
@C-Achard C-Achard added GUI issues relating to GUI bug fix! fix for a real buggy one... labels Aug 28, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the Analyze Videos GUI workflow to avoid GUI freezes by ensuring trajectory plots are only displayed from the main (GUI) thread after background analysis completes successfully.

Changes:

  • Stores plotting options/batches before launching the worker thread and defers interactive plotting to a finished-handler slot.
  • Forces the analysis pipeline to run plot_trajectories(..., showfigures=False) and only opens figures when analysis succeeds and the user requested plot display.
  • Centralizes UI reset (button/progress bar) in the completion handler.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +72 to +75
@Slot()
def _handle_analysis_error(self):
self._analysis_failed = True

Comment on lines +76 to +97
@Slot()
def _handle_analysis_finished(self):
try:
if (
not self._analysis_failed
and self._pending_plot_options is not None
and self._pending_plot_batches is not None
and self._pending_plot_options.plot_trajectories
and self._pending_plot_options.show_trajectory_plots
):
self._show_trajectory_plots(
self._pending_plot_options,
self._pending_plot_batches,
)
finally:
self._pending_plot_options = None
self._pending_plot_batches = None
self._analysis_failed = False

self.analyze_videos_btn.setEnabled(True)
self.root._progress_bar.hide()

@C-Achard C-Achard mentioned this pull request Aug 28, 2026
2 tasks
@deruyter92 deruyter92 added the 3.1 label Aug 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3.1 bug fix! fix for a real buggy one... GUI issues relating to GUI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DLC Freezing Issue

3 participants