Skip to content

fix: Dispose _autoFetchTimer before _setting set to null #792

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 6, 2024

Conversation

gadfly3173
Copy link
Contributor

I met NRE when switching the workspace, I think this can fix the issue.

Crash::: System.NullReferenceException: Object reference not set to an instance of an object.

----------------------------
Version: 8.41.0.0
OS: Unix 6.9.6.64
Framework: .NETCoreApp,Version=v9.0
Source: SourceGit
---------------------------

   at SourceGit.ViewModels.Repository.AutoFetchImpl(Object sender) + 0x137
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext, ContextCallback, Object) + 0xb7
--- End of stack trace from previous location ---
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext, ContextCallback, Object) + 0x123
   at System.Threading.TimerQueueTimer.Fire(Boolean) + 0x5a
   at System.Threading.TimerQueue.FireNextTimers() + 0x240
   at System.Threading.ThreadPoolWorkQueue.Dispatch() + 0x25c
   at System.Threading.PortableThreadPool.WorkerThread.WorkerThreadStart() + 0x15c
   at System.Threading.Thread.StartThread(IntPtr) + 0x109
   at System.Threading.Thread.ThreadEntryPoint(IntPtr) + 0x19

@love-linger love-linger self-assigned this Dec 6, 2024
@love-linger love-linger added the bug Something isn't working label Dec 6, 2024
@love-linger love-linger merged commit c062f27 into sourcegit-scm:develop Dec 6, 2024
13 checks passed
@gadfly3173 gadfly3173 deleted the fix/potential-nre branch December 6, 2024 07:32
gadfly3173 added a commit to gadfly3173/sourcegit that referenced this pull request Mar 31, 2025
sourcegit-scm#792 sourcegit-scm#1121

Replace System.Threading.Timer with PeriodicTimer for auto fetch functionality to:
- Handle cancellation gracefully during repository close
- Avoid unhandled exceptions in timer callbacks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants