🐞 Segfault when using asset catalog colors

未關閉
#368 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

評估

難度
4/5
預估耗時
3-5 天
新手友好度
38/100
Issue 類型
缺陷
描述清晰度
基本清楚
活躍度
停滯
技術堆疊
swift
領域
desktop

研究方向

從連結的 EditorThemeReproduction.zip 中的 ContentView.swift 開始,使用 asset catalog 中的 NSColor 值,尤其是 NSColor.editorBackground,重現啟動時的 segfault。比較失敗的 EditorTheme 建構與可正常運作的 usingColorSpace(.sRGB) 情況。當 asset catalog 色彩不需明確的色彩空間轉換即可定義 EditorTheme,且重現應用程式能在沒有 segfault 的情況下啟動時,即表示完成。

由索引模型根據 Issue 內容生成。

描述

bug
Description

When creating an EditorTheme from asset catalog colours, a segfault occurs at launch unless the background colour is explicitly cast to sRGB (NSColor.editorBackground.usingColorSpace(.sRGB)!).

To Reproduce
  1. Create a new SwiftUI macOS app
  2. Add CodeEditSourceEditor as a dependency
  3. Add sRGB colors sets to the Asset catalog
  4. Use those colors through NSColor to define an EditorTheme (e.g. NSColor.editorBackground)
  5. Launch the app
  6. Something segfaults
  7. If you set the background to NSColor.editorBackground.usingColorSpace(.sRGB)!, it doesn't
Expected Behavior

It should be possible to use colours from the asset catalog to define the theme colours without additional hijinks.

Version Information

CodeEditSourceEditor: 0.15.2
macOS: 15.7.4
Xcode: 26.3

Additional Context

Minimal reproduction project: EditorThemeReproduction.zip (ContentView.swift contains all the relevant code.)

How I'm creating the theme (the asset catalog is included with the above project):

extension EditorTheme {
    /// Creates an ``EditorTheme`` from colors defined in the asset catalog.
    static func fromAssetCatalog() -> Self {
        EditorTheme(
            text: EditorTheme.Attribute(color: NSColor.editorText),
            insertionPoint: NSColor.editorInsertionPoint,
            invisibles: EditorTheme.Attribute(color: NSColor.editorInvisibles),

            // This segfaults:
            background: NSColor.editorBackground,

            // This does not, despite the asset catalog color sets being defined as sRGB
            // background: NSColor.editorBackground.usingColorSpace(.sRGB)!,

            lineHighlight: NSColor.editorLineHighlight,
            selection: NSColor.editorSelection,
            keywords: EditorTheme.Attribute(
                color: NSColor.editorKeywords,
                bold: true
            ),
            commands: EditorTheme.Attribute(color: NSColor.editorCommands),
            types: EditorTheme.Attribute(color: NSColor.editorTypes),
            attributes: EditorTheme.Attribute(color: NSColor.editorAttributes),
            variables: EditorTheme.Attribute(color: NSColor.editorVariables),
            values: EditorTheme.Attribute(color: NSColor.editorValues),
            numbers: EditorTheme.Attribute(color: NSColor.editorNumbers),
            strings: EditorTheme.Attribute(color: NSColor.editorStrings),
            characters: EditorTheme.Attribute(color: NSColor.editorCharacters),
            comments: EditorTheme.Attribute(color: NSColor.editorComments)
        )
    }
}
Screenshots
Xcode segfault screenshot
主要語言
Swift
星號
720
分支
162
PR 合併指標
30 天內沒有已合併 PR

貢獻指南

這個儲存庫沒有索引到貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

CodeEditApp/CodeEditSourceEditor 的其他 Issue

查看 CodeEditApp/CodeEditSourceEditor 的全部 Issue

相似的 Issue

更多 Swift Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。