0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-02-19 05:15:44 -05:00

Merge pull request #3094 from penpot/hotfix-1.17

🐛 Fix problem with invalid geometry
This commit is contained in:
Alejandro 2023-03-31 14:10:36 +02:00 committed by GitHub
commit 04b7d8e1e2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 4 deletions

View file

@ -318,8 +318,10 @@
(defn unit
[p1]
(let [p-length (length p1)]
(Point. (/ (dm/get-prop p1 :x) p-length)
(/ (dm/get-prop p1 :y) p-length))))
(if (mth/almost-zero? p-length)
(Point. 0 0)
(Point. (/ (dm/get-prop p1 :x) p-length)
(/ (dm/get-prop p1 :y) p-length)))))
(defn perpendicular
[pt]

View file

@ -9,7 +9,8 @@
[app.common.data :as d]
[app.common.geom.matrix :as gmt]
[app.common.geom.point :as gpt]
[app.common.geom.shapes.rect :as gpr]))
[app.common.geom.shapes.rect :as gpr]
[app.common.math :as mth]))
(defn center-rect
[{:keys [x y width height]}]
@ -71,3 +72,15 @@
[{:keys [x1 y1 x2 y2] :as sr} matrix]
(let [[c1 c2] (transform-points [(gpt/point x1 y1) (gpt/point x2 y2)] matrix)]
(gpr/corners->selrect c1 c2)))
(defn invalid-geometry?
[{:keys [points selrect]}]
(or (mth/nan? (:x selrect))
(mth/nan? (:y selrect))
(mth/nan? (:width selrect))
(mth/nan? (:height selrect))
(some (fn [p]
(or (mth/nan? (:x p))
(mth/nan? (:y p))))
points)))

View file

@ -9,6 +9,7 @@
[app.common.data :as d]
[app.common.data.macros :as dm]
[app.common.geom.point :as gpt]
[app.common.geom.shapes.common :as gco]
[app.common.geom.shapes.constraints :as gct]
[app.common.geom.shapes.flex-layout :as gcl]
[app.common.geom.shapes.pixel-precision :as gpp]
@ -175,6 +176,7 @@
(let [children (->> (cph/get-immediate-children objects (:id parent))
(remove :hidden)
(remove gco/invalid-geometry?)
(map apply-modifiers))
layout-data (gcl/calc-layout-data parent children @transformed-parent-bounds)
children (into [] (cond-> children (not (:reverse? layout-data)) reverse))
@ -215,7 +217,8 @@
(ctm/resize-parent (gpt/point 1 scale-height) origin (:transform parent) (:transform-inverse parent)))))
children (->> (cph/get-immediate-children objects parent-id)
(remove :hidden))
(remove :hidden)
(remove gco/invalid-geometry?))
content-bounds
(when (and (d/not-empty? children) (or (ctl/auto-height? parent) (ctl/auto-width? parent)))