mirror of
https://github.com/penpot/penpot.git
synced 2025-06-13 02:01:39 +02:00
🐛 Fix reference counting of file-media objects in :fill-image attr
This commit is contained in:
parent
b8dee17075
commit
661a916a5f
2 changed files with 14 additions and 5 deletions
|
@ -516,6 +516,9 @@
|
||||||
:media (count media)
|
:media (count media)
|
||||||
::l/sync? true)
|
::l/sync? true)
|
||||||
|
|
||||||
|
(doseq [item media]
|
||||||
|
(l/debug :hint "write penpot file media object" :id (:id item) ::l/sync? true))
|
||||||
|
|
||||||
(doto output
|
(doto output
|
||||||
(write-obj! file)
|
(write-obj! file)
|
||||||
(write-obj! media))
|
(write-obj! media))
|
||||||
|
@ -770,7 +773,7 @@
|
||||||
(defn- lookup-index
|
(defn- lookup-index
|
||||||
[id]
|
[id]
|
||||||
(let [val (get-in @*state* [:index id])]
|
(let [val (get-in @*state* [:index id])]
|
||||||
(l/trace :fn "lookup-index" :id id :val val ::l/sync? true)
|
(l/debug :fn "lookup-index" :id id :val val ::l/sync? true)
|
||||||
(when (and (not (::ignore-index-errors? *options*)) (not val))
|
(when (and (not (::ignore-index-errors? *options*)) (not val))
|
||||||
(ex/raise :type :validation
|
(ex/raise :type :validation
|
||||||
:code :incomplete-index
|
:code :incomplete-index
|
||||||
|
@ -783,7 +786,7 @@
|
||||||
index index]
|
index index]
|
||||||
(if-let [id (first items)]
|
(if-let [id (first items)]
|
||||||
(let [new-id (if (::overwrite? *options*) id (uuid/next))]
|
(let [new-id (if (::overwrite? *options*) id (uuid/next))]
|
||||||
(l/trace :fn "update-index" :id id :new-id new-id ::l/sync? true)
|
(l/debug :fn "update-index" :id id :new-id new-id ::l/sync? true)
|
||||||
(recur (rest items)
|
(recur (rest items)
|
||||||
(assoc index id new-id)))
|
(assoc index id new-id)))
|
||||||
index)))
|
index)))
|
||||||
|
@ -801,8 +804,7 @@
|
||||||
(update-in [:metadata :id] lookup-index)
|
(update-in [:metadata :id] lookup-index)
|
||||||
|
|
||||||
;; Relink paths with fill image
|
;; Relink paths with fill image
|
||||||
(and (map? (:fill-image form))
|
(map? (:fill-image form))
|
||||||
(= :path (:type form)))
|
|
||||||
(update-in [:fill-image :id] lookup-index)
|
(update-in [:fill-image :id] lookup-index)
|
||||||
|
|
||||||
;; This covers old shapes and the new :fills.
|
;; This covers old shapes and the new :fills.
|
||||||
|
|
|
@ -113,8 +113,15 @@
|
||||||
(mapcat vals)
|
(mapcat vals)
|
||||||
(keep (fn [{:keys [type] :as obj}]
|
(keep (fn [{:keys [type] :as obj}]
|
||||||
(case type
|
(case type
|
||||||
:path (get-in obj [:fill-image :id])
|
:path (get-in obj [:fill-image :id])
|
||||||
|
:bool (get-in obj [:fill-image :id])
|
||||||
|
;; NOTE: because of some bug, we ended with
|
||||||
|
;; many shape types having the ability to
|
||||||
|
;; have fill-image attribute (which initially
|
||||||
|
;; designed for :path shapes).
|
||||||
|
:group (get-in obj [:fill-image :id])
|
||||||
:image (get-in obj [:metadata :id])
|
:image (get-in obj [:metadata :id])
|
||||||
|
|
||||||
nil))))
|
nil))))
|
||||||
pages (concat
|
pages (concat
|
||||||
(vals (:pages-index data))
|
(vals (:pages-index data))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue