{"record":{"id":"1cabe5aea4a94826","repo":"stride3d/stride","slug":"characterbitmap","errorCode":null,"errorMessage":"CharacterBitmap","messagePattern":"CharacterBitmap","errorType":"exception","errorClass":"ObjectDisposedException","httpStatus":null,"severity":"error","filePath":"sources/engine/Stride.Graphics/Font/CharacterBitmap.cs","lineNumber":164,"sourceCode":"        /// Gets a value indicating whether the <see cref=\"CharacterBitmap\"/> has been disposed.\n        /// </summary>\n        public bool IsDisposed\n        {\n            get\n            {\n                return disposed;\n            }\n        }\n\n        /// <summary>\n        /// Gets the number of bitmap rows.\n        /// </summary>\n        public int Rows\n        {\n            get\n            {\n                if (disposed)\n                    throw new ObjectDisposedException(\"CharacterBitmap\", \"Cannot access a disposed object.\");\n\n                return rows;\n            }\n        }\n\n        /// <summary>\n        /// Gets the number of pixels in bitmap row.\n        /// </summary>\n        public int Width\n        {\n            get\n            {\n                if (disposed)\n                    throw new ObjectDisposedException(\"CharacterBitmap\", \"Cannot access a disposed object.\");\n\n                return width;\n            }\n        }","sourceCodeStart":146,"sourceCodeEnd":182,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.Graphics/Font/CharacterBitmap.cs#L146-L182","documentation":"CharacterBitmap.Rows returns the glyph bitmap height in pixels. Stride guards all bitmap accessors with a disposed check and throws ObjectDisposedException naming 'CharacterBitmap' so callers detect use-after-dispose instead of reading freed FreeType memory.","triggerScenarios":"Accessing the Rows property after CharacterBitmap.Dispose() (or its owner FontData/Font being disposed) has been called.","commonSituations":"Caching CharacterBitmap objects across frames while the font is reloaded; disposing a Font at scene unload while a background thread still reads glyph metrics.","solutions":["Re-fetch the CharacterBitmap from the font instead of using the stale disposed instance","Ensure the owning Font/FontData outlives all code that reads glyph metrics","Dispose the font only after all consumers are finished (e.g. on full shutdown)"],"exampleFix":"// before\nvar rows = cachedBitmap.Rows;\n// after\nvar bitmap = font.GetBitmap(character);\nif (bitmap == null) return;\nvar rows = bitmap.Rows;","handlingStrategy":"try-catch","validationCode":"if (bitmap == null || bitmapDisposed) return fallback;","typeGuard":"bool IsUsable(CharacterBitmap b) => b != null && !b.IsDisposed;","tryCatchPattern":"try { rows = bitmap.Rows; }\ncatch (ObjectDisposedException)\n{\n    bitmap = font.GetBitmap(character);\n    rows = bitmap.Rows;\n}","preventionTips":["Treat CharacterBitmap as short-lived: read metrics immediately after fetching","Clear glyph caches when disposing a Font","Never pass CharacterBitmap instances across font lifetime boundaries"],"tags":["fonts","object-disposed","lifecycle"],"backgroundTag":"invalid-state-transition","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}