Harden nre close filtergrid#638
Merged
Merged
Conversation
Hirogen
commented
Jun 24, 2026
Collaborator
- _isClosing flag + guards in both CellValueNeeded handlers (the NRE fix)
- JoinWorker() helper + WORKER_SHUTDOWN_TIMEOUT, wired into both stop methods
- restored _timeShiftSyncWakeupEvent.Set() in StopTimestampSyncThread
Closing a LogWindow could throw a NullReferenceException from LogfileReader.GetLogLineMemories. ClearAndDisposeGrids() calls Rows.Clear(), which ends any in-progress cell edit and fires CellValueNeeded into a reader whose buffers are being torn down. The existing guards (_isDeleted, _filterResultList bounds) don't cover a normal close, so the callback still dispatched into the dying reader. - Add an _isClosing flag, set at the top of CloseLogWindow, and short- circuit both OnDataGridViewCellValueNeeded and OnFilterGridViewCellValueNeeded so no grid callback reaches the reader once teardown has started. While here, make the worker task handles live again. Since the Thread->Task conversion (45d1c62) _logEventHandlerTask and _timeShiftSyncTask were write-only; shutdown relied solely on _cts.Cancel() and the leftover .Abort()/.Join() calls were commented out. - Join both workers on shutdown via a bounded JoinWorker() helper (WORKER_SHUTDOWN_TIMEOUT) so close drains them deterministically before the grids are disposed, and never hangs if a worker is blocked. - Restore _timeShiftSyncWakeupEvent.Set() in StopTimestampSyncThread: the sync worker parks on a no-timeout WaitOne() and stop never woke it, so it would otherwise never observe the cancel flag.
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.