mirror of
https://github.com/penpot/penpot.git
synced 2025-05-20 19:26: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
|
"Generate changes to remove the links between a shape and all its children
|
||||||
with a component."
|
with a component."
|
||||||
[shape-id container]
|
[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))
|
(let [shapes (cp/get-object-with-children shape-id (:objects container))
|
||||||
rchanges (mapv (fn [obj]
|
rchanges (mapv (fn [obj]
|
||||||
(make-change
|
(make-change
|
||||||
|
@ -646,6 +647,9 @@
|
||||||
:shape (str (:name shape-inst))
|
:shape (str (:name shape-inst))
|
||||||
:component (:name component))
|
: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?)
|
(let [omit-touched? (not reset?)
|
||||||
clear-remote-synced? (and initial-root? reset?)
|
clear-remote-synced? (and initial-root? reset?)
|
||||||
set-remote-synced? (and (not initial-root?) reset?)
|
set-remote-synced? (and (not initial-root?) reset?)
|
||||||
|
@ -728,7 +732,7 @@
|
||||||
false)]
|
false)]
|
||||||
|
|
||||||
[(d/concat rchanges child-rchanges)
|
[(d/concat rchanges child-rchanges)
|
||||||
(d/concat uchanges child-uchanges)]))
|
(d/concat uchanges child-uchanges)])))
|
||||||
|
|
||||||
(defn generate-sync-shape-inverse
|
(defn generate-sync-shape-inverse
|
||||||
"Generate changes to update the component a shape is linked to, from
|
"Generate changes to update the component a shape is linked to, from
|
||||||
|
@ -764,6 +768,9 @@
|
||||||
:shape (str (:name shape-inst))
|
:shape (str (:name shape-inst))
|
||||||
:component (:name component))
|
: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)
|
(let [component-container (cp/make-container component :component)
|
||||||
|
|
||||||
omit-touched? false
|
omit-touched? false
|
||||||
|
@ -853,7 +860,7 @@
|
||||||
uchanges (mapv check-local uchanges)]
|
uchanges (mapv check-local uchanges)]
|
||||||
|
|
||||||
[(d/concat rchanges child-rchanges)
|
[(d/concat rchanges child-rchanges)
|
||||||
(d/concat uchanges child-uchanges)]))
|
(d/concat uchanges child-uchanges)])))
|
||||||
|
|
||||||
|
|
||||||
; ---- Operation generation helpers ----
|
; ---- Operation generation helpers ----
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue