Run trajectory plots after analysis completes - #3466
Draft
C-Achard wants to merge 1 commit into
Draft
Conversation
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.
Contributor
There was a problem hiding this comment.
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() | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.