🐞 Segfault when using asset catalog colors

Đang mở
#368 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
38/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
swift
Lĩnh vực
desktop

Hướng nghiên cứu

Bắt đầu với ContentView.swift trong EditorThemeReproduction.zip được liên kết và tái hiện segfault khi khởi chạy bằng các giá trị NSColor từ asset catalog, đặc biệt là NSColor.editorBackground. So sánh cách xây dựng EditorTheme bị lỗi với trường hợp usingColorSpace(.sRGB) hoạt động. Công việc được hoàn tất khi các màu từ asset catalog có thể định nghĩa một EditorTheme mà không cần chuyển đổi color-space tường minh và ứng dụng tái hiện khởi chạy mà không xảy ra segfault.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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
Ngôn ngữ chính
Swift
Star
720
Fork
162
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của CodeEditApp/CodeEditSourceEditor

Tất cả issue của CodeEditApp/CodeEditSourceEditor

Issue tương tự

Thêm issue về Swift

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.