🐛 Fix shape leaking on deletion when is grouped.

This commit is contained in:
Andrey Antukh 2020-06-10 08:29:13 +02:00
parent 2d4e76619f
commit 7fb897a7ad
3 changed files with 22 additions and 6 deletions

View file

@ -440,9 +440,16 @@
(defmethod process-change :del-obj
[data {:keys [id] :as change}]
(when-let [{:keys [frame-id shapes] :as obj} (get-in data [:objects id])]
(let [data (update data :objects dissoc id)]
(let [objects (:objects data)
parent-id (get-parent id objects)
parent (get objects parent-id)
data (update data :objects dissoc id)]
(cond-> data
(contains? (:objects data) frame-id)
(and (not= parent-id frame-id)
(= :group (:type parent)))
(update-in [:objects parent-id :shapes] (fn [s] (filterv #(not= % id) s)))
(contains? objects frame-id)
(update-in [:objects frame-id :shapes] (fn [s] (filterv #(not= % id) s)))
(seq shapes) ; Recursive delete all dependend objects