Florian Müllner 829d2fd469 st/theme: Reuse stylesheets if possible
The following happens when processing an `@import()` rule:

 1. `_st_theme_resolve_url()` to resolve file
 2. `insert_stylesheet()` to track file/sheet
   a. take ownership of file/sheet (ref)
   b. use file as key in `stylesheets_by_file` hash table
   c. use file as value in `files_by_stylesheet` hash table
 3. release reference to file

This leads to a refcount error when importing a file that
was already parsed before:

 1. file start with refcount 1
 2. `insert_stylesheet()`
   a. increases refcount to 2
   b. inserting into `stylesheets_by_file` *decreases* the
      passed-in key if the key already exists
   c. `files_by_stylesheet` now tracks a file with recount 1
 3. releases the last reference to file

The file object tracked in `files_by_stylesheet` is now invalid,
and accessing it results in a crash.

Avoid this issue by reusing existing stylesheets, so we don't insert
a stylesheet that's already tracked.

As a side-effect, this also saves us from re-parsing the same file
unnecessarily.

Closes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/7306
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3619>
2025-01-30 16:43:57 +00:00
..
2024-10-16 13:17:45 +02:00
2024-10-16 13:17:45 +02:00
2024-10-16 13:17:45 +02:00
2024-10-16 13:17:45 +02:00
2024-10-16 13:17:45 +02:00
2024-10-16 13:17:45 +02:00
2024-10-16 13:17:45 +02:00
2024-10-16 13:17:45 +02:00
2024-10-16 13:17:45 +02:00
2024-10-16 13:17:45 +02:00
2022-08-02 16:13:54 +00:00
2024-10-16 13:17:45 +02:00
2024-10-16 13:17:45 +02:00
2024-10-16 13:17:45 +02:00
2024-10-16 13:17:45 +02:00
2024-10-16 13:17:45 +02:00
2024-10-16 13:17:45 +02:00
2023-08-31 03:44:32 +00:00
2024-10-16 13:17:45 +02:00