mirror of
https://github.com/penpot/penpot.git
synced 2025-05-20 05:46:11 +02:00
🐛 Protect against broken component refs #1114
This commit is contained in:
parent
9d545004cb
commit
c6fe19c321
1 changed files with 155 additions and 148 deletions
|
@ -204,6 +204,7 @@
|
|||
"Generate changes to remove the links between a shape and all its children
|
||||
with a component."
|
||||
[shape-id container]
|
||||
(log/debug :msg "Detach instance" :shape-id shape-id :container (:id container))
|
||||
(let [shapes (cp/get-object-with-children shape-id (:objects container))
|
||||
rchanges (mapv (fn [obj]
|
||||
(make-change
|
||||
|
@ -646,6 +647,9 @@
|
|||
:shape (str (:name shape-inst))
|
||||
:component (:name component))
|
||||
|
||||
(if (nil? shape-main)
|
||||
;; This should not occur, but protect against it in any case
|
||||
(generate-detach-instance (:id shape-inst) container)
|
||||
(let [omit-touched? (not reset?)
|
||||
clear-remote-synced? (and initial-root? reset?)
|
||||
set-remote-synced? (and (not initial-root?) reset?)
|
||||
|
@ -728,7 +732,7 @@
|
|||
false)]
|
||||
|
||||
[(d/concat rchanges child-rchanges)
|
||||
(d/concat uchanges child-uchanges)]))
|
||||
(d/concat uchanges child-uchanges)])))
|
||||
|
||||
(defn generate-sync-shape-inverse
|
||||
"Generate changes to update the component a shape is linked to, from
|
||||
|
@ -764,6 +768,9 @@
|
|||
:shape (str (:name shape-inst))
|
||||
:component (:name component))
|
||||
|
||||
(if (nil? shape-main)
|
||||
;; This should not occur, but protect against it in any case
|
||||
empty-changes
|
||||
(let [component-container (cp/make-container component :component)
|
||||
|
||||
omit-touched? false
|
||||
|
@ -853,7 +860,7 @@
|
|||
uchanges (mapv check-local uchanges)]
|
||||
|
||||
[(d/concat rchanges child-rchanges)
|
||||
(d/concat uchanges child-uchanges)]))
|
||||
(d/concat uchanges child-uchanges)])))
|
||||
|
||||
|
||||
; ---- Operation generation helpers ----
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue