You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Follow-up from Phase 1 (#1938 / the slim-CvObject work).
Background
Phase 1 made CvObject a self-contained slim base that owns its OpenCvSafeHandle, and removed the dead memory machinery from DisposableObject. DisposableObject was not deleted: it now survives, trimmed to the bare dispose/finalize pattern, solely as the base for a handful of legacy utility types that hold managed-only unmanaged state (raw GCHandles) rather than a native OpenCV pointer.
These utilities are old, have known implementation smells, and were intentionally deferred. This issue tracks redesigning them so DisposableObject can be deleted entirely.
Scope
Type
Location
Notes
ArrayAddress1<T>
Internal/Util/ArrayAddress.cs
Scoped array pinning (GCHandle.Alloc(Pinned)) for passing managed arrays to native calls. Candidate to replace with fixed / Span<T> / MemoryHandle / GCHandle-in-a-ref struct.
ArrayAddress2<T>
Internal/Util/ArrayAddress2.cs
Same, for jagged T[][] (array of pinned arrays).
Window
Modules/highgui/Window.cs
HighGUI window wrapper; manages mouse-callback GCHandle lifetime, a static name->Window dictionary, and child trackbars.
CvTrackbar
Modules/highgui/CvTrackbar.cs
Holds two GCHandles for the trackbar callback delegates.
ResourcesTracker
Fundamentals/ResourcesTracker.cs
Scope that batch-disposes tracked IDisposables. Originated from a community PR; its real value is questioned — reconsider whether to keep, redesign (e.g. as a readonly struct scope), or remove.
Goals
Migrate each type off DisposableObject (to IDisposable directly, a ref struct/scoped pattern, or modern pinning APIs as appropriate), then delete DisposableObject.
Modernize the array-pinning helpers (ArrayAddress1/2) — most call sites are scoped to a single P/Invoke and could use fixed/Span with no heap allocation or finalizer.
Tidy callback/GCHandle lifetime in Window/CvTrackbar.
Decide the fate of ResourcesTracker.
Constraints
New/edited .cs: UTF-8 with BOM; repo content in English.
Activity
Merge pull request #1972 from shimat/feature/highgui-window-modernize-5x
Move multidimensional-array entry points to [LibraryImport] via Span
Make ArrayAddress1/2 scoped ref structs (off DisposableObject)
Modernize Window/CvTrackbar; delete DisposableObject (closes shimat#1941