From 9df6d73db8773e470d4c456f0223985ddcd84bc7 Mon Sep 17 00:00:00 2001 From: PhatPhuckDave Date: Fri, 26 Sep 2025 18:31:10 +0200 Subject: [PATCH] Enhance template management in VideoEditor by removing future templates and ending current ones This commit updates the template handling logic in the VideoEditor to remove any templates that start after the current frame and properly end templates that start at the current frame. This change improves the clarity and efficiency of template management during video editing sessions, ensuring that only relevant templates are active. Debug messages have been added to provide insights into the template removal and ending process. --- croppa/main.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/croppa/main.py b/croppa/main.py index d08f867..d85ada6 100644 --- a/croppa/main.py +++ b/croppa/main.py @@ -2410,10 +2410,16 @@ class VideoEditor: if end_frame is None: end_frame = self.total_frames - 1 - # End the previous template at the current frame (if there is one) - if self.current_template_id is not None and self.current_template_id in self.templates: - self.templates[self.current_template_id]['end_frame'] = self.current_frame - 1 - print(f"DEBUG: Ended previous template {self.current_template_id} at frame {self.current_frame - 1}") + # End any templates that start after the current frame + for template_id, template_data in list(self.templates.items()): + if template_data['start_frame'] > self.current_frame: + # This template starts after the current frame, so remove it + del self.templates[template_id] + print(f"DEBUG: Removed future template {template_id} that started at frame {template_data['start_frame']}") + elif template_data['start_frame'] == self.current_frame: + # This template starts at the same frame, end it at the previous frame + self.templates[template_id]['end_frame'] = self.current_frame - 1 + print(f"DEBUG: Ended template {template_id} at frame {self.current_frame - 1}") self.templates[template_id] = { 'template': template.copy(),