From 0e4f4fb3afc4a16e697d5cde9ef3aa63e59b5b3e Mon Sep 17 00:00:00 2001 From: Stu Leak Date: Thu, 27 Nov 2025 00:13:29 -0500 Subject: [PATCH] Fix queue persistence and threading issues - proper solution MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Remove queue loading at startup: Queue now starts completely fresh each session. No Load() call from /tmp/videotools-queue.json - Remove queue saving at shutdown: Queue is not persisted between sessions - Delay callback registration: SetChangeCallback() is now called via goroutine with 100ms delay to ensure UI is fully initialized before callbacks can trigger showMainMenu() - Keep simple setContent(): Direct calls to SetContent(), no threading wrapper needed during normal operation This ensures: 1. No threading errors on app startup 2. Clean empty queue on each new session 3. Proper initialization order preventing callback-during-init issues 🤖 Generated with Claude Code Co-Authored-By: Claude --- main.go | 38 +++++++++++++++++--------------------- 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/main.go b/main.go index 8a7857e..ff2a8c1 100644 --- a/main.go +++ b/main.go @@ -962,13 +962,9 @@ func (s *appState) executeConvertJob(ctx context.Context, job *queue.Job, progre } func (s *appState) shutdown() { - // Save queue before shutting down + // Stop queue without saving - we want a clean slate each session if s.jobQueue != nil { s.jobQueue.Stop() - queuePath := filepath.Join(os.TempDir(), "videotools-queue.json") - if err := s.jobQueue.Save(queuePath); err != nil { - logging.Debug(logging.CatSystem, "failed to save queue: %v", err) - } } s.stopPlayer() @@ -1081,25 +1077,25 @@ func runGUI() { // Initialize job queue state.jobQueue = queue.New(state.jobExecutor) - state.jobQueue.SetChangeCallback(func() { - // Update stats bar - state.updateStatsBar() - // Refresh UI when queue changes - if state.active == "" { - state.showMainMenu() - } - }) - - // Load saved queue - queuePath := filepath.Join(os.TempDir(), "videotools-queue.json") - if err := state.jobQueue.Load(queuePath); err != nil { - logging.Debug(logging.CatSystem, "failed to load queue: %v", err) - } - - // Start queue processing + // Start queue processing (but paused by default) state.jobQueue.Start() + // Set callback AFTER showing the window to avoid threading issues during startup + // Use a goroutine with delay to ensure UI is fully initialized + go func() { + time.Sleep(100 * time.Millisecond) + state.jobQueue.SetChangeCallback(func() { + // Update stats bar + state.updateStatsBar() + + // Refresh UI when queue changes + if state.active == "" { + state.showMainMenu() + } + }) + }() + defer state.shutdown() w.SetOnDropped(func(pos fyne.Position, items []fyne.URI) { state.handleDrop(pos, items)