Fix loading variables quote on quote.......
This commit is contained in:
		@@ -215,25 +215,31 @@ class VideoEditor:
 | 
				
			|||||||
            # Restore state values
 | 
					            # Restore state values
 | 
				
			||||||
            if 'current_frame' in state:
 | 
					            if 'current_frame' in state:
 | 
				
			||||||
                self.current_frame = state['current_frame']
 | 
					                self.current_frame = state['current_frame']
 | 
				
			||||||
 | 
					                print(f"Loaded current_frame: {self.current_frame}")
 | 
				
			||||||
            if 'crop_rect' in state and state['crop_rect'] is not None:
 | 
					            if 'crop_rect' in state and state['crop_rect'] is not None:
 | 
				
			||||||
                self.crop_rect = tuple(state['crop_rect'])
 | 
					                self.crop_rect = tuple(state['crop_rect'])
 | 
				
			||||||
                print(f"DEBUG: Loaded crop_rect: {self.crop_rect}")
 | 
					                print(f"Loaded crop_rect: {self.crop_rect}")
 | 
				
			||||||
            if 'zoom_factor' in state:
 | 
					            if 'zoom_factor' in state:
 | 
				
			||||||
                self.zoom_factor = state['zoom_factor']
 | 
					                self.zoom_factor = state['zoom_factor']
 | 
				
			||||||
 | 
					                print(f"Loaded zoom_factor: {self.zoom_factor}")
 | 
				
			||||||
            if 'zoom_center' in state and state['zoom_center'] is not None:
 | 
					            if 'zoom_center' in state and state['zoom_center'] is not None:
 | 
				
			||||||
                self.zoom_center = tuple(state['zoom_center'])
 | 
					                self.zoom_center = tuple(state['zoom_center'])
 | 
				
			||||||
 | 
					                print(f"Loaded zoom_center: {self.zoom_center}")
 | 
				
			||||||
            if 'rotation_angle' in state:
 | 
					            if 'rotation_angle' in state:
 | 
				
			||||||
                self.rotation_angle = state['rotation_angle']
 | 
					                self.rotation_angle = state['rotation_angle']
 | 
				
			||||||
 | 
					                print(f"Loaded rotation_angle: {self.rotation_angle}")
 | 
				
			||||||
            if 'brightness' in state:
 | 
					            if 'brightness' in state:
 | 
				
			||||||
                self.brightness = state['brightness']
 | 
					                self.brightness = state['brightness']
 | 
				
			||||||
 | 
					                print(f"Loaded brightness: {self.brightness}")
 | 
				
			||||||
            if 'contrast' in state:
 | 
					            if 'contrast' in state:
 | 
				
			||||||
                self.contrast = state['contrast']
 | 
					                self.contrast = state['contrast']
 | 
				
			||||||
 | 
					                print(f"Loaded contrast: {self.contrast}")
 | 
				
			||||||
            if 'cut_start_frame' in state:
 | 
					            if 'cut_start_frame' in state:
 | 
				
			||||||
                self.cut_start_frame = state['cut_start_frame']
 | 
					                self.cut_start_frame = state['cut_start_frame']
 | 
				
			||||||
                print(f"Restored cut_start_frame: {self.cut_start_frame}")
 | 
					                print(f"Loaded cut_start_frame: {self.cut_start_frame}")
 | 
				
			||||||
            if 'cut_end_frame' in state:
 | 
					            if 'cut_end_frame' in state:
 | 
				
			||||||
                self.cut_end_frame = state['cut_end_frame']
 | 
					                self.cut_end_frame = state['cut_end_frame']
 | 
				
			||||||
                print(f"Restored cut_end_frame: {self.cut_end_frame}")
 | 
					                print(f"Loaded cut_end_frame: {self.cut_end_frame}")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            # Validate cut markers against current video length
 | 
					            # Validate cut markers against current video length
 | 
				
			||||||
            if self.cut_start_frame is not None and self.cut_start_frame >= self.total_frames:
 | 
					            if self.cut_start_frame is not None and self.cut_start_frame >= self.total_frames:
 | 
				
			||||||
@@ -250,14 +256,19 @@ class VideoEditor:
 | 
				
			|||||||
                print(f"Markers will be drawn at: Start {start_progress:.4f} ({self.cut_start_frame}/{self.total_frames}), End {end_progress:.4f} ({self.cut_end_frame}/{self.total_frames})")
 | 
					                print(f"Markers will be drawn at: Start {start_progress:.4f} ({self.cut_start_frame}/{self.total_frames}), End {end_progress:.4f} ({self.cut_end_frame}/{self.total_frames})")
 | 
				
			||||||
            if 'looping_between_markers' in state:
 | 
					            if 'looping_between_markers' in state:
 | 
				
			||||||
                self.looping_between_markers = state['looping_between_markers']
 | 
					                self.looping_between_markers = state['looping_between_markers']
 | 
				
			||||||
 | 
					                print(f"Loaded looping_between_markers: {self.looping_between_markers}")
 | 
				
			||||||
            if 'display_offset' in state:
 | 
					            if 'display_offset' in state:
 | 
				
			||||||
                self.display_offset = state['display_offset']
 | 
					                self.display_offset = state['display_offset']
 | 
				
			||||||
 | 
					                print(f"Loaded display_offset: {self.display_offset}")
 | 
				
			||||||
            if 'playback_speed' in state:
 | 
					            if 'playback_speed' in state:
 | 
				
			||||||
                self.playback_speed = state['playback_speed']
 | 
					                self.playback_speed = state['playback_speed']
 | 
				
			||||||
 | 
					                print(f"Loaded playback_speed: {self.playback_speed}")
 | 
				
			||||||
            if 'seek_multiplier' in state:
 | 
					            if 'seek_multiplier' in state:
 | 
				
			||||||
                self.seek_multiplier = state['seek_multiplier']
 | 
					                self.seek_multiplier = state['seek_multiplier']
 | 
				
			||||||
 | 
					                print(f"Loaded seek_multiplier: {self.seek_multiplier}")
 | 
				
			||||||
            if 'is_playing' in state:
 | 
					            if 'is_playing' in state:
 | 
				
			||||||
                self.is_playing = state['is_playing']
 | 
					                self.is_playing = state['is_playing']
 | 
				
			||||||
 | 
					                print(f"Loaded is_playing: {self.is_playing}")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            # Validate and clamp values
 | 
					            # Validate and clamp values
 | 
				
			||||||
            self.current_frame = max(0, min(self.current_frame, getattr(self, 'total_frames', 1) - 1))
 | 
					            self.current_frame = max(0, min(self.current_frame, getattr(self, 'total_frames', 1) - 1))
 | 
				
			||||||
@@ -443,14 +454,20 @@ class VideoEditor:
 | 
				
			|||||||
            if self.fps > 60:
 | 
					            if self.fps > 60:
 | 
				
			||||||
                print("  Warning: High framerate video - may impact playback smoothness")
 | 
					                print("  Warning: High framerate video - may impact playback smoothness")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        # Reset playback state for new media
 | 
					        # Try to load saved state for this media file first
 | 
				
			||||||
 | 
					        if self.load_state():
 | 
				
			||||||
 | 
					            print("Loaded saved state for this media file")
 | 
				
			||||||
 | 
					            if self.cut_start_frame is not None:
 | 
				
			||||||
 | 
					                print(f"  Cut start frame: {self.cut_start_frame}")
 | 
				
			||||||
 | 
					            if self.cut_end_frame is not None:
 | 
				
			||||||
 | 
					                print(f"  Cut end frame: {self.cut_end_frame}")
 | 
				
			||||||
 | 
					        else:
 | 
				
			||||||
 | 
					            print("No saved state found for this media file")
 | 
				
			||||||
 | 
					            # Only reset to defaults if no state was loaded
 | 
				
			||||||
            self.current_frame = 0
 | 
					            self.current_frame = 0
 | 
				
			||||||
            self.is_playing = False if self.is_image_mode else False  # Images start paused
 | 
					            self.is_playing = False if self.is_image_mode else False  # Images start paused
 | 
				
			||||||
            self.playback_speed = 1.0
 | 
					            self.playback_speed = 1.0
 | 
				
			||||||
            self.seek_multiplier = 1.0
 | 
					            self.seek_multiplier = 1.0
 | 
				
			||||||
        self.current_display_frame = None
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        # Reset crop, zoom, rotation, brightness/contrast, and cut settings for new media
 | 
					 | 
				
			||||||
            self.crop_rect = None
 | 
					            self.crop_rect = None
 | 
				
			||||||
            self.crop_history = []
 | 
					            self.crop_history = []
 | 
				
			||||||
            self.zoom_factor = 1.0
 | 
					            self.zoom_factor = 1.0
 | 
				
			||||||
@@ -462,15 +479,8 @@ class VideoEditor:
 | 
				
			|||||||
            self.cut_end_frame = None
 | 
					            self.cut_end_frame = None
 | 
				
			||||||
            self.display_offset = [0, 0]
 | 
					            self.display_offset = [0, 0]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        # Try to load saved state for this media file
 | 
					        # Always reset these regardless of state
 | 
				
			||||||
        if self.load_state():
 | 
					        self.current_display_frame = None
 | 
				
			||||||
            print("Loaded saved state for this media file")
 | 
					 | 
				
			||||||
            if self.cut_start_frame is not None:
 | 
					 | 
				
			||||||
                print(f"  Cut start frame: {self.cut_start_frame}")
 | 
					 | 
				
			||||||
            if self.cut_end_frame is not None:
 | 
					 | 
				
			||||||
                print(f"  Cut end frame: {self.cut_end_frame}")
 | 
					 | 
				
			||||||
        else:
 | 
					 | 
				
			||||||
            print("No saved state found for this media file")
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def switch_to_video(self, index: int):
 | 
					    def switch_to_video(self, index: int):
 | 
				
			||||||
        """Switch to a specific video by index"""
 | 
					        """Switch to a specific video by index"""
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user